<div dir="ltr">Thank you for the clarification. That's very helpful. Comments inline.<div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 5, 2013 at 6:27 PM, Shankar Easwaran <span dir="ltr"><<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF"><div class="im">
    <div>On 6/5/2013 6:52 PM, Rui Ueyama wrote:<br>
    </div>
    <blockquote type="cite">
      <pre>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.
</pre>
    </blockquote></div>
    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.<br>
    <br>
    See the thread
    <a href="http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20121022/154084.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20121022/154084.html</a>
    for more details on it.</div></blockquote><div><br></div><div style>I see. So, because all atoms in the same section (except weak symbols) are reachable from each other, if there's a reference from a live atom to one of them, all the other atoms in the same section (again, except weak ones) become alive and will be emitted to the output binary. Is this understanding correct?</div>

<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"><div class="im">


    <blockquote type="cite">
      <pre>- 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?</pre>
    </blockquote></div>
    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:<br>
    <br>
    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). <br>
    <br>
    There are multiple tests (weak*.test), testing these scenarios.<br>
    <br>
    As you would have noticed, these are very critical for the final ELF
    image to work, in all cases.</div></blockquote><div><br></div><div style>Let me double check if I understand what you said by drawing a graph. Normal arrow denotes Layout-After edge, and empty arrow denotes Layout-Before edge. If a section has symbol A, W and C in this order, and W is a weak symbol, then the resulting graph will look like this (Not sure pasting a image will really work on this mailing list but let me try...): </div>

<div><br></div><div><img src="cid:ii_13f17a6c083fc0de" alt="Inline image 1"><br></div><div><br></div><div style>where W' is an anonymous atom having the content of W. If W is overridden by a non-weak symbol, W will be GC'ed (dead-stripped) away, but its contents will still be emitted to the resulting binary as W' is alive (assuming A or C are alive), although there are no atoms that really refer W's content. Is this correct?</div>

<div style><br></div><div style>And if there are two weak symbols, W1 and W2, between symbol A and C, then the graph should become like this, right?</div><div style><br></div><div style><img src="cid:ii_13f17a7c3618006b" alt="Inline image 2"><br>

</div><div style><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF">


    <blockquote type="cite"><div class="im">
      <pre>On Wed, Jun 5, 2013 at 2:52 PM, Rui Ueyama <a href="mailto:ruiu@google.com" target="_blank"><ruiu@google.com></a> wrote:

</pre>
      <blockquote type="cite">
        <pre>Hi shankarke,

 - Split createAtom() in lib/ReaderWriter/ELF/File.h into small methods.
 - Added comments to code in other methods.

No functionality changes.

<a href="http://llvm-reviews.chandlerc.com/D921" target="_blank">http://llvm-reviews.chandlerc.com/D921</a>

Files:
  lib/ReaderWriter/ELF/File.h
  test/elf/X86_64/weak-override.test

</pre>
      </blockquote>
      <pre></pre>
      <br>
      <fieldset></fieldset>
      <br>
      </div><pre>_______________________________________________
llvm-commits mailing list
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><span class=""><font color="#888888">
</font></span></pre><span class=""><font color="#888888">
    </font></span></blockquote><span class=""><font color="#888888">
    <br>
    <br>
    <pre cols="72">-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation</pre>
  </font></span></div>

</blockquote></div><br></div></div>