PATCH: Revised fix for gold problem with weak undefined symbols

Cary Coutant ccoutant@google.com
Wed Apr 16 21:12:00 GMT 2008


This patch brings gold into better agreement with gnu ld in its
handling of weak undefined symbols. It turns out that for non-PIC code
in a shared library, gnu ld would emit a dynamic relocation so that a
weak undef would be resolved dynamically; gnu ld appears to statically
resolve weak undefs to zero only when linking an executable. I've
added several additional test cases and verified that gold's behavior
matches gnu ld's behavior in each case.

    * symtab.h (Symbol::is_strong_undefined): Removed unused function.
    (Symbol::needs_plt_entry): Allow weak undefined symbols.
    (Symbol::needs_dynamic_reloc): Allow weak undefined symbols when
    building shared libraries.
    * testsuite/Makefile.am (weak_undef_nonpic_test): New target.
    (weak_undef_file1_nonpic.o, weak_undef_file2_nonpic.o)
    (weak_undef_lib_nonpic.so, alt/weak_undef_lib_nonpic.so): New targets.
    * testsuite/Makefile.in: Rebuild.
    * testsuite/weak_undef.h: New file.
    * testsuite/weak_undef_file1.cc: Add extra test cases.
    * testsuite/weak_undef_file2.cc: Likewise.
    * testsuite/weak_undef_test.cc: Likewise.

OK?

-cary
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: weak-undef-patch-2.txt
URL: <https://sourceware.org/pipermail/binutils/attachments/20080416/427ade81/attachment.txt>


More information about the Binutils mailing list