diff options
author | Alan Modra <amodra@gmail.com> | 2016-12-29 22:49:41 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2016-12-29 23:56:54 +1030 |
commit | e81830c5c61a8665c098189d069cc68b0df113d3 (patch) | |
tree | 3fa10c6cc2cd921b4341168bca62d4df130e2ab1 /bfd/elf32-hppa.c | |
parent | ffdc5f48ee608b4750df5e34c10598f0f2c158d3 (diff) | |
download | binutils-gdb-e81830c5c61a8665c098189d069cc68b0df113d3.tar.gz |
link_hash_copy_indirect and symbol flags
A while ago HJ fixed PR ld/18720 with commit 6e33951ed, which, among
other things, modified _bfd_elf_link_hash_copy_indirect to not copy
ref_dynamic, ref_regular, ref_regular_nonweak, non_got_ref, needs_plt
and pointer_equality_needed when setting up an indirect non-versioned
symbol pointing to a non-default versioned symbol. I didn't notice at
the time, but the pr18720 testcase fails on hppa-linux with
"internal error, aborting at binutils-gdb-2.28/bfd/elf32-hppa.c:3933
in elf32_hppa_relocate_section".
Now hppa-linux creates entries in the plt even for local functions, if
they are referenced using plabel (function pointer) relocations. So
needs_plt is set for foo when processing pr18720a.o. When the aliases
in pr28720b.o are processed, we get an indirection from foo to
foo@FOO, but don't copy needs_plt. Since foo@FOO is the "real" symbol
that is used after that point, no plt entry is made for foo and we
bomb when relocating the plabel.
As shown by the hppa-linux scenario, needs_plt should be copied even
for non-default versioned symbols. I believe all of the others ought
to be copied too, with the exception of ref_dynamic. Not copying
ref_dynamic is right because if a shared lib references "foo" it
should not be satisfied by any non-default version "foo@FOO".
* elflink.c (_bfd_elf_link_hash_copy_indirect): Only omit
copying one flag, ref_dynamic, when versioned_hidden.
* elf64-ppc.c (ppc64_elf_copy_indirect_symbol): Likewise.
* elf32-hppa.c (elf32_hppa_copy_indirect_symbol): Use same
logic for copying weakdef flags. Copy plabel flag and merge
tls_type.
* elf32-i386.c (elf_i386_copy_indirect_symbol): Use same logic
for copying weakdef flags.
* elf32-ppc.c (ppc_elf_copy_indirect_symbol): Likewise.
* elf32-s390.c (elf_s390_copy_indirect_symbol): Likewise.
* elf32-sh.c (sh_elf_copy_indirect_symbol): Likewise.
* elf64-s390.c (elf_s390_copy_indirect_symbol): Likewise.
* elfnn-ia64.c (elfNN_ia64_hash_copy_indirect): Likewise.
* elf64-x86-64.c (elf_x86_64_copy_indirect_symbol): Likewise.
Simplify.
Diffstat (limited to 'bfd/elf32-hppa.c')
-rw-r--r-- | bfd/elf32-hppa.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index cbe42cfde9f..eab384b7ed7 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -1056,19 +1056,20 @@ elf32_hppa_copy_indirect_symbol (struct bfd_link_info *info, /* If called to transfer flags for a weakdef during processing of elf_adjust_dynamic_symbol, don't copy non_got_ref. We clear it ourselves for ELIMINATE_COPY_RELOCS. */ - eh_dir->ref_dynamic |= eh_ind->ref_dynamic; + if (eh_dir->versioned != versioned_hidden) + eh_dir->ref_dynamic |= eh_ind->ref_dynamic; eh_dir->ref_regular |= eh_ind->ref_regular; eh_dir->ref_regular_nonweak |= eh_ind->ref_regular_nonweak; eh_dir->needs_plt |= eh_ind->needs_plt; } else { - if (eh_ind->root.type == bfd_link_hash_indirect - && eh_dir->got.refcount <= 0) - { - hh_dir->tls_type = hh_ind->tls_type; - hh_ind->tls_type = GOT_UNKNOWN; - } + if (eh_ind->root.type == bfd_link_hash_indirect) + { + hh_dir->plabel |= hh_ind->plabel; + hh_dir->tls_type |= hh_ind->tls_type; + hh_ind->tls_type = GOT_UNKNOWN; + } _bfd_elf_link_hash_copy_indirect (info, eh_dir, eh_ind); } |