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

Shankar Easwaran shankare at codeaurora.org
Wed Oct 24 04:27:46 PDT 2012


Hi Nick,

Thanks for your comments.

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.
I am trying to do the latter, they can only be removed only if the 
section is removed. I couldnt follow why the 'none' reference would not 
keep the functions together though.

>
> 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.
If clang produces the equivalent of -ffunction-sections/-fdata-sections 
then the linker behaviour will match because atoms within a section will 
only point to what the section refers to, than referring to each symbol 
within the section.
>
> 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.

ReaderELF also has the same functionality but the problem is each 
relocation entry points to the symbol index of the symbol that appeared 
in the symbol table.

The code is exactly in the same loop as the darwin linker, but the 
symbol doesnot have the symbol index on where it appears in the symbol 
table.

> Also, on the test case (section-relocs.txt):
> * What is the empty atom at the start named .text with no content?
This is a section local symbol, which shouldnot appear after the 
WriterELF changes.
> * Atoms in .text and .data should not need a custom section-choice.  Those are the default section for code and data content types.
Ok.
> * 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.

I will change the test to use clang.

Thanks

Shankar Easwaran




More information about the llvm-commits mailing list