83835daada
Fedora commit: 4f55bd2df5c705c99f21e1d35941843212b3e3a1 Related: #1945473 Resolves: #1945472 Resolves: #1915330
64 lines
1.3 KiB
Bash
64 lines
1.3 KiB
Bash
#!/bin/bash
|
|
# Wrapper script for find-debuginfo.sh
|
|
#
|
|
# Usage:
|
|
# wrap-find-debuginfo.sh LDSO-PATH SCRIPT-PATH SCRIPT-ARGS...
|
|
#
|
|
# The wrapper saves the original versions of the file at LDSO-PATH,
|
|
# invokes SCRIPT-PATH with SCRIPT-ARGS, and then restores the
|
|
# LDSO-PATH file. As a result, LDSO-PATH has unchanged debuginfo even
|
|
# after debuginfo extraction.
|
|
|
|
set -ex
|
|
|
|
ldso_tmp="$(mktemp)"
|
|
|
|
cleanup () {
|
|
rm -f "$ldso_tmp"
|
|
}
|
|
trap cleanup 0
|
|
|
|
ldso_path="$1"
|
|
shift
|
|
script_path="$1"
|
|
shift
|
|
|
|
# Preserve the original file.
|
|
cp "$ldso_path" "$ldso_tmp"
|
|
|
|
# Run the debuginfo extraction.
|
|
"$script_path" "$@"
|
|
|
|
# Restore the original file.
|
|
cp "$ldso_tmp" "$ldso_path"
|
|
|
|
# Reduce the size of notes. Primarily for annobin.
|
|
objcopy --merge-notes "$ldso_path"
|
|
|
|
# Rewrite the source file paths to match the extracted locations.
|
|
# First compute the arguments for invoking debugedit. See
|
|
# find-debuginfo.sh.
|
|
debug_dest_name="/usr/src/debug"
|
|
last_arg=
|
|
while true ; do
|
|
arg="$1"
|
|
shift || break
|
|
case "$arg" in
|
|
(--unique-debug-src-base)
|
|
debug_dest_name="/usr/src/debug/$1"
|
|
shift
|
|
;;
|
|
(-*)
|
|
;;
|
|
(*)
|
|
last_arg="$arg"
|
|
;;
|
|
esac
|
|
done
|
|
debug_base_name=${last_arg:-$RPM_BUILD_ROOT}
|
|
/usr/lib/rpm/debugedit -b "$debug_base_name" -d "$debug_dest_name" -n \
|
|
$ldso_path
|
|
|
|
# Apply single-file DWARF optimization.
|
|
dwz $ldso_path
|