Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to keep old binaries running as the system changes?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
tholin
Tux's lil' helper
Tux's lil' helper


Joined: 04 Oct 2008
Posts: 88

PostPosted: Fri Jan 13, 2017 10:37 am    Post subject: How to keep old binaries running as the system changes? Reply with quote

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
View user's profile Send private message
C5ace
Apprentice
Apprentice


Joined: 23 Dec 2013
Posts: 162
Location: Brisbane, Australia

PostPosted: Fri Jan 13, 2017 12:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum