From d33d231120a1a3cbe4563fd7032bfd64aa4a3e04 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sun, 16 May 2021 10:05:06 +0200 Subject: [PATCH] Small hack to elfloader, so dosbox, unity3d and torchlight2 all seems to works now --- src/elfs/elfloader.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/elfs/elfloader.c b/src/elfs/elfloader.c index 5fe4d37f6c..340366561a 100755 --- a/src/elfs/elfloader.c +++ b/src/elfs/elfloader.c @@ -484,12 +484,12 @@ int RelocateElfREL(lib_t *maplib, lib_t *local_maplib, elfheader_t* head, int cn end = offs + sym->st_size; if(sym->st_size) { printf_log(LOG_DUMP, "Apply %s R_386_GLOB_DAT with R_386_COPY @%p/%p (%p/%p -> %p/%p) size=%d on sym=%s \n", (bind==STB_LOCAL)?"Local":"Global", p, globp, (void*)(p?(*p):0), (void*)(globp?(*globp):0), (void*)offs, (void*)globoffs, sym->st_size, symname); - *p = globoffs; - AddWeakSymbol(GetGlobalData(maplib), symname, offs, end-offs+1); + memmove((void*)globoffs, (void*)offs, sym->st_size); // preapply to copy part from lib to main elf + AddWeakSymbol(GetGlobalData(maplib), symname, offs, sym->st_size); } else { printf_log(LOG_DUMP, "Apply %s R_386_GLOB_DAT with R_386_COPY @%p/%p (%p/%p -> %p/%p) null sized on sym=%s \n", (bind==STB_LOCAL)?"Local":"Global", p, globp, (void*)(p?(*p):0), (void*)(globp?(*globp):0), (void*)offs, (void*)globoffs, symname); - *p = globoffs; } + *p = globoffs; } else { // Look for same symbol already loaded but not in self (so no need for local_maplib here) if (GetGlobalNoWeakSymbolStartEnd(maplib, symname, &globoffs, &globend)) { @@ -798,7 +798,7 @@ void AddSymbols(lib_t *maplib, kh_mapsymbols_t* mapsymbols, kh_mapsymbols_t* wea int vis = h->SymTab[i].st_other&0x3; if((type==STT_OBJECT || type==STT_FUNC || type==STT_COMMON || type==STT_TLS || type==STT_NOTYPE) && (vis==STV_DEFAULT || vis==STV_PROTECTED) && (h->SymTab[i].st_shndx!=0)) { - if((bind==10/*STB_GNU_UNIQUE*/ || (bind==STB_GLOBAL && type==STT_FUNC)) && FindGlobalSymbol(maplib, symname)) + if((bind==STB_GNU_UNIQUE /*|| (bind==STB_GLOBAL && type==STT_FUNC)*/) && FindGlobalSymbol(maplib, symname)) continue; uintptr_t offs = (type==STT_TLS)?h->SymTab[i].st_value:(h->SymTab[i].st_value + h->delta); uint32_t sz = h->SymTab[i].st_size; @@ -823,7 +823,7 @@ void AddSymbols(lib_t *maplib, kh_mapsymbols_t* mapsymbols, kh_mapsymbols_t* wea //st_shndx==65521 means ABS value if((type==STT_OBJECT || type==STT_FUNC || type==STT_COMMON || type==STT_TLS || type==STT_NOTYPE) && (vis==STV_DEFAULT || vis==STV_PROTECTED) && (h->DynSym[i].st_shndx!=0 && h->DynSym[i].st_shndx<=65521)) { - if((bind==10/*STB_GNU_UNIQUE*/ || (bind==STB_GLOBAL && type==STT_FUNC)) && FindGlobalSymbol(maplib, symname)) + if((bind==STB_GNU_UNIQUE || (bind==STB_GLOBAL && type==STT_FUNC)) && FindGlobalSymbol(maplib, symname)) continue; uintptr_t offs = (type==STT_TLS)?h->DynSym[i].st_value:(h->DynSym[i].st_value + h->delta); uint32_t sz = h->DynSym[i].st_size;