From 91546004903eea5d5267d59898a6029ba1d64031 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Fri, 18 Oct 2024 03:20:17 +0200 Subject: [PATCH] strip: Treat bare object files like static libs, not shared libs Debug symbols should only be split from finally linked ELFs, not bare object files. We're already excluding static libraries from splitting for a similar reason. The `.gnu_debuglink` sections are also mishandled by LLVM's LLD, which copies them to its output. For example, this affects Arch Linux's `/usr/lib/Scrt1.o`. While we're here (and it changes the code less), also strip GNU LTO data from bare objects, again for the same reason we're removing it from static libraries, and apply static library stripping instead of shared library stripping. See: https://bugs.gentoo.org/787623 --- scripts/libmakepkg/tidy/strip.sh.in | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/libmakepkg/tidy/strip.sh.in b/scripts/libmakepkg/tidy/strip.sh.in index 0b2d061f..70121287 100644 --- a/scripts/libmakepkg/tidy/strip.sh.in +++ b/scripts/libmakepkg/tidy/strip.sh.in @@ -166,7 +166,7 @@ tidy_strip() { # guile-2.2 [[ "$binary" =~ .*/guile/.*\.go$ ]] && continue - local STATICLIB=0 + local STATICOBJ=0 case "$(LC_ALL=C readelf -h "$binary" 2>/dev/null)" in *Type:*'DYN (Shared object file)'*) # Libraries (.so) or Relocatable binaries strip_flags="$STRIP_SHARED";; @@ -180,10 +180,10 @@ tidy_strip() { fi ;; *Type:*'REL (Relocatable file)'*) # Libraries (.a) or objects - if ar t "$binary" &>/dev/null; then # Libraries (.a) + if [[ $binary = *'.o' ]] || ar t "$binary" &>/dev/null; then strip_flags="$STRIP_STATIC" - STATICLIB=1 - elif [[ $binary = *'.ko' || $binary = *'.o' ]]; then # Kernel module or object file + STATICOBJ=1 + elif [[ $binary = *'.ko' ]]; then # Kernel modules strip_flags="$STRIP_SHARED" else continue @@ -192,9 +192,9 @@ tidy_strip() { *) continue ;; esac - (( ! STATICLIB )) && collect_debug_symbols "$binary" + (( ! STATICOBJ )) && collect_debug_symbols "$binary" strip_file "$binary" ${strip_flags} - (( STATICLIB )) && strip_lto "$binary" + (( STATICOBJ )) && strip_lto "$binary" done elif check_option "debug" "y"; then