[llvm-commits] [lld] add support for followon references

Nick Kledzik kledzik at apple.com
Thu Nov 1 13:40:34 PDT 2012


Shankar,

Implementing follow-on references is really two steps: 1) core linking, 2) having ELF Reader create them if needed.

For the core linking step, you need a bunch of yaml test cases which verify that the follow-on constraint is respected.  For example:
a) input has A, B, C, D with follow-on from B to C, a regular reference from D to B, and mark D don't dead strip, then enable dead strip and verify output is B, C, D.
b) input is A, B, C with following from C to B and B to A.  Verify output is C, B, A (Note, you'll need to write a pass to do the re-order).

It should probably be illegal to have mergable atom involved in a follow-on reference.

Someone had an example of ELF that has a function doing a fixed jump backwards into an anonymous code before it.   Just having follow-on references is not enough to support that in the face of dead code stripping.  You also need preceded-by references (sort of doubly linked list).  

Given that the idea here is to make negative Kind values be "core" References, supported on all platforms, lld::Reference should have a kindToString() and kindFromString() methods which do the conversion iff and only iff the kind is a core kind.  Then platform specific kindToString() and kindFromString() don't have to add core <value,string> entries to their tables, they instead call through to do conversion of core kinds.

I don't think there is a need for a FollowOnReference class.  The Readers that currently create References just need to be able to create a Reference with the kind set to kindFollowOnReference.

Also, given that kindFollowOnReference is scoped inside of lld::Reference, the "Reference" part of the string is redundant.  That is, clients will use lld::Reference::kindFollowOn. 

If you plan to add the back references too. We should come up with names that work together, such as:
   kindFollowedBy, kindPrecededBy
   kindLayoutBefore, kindLayoutAfter

-Nick

On Nov 1, 2012, at 7:24 AM, Shankar Easwaran wrote:
> Can you please review the patch to add support for followon references in lld. The patch includes a test case for the changes done in ReaderELF.
> 
> Thanks
> 
> Shankar Easwaran
> 
> -- 
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation
> 
> <followon_reference.diff>




More information about the llvm-commits mailing list