Open mologie opened 1 year ago
Just hit this bug. I have a script that, after building a couple of shared libraries, executes patchelf --set-rpath '$ORIGIN'
then llvm-strip-16 -S
, and I got that same result as @mologie:
ubuntu@ubuntu:~/Workspace/native-deps/out/lib$ ldd libpdfium.so
not a dynamic executable
Inverting the patchelf
call with llvm-strip
fixed the issue
I encountered this issue with patchelf 0.18.0 (from Ubuntu 24.04 on GitHub Actions) and llvm-strip 18.0.2 (from the Android NDK version 27.1.12297006).
The error message from Android was very confusing:
dlopen failed: cannot find "ED_set_revocationDate" from verneed[0] in DT_NEEDED list for "/data/app/~~Rr0R8wZnu25DjWkjOaOrRg==/com.chaquo.python.demo3-rax9ByToGYEcHJfwYeyCzg==/base.apk!/lib/arm64-v8a/libcrypto_python.so"
It looks like it's trying to read the "version needs" section but is finding a fragment of a symbol where there should be a library name. But llvm-readelf shows that section to be normal:
Version needs section '.gnu.version_r' contains 2 entries:
Addr: 0000000000023284 Offset: 0x023284 Link: 26 (.dynstr)
0x0000: Version: 1 File: libdl.so Cnt: 1
0x0020: Name: LIBC Flags: none Version: 7
0x0010: Version: 1 File: libc.so Cnt: 1
0x0030: Name: LIBC Flags: none Version: 6
The offending string appears in the middle of the .dynsym table:
3789: 00000000002e8c78 96 FUNC GLOBAL DEFAULT 12 X509_REVOKED_set_revocationDate@@OPENSSL_3.0.0
As in the previous comment, calling strip before patchelf fixes the problem. Unfortunately this isn't an adequate workaround on Android, because the app build tool strips libraries automatically, including in my users' apps which I have no control over.
Describe the bug
Running
patchelf
on any ELF file causesllvm-strip-14
to corrupt it afterwards. (One might argue that this is an llvm-strip bug, and it probably is, but patchelf might be able to produce an ELF file in a format that's still processable with LLVM.)Affects: All patchelf versions from 0.14 to 0.18 that I tested, LLVM 14 and 15
Steps To Reproduce
tl;dr: Run
patchelf --set-rpath '$ORIGIN'
on any binary, then runllvm-strip
with standard args on it. The output is always corrupted.Use an Ubuntu 22.04 image and install
llvm-14-tools
forllvm-strip-14
. (llvm-15-tools
is similarly affected.)The
a.*
binaries are attached: patchelf-strip-corruption.tar.gzExpected behavior
I expected
llvm-strip
to work. Specifically, I'd have expected theldd a.patched.stripped
command to report that it's still a dynamic executable, and./a.patched.stripped
should not have segfaulted.patchelf --version
outputpatchelf 0.18.0
Additional context
Files in this report are from Ubuntu 22.04 x86_64, but it appears to happen on any OS and with any LLVM distribution. Gave Arch Linux x86_64 and Ubuntu for arm64 a shot. Strip from binutils does not corrupt the ELF files.