<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Hi Nick,<br>
<br>
This is the overall design that I am working on to support
reading/resolving section groups in the YAML reader.<br>
<br>
a) Read all atoms<br>
b) any atoms with group-parent references are moved to
AtomList<lld::DefinedAtom> _groupChildAtoms;<br>
c) There would also be a map _groupChildMap that has a key from
groupChild to groupParent, this is to support (d)<br>
d) If there is a reference to a groupChild from another
child(whose parent is different from the previous group child),
the groupChild reference is changed to refer to a undefined atom
for the groupChild<br>
e) if there is a reference to a groupchild that doesnot have a
group-parent reference, and if the reference is not to a atom that
is undefined, create an undefinedatom and point the group child.<br>
<br>
<b>We could also do something where all groupchild references
refer to undefined atoms.</b><br>
<br>
<b>There seems to be a caveat even after everything looks sane.<br>
<br>
a) There is a funny case of what do we do when the group child
is a local symbol ? So if there is a reference to a group child
whose scope is local, we cannot create a undefined reference to
the group child right ?<br>
</b><br>
<b>b) The problem is we call the RoundTripYAML reader/writer and
the RoundTripNative reader/writer, which happens to be called
after the resolver is called, which would create undefined
references to atoms!.</b><b><br>
</b><b><br>
</b>I am concerned on just the above cases ?<br>
<br>
Do we want to have a different mode in the YAML reader when called
from RoundTripYAMLPass not to create undefined atoms ? <br>
<br>
Am I missing something ?<br>
<br>
Thanks<br>
<br>
Shankar Easwaran<br>
<br>
On 3/14/2014 8:29 PM, Nick Kledzik wrote:<br>
</div>
<blockquote
cite="mid:AC057FF5-E7F7-432C-8951-A33725E10A14@apple.com"
type="cite">
<pre wrap="">
On Mar 14, 2014, at 4:37 PM, Shankar Easwaran <a class="moz-txt-link-rfc2396E" href="mailto:shankare@codeaurora.org"><shankare@codeaurora.org></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">On 3/14/2014 5:52 PM, Nick Kledzik wrote:
</pre>
<blockquote type="cite">
<pre wrap="">On Mar 13, 2014, at 8:24 PM, Shankar Kalpathi Easwaran <a class="moz-txt-link-rfc2396E" href="mailto:shankarke@gmail.com"><shankarke@gmail.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap=""> I dont think the multithreaded model of processing all the object files first is going to work with the ELF linker, as resolution happens in the way input files are processed from command line.
This is what I see with the GNU linker :-
a) The groups are being resolved as and when input files are processed by the resolver. We cannot delay processing the group members after the resolver has processed all files.
b) Consider the below example :-
</pre>
</blockquote>
<pre wrap="">...
</pre>
<blockquote type="cite">
<pre wrap=""> With the command line ld foo.o bar.o libarchive.a, when symbols from bar.o are processed, **global-f3 becomes a undefined symbol** and pulls the global-f3 from libarchive.a
How do we handle all these cases with lld ?
<a class="moz-txt-link-freetext" href="http://llvm-reviews.chandlerc.com/D2961">http://llvm-reviews.chandlerc.com/D2961</a>
</pre>
</blockquote>
<pre wrap="">Given that the ELF linker needs those semantics, it seems that the Resolver and symbol table building must be done serially, in command line order. The object files could still be parsed in parallel, but the results would need to be buffered and added to the symbol table in command line order. Given that, here are two possible algorithms:
1) Groups are like static libraries
a) group child atoms are not returned in the defined() atoms collection, but group parents are.
b) files are added to the symbol table in command line order
c) when a group parent atom is added to the symbol table, its name is checked to see if that group name has been seen yet by the symbol table. If not, the group name is added and all its children are also added. If the group name has already been seen, then the group’s child remain unseen by the symbol table.
Problem: uses of any atom in a group from outside the group would require the ELF reader to synthesized UndefinedAtom and have that be referenced. In a way this is good because it enforces that groups can be removed.
</pre>
</blockquote>
<pre wrap="">Thanks for the great suggestion. We could follow the option (1) above, as the group childs are not seen by the rest of the linker until the group is added.
Are you saying that the group childs are internal to the lld::File, and can be only referenced from the group-child references in the parent atom (contentType:kindGroupComdat) ?
</pre>
</blockquote>
<pre wrap="">Without adding some other mechanism for getting a list of atoms, yes, that is how to do it.
</pre>
<blockquote type="cite">
<pre wrap="">
To support groups in the core/yaml reader, the user has to be explicit in creating undefined/defined atoms for the group child members ?
</pre>
</blockquote>
<pre wrap="">I supposed you could have the yaml reader detect and automatically create the UndefinedAtoms. I’m not sure which is easier.
Also, this is going to require making lots of error laden test cases in ELF assembly and see how the existing ELF linkers handle them. For instance if group g1 contains a function that calls foo, and that is the only call to foo in the object file, when that file is loaded, if g1 is not used (because another group named g1 already exists), will the undef for foo get added to the global symbol table? If not, then somehow undefined symbols also need to be associated with groups.
-Nick
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation</pre>
</body>
</html>