[PATCH] Reload undefined atoms to use possibly new undefines.

Shankar Kalpathi Easwaran shankarke at gmail.com
Mon Nov 18 10:12:07 PST 2013


  I am trying to understand fallbacks. Help me understand fallback atoms.

  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.

  For example :-

  1.c
  ----
  int main() { printf("Hello World\n"); return 0; }

  ld 1.o <archive library> <shared library>

  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.


================
Comment at: lib/Core/Resolver.cpp:113-116
@@ -112,4 +112,6 @@
       // symbol with the name to give it a second chance. This feature is used
       // for COFF "weak external" symbol.
-      if (!_symbolTable.isDefined(undefName)) {
+      const Atom *maybeUndefAtom = _symbolTable.findByName(undefName);
+      assert(maybeUndefAtom);
+      if (auto *undefAtom = dyn_cast<const UndefinedAtom>(maybeUndefAtom)) {
         if (const UndefinedAtom *fallbackUndefAtom = undefAtom->fallback()) {
----------------
testcase ? how does the undefined atom doesnot have the change to the new fallback atom ? I couldnot follow why you need a extra search.


http://llvm-reviews.chandlerc.com/D2162



More information about the llvm-commits mailing list