This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] PR ld/18720: Properly merge hidden versioned symbol
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Binutils <binutils at sourceware dot org>
- Date: Mon, 1 Feb 2016 12:47:32 -0800
- Subject: Re: [PATCH] PR ld/18720: Properly merge hidden versioned symbol
- Authentication-results: sourceware.org; auth=none
- References: <20150726221550 dot GA16472 at gmail dot com> <20150801140704 dot GA23091 at gmail dot com> <20160201202246 dot GL7732 at vapier dot lan>
On Mon, Feb 1, 2016 at 12:22 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On 01 Aug 2015 07:07, H.J. Lu wrote:
>> On Sun, Jul 26, 2015 at 03:15:50PM -0700, H.J. Lu wrote:
>> > The non-default versioned symbol can only be merged with the versioned
>> > symbol with the same symbol version. _bfd_elf_merge_symbol should
>> > check the symbol version before merging the new non-default versioned
>> > symbol with the existing symbol. _bfd_elf_link_hash_copy_indirect can't
>> > copy any references to the non-default versioned symbol. We need to
>> > bind a symbol locally when linking executable if it is locally defined,
>> > non-default versioned, not referenced by shared library and not exported.
>> > ---
>> > bfd/
>> >
>> > PR ld/18720
>> > * elf-bfd.h (elf_link_hash_entry): Add nondeflt_version.
>> > * elflink.c (_bfd_elf_merge_symbol): Add a parameter to indicate
>> > if the new symbol matches the existing one. The new non-default
>> > versioned symbol symbol matches the existing symbol if they have
>> > the same symbol version. Update the existing symbol only if they
>> > match.
>> > (_bfd_elf_add_default_symbol): Update call to
>> > _bfd_elf_merge_symbol.
>> > (elf_link_add_object_symbols): Override a definition only if the
>> > new symbol matches the existing one.
>> > (_bfd_elf_link_hash_copy_indirect): Don't copy any references to
>> > the non-default versioned symbol.
>> > (elf_link_output_extsym): Bind a symbol locally when linking
>> > executable if it is locally defined, non-default versioned, not
>> > referenced by shared library and not exported.
>>
>> Here is the upated patch which uses the existing "hidden" field in
>> elf_link_hash_entry. Any objections, comments?
>
> this breaks asan. simple test case:
> $ echo 'main() { fork(); }' > test.c
> $ gcc -fsanitize=address -c test.c
> $ gcc -fsanitize=address test.o
> ld: /usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/libasan.so: undefined reference to symbol 'fork@GLIBC_2.2.5'
> /lib64/libpthread.so.0: error adding symbols: DSO missing from command line
> collect2: error: ld returned 1 exit status
>
> i'm guessing this will also break any library that links against pthread
> but the main app itself doesn't.
> -mike
Please open a binutils bug.
Thanks.
--
H.J.