From 2e466a0073d2308544dd073dda595e7e77189fce Mon Sep 17 00:00:00 2001 From: Arjun Shankar Date: Tue, 6 Sep 2022 19:56:05 +0200 Subject: [PATCH] Retain libc.so.6 debuglink section, remove ld.so debuginfo file (#2090744) This commit fixes wrap-find-debuginfo.sh so that: * the .gnu_debuglink section of libc.so.6 is retained, and * the redundant debuginfo file generated for ld.so is removed Co-Authored-By: Benjamin Herrenschmidt Reviewed-by: Florian Weimer Rawhide commit: 8e2d77f7341a666f743f96c6b378b36ea7539ae1 --- glibc.spec | 7 ++++++- wrap-find-debuginfo.sh | 24 +++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/glibc.spec b/glibc.spec index 282f514..99ccd0b 100644 --- a/glibc.spec +++ b/glibc.spec @@ -152,7 +152,7 @@ end \ Summary: The GNU libc libraries Name: glibc Version: %{glibcversion} -Release: 16%{?dist} +Release: 17%{?dist} # In general, GPLv2+ is used by programs, LGPLv2+ is used for # libraries. @@ -2171,6 +2171,11 @@ update_gconv_modules_cache () %files -f compat-libpthread-nonshared.filelist -n compat-libpthread-nonshared %changelog +* Tue Sep 06 2022 Arjun Shankar - 2.35-17 +- Co-Authored-By: Benjamin Herrenschmidt +- Retain .gnu_debuglink section in libc.so.6 (#2090744) +- Remove redundant ld.so debuginfo file (#2090744) + * Tue Aug 23 2022 Arjun Shankar - 2.35-16 - Auto-sync with upstream branch release/2.35/master, commit 83f1d9851e0b143991448d41ff50744d9972cb6e: diff --git a/wrap-find-debuginfo.sh b/wrap-find-debuginfo.sh index 6a558df..3157d69 100644 --- a/wrap-find-debuginfo.sh +++ b/wrap-find-debuginfo.sh @@ -17,6 +17,7 @@ set -ex ldso_tmp="$(mktemp)" libc_tmp="$(mktemp)" +libc_dlink_tmp="$(mktemp)" # Prefer a separately installed debugedit over the RPM-integrated one. if command -v debugedit >/dev/null ; then @@ -26,7 +27,7 @@ else fi cleanup () { - rm -f "$ldso_tmp" "$libc_tmp" + rm -f "$ldso_tmp" "$libc_tmp" "$libc_dlink_tmp" } trap cleanup 0 @@ -66,6 +67,10 @@ cp "$libc_path" "$libc_tmp" # Run the debuginfo extraction. "$script_path" "$@" +# libc.so.6: Extract the .gnu_debuglink section +objcopy -j.gnu_debuglink --set-section-flags .gnu_debuglink=alloc \ + -O binary "$libc_path" "$libc_dlink_tmp" + # Restore the original files. cp "$ldso_tmp" "$ldso_path" cp "$libc_tmp" "$libc_path" @@ -74,6 +79,23 @@ cp "$libc_tmp" "$libc_path" objcopy --merge-notes "$ldso_path" objcopy --merge-notes "$libc_path" +# libc.so.6: Restore the .gnu_debuglink section +objcopy --add-section .gnu_debuglink="$libc_dlink_tmp" "$libc_path" + +# ld.so does not have separated debuginfo and so the debuginfo file +# generated by find-debuginfo is redundant. Therefore, remove it. +ldso_debug= +for ldso_debug_candidate in `find "$sysroot_path" -regextype posix-extended \ + -regex '.*/ld(-.*|64|)\.so\.[0-9]+.*debug$' -type f` ; do + if test -z "$ldso_debug" ; then + ldso_debug="$ldso_debug_candidate" + else + echo "error: multiple ld.so debug candidates: $ldso_debug, $ldso_debug_candidate" + exit 1 + fi +done +rm -f "$ldso_debug" + # libc.so.6: Reduce to valuable symbols. Eliminate file symbols, # annobin symbols, and symbols used by the glibc build to implement # hidden aliases (__EI_*). We would also like to remove __GI_*