Support dead-stripping in ELF objects

Nick Kledzik kledzik at apple.com
Tue Apr 2 17:10:49 PDT 2013


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