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

Rui Ueyama ruiu at google.com
Mon Nov 18 12:56:22 PST 2013


Thank you for reviewing.

On Mon, Nov 18, 2013 at 10:12 AM, Shankar Kalpathi Easwaran <
shankarke at gmail.com> wrote:

>
>   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.
>

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.

================
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131118/bc1bc8ad/attachment.html>


More information about the llvm-commits mailing list