Re: --orphan-handling=warn

From: Kees Cook
Date: Tue Feb 25 2020 - 14:43:03 EST


On Tue, Feb 25, 2020 at 01:29:51PM -0500, Arvind Sankar wrote:
> On Mon, Feb 24, 2020 at 09:35:04PM -0800, Kees Cook wrote:
> > Actually, it's rather opposed to the FGKASLR series, as for that, I need
> > some kind of linker script directive like this:
> >
> > /PASSTHRU/ : {
> > *(.text.*)
> > }
> >
> > Where "PASSTHRU" would create a 1-to-1 input-section to output-section
> > with the same name, flags, etc.
> >
> > ld.bfd's handling of orphan sections named .text.* is to put them each
> > as a separate output section, after the existing .text output section.
> >
> > ld.lld's handling of orphan sections named .text.* is to put them into
> > the .text output section.
>
> This doesn't match ld's documentation [1] of how orphan sections are to
> be handled, it's supposed to append it into an existing output section
> only if the names match exactly, creating a new one if that isn't so. If
> ld.lld is to be a drop-in replacement for ld.bfd, this probably needs to
> change?

That would be lovely! :P

> Also ld.lld doesn't seem to support the --unique option, I think you'll
> also want that for FGKASLR to avoid merging static functions with the
> same name from unrelated source files.

Right, yes, that seems like something we have to depend on.

>
> [1] https://sourceware.org/binutils/docs/ld/Orphan-Sections.html
>
> >
> > For FGKASLR (as it is currently implemented[2]), the sections need to be
> > individually named output sections (as bfd does it). *However*, with the
> > "warn on orphans" patch, FGKASLR's intentional orphaning will backfire
> > (I guess the warning could be turned off, but I'd like lld to handle
> > FGKASLR at some point.)
> >
> > Note that cheating and doing the 1-to-1 mapping by handy with a 40,000
> > entry linker script ... made ld.lld take about 15 minutes to do the
> > final link. :(
>
> Out of curiosity, how long does ld.bfd take on that linker script :)

A single CPU at 100% for 15 minutes. :)

--
Kees Cook