From c5d328a5dab491738fc59325b0e819fb925bb530 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sun, 19 Sep 2021 16:06:24 +0200 Subject: Fixed a bug with some TLS relocation when symbol is in another elf (helps c++ softs, probably other too) --- src/elfs/elfloader.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/elfs/elfloader.c b/src/elfs/elfloader.c index 22977cc3..9ab2de18 100755 --- a/src/elfs/elfloader.c +++ b/src/elfs/elfloader.c @@ -574,7 +574,7 @@ int RelocateElfRELA(lib_t *maplib, lib_t *local_maplib, int bindnow, elfheader_t uint64_t *p = (uint64_t*)(rela[i].r_offset + head->delta); uintptr_t offs = 0; uintptr_t end = 0; - elfheader_t* h_tls = head; + elfheader_t* h_tls = NULL;//head; int version = head->VerSym?((Elf64_Half*)((uintptr_t)head->VerSym+head->delta))[ELF64_R_SYM(rela[i].r_info)]:-1; if(version!=-1) version &=0x7fff; const char* vername = GetSymbolVersion(head, version); @@ -744,7 +744,7 @@ int RelocateElfRELA(lib_t *maplib, lib_t *local_maplib, int bindnow, elfheader_t offs = getElfIndex(my_context, h_tls); } if(p) { - printf_dump(LOG_NEVER, "Apply %s %s @%p with sym=%s (%p -> %p)\n", "R_X86_64_DTPMOD64", (bind==STB_LOCAL)?"Local":"Global", p, symname, *(void**)p, (void*)offs); + printf_dump(LOG_NEVER, "Apply %s %s @%p with sym=%s (%p -> %p)\n", (bind==STB_LOCAL)?"Local":"Global", "R_X86_64_DTPMOD64", p, symname, *(void**)p, (void*)offs); *p = offs; } else { printf_log(LOG_NONE, "Warning, Symbol %s or Elf not found, but R_X86_64_DTPMOD64 Slot Offset is NULL \n", symname); @@ -760,7 +760,7 @@ int RelocateElfRELA(lib_t *maplib, lib_t *local_maplib, int bindnow, elfheader_t } // return -1; } else { - if(h_tls) + if(!symname || symname[0]=='\0' || bind==STB_LOCAL) offs = sym->st_value; if(p) { int64_t tlsoffset = offs; // it's not an offset in elf memory -- cgit 1.4.1