[llvm-commits] [LLD] Patch to tie Atoms in a section together

Nick Kledzik kledzik at apple.com
Tue Oct 23 23:28:14 PDT 2012


On Oct 23, 2012, at 7:49 PM, Shankar Easwaran wrote:
> This is a LLD patch for the ELF linker so that Atoms in a section are tied together preventing atoms within a section not garbage collected

This requires some more explanation.  Are you trying to prevent them from ever being removed?  Or they can only be removed is everything is the section is removed?  If the former, the dead-strip setting would do the same.  If the latter, if you are trying to keep the order of the functions, do you want something stronger which says they cannot be reordered too?  The "none" reference just keeps them alive.

Can we also define some opt-out mechanism for this.  That is when clang produces an ELF file, it won't have the layout restrictions that hand written assembly might have.  So, it would give the linker more flexibility if the clang produced ELF file could be marked to opt-out of these added restrictions.

With regards to the code to do this, it seems like it is O(n^2).    The new method getSymbolIndex() searches the whole symbol table.  The darwin linker (when it needs to do this) puts all the atoms that came from one section into a list, sorts the list by address of each atom in the .o file, then walks the list and adds the references.

Also, on the test case (section-relocs.txt):
* What is the empty atom at the start named .text with no content?
* Atoms in .text and .data should not need a custom section-choice.  Those are the default section for code and data content types.
* This test uses gcc which means it is not cross platform (i.e. it will fail to run on darwin).  We want all test to be runnable on all platforms.

-Nick


> 
> * Changes to ReaderELF to add a 'NONE' relocation from the current atom to the previous atom
> * Changes to ELF.h to add a function to retrieve the symbol index for a particular symbol table entry
> * TestCase
> 
> Ok to submit ?
> 
> Thanks
> 
> Shankar Easwaran
> 
> -- 
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation
> 
> <lld-readerelf-changes.diff><llvm-elf-header-changes.diff><ReaderELF.cpp.diff><TestingHelpers.cpp.diff>_______________________________________________
> 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