patchelf icon indicating copy to clipboard operation
patchelf copied to clipboard

Fix assertion failure when setting the interpreter of a debug-only executable

Open corngood opened this issue 7 months ago • 2 comments

The included test currently fails only on binutils 2.44, which is available on nixpkgs-unstable. I've only tested on x86_64-linux.

Perhaps lastReplaced should be renamed because it no longer ends up pointing to the actual last replaced section.

corngood avatar Apr 21 '25 00:04 corngood

Should we also bail out of setInterpreter if .interp is NOBITS? If so, should it be an error?

Unfortunately auto-patchelf calls --set-interpreter on any ELF where .interp exists, even if it's NOBITS, so if we make it an error, changes will still be required there.

corngood avatar Apr 21 '25 00:04 corngood

The test I added showed another problem when run with clang. It looks like clang outputs ET_DYN, which means it doesn't even hit the other fix in rewriteSectionsExecutable.

The problem with clang (with both old and new binutils) is that it's accessing .dynamic even if it's NOBITS. I've pushed a fix for that in ad3d3d4abbcff52e142732b04dd27257d35285b6.

corngood avatar Apr 21 '25 00:04 corngood