about summary refs log tree commit diff stats
path: root/src/elfs
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-03-25 17:02:51 +0100
committerptitSeb <sebastien.chev@gmail.com>2021-03-25 17:02:51 +0100
commita701ff87ecb8c74d0a1da2e5b3d00c3ccde91aae (patch)
tree03910bfb57e6c155c920b7f61f0dd1248d7911da /src/elfs
parent6e78bc1726047f5462517d5fd1954fcbe080e1b4 (diff)
downloadbox64-a701ff87ecb8c74d0a1da2e5b3d00c3ccde91aae.tar.gz
box64-a701ff87ecb8c74d0a1da2e5b3d00c3ccde91aae.zip
More libc wrapped symbols
Diffstat (limited to 'src/elfs')
-rwxr-xr-xsrc/elfs/elfloader.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/elfs/elfloader.c b/src/elfs/elfloader.c
index 652ec253..e1dc2ca1 100755
--- a/src/elfs/elfloader.c
+++ b/src/elfs/elfloader.c
@@ -552,6 +552,7 @@ int RelocateElfRELA(lib_t *maplib, lib_t *local_maplib, elfheader_t* head, int c
         uintptr_t globoffs, globend;
         uint64_t* globp;
         uintptr_t tmp = 0;
+        intptr_t delta;
         switch(ELF64_R_TYPE(rela[i].r_info)) {
             case R_X86_64_NONE:
             case R_X86_64_PC32:
@@ -646,6 +647,26 @@ int RelocateElfRELA(lib_t *maplib, lib_t *local_maplib, elfheader_t* head, int c
                     *p /*+*/= offs+rela[i].r_addend;
                 }
                 break;
+            case R_X86_64_TPOFF64:
+                // Negated offset in static TLS block
+                {
+                    if(h_tls)
+                        offs = sym->st_value;
+                    else {
+                        if(local_maplib)
+                            h_tls = GetGlobalSymbolElf(local_maplib, symname);
+                        if(!h_tls)
+                            h_tls = GetGlobalSymbolElf(maplib, symname);
+                    }
+                    if(h_tls) {
+                        delta = *(int*)p;
+                        printf_log(LOG_DUMP, "Applying %s %s on %s @%p (%ld -> %ld)\n", (bind==STB_LOCAL)?"Local":"Global", DumpRelType(t), symname, p, delta, (int64_t)offs + h_tls->tlsbase);
+                        *p = (uintptr_t)((int64_t)offs + h_tls->tlsbase);
+                    } else {
+                        printf_log(LOG_INFO, "Warning, cannot apply %s %s on %s @%p (%ld), no elf_header found\n", (bind==STB_LOCAL)?"Local":"Global", DumpRelType(t), symname, p, (int64_t)offs);
+                    }
+                }
+                break;
             case R_X86_64_DTPMOD64:
                 // ID of module containing symbol
                 if(!symname || symname[0]=='\0' || bind==STB_LOCAL)