Open mika-fischer opened 10 months ago
Might be related to https://github.com/NixOS/patchelf/pull/475
I can see a very similar issue in the latest Ubuntu Focal with patchelf
0.18.0 compiled from source. It seems that a call to --set-rpath
somehow corrupts the ELF binary to the point where ld.so
no longer recognizes it as a dynamic executable. That being said, even though my symptoms fit the description above I am uncertain whether this is due to header alignment. I will try to confirm this and get back.
In the meantime, here is my minimal example that you can try e.g. in a Docker container:
cp /lib/x86_64-linux-gnu/libxcb-image.so.0 .
ldd libxcb-image.so.0
linux-vdso.so.1 (0x00007ffcde5e9000)
libxcb-shm.so.0 => /lib/x86_64-linux-gnu/libxcb-shm.so.0 (0x00007f1b1a17e000)
libxcb-util.so.1 => /lib/x86_64-linux-gnu/libxcb-util.so.1 (0x00007f1b19f78000)
libxcb.so.1 => /lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f1b19f4e000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1b19d5c000)
libXau.so.6 => /lib/x86_64-linux-gnu/libXau.so.6 (0x00007f1b19d56000)
libXdmcp.so.6 => /lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f1b19d4e000)
/lib64/ld-linux-x86-64.so.2 (0x00007f1b1a39b000)
libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f1b19d32000)
patchelf --set-rpath \$ORIGIN libxcb-image.so.0
ldd libxcb-image.so.0
not a dynamic executable
I am attaching a side-by-side diff of objdump -x
of the patched ELF binary: diff_set_rpath.txt
Still an issue with HEAD...
Describe the bug
Using
--set-rpath
with 0.18.0 creates a broken header alignment. Using the patched library leads toerror while loading shared libraries: libcudart.so.11.0: ELF load command address/offset not properly aligned
. 0.17.2 works fineSteps To Reproduce
patchelf-regression.zip
Note that VirtAddr-Offset does is not aligned by Align
Expected behavior 0.17.2 produces
Note that VirtAddr-Offset does is aligned by Align
patchelf --version
outputpatchelf 0.18.0