Support dead-stripping in ELF objects

Robinson, Paul Paul_Robinson at playstation.sony.com
Tue Apr 2 18:22:07 PDT 2013


Nick, Shankar, and Jim all asked about some indication in the object
file that .subsections_via_symbols is in effect and the relocs are right.

The obvious place to put that indication is in the ELF header e_flags
field, and that's what I do in my private target.  However, the e_flags
field is specified to be processor-specific so it's kind of hard to
pick a flag bit and be sure nobody uses it for something else anywhere,
across all (ELF-using) targets.  I am willing to put out infrastructure
to make it easy for any particular target to define a flag, but I am
reluctant to say one-flag-fits-all.  (AFAICT, x86 and ARM don't define
any, but MIPS and SPARC do [differently]. Haven't looked any further.)
Not having one-flag-fits-all of course makes lld's life more complicated,
if lld wants to take advantage of this stuff.

Jim also said:
> > My only real concern is that without a consumer for the information,
> bitrot can easily set in. Do you know if there's work coming (maybe in
> lld?) that would take advantage of this information?

Apparently lld would like to...  also my toolchain uses this feature.
We are not living on trunk at the moment although we are trying to get
there, with a bot and everything.

Thanks,
--paulr

> -----Original Message-----
> From: Nick Kledzik [mailto:kledzik at apple.com]
> Sent: Tuesday, April 02, 2013 5:11 PM
> To: Robinson, Paul
> Cc: commits
> Subject: Re: Support dead-stripping in ELF objects
> 
> If this happens, please add some magic flag or section to the generated
> ELF .o file so the linker knows it can handle the file more
> aggressively.
> 
> The lld uses an "atom" model where each function or global-variable is a
> separate atom that can be freely moved around.  But currently since ELF
> files may be missing relocations (which you have fixed), so the lld
> linker creates a bunch of extra internal data structures to keep the elf
> atoms in a section pinned together. If lld could tell the file was
> generated by a newer llvm, then lld could skip the generation of the
> extra pinning data structures.
> 
> -Nick
> 
> On Apr 2, 2013, at 3:13 PM, Jim Grosbach <grosbach at apple.com> wrote:
> > Seems generally reasonable to me. MachO uses that directive to twiddle
> a bit in the .o file to let the linker know the rest of the file has
> been laid out in such a way that it can play tricks like dead stripping
> and otherwise moving atoms around relative to one another. In addition
> to changing how the relocs are handled, I'd suggest adding something
> like that for ELF so a linker can know at a glance which files it can
> play games with.
> >
> > My only real concern is that without a consumer for the information,
> bitrot can easily set in. Do you know if there's work coming (maybe in
> lld?) that would take advantage of this information?
> >
> > -Jim
> >
> >
> > On Mar 26, 2013, at 9:45 AM, "Robinson, Paul"
> <Paul.Robinson at am.sony.com> wrote:
> >
> >> Ping...
> >>
> >>> -----Original Message-----
> >>> From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-
> >>> bounces at cs.uiuc.edu] On Behalf Of Robinson, Paul
> >>> Sent: Thursday, March 21, 2013 11:30 AM
> >>> To: llvm-commits at cs.uiuc.edu commits (llvm-commits at cs.uiuc.edu)
> >>> Subject: RE: Support dead-stripping in ELF objects
> >>>
> >>> This time with the attachment...
> >>> --paulr
> >>>
> >>>> -----Original Message-----
> >>>> From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-
> >>>> bounces at cs.uiuc.edu] On Behalf Of Robinson, Paul
> >>>> Sent: Thursday, March 21, 2013 11:14 AM
> >>>> To: llvm-commits at cs.uiuc.edu commits (llvm-commits at cs.uiuc.edu)
> >>>> Subject: Support dead-stripping in ELF objects
> >>>>
> >>>> A while back I implemented some private changes to how relocations
> >>>> were handled in the ELF object writer, so that our linker could
> >>>> support dead-stripping.  Apparently MachO has a similar feature, so
> I
> >>>> leveraged some of what was done for that target, including reusing
> the
> >>>> assembler flag/directive.
> >>>>
> >>>> I'm told that there may be broader interest in supporting
> >>>> dead-stripping in ELF objects, so here's the patch.
> >>>>
> >>>> There is currently no in-tree ELF-using target that invokes this
> >>>> stuff; I'm putting it out there so anyone who's interested can take
> >>>> advantage of it in their own target/toolchain.
> >>>>
> >>>> Please review, and commit for me if it's okay.
> >>>>
> >>>> Thanks,
> >>>> --paulr
> >>>>
> >>>>
> >>>>
> >>>> _______________________________________________
> >>>> llvm-commits mailing list
> >>>> llvm-commits at cs.uiuc.edu
> >>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> >>
> >> <Deadstrip-diff.txt>_______________________________________________
> >> llvm-commits mailing list
> >> llvm-commits at cs.uiuc.edu
> >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 






More information about the llvm-commits mailing list