about summary refs log tree commit diff stats
path: root/src/elfs/elfloader.c
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-02-16 13:44:54 +0100
committerptitSeb <sebastien.chev@gmail.com>2024-02-16 13:44:54 +0100
commit65f75b0cc0ead29db622afc790b6167c476e4960 (patch)
treef4a2ab63e4f12ba67995a25c029468807d5e83fe /src/elfs/elfloader.c
parentc50b0ef9e8342b634af873134a52ec3b7b889f42 (diff)
downloadbox64-65f75b0cc0ead29db622afc790b6167c476e4960.tar.gz
box64-65f75b0cc0ead29db622afc790b6167c476e4960.zip
[ELFLOADER] Better handling of STB_GNU_UNIQUE binded symbol (prevent dlclose)
Diffstat (limited to 'src/elfs/elfloader.c')
-rw-r--r--src/elfs/elfloader.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/elfs/elfloader.c b/src/elfs/elfloader.c
index 9f01f75b..f68658d7 100644
--- a/src/elfs/elfloader.c
+++ b/src/elfs/elfloader.c
@@ -499,6 +499,21 @@ void GrabX64CopyMainElfReloc(elfheader_t* head)
         }
     }
 }
+void CheckGNUUniqueBindings(elfheader_t* head)
+{
+    if(head->rela) {
+        int cnt = head->relasz / head->relaent;
+        Elf64_Rela* rela = (Elf64_Rela *)(head->rela + head->delta);
+        printf_dump(LOG_DEBUG, "Checking for symbol with STB_GNU_UNIQUE bindingsfor %s\n", head->name);
+        for (int i=0; i<cnt; ++i) {
+            int bind = ELF64_ST_BIND(rela[i].r_info);
+            if(bind == STB_GNU_UNIQUE) {
+                head->gnuunique = 1;
+                return; // can stop searching
+            }
+        }
+    }
+}
 
 static elfheader_t* checkElfLib(elfheader_t* h, library_t* lib)
 {