diff options
author | aszlig <aszlig@nix.build> | 2018-11-26 01:58:36 +0100 |
---|---|---|
committer | aszlig <aszlig@nix.build> | 2018-11-26 01:58:36 +0100 |
commit | 4a6e3e4185dcbe53c3d5eceaf2570d51516ad2b4 (patch) | |
tree | cbba0b7cad12e985e76934f975fdd2e78a3dc577 /pkgs/build-support | |
parent | 9f23a63f79e1a9d4a7f51444c12605d73ec770e1 (diff) |
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>
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/setup-hooks/auto-patchelf.sh | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/pkgs/build-support/setup-hooks/auto-patchelf.sh b/pkgs/build-support/setup-hooks/auto-patchelf.sh index 9a124f415b8cc..5bedd1a9f9caf 100644 --- a/pkgs/build-support/setup-hooks/auto-patchelf.sh +++ b/pkgs/build-support/setup-hooks/auto-patchelf.sh @@ -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) |