NixOS / patchelf

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

patchelf: cannot find section '.dynamic'. The input file is most likely statically linked #465

Open yonghui-zhao opened 1 year ago

yonghui-zhao commented 1 year ago

Describe the bug

readelf -S ld-2.17.so | grep dynamic

[17] .dynamic DYNAMIC 0000000000221e00 00021e00

readelf -S ld-linux-x86-64.so.2 | grep dynamic

[17] .dynamic DYNAMIC 0000000000221e00 00021e00

patchelf --set-rpath :/lib64/:../lib64/xxxxx/:/opt/xxxxx/lib64/xxxx ld-2.17.so

readelf -S ld-linux-x86-64.so.2 | grep dynamic

readelf: Error: no .dynamic section in the dynamic segment

patchelf --set-rpath :/lib64/:../lib64/xxxxxx/:/opt/xxxxx/lib64/xxxxxld-linux-x86-64.so.2

patchelf: cannot find section '.dynamic'. The input file is most likely statically linked

patchelf --version

patchelf 0.12

Mic92 commented 1 year ago

I cannot reproduce this with glibc 2.35-224 ($ cp /nix/store/lqz6hmd86viw83f9qll2ip87jhb7p1ah-glibc-2.35-224/lib/ld-linux-x86-64.so.2 /tmp/foo.so)

./src/patchelf --set-rpath foo /tmp/foo.so

on git commit 8d3188daa7fbefb93e8d967d2967ca45934c30aa

But also what are you trying to achieve here? You cannot set an RPATH on your linker since your linker will not read itself for this information and also has no dependencies. Instead you need to patch other libraries or executables to have this information

yonghui-zhao commented 1 year ago

Cannot find section .dynamic #143 is same problom