NixOS / patchelf

A small utility to modify the dynamic linker and RPATH of ELF executables
GNU General Public License v3.0
3.48k stars 483 forks source link

version GLIBC_2.2.5 not defined in file libc.so.6 #486

Closed git801 closed 1 year ago

git801 commented 1 year ago

I would like to run a test tool (i have no source code) that complied with GLIBC 2.17 on a host that GLIBC 2.12, from this question I learned to use "readelf" to change GLIBC 2.17 to 2.2.5 , and i learned to use "patchelf" to Add a declared dependency on a dynamic library, because in the old version of glibc clock_gettime is provided by the librt library, and also version 2.2.5

patchelf --add-needed librt.so.1 libpython3.6m.so.1.0

I thought it would solve every issue but no, there was again one more issue:

[58454] Error loading Python lib '/home/jhon/Desktop/test/libpython3.6m.so.1.0': dlopen: /home/jhon/Desktop/test/libpython3.6m.so.1.0: symbol clock_gettime, version GLIBC_2.2.5 not defined in file libc.so.6 with link time reference

But I do have this after patchelf:

1

I couldn't find any useful information online, except this page.

I'm using Cent OS 6.10.

If anyone has any clue, I would highly appreciate it. Thank you.

git801 commented 1 year ago

readelf -sV libc.so.6 result :

3

in '.gnu.version' and '.dynsym' ,there are mayn GLIBC_2.2.5, but in '.gnu.version_r' no GLIBC_2.2.5

Mic92 commented 1 year ago

librt.so is part of the glibc. You cannot only replace librt as it will be not be compatible with the old glibc on the system. You would need to ship also install glibc 2.17 on the machine where you want to run this program and than do something like this: yournew-libc/ld-linux-x86-64.so.2 yourbinary (this can be also done by setting the interpreter path in the binary). I provide more information about what the elf interpreter does in this article: https://blog.thalheim.io/2022/12/31/nix-ld-a-clean-solution-for-issues-with-pre-compiled-executables-on-nixos/