glibc/wrap-find-debuginfo.sh
Florian Weimer 8d4b53ceef Switch to the distribution debuginfo generation mechanism
This needs a wrapper script around find-debuginfo.sh, so that
ld.so is not stripped.

This commit resolves debuginfo file conflicts (#1886295) because
the ldconfig debuginfo file now includes the architecture name.
All debugging information is preserved in ld.so (#1905611).  With
the distribution defaults, we strip all binaries again (#1661510).
2021-05-11 17:30:04 +02:00

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