eu-strip --reloc-debug-sections-only on linux .debug objects

Vitaly Chikunov vt@altlinux.org
Tue Dec 8 23:22:33 GMT 2020


Mark,

On Tue, Dec 08, 2020 at 03:21:12PM +0100, Mark Wielaard wrote:
> Hi Vitaly,
> 
> On Mon, 2020-12-07 at 18:59 +0300, Vitaly Chikunov wrote:
> > Is it safe to run `eu-strip --reloc-debug-sections-only` on Linux
> > kernel
> > .debug files, such as vmlinux.debug and .ko.debug modules?
> 
> Yes, it was designed to be used on linux .ko.debug modules.

Thanks!

> vmlinux.debug itself is a special case though. It does contain
> relocation between debug sections, but those are not supposed to be
> applied and eu-strip --reloc-debug-sections will normally ignore them
> because vmlinux is ET_EXEC. See also this recent discussion:
> https://gcc.gnu.org/pipermail/gcc/2020-December/234392.html

Yes, if kernel is compiled without CONFIG_X86_NEED_RELOCS `eu-strip
--reloc-debug-sections-only` does noting to vmlinux.debug, but if it's
compiled with `CONFIG_X86_NEED_RELOCS=y` then `eu-strip
--reloc-debug-sections-only` actually reduces vmlinux.debug size (almost
twice in my experiments).

So, I wonder if we don't touch vmlinux binary would eu-strip
--reloc-debug-sections for vmlinux.debug break something somehow in
subtle way or it's safe.


> > It's really reduces size significantly. Description for .ko in
> > PR#24344 looks good (that it strips linking information that does not
> > needed for the kernel, but effect for vmlinux.debug in unstated), 
> 
> vmlinux itself needs to be handled slightly differently, see the thread
> above. But I don't fully understand the effect of --emit-relocs --
> discard-none ld options that the x86_64 kernel uses (it might be
> different for other arches).

`--emit-relocs --discard-none` pair is only used for x86_64 when
CONFIG_X86_NEED_RELOCS is enabled, which is used for KASLR or kdump
kernels (AFAIK).

So, question is what will happen if we don't touch vmlinux, but strip
trivial relocs for vmlinux.debug. Or better just not strip like this
(yet).

> > but, I
> > want to be extra sure it's safe to add to our (ALT Linux) packaging
> > system for -debuginfo rpms.
> 
> Upstream rpm comes with find-debuginfo.sh which takes an -r option. 
> The -r flag says to use eu-strip --reloc-debug-sections. Which the
> fedora kernel.spec uses.

I will implement this then.

Thanks,

> 
> Cheers,
> 
> Mark


More information about the Elfutils-devel mailing list