Don't try to apply patchelf to non-ELF binaries
This commit is contained in:
parent
bf63de1613
commit
d71a4851e8
@ -13,11 +13,7 @@ _separateDebugInfo() {
|
|||||||
# Find executables and dynamic libraries.
|
# Find executables and dynamic libraries.
|
||||||
local i magic
|
local i magic
|
||||||
while IFS= read -r -d $'\0' i; do
|
while IFS= read -r -d $'\0' i; do
|
||||||
# Skip non-ELF files.
|
if ! isELF "$i"; then continue; fi
|
||||||
exec {fd}< "$i"
|
|
||||||
read -n 4 -u $fd magic
|
|
||||||
exec {fd}<&-
|
|
||||||
if ! [[ "$magic" =~ ELF ]]; then continue; fi
|
|
||||||
|
|
||||||
# Extract the Build ID. FIXME: there's probably a cleaner way.
|
# Extract the Build ID. FIXME: there's probably a cleaner way.
|
||||||
local id="$(readelf -n "$i" | sed 's/.*Build ID: \([0-9a-f]*\).*/\1/; t; d')"
|
local id="$(readelf -n "$i" | sed 's/.*Build ID: \([0-9a-f]*\).*/\1/; t; d')"
|
||||||
@ -34,7 +30,7 @@ _separateDebugInfo() {
|
|||||||
|
|
||||||
# Also a create a symlink <original-name>.debug.
|
# Also a create a symlink <original-name>.debug.
|
||||||
ln -sfn ".build-id/${id:0:2}/${id:2}.debug" "$dst/../$(basename "$i")"
|
ln -sfn ".build-id/${id:0:2}/${id:2}.debug" "$dst/../$(basename "$i")"
|
||||||
done < <(find "$prefix" -type f -a \( -perm /0100 -o -name "*.so" -o -name "*.so.*" \) -print0)
|
done < <(find "$prefix" -type f -print0)
|
||||||
}
|
}
|
||||||
|
|
||||||
# - We might prefer to compress the debug info during link-time already,
|
# - We might prefer to compress the debug info during link-time already,
|
||||||
|
@ -5,12 +5,15 @@
|
|||||||
fixupOutputHooks+=('if [ -z "$dontPatchELF" ]; then patchELF "$prefix"; fi')
|
fixupOutputHooks+=('if [ -z "$dontPatchELF" ]; then patchELF "$prefix"; fi')
|
||||||
|
|
||||||
patchELF() {
|
patchELF() {
|
||||||
header "patching ELF executables and libraries in $prefix"
|
header "shrinking RPATHs of ELF executables and libraries in $prefix"
|
||||||
if [ -e "$prefix" ]; then
|
|
||||||
find "$prefix" \( \
|
local i
|
||||||
\( -type f -a -name "*.so*" \) -o \
|
while IFS= read -r -d $'\0' i; do
|
||||||
\( -type f -a -perm -0100 \) \
|
if [[ "$i" =~ .build-id ]]; then continue; fi
|
||||||
\) -print -exec patchelf --shrink-rpath '{}' \;
|
if ! isELF "$i"; then continue; fi
|
||||||
fi
|
echo "shrinking $i"
|
||||||
|
patchelf --shrink-rpath "$i" || true
|
||||||
|
done < <(find "$prefix" -type f -print0)
|
||||||
|
|
||||||
stopNest
|
stopNest
|
||||||
}
|
}
|
||||||
|
@ -180,6 +180,17 @@ installBin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Return success if the specified file is an ELF object.
|
||||||
|
isELF() {
|
||||||
|
local fn="$1"
|
||||||
|
local magic
|
||||||
|
exec {fd}< "$fn"
|
||||||
|
read -n 4 -u $fd magic
|
||||||
|
exec {fd}<&-
|
||||||
|
if [[ "$magic" =~ ELF ]]; then return 0; else return 1; fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# Initialisation.
|
# Initialisation.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user