View previous topic :: View next topic |
Author |
Message |
tholin Apprentice
Joined: 04 Oct 2008 Posts: 203
|
Posted: Fri Jan 13, 2017 10:37 am Post subject: How to keep old binaries running as the system changes? |
|
|
I have a script that runs some benchmarks and produce some statistics. I usually run it after major kernel version updates to check for performance regressions (power management code often regress). I've put all the benchmark binaries in a folder so I always use the same binaries. The binaries use shared libraries so I also copy them to the folder and use something like LD_LIBRARY_PATH=lib bin/benchmark to run them.
This worked fine until some days ago when glibc was updated on the system. After that all the copied binaries started to segfault. The reason was that dynamically linked elf files got a header called .interp which is a string describing which interpreter (dynamic linker) to use. It was set to /lib64/ld-linux-x86-64.so.2 -> ld-2.23.so on all binaries. So the dynamic linker from one version of glibc tried to link in libc.so from another version and that didn't work.
I tried to work around the problem by placing ld-2.22.so in the folder and starting the binaries like LD_LIBRARY_PATH=lib lib/ld-2.22.so bin/benchmark. That worked for some of the benchmarks but some still segfaulted. I believe they spawned their own subprocesses and off course they didn't use ld-2.22.so for that. I also tried to patch all binaries with patchelf --set-interpreter to the bundled interpreter but this also fails for some of the benchmarks. I don't know why.
There must be some better way of doing this? I've considered setting up a full chroot with everything needed but then I'd have to switch to root to chroot into the folder every time. Statically compiling the binaries might work but I can't use portage for that because the benchmarks don't have any static useflag. There is no guarantee they can be statically compiled at all. They might have calls to dlopen and such. What is the best way to keep old binaries around and have them work for many years? |
|
Back to top |
|
|
C5ace Guru
Joined: 23 Dec 2013 Posts: 472 Location: Brisbane, Australia
|
Posted: Fri Jan 13, 2017 12:00 pm Post subject: |
|
|
Compile and link your benchmark application with the gcc -static-libgcc flag. This will staticaly link the library into your benchmark applications and make them independent at runtime from the installed libraries like glibc. |
|
Back to top |
|
|
|