patchelf
patchelf copied to clipboard
patchelf --remove-rpath leaves the rpath string the file
Describe the bug
After running patchelf --remove-rpath on a shared library, readelf -a | grep $OLD_RPATH will show no matches. However the string has been left behind in the binary.
Steps To Reproduce
Please include exact steps with an attached binary so that another person can reproduce the problem.
patchelf --remove-rpath libgcc_s.so.1
readelf -a libgcc_s.so.1 | grep /nix/store/kvjzg
strings libgcc_s.so.1 | grep /nix/store/kvjzg
/nix/store/7rb10j6ifizp05pm2h51sjwiky5wnkb8-xgcc-11.3.0-lib/lib:/nix/store/kvjzg5xf51niicmw9fndxws1akgz21p4-bootstrap-stage0-glibc-bootstrap/lib:/nix/store/4b30jk1h42q5qs71l4sbv8cr3hnxdys4-bootstrap-tools/lib
Expected behavior
No output from the second command. Nix's reference scanner depends on this.
patchelf --version output
patchelf 0.15.0
Additional context
Add any other context about the problem here.
Temporary workaround is patchelf --set-rpath ""
Just now it only removes the dyn section: https://github.com/NixOS/patchelf/blob/5908e16cd562bcb1909be4de0409c4912a8afc52/src/patchelf.cc#L1400 it could also override the old string with XXX
Just now it only removes the dyn section:
https://github.com/NixOS/patchelf/blob/5908e16cd562bcb1909be4de0409c4912a8afc52/src/patchelf.cc#L1400
it could also override the old string with
XXX
Isn't modifying the old value potentially dangerous? Is there anything that says multiple dyn entries can't refer to the same string in the table (or even the suffix of an existing string)?
Isn't modifying the old value potentially dangerous? Is there anything that says multiple dyn entries can't refer to the same string in the table (or even the suffix of an existing string)?
Yikes. That is probably the case.
Isn't modifying the old value potentially dangerous? Is there anything that says multiple dyn entries can't refer to the same string in the table (or even the suffix of an existing string)?
Yes, you are right. I forgot about this optimization...
Isn't this a problem for --set-rpath as well?
Right now --set-rpath "" blanks the rpath:
https://github.com/NixOS/patchelf/blob/e37f892b12ff900ab5e733f688548c87cd14ef02/src/patchelf.cc#L1566-L1570
Isn't this a problem for
--set-rpathas well?
I think it is. I am surprised it never got filed as an issue...
Isn't this a problem for
--set-rpathas well?I think it is. I am surprised it never got filed as an issue...
Perhaps https://github.com/NixOS/patchelf/issues/162 is such an issue.
Perhaps #162 is such an issue.
Wow that looks highly likely to be the case.