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]

Re: Weak references, --as-needed, and pthreads


>>> In general, it really must pick the base version for the symbol because
>>> the
>>> binary could have been produced before symbol versioning was introduced
>>> for
>>> this particular library.
>>>
>>> In particular, a reference (weak or strong) to any glibc symbol really
>>> must
>>> have an attached symbol version, especially if a weak function symbol is
>>> actually used to call the function, otherwise the binary is invalid and
>>> might fail to work with any future glibc update.

I've committed this patch, which lets a dynamic definition override an
earlier one if the earlier one is from a not-needed library, so that
we can retain the version information from the binding to the needed
library. In order to do that, the tracking of needed/not-needed had to
be moved up to symbol resolution time, instead of during
Symbol_table::set_dynsym_indexes().

In cases where we still end up discarding version information, I've
added a warning.

> Yes, and it should emit a weak version, so that loading of the library with
> the weak reference is not rejected if the referenced library does not
> provide that symbol version.

I have not done this; I'll save it for a follow-up, after I figure out
what a weak version is and how to emit one.

-cary


2018-06-21  Cary Coutant  <ccoutant@gmail.com>

gold/
        * resolve.cc (Symbol_table::resolve): Rename tobinding to
        orig_tobinding.  Call set_is_needed() for objects that resolve
        non-weak references.
        (Symbol_table::should_override): Allow a dynamic definition to
        override an earlier one in a not-needed library.
        * symtab.cc (Symbol_table::set_dynsym_indexes): Remove separate
        processing for as-needed symbols.  Add warning when discarding
        version informatin.
        * testsuite/Makefile.am (weak_as_needed): New test case.
        * testsuite/Makefile.in: Regenerate.
        * testsuite/weak_as_needed.sh: New test script.
        * testsuite/weak_as_needed_a.c: New source file.
        * testsuite/weak_as_needed_b.c: New source file.
        * testsuite/weak_as_needed_b.script: New version script.
        * testsuite/weak_as_needed_c.c: New source file.
        * testsuite/weak_as_needed_c.script: New version script.

Attachment: weak-as-needed.patch
Description: Binary data


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