Re: [PATCH 2/2] x86/boot/compressed: Remove unnecessary sections from bzImage

From: Arvind Sankar
Date: Sat Feb 22 2020 - 10:39:29 EST


On Sat, Feb 22, 2020 at 12:42:42AM -0700, Nathan Chancellor wrote:
>
> Thanks for the clarity. With your suggestion (diff below), I see the
> following error:
>
> arch/x86/boot/compressed/vmlinux: no symbols
> ld.lld: error: undefined symbol: ZO_input_data
> >>> referenced by arch/x86/boot/header.o:(.header+0x59)
>
> ld.lld: error: undefined symbol: ZO_z_input_len
> >>> referenced by arch/x86/boot/header.o:(.header+0x5D)
> make[3]: *** [../arch/x86/boot/Makefile:108: arch/x86/boot/setup.elf]
>
> It seems like the section still isn't being added?
>
> Cheers,
> Nathan

It seems like lld also doesn't treat .symtab as special and is
discarding it, but that one is actually essential to be able to build
the bzImage.

The sections that GNU ld ends up discarding via that *(*) directive are
.dynsym, .dynstr, .gnu.hash, .eh_frame, .rela.dyn, .comment and
.dynamic.

Out of these, only .eh_frame has any significant size, and that's what
we discard in the other linker scripts (in kernel/vmlinux.lds.S and
boot/setup.ld).

It looks like it would be safest to just do
/DISCARD/ : {
*(.eh_frame)
}
instead. If you can double-check that that works with lld, I can send
out a new version.

Thanks and sorry for the breakage.