[PATCH] [ELF] Refactor File.h.

Shankar Easwaran shankare at codeaurora.org
Wed Jun 5 18:27:03 PDT 2013


On 6/5/2013 6:52 PM, Rui Ueyama wrote:
> Shankar,
>
> I tried not to change the behavior of the existing code when I was doing
> this. I splitt the function and felt like it became easier to read, but I
> still don't fully understand the logic of createAtom. Can I ask a few
> questions?
>
> - Looks like we create both LayoutBefore and LayoutAfter references. Do we
> really need to create both? If A-layout-before-B is equivalent to
> B-layout-after-A it doesn't look necessary.
This is needed so that garbage collection wont remove the reference. If 
there is no atom thats referencing the current atom, that atom will be 
removed. So its needed for Atoms in a section to have both layout-after 
and layout-before.

See the thread 
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20121022/154084.html 
for more details on it.
> - The constraints and the reason that weak symbols need to satisfy about
> Reference are not very clear. Why are we handling weak symbols in such a
> way and how these References are handled in the later passes?
Weak references are tricky, that they can be overridden, so what we do 
is when there is a weak reference that contains some data, we create a 
weak atom followed by an anonymous atom that holds the data(Because of 
the same property that you want to keep everything in the ELF section). 
If the weak atom gets overridden you can safely remove the weak atom, 
since there is nothing that refers to (no layout before). Also another 
thing thats used is for example:

An atom "A" is followed by a Weak atom(W). We create the three atoms A, 
W, W' (the atom that holds the data) and make A to be followed by W' and 
a back reference of layout before from W' to A. There is a bug that if 
there are two weak atoms one after another though, that some of the 
references are not created properly(I am going to fix that later).

There are multiple tests (weak*.test), testing these scenarios.

As you would have noticed, these are very critical for the final ELF 
image to work, in all cases.

>
> On Wed, Jun 5, 2013 at 2:52 PM, Rui Ueyama <ruiu at google.com> wrote:
>
>> Hi shankarke,
>>
>>   - Split createAtom() in lib/ReaderWriter/ELF/File.h into small methods.
>>   - Added comments to code in other methods.
>>
>> No functionality changes.
>>
>> http://llvm-reviews.chandlerc.com/D921
>>
>> Files:
>>    lib/ReaderWriter/ELF/File.h
>>    test/elf/X86_64/weak-override.test
>>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130605/7f620727/attachment.html>


More information about the llvm-commits mailing list