strip: Overwrite debuglink when it's already present

When objcopy encounters an already-present section, adding the new
debuglink will fail with a warning. Remove any existing `.gnu_debuglink`
section to work around this problem.

Arch Linux's `rust` package is affected by this. Apparently when LLVM's
LLD links in `/usr/lib/Scrt1.o` it will also copy the `.gnu_debuglink`
section.

See: https://bugs.gentoo.org/787623
This commit is contained in:
Jan Alexander Steffens (heftig) 2024-10-18 03:02:31 +02:00 committed by Allan McRae
parent 71afd4d88f
commit e0162a6868

View file

@ -100,6 +100,7 @@ collect_debug_symbols() {
return
fi
safe_objcopy "$binary" --remove-section=.gnu_debuglink
safe_objcopy "$binary" --add-gnu-debuglink="$dbgdir/${binary#/}.debug"
# create any needed hardlinks