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>
This commit is contained in:
parent
9f23a63f79
commit
4a6e3e4185
1 changed files with 4 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue