<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi Nick,<br>
<br>
In addition to what you mentioned, I think there needs a special
*AliasReference* that need to be created which the DefinedAtom
points to.<br>
<br>
Thanks<br>
<br>
Shankar Easwaran<br>
<div class="moz-forward-container"><br>
<br>
-------- Original Message --------
<table class="moz-email-headers-table" cellpadding="0"
cellspacing="0" border="0">
<tbody>
<tr>
<th align="RIGHT" nowrap="nowrap" valign="BASELINE">Subject:
</th>
<td>Re: [PATCH] Add a fallback mechanism for undefined atom.</td>
</tr>
<tr>
<th align="RIGHT" nowrap="nowrap" valign="BASELINE">Date: </th>
<td>Thu, 29 Aug 2013 15:15:49 -0700</td>
</tr>
<tr>
<th align="RIGHT" nowrap="nowrap" valign="BASELINE">From: </th>
<td><a class="moz-txt-link-abbreviated" href="mailto:kledzik@apple.com">kledzik@apple.com</a> <a class="moz-txt-link-rfc2396E" href="mailto:kledzik@apple.com"><kledzik@apple.com></a></td>
</tr>
<tr>
<th align="RIGHT" nowrap="nowrap" valign="BASELINE">Reply-To:
</th>
<td><a class="moz-txt-link-abbreviated" href="mailto:reviews+D1550+public+25c98da67f89e22f@llvm-reviews.chandlerc.com">reviews+D1550+public+25c98da67f89e22f@llvm-reviews.chandlerc.com</a></td>
</tr>
<tr>
<th align="RIGHT" nowrap="nowrap" valign="BASELINE">To: </th>
<td><a class="moz-txt-link-abbreviated" href="mailto:shankarke@gmail.com">shankarke@gmail.com</a>, <a class="moz-txt-link-abbreviated" href="mailto:kledzik@apple.com">kledzik@apple.com</a>,
<a class="moz-txt-link-abbreviated" href="mailto:bigcheesegs@gmail.com">bigcheesegs@gmail.com</a>, <a class="moz-txt-link-abbreviated" href="mailto:ruiu@google.com">ruiu@google.com</a></td>
</tr>
<tr>
<th align="RIGHT" nowrap="nowrap" valign="BASELINE">CC: </th>
<td><a class="moz-txt-link-abbreviated" href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a></td>
</tr>
</tbody>
</table>
<br>
<br>
<pre> Interesting feature.
What happens if a.o has an undefine foo which says its fallback is bar, but in b.o an undefine for foo says its fallback is baz? Is that an error, or does each fallback apply to its original usage. The problem is that the Resolver is currently coalescing UndefinedAtoms based on their name. I does not know that fallbacks need to match too.
Another variant is to have Undefined return a alternate name as a string, rather than returning a new UndefinedAtom object.
Another approach is to use weak aliases. That is if a.o has an undefine for foo with a fallback of bar, that when parsing that .o file into atoms produces an UndefinedAtom for foo, but also a DefinedAtom with name=foo, weak (mergeAsWeak), hidden (scopeLinkageUnit), size=0, isAlias=true which aliases to bar. So, it any definition of foo does show up, it will override the weak alias. If not the weak alias will be used and change the reference to bar.
I don't think the isAlias support is all wired up in lld. But weak aliases are something common in ELF. So would should get it working, and doing so may provide a way to implement this COFF feature.
One issue is how this interacts with static libraries. The weak alias for foo make look like there is a definition, so any static archives will not be searched for foo. That seems different than what you want. I'm not sure what the gnu linker does about this with weak aliases. We may need a new resolver option as to how to handle this.
================
Comment at: lib/Core/Resolver.cpp:214
@@ +213,3 @@
+ // for COFF "weak external" symbol.
+ const UndefinedAtom *fallbackUndefAtom = undefAtom->fallback();
+ if (fallbackUndefAtom) {
----------------
You need to re-test:
if (!_symbolTable.isDefined(undefName)
because searchLibraries() may have already found a definition.
<a class="moz-txt-link-freetext" href="http://llvm-reviews.chandlerc.com/D1550">http://llvm-reviews.chandlerc.com/D1550</a>
_______________________________________________
llvm-commits mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a>
</pre>
<br>
</div>
<br>
</body>
</html>