From a701ff87ecb8c74d0a1da2e5b3d00c3ccde91aae Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Thu, 25 Mar 2021 17:02:51 +0100 Subject: More libc wrapped symbols --- src/elfs/elfloader.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/elfs') 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) -- cgit 1.4.1