diff options
author | Harmen Stoppels <me@harmenstoppels.nl> | 2024-01-30 22:36:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-30 22:36:49 +0100 |
commit | 28eea2994f04ec73f647cf636de433fbc9317c4c (patch) | |
tree | 177b258cbb2b0a855cdb901c2f3c1b02b2f82515 /LICENSE-MIT | |
parent | 6d55caabe88f00aff7ce82e07f1de5b8f136e1e3 (diff) | |
download | spack-28eea2994f04ec73f647cf636de433fbc9317c4c.tar.gz spack-28eea2994f04ec73f647cf636de433fbc9317c4c.tar.bz2 spack-28eea2994f04ec73f647cf636de433fbc9317c4c.tar.xz spack-28eea2994f04ec73f647cf636de433fbc9317c4c.zip |
elf: relocate PT_INTERP (#42318)
Relocation of `PT_INTERP` in ELF files already happens to work from long to short path, thanks to generic binary relocation (i.e. find and replace). This PR improves it:
1. Adds logic to grow `PT_INTERP` strings through patchelf (which is only useful if the interpreter and rpath paths are the _only_ paths in the binary that need to be relocated)
2. Makes shrinking `PT_INTERP` cleaner. Before this PR when you would use Spack-built glibc as link dep, and relocate
executables using its dynamic linker, you'd end up with
```
$ file exe
exe: ELF 64-bit LSD pie executable, ..., interpreter /////////////////////////////////////////////////path/to/glibc/lib/ld-linux.so
```
With this PR you get something sensible:
```
$ file exe
exe: ELF 64-bit LSD pie executable, ..., interpreter /path/to/glibc/lib/ld-linux.so
```
When Spack cannot modify the interpreter or rpath strings in-place, it errors out without modifying the file, and leaves both tasks to patchelf instead.
Also add type hints to `elf.py`.
Diffstat (limited to 'LICENSE-MIT')
0 files changed, 0 insertions, 0 deletions