mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-23 09:00:51 +00:00
autoPatchelfHook: Skip on missing segment headers
If the file in question is not a shared object file but an ELF, we
really want to skip the file, because we won't have anything to patch
there.
For example if the file is created via "gcc -c -o foo.o foo.c", we don't
get a segment header and so far autoPatchelf was trying to patch such a
file.
By checking for missing segment headers, we're now no longer going to
attempt patching such a file.
Signed-off-by: aszlig <aszlig@nix.build>
Reported-by: Sander van der Burg <svanderburg@gmail.com>
(cherry picked from commit 4a6e3e4185)
This commit is contained in:
@@ -205,9 +205,12 @@ autoPatchelf() {
|
||||
# outside of this function.
|
||||
while IFS= read -r -d $'\0' file; do
|
||||
isELF "$file" || continue
|
||||
segmentHeaders="$(LANG=C readelf -l "$file")"
|
||||
# Skip if the ELF file doesn't have segment headers (eg. object files).
|
||||
echo "$segmentHeaders" | grep -q '^Program Headers:' || continue
|
||||
if isExecutable "$file"; then
|
||||
# Skip if the executable is statically linked.
|
||||
LANG=C readelf -l "$file" | grep -q "^ *INTERP\\>" || continue
|
||||
echo "$segmentHeaders" | grep -q "^ *INTERP\\>" || continue
|
||||
fi
|
||||
autoPatchelfFile "$file"
|
||||
done < <(find "$@" ${norecurse:+-maxdepth 1} -type f -print0)
|
||||
|
||||
Reference in New Issue
Block a user