-
Notifications
You must be signed in to change notification settings - Fork 21
/
brp-15-strip-debug
executable file
·45 lines (42 loc) · 1.46 KB
/
brp-15-strip-debug
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
# If using normal root, avoid changing anything.
if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
echo "RPM_BUILD_ROOT is not set or set to / : skipping strip"
exit 0
fi
if [ "$NO_BRP_STRIP_DEBUG" = "true" ] ; then
echo "NO_BRP_STRIP_DEBUG is set: skipping strip"
exit 0
fi
FIND_IGNORE=(
'('
-path "$RPM_BUILD_ROOT/usr/lib/debug" -o -path
"$RPM_BUILD_ROOT/lib/modules" -o -path "$RPM_BUILD_ROOT/opt/cross" -o
-path "$RPM_BUILD_ROOT/proc"
')'
-prune -o
)
# Strip debuginfo from ELF binaries, but not static libraries or kernel modules
find "$RPM_BUILD_ROOT" "${FIND_IGNORE[@]}" \( -name "*.a" -o -name "*.ko" \) \
-prune -o \
-type f \( -perm /0111 -o -name "*.so*" \) \
-exec file {} + | \
sed -n -e 's/^\(.*\):[ ]*ELF.*, not stripped.*$/\1/p' | while read f; do
mode="$(stat -c %a "$f")"
chmod u+w "$f" || :
${CROSS_COMPILE}strip -p --strip-debug --discard-locals -R .comment -R .note "$f" || :
chmod "$mode" "$f"
done
# Don't strip debuginfo from static libs, but compiler-generated local symbols
find "$RPM_BUILD_ROOT" "${FIND_IGNORE[@]}" -type f -name "*.[ao]" -print | while read f; do
case $(file "$f") in
*"current ar"*|*ELF*", not stripped"*)
chmod u+w "$f" || :
${CROSS_COMPILE}strip -p --discard-locals -R .comment -R .note -R .gnu.lto_* -R .gnu.debuglto_* -R __patchable_function_entries -N __gnu_lto_v1 "$f" || :
;;
*)
echo "WARNING: Strange looking archive $(file $f)"
continue
;;
esac
done