You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Using patchelf --add-needed and --remove-needed breaks PIE executable #115
I am using Ubuntu 16.04 LTS and uname -a gives the following output: Linux terrier 4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:47:47 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
I am also using patchelf on current master version, that is commit hash: 327d80443672c397970738f9e216a7e86cbf3ad7
Sorry if the bug report is not very helpful, I will gladly provide any information that you deem necessary.
A probable cause is that --remove-needed doesn't update the symbol versioning table. I have some WIP patches that I might get finished at some point...
Some derivations of my custom nixpkgs-overlay broke on the upgrade to 18.03 with a dl-version.c: 224: _dl_check_map_versions: Assertion needed != NULL' failed`. There hasn't been any patchelf version-bump in the meantime, but it's got something to do with the remove-needed. @dezgeg: Do you have this WIP somewhere on github?
I've stumbled upon this and it is still happening. Take a simple "Hello, world!" executable and compile it: gcc -pie -fPIE -o hello hello.c
and run patchelf --add-needed libsomething.so ./hello
Running the ELF post edit results in cannot execute binary file: Exec format error
Unfortunately the link is now bit-rotted, and the file was never committed.
In the future, we should get all test executables in draft PRs at a minimum, so we don't have such bit-rot problems.
(From-source test data might seem better, but the interesting thing is 99% the toolchain you used, not the code you wrote. So unless one can produce that exact toolchain from source (e.g. with an exact Nixpkgs revision), one is best off us just giving us a binary. So it is very good we finally got one. We just failed to commit it in time.)
Activity
gamazeps commentedon Jan 31, 2017
A colleague on NixOS could not reproduce this.
I am using Ubuntu 16.04 LTS and
uname -agives the following output:Linux terrier 4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:47:47 UTC 2017 x86_64 x86_64 x86_64 GNU/LinuxI am also using patchelf on current master version, that is commit hash:
327d80443672c397970738f9e216a7e86cbf3ad7Sorry if the bug report is not very helpful, I will gladly provide any information that you deem necessary.
dezgeg commentedon Apr 16, 2017
A probable cause is that
--remove-neededdoesn't update the symbol versioning table. I have some WIP patches that I might get finished at some point...knedlsepp commentedon Apr 11, 2018
Some derivations of my custom nixpkgs-overlay broke on the upgrade to 18.03 with a
dl-version.c: 224: _dl_check_map_versions: Assertionneeded != NULL' failed`. There hasn't been any patchelf version-bump in the meantime, but it's got something to do with the remove-needed. @dezgeg: Do you have this WIP somewhere on github?Knightingales commentedon Mar 21, 2019
I've stumbled upon this and it is still happening. Take a simple "Hello, world!" executable and compile it:
gcc -pie -fPIE -o hello hello.cand run
patchelf --add-needed libsomething.so ./helloRunning the ELF post edit results in
cannot execute binary file: Exec format errordomenkozar commentedon Mar 29, 2019
Maybe try with new release? https://nixos.org/releases/patchelf/patchelf-0.10/
ezyang commentedon Aug 4, 2019
I am able to confirm that
--replace-neededdid not work with patchelf-0.9 from my distro with this error message, but worked when I used master.domenkozar commentedon Jun 10, 2020
This is probably fixed, but needs a regression test.
airlsyn commentedon Jun 15, 2020
I met the same error while using
patchelf-0.11to remove needed so on ubuntu 18.04when edit so
the following error would occur
domenkozar commentedon Jun 15, 2020
@EricXSun could you attach
libonnxruntime.soairlsyn commentedon Jun 15, 2020
@domenkozar pls see the shared file
https://drive.google.com/file/d/1rQZYIkzOu4UGJ4Cczm-FVM2LrxYw1Xc0/view?usp=sharing
airlsyn commentedon Jun 16, 2020
@domenkozar any progress?
domenkozar commentedon Jun 16, 2020
I can reproduce.
Someone could rebase #166 and check if that PR fixes the problem.
airlsyn commentedon Jun 17, 2020
I guess it won't be ok, i.e., will not fix this problem.
the problem here, looks like things in
replaceNeeded, updating the.gnu.version_rsectionEricson2314 commentedon Aug 13, 2025
Unfortunately the link is now bit-rotted, and the file was never committed.
In the future, we should get all test executables in draft PRs at a minimum, so we don't have such bit-rot problems.
(From-source test data might seem better, but the interesting thing is 99% the toolchain you used, not the code you wrote. So unless one can produce that exact toolchain from source (e.g. with an exact Nixpkgs revision), one is best off us just giving us a binary. So it is very good we finally got one. We just failed to commit it in time.)