patchelf
patchelf copied to clipboard
stripping debug symbols after running patchelf --no-default-lib corrupts executable
This is related to #145 but I think is a different issue, since in this case the problem happens when patchelf runs with the option --no-default-lib (but if that option is not passed then the issue can't be reproduced) and #145 was an issue when passing --set-rpath $myrpath to patchelf, which is fixed.
This was tested with patchelf built from master as of today (8f5ac59adec499a4cbb871ffe935f944037b8468)
- Download the attached mb.zip file that contains an ELF binary inside and uncompress it (FYI: this binary was built with clang)
- Check that you can run
lddover the binary and it tries to find several libraries on the system
$ ldd MiniBrowser
- output: http://sprunge.us/FJ6XSH
- Run over it this patchelf command
patchelf --no-default-lib MiniBrowser
- Run again
lddand check how now it doesn't find any library becauseNODEFLIBis set
$ ldd MiniBrowser
- output: http://sprunge.us/ZBbBBc
- Strip the binary, you can see how
stripprints a warning
$ strip -g MiniBrowser
strip: stv8EN8Y: warning: allocated section `.dynstr' not in segment
- Run
lddagain, the binary is corrupted
$ ldd MiniBrowser
./MiniBrowser: ./MiniBrowser: no version information available (required by ./MiniBrowser)
./MiniBrowser: ./MiniBrowser: no version information available (required by ./MiniBrowser)
./MiniBrowser: ./MiniBrowser: no version information available (required by ./MiniBrowser)
linux-vdso.so.1 (0x00007ffe8e9fe000)
If the order of the commands is inverted (first strip and then patchelf) the issue doesn't happen.