strip: Overwrite existing debuglink and treat bare objects like static libs
-
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. -
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.