1

Is there a utility for editing the symbol version in a compiled binary (executable or shared library)?

For example, if I have

> nm a.out
...
                 U powf@@GLIBC_2.27

I would like to change it to

> nm a.out
...
                 U powf@GLIBC_2.2.5

I'm able to make this version change by adding

__asm__(".symver powf,powf@GLIBC_2.2.5");

to a source file, but I want to do this for binaries that are already compiled.

Editing the binary hex almost works, but since desired symbol version is 1 character longer than the original, I can only manage to make it say

/usr/lib/libm.so.6: version `GLIBC_2.2.' not found

at runtime.

Overall, I'm attempting to make a binary compiled against glibc 2.27+ compatible with older versions of glibc, and if this method works, it would be far easier than other alternatives, e.g. compiling a custom GCC/glibc/libstdc++/dependencies toolchain.

Vortico
  • 2,610
  • 2
  • 32
  • 49
  • glibc is generally only backwards ABI-compatible (i.e. a binary compiled against 2.2.5 *should* work with 2.27, but the other way round is unlikely in the best case scenario). See [this answer](https://stackoverflow.com/questions/11107263/how-compatible-are-different-versions-of-glibc). – Simon Doppler May 13 '19 at 15:15
  • Hmm, I suppose you're right in general. It seems to work for all functions I've tried using `objcopy --redefine-sym powf@@GLIBC_2.27=powf@GLIBC_2.2.5 file`, but who knows what corner cases could arise. – Vortico May 14 '19 at 09:52

0 Answers0