···13 # Find executables and dynamic libraries.
14 local i magic
15 while IFS= read -r -d $'\0' i; do
16- # Skip non-ELF files.
17- exec {fd}< "$i"
18- read -n 4 -u $fd magic
19- exec {fd}<&-
20- if ! [[ "$magic" =~ ELF ]]; then continue; fi
2122 # Extract the Build ID. FIXME: there's probably a cleaner way.
23 local id="$(readelf -n "$i" | sed 's/.*Build ID: \([0-9a-f]*\).*/\1/; t; d')"
···3435 # Also a create a symlink <original-name>.debug.
36 ln -sfn ".build-id/${id:0:2}/${id:2}.debug" "$dst/../$(basename "$i")"
37- done < <(find "$prefix" -type f -a \( -perm /0100 -o -name "*.so" -o -name "*.so.*" \) -print0)
38}
3940# - We might prefer to compress the debug info during link-time already,
···13 # Find executables and dynamic libraries.
14 local i magic
15 while IFS= read -r -d $'\0' i; do
16+ if ! isELF "$i"; then continue; fi
00001718 # Extract the Build ID. FIXME: there's probably a cleaner way.
19 local id="$(readelf -n "$i" | sed 's/.*Build ID: \([0-9a-f]*\).*/\1/; t; d')"
···3031 # Also a create a symlink <original-name>.debug.
32 ln -sfn ".build-id/${id:0:2}/${id:2}.debug" "$dst/../$(basename "$i")"
33+ done < <(find "$prefix" -type f -print0)
34}
3536# - We might prefer to compress the debug info during link-time already,
···5fixupOutputHooks+=('if [ -z "$dontPatchELF" ]; then patchELF "$prefix"; fi')
67patchELF() {
8- header "patching ELF executables and libraries in $prefix"
9- if [ -e "$prefix" ]; then
10- find "$prefix" \( \
11- \( -type f -a -name "*.so*" \) -o \
12- \( -type f -a -perm -0100 \) \
13- \) -print -exec patchelf --shrink-rpath '{}' \;
14- fi
00015 stopNest
16}
···5fixupOutputHooks+=('if [ -z "$dontPatchELF" ]; then patchELF "$prefix"; fi')
67patchELF() {
8+ header "shrinking RPATHs of ELF executables and libraries in $prefix"
9+10+ local i
11+ while IFS= read -r -d $'\0' i; do
12+ if [[ "$i" =~ .build-id ]]; then continue; fi
13+ if ! isELF "$i"; then continue; fi
14+ echo "shrinking $i"
15+ patchelf --shrink-rpath "$i" || true
16+ done < <(find "$prefix" -type f -print0)
17+18 stopNest
19}