[llvm-commits] Followon/Preceded-By reference support in lld

Nick Kledzik kledzik at apple.com
Mon Nov 12 15:05:24 PST 2012


On Nov 12, 2012, at 5:58 PM, Shankar Easwaran wrote:
> Thanks Nick.
> 
> Will not the current resolver throw an error, if any of the references are not satisfied ? I couldnt follow on why there is a need for a seperate pass ?
The whole point of these (and why I suggested the rename to "layout") is they control the order the atoms are laid out (assigned addresses).   If I have atoms:  A, B, and C (in that order) but C has a kindLayoutBefore reference to B, then the final atom list better have C before B (e.g.  A, C, B).  The resolver just verifies that that target of each reference exists. 

The various Passes could do all sorts of transformations (add, remove, move) to the Atoms.  You need a Pass (one of the last run) which does a final check and move some atoms to ensure the layout constraints are met.

-Nick

> 
> Also with the current changes, ReaderELF only creates a followon/preceded-by reference only for symbols that are Defined.
> 
> Thanks
> 
> Shankar Easwaran
> 
> +---
> +atoms:
> +    - name:              A
> +      scope:             global
> +      type:              code
> +      section-choice:    custom-required
> +      section-name:      .text
> +
> 
>> Please change the ELF Reader and Writer so that the default section for type "code" is ".text".   The custom-required section is intended for user supplied sections like e.g. __attribute__((section(".foobar"))) not any of the standard sections.  This will reduce the "noise" and size of many test cases.
> Ok.
> 
>>>  +  enum {
>>> +    FollowOn = -1,
>>> +    PrecededBy = -2,
>>> +    LayoutBefore = -3,
>>> +    LayoutAfter = -4
>>> +  };
>>> +
>> We only need two of these four.  I was suggesting that kindLayoutBefore and kindLayoutAfter are clearer names than follow-on and preceded-by.
>> 
> Ok, will change it to LayoutBefore/LayoutAfter.
>> +private: + std::map<int32_t, StringRef> _kindToString; + std::map<StringRef, int32_t> _stringToKind; +}; } // namespace lld
>> The mapping is the same for every Reference instance, so there is no need for a copy of the mapping in every object.  In other words, the mapping should be static.   And, for two entries a map is overkill.   Just make a static const array like was done in TestingKindMapping and walk the list looking for a match.
> Sure, Will do this change.
> 
>> 
>> You also need to create a Pass which sorts atoms to ensure all "before" and "after" references are satisfied, and errors if unsatisfiable.
> 
> Will not, the current resolver throw up an error, if any of the references are unsatisfied ? Also with ReaderELF, the followon and preceded by reference are created only for DefinedAtoms.
> 
> Thanks
> 
> Shankar Easwaran
> 
> -- 
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation
> 




More information about the llvm-commits mailing list