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

From: Nick Desaulniers
Date: Sat Feb 22 2020 - 18:20:55 EST


On Sat, Feb 22, 2020 at 8:22 AM Arvind Sankar <nivedita@xxxxxxxxxxxx> wrote:
>
> On Sat, Feb 22, 2020 at 08:42:54AM +0100, Borislav Petkov wrote:
> > On Fri, Feb 21, 2020 at 11:21:44PM -0800, Fangrui Song wrote:
> > > In GNU ld, it seems that .shstrtab .symtab and .strtab are special
> > > cased. Neither the input section description *(.shstrtab) nor *(*)
> > > discards .shstrtab . I feel that this is a weird case (probably even a bug)
> > > that lld should not implement.
> >
> > Ok, forget what the tools do for a second: why is .shstrtab special and
> > why would one want to keep it?
> >
> > Because one still wants to know what the section names of an object are
> > or other tools need it or why?
> >
> > Thx.
> >
> > --
> > Regards/Gruss,
> > Boris.
> >
> > https://people.kernel.org/tglx/notes-about-netiquette
>
> .shstrtab is required by the ELF specification. The e_shstrndx field in
> the ELF header is the index of .shstrtab, and each section in the
> section table is required to have an sh_name that points into the
> .shstrtab.

Yeah, I can see it both ways. That `*` doesn't glob all remaining
sections is surprising to me, but bfd seems to be "extra helpful" in
not discarding sections that are required via ELF spec.

Kees is working on a series to just be explicit about what sections
are ordered where, and what's discarded, which should better handle
incompatibilities between linkers in regards to orphan section
placement and "what does `*` mean." Kees, that series can't come soon
enough. ;) (I think it's intended to help "fine grain" (per function)
KASLR). More comments in the other thread.

Taken from the Zen of Python, but in regards to sections in linker
scripts, "explicit is better than implicit."
--
Thanks,
~Nick Desaulniers