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

Nick Kledzik kledzik at apple.com
Wed Oct 24 18:44:12 PDT 2012


On Oct 24, 2012, at 6:25 PM, Shankar Easwaran wrote:

>>>> 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.
>> If someone were to write a Pass which re-ordered functions based.  How would the pass know to not re-order those functions?
>> 
> I will go ahead and create a reference from the current symbol to the next symbol too, so that they dont get reordered.

Shankar,

I think you are missing my point.  Garbage collection (aka dead stripping) and atom re-ordering are different things.  They both will cause problems with assembly code written assuming only whole sections will copied to output files.   But, adding a reference only prevents garbage collection.  It does not stop re-ordering of atoms.

To stop re-ordering of atoms, the darwin linker uses a special reference  kind called a follow-on.  The re-ordering pass knows it cannot move an atom relative to another atom that has a follow-on reference to it.   More specifically, if A has a follow-on reference to B, then atom B must immediately follow (be laid out) after atom A.

Currently in lld, all References are platform specific.  We don't yet have a way that generic Passes can infer meaning from reference kinds.

-Nick



More information about the llvm-commits mailing list