<div dir="ltr">Thank you for reviewing.<div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 18, 2013 at 10:12 AM, Shankar Kalpathi Easwaran <span dir="ltr"><<a href="mailto:shankarke@gmail.com" target="_blank">shankarke@gmail.com</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"><br>
  I am trying to understand fallbacks. Help me understand fallback atoms.<br>
<br>
  I think the search for fallbacks is being done too early. It should be done possibly just before exiting the link after printing out undefined symbols.<br>
<br>
  For example :-<br>
<br>
  1.c<br>
  ----<br>
  int main() { printf("Hello World\n"); return 0; }<br>
<br>
  ld 1.o <archive library> <shared library><br>
<br>
  say printf has a undefFallBack atom thats set to puts, say the shared library contained a definition of printf. Currently the code would assume that if the current archive library doesnot have a defined atom for printf, check for puts.  The fallback atom should be used only if the atom was undefined atom after the whole link.<br>

</blockquote><div><br></div><div>That's a good point. It's also odd that the fallback atom is handled only when we are reading from a library file -- that should work on regular object files as well. It seems that we do not really implement the correct semantics of Weak External. Will investigate what's the desired behavior and update the patch.</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">
================<br>
Comment at: lib/Core/Resolver.cpp:113-116<br>
@@ -112,4 +112,6 @@<br>
<div class="im">       // symbol with the name to give it a second chance. This feature is used<br>
       // for COFF "weak external" symbol.<br>
-      if (!_symbolTable.isDefined(undefName)) {<br>
+      const Atom *maybeUndefAtom = _symbolTable.findByName(undefName);<br>
+      assert(maybeUndefAtom);<br>
</div>+      if (auto *undefAtom = dyn_cast<const UndefinedAtom>(maybeUndefAtom)) {<br>
<div class="im">         if (const UndefinedAtom *fallbackUndefAtom = undefAtom->fallback()) {<br>
</div>----------------<br>
testcase ? how does the undefined atom doesnot have the change to the new fallback atom ? I couldnot follow why you need a extra search.<br>
<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D2162" target="_blank">http://llvm-reviews.chandlerc.com/D2162</a><br>
</blockquote></div><br></div></div>