diff options
| author | ptitSeb <seebastien.chev@gmail.com> | 2023-08-26 17:08:27 +0200 |
|---|---|---|
| committer | ptitSeb <seebastien.chev@gmail.com> | 2023-08-26 17:08:27 +0200 |
| commit | aa051b662e3a0e8c80e7b6373d35e22da3c42d79 (patch) | |
| tree | c8a5ce1db387794f304d618fc9b1801661319ca6 /src | |
| parent | 5fabd602aea1937e3c5ce58843504c2492b8c0ec (diff) | |
| download | box64-aa051b662e3a0e8c80e7b6373d35e22da3c42d79.tar.gz box64-aa051b662e3a0e8c80e7b6373d35e22da3c42d79.zip | |
Fixed detection and loading of program linked with glibc 2.34+
Diffstat (limited to 'src')
| -rw-r--r-- | src/elfs/elfparser.c | 17 | ||||
| -rw-r--r-- | src/include/elfloader.h | 1 | ||||
| -rw-r--r-- | src/main.c | 6 |
3 files changed, 20 insertions, 4 deletions
diff --git a/src/elfs/elfparser.c b/src/elfs/elfparser.c index 1701378f..61799dae 100644 --- a/src/elfs/elfparser.c +++ b/src/elfs/elfparser.c @@ -466,4 +466,19 @@ const char* GetNeededVersionString(elfheader_t* h, const char* libname, int idx) } } return NULL; -} \ No newline at end of file +} + +int GetNeededVersionForLib(elfheader_t* h, const char* libname, const char* ver) +{ + if(!libname || !ver) + return 0; + int n = GetNeededVersionCnt(h, libname); + if(!n) + return 0; + for(int i=0; i<n; ++i) { + const char* vername = GetNeededVersionString(h, libname, i); + if(vername && !strcmp(ver, vername)) + return 1; + } + return 0; +} diff --git a/src/include/elfloader.h b/src/include/elfloader.h index ca8839df..d9d7f152 100644 --- a/src/include/elfloader.h +++ b/src/include/elfloader.h @@ -67,6 +67,7 @@ int SameVersionedSymbol(const char* name1, int ver1, const char* vername1, const int GetVersionIndice(elfheader_t* h, const char* vername); int GetNeededVersionCnt(elfheader_t* h, const char* libname); const char* GetNeededVersionString(elfheader_t* h, const char* libname, int idx); +int GetNeededVersionForLib(elfheader_t* h, const char* libname, const char* ver); kh_mapsymbols_t* GetMapSymbols(elfheader_t* h); kh_mapsymbols_t* GetWeakSymbols(elfheader_t* h); diff --git a/src/main.c b/src/main.c index 14e04d11..e8ebe74d 100644 --- a/src/main.c +++ b/src/main.c @@ -1701,6 +1701,9 @@ int main(int argc, const char **argv, char **env) { for(int i=nextarg; i<argc; ++i) argv[i] -= diff; // adjust strings } + box64_isglibc234 = GetNeededVersionForLib(elf_header, "libc.so.6", "GLIBC_2.34"); + if(box64_isglibc234) + printf_log(LOG_DEBUG, "Program linked with GLIBC 2.34+\n"); // get and alloc stack size and align if(CalcStackSize(my_context)) { printf_log(LOG_NONE, "Error: allocating stack\n"); @@ -1726,9 +1729,6 @@ int main(int argc, const char **argv, char **env) { // export symbols AddSymbols(my_context->maplib, GetMapSymbols(elf_header), GetWeakSymbols(elf_header), GetLocalSymbols(elf_header), elf_header); - box64_isglibc234 = GetVersionIndice(elf_header, "GLIBC_2.34")?1:0; - if(box64_isglibc234) - printf_log(LOG_DEBUG, "Program linked with GLIBC 2.34+\n"); if(wine_preloaded) { uintptr_t wineinfo = FindSymbol(GetMapSymbols(elf_header), "wine_main_preload_info", -1, NULL, 1, NULL); if(!wineinfo) wineinfo = FindSymbol(GetWeakSymbols(elf_header), "wine_main_preload_info", -1, NULL, 1, NULL); |