This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][GOLD] Let a weak reference override a dynamic weak reference.


Hi,

    This patch fixes a problem in which a weak reference in input
because a non-weak reference in the output when gold sees another weak
reference to the same symbol in a DSO first.  This was first found in
a scenario involving something like:

    ld .... -ldso -lstatic

If both libdso.so and the part of libstatic.a that get linked contain
weak references to some symbol S, gold enters a dynamic weak reference
to S into the symbol table first.  The symbol will also have the
previous binding intialized to be non-weak.  After that, gold sees the
static weak reference to S in libstatic.a and tries to resolve the
symbol.   The static weak reference will be ignored by the resolver.
When gold finally outputs S, it will find S to be a dynamic weak
reference and will use the previous non-weak binding!   The fix is to
let a weak reference override an existing dynamic weak reference to
the same symbol.  This has been tested for x86_64.

-Doug

2010-08-27  Doug Kwan  <dougkwan@google.com>

        * gold/resolve.cc (Symbol_table::should_override): Let a weak
        reference override an existing dynamic weak reference.
        * testsuite/Makefile.am: Add new test dyn_weak_ref.
        * testsuite/Makefile.in: Regenerate.
        * testsuite/dyn_weak_ref.sh: New file.
        * testsuite/dyn_weak_ref_1.c: Ditto.
        * testsuite/dyn_weak_ref_2.c: Ditto.

Attachment: patch-weak-ref.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]