I have a proprietary ELF binary that I am trying to run. It is dynamically linked, but only against the normal libc stuff:
$ file binary
binary: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=e02a29757b79db68a7bd41a731c6eb7d3e2a0382, with debug_info, not stripped
$ ldd binary
linux-vdso.so.1 (0x00007f5556bc1000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f5556b7f000)
libm.so.6 => /lib64/libm.so.6 (0x00007f5556a9e000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f5556a99000)
librt.so.1 => /lib64/librt.so.1 (0x00007f5556a94000)
libc.so.6 => /lib64/libc.so.6 (0x00007f55568b2000)
/lib64/ld-linux-x86-64.so.2 (0x00007f5556bc3000)
The part I care about is the SDL2 library, which has been statically linked in:
$ nm binary | grep SDL
...
0000000000482610 T SDL_VideoInit
0000000000478110 t SDL_VideoInit_DEFAULT
00000000004b61a0 T SDL_VideoInit_REAL
0000000000482620 T SDL_VideoQuit
000000000047d400 t SDL_VideoQuit_DEFAULT
00000000004b5f80 T SDL_VideoQuit_REAL
0000000000480de0 T SDL_WaitEvent
0000000000480df0 T SDL_WaitEventTimeout
000000000047bab0 t SDL_WaitEventTimeout_DEFAULT
00000000004845e0 T SDL_WaitEventTimeout_REAL
000000000047bae0 t SDL_WaitEvent_DEFAULT
00000000004842f0 T SDL_WaitEvent_REAL
00000000004824d0 T SDL_WaitThread
00000000004782a0 t SDL_WaitThread_DEFAULT
00000000004a6760 T SDL_WaitThread_REAL
...
(SDL is LGPL, so AFAIK it should not be statically linked, but it has been.) Actually SDL2 is no longer LGPL.
In order to get this to run on my system I want to replace the SDL library that was statically linked. The binary is not stripped, and the debug symbols are clearly in place, so I have some hope that this is possible.
Is there some tool that I can use to remove these symbols and replace them with a dynamic reference to an SDL .so file?
I know that there is no guarantee of success (for instance some functions may have been inlined), but is there a reasonable way to try?
bonus question: Why are the symbols duplicated with _REAL
and _DEFUALT
suffixes? I thought those were for versioning with .so files. What would they be doing when statically linked?
README-dynapi.md
.