diff options
author | Alan Modra <amodra@gmail.com> | 2014-07-02 15:07:18 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2014-07-02 18:16:14 +0930 |
commit | d1eca1e41ddae8c3cd925be827640de919301432 (patch) | |
tree | 94f81941bc024992334cec35ad62ad86418db131 /bfd/elf32-ppc.c | |
parent | 9b11e3a7327f7b1fd5d40a6450a3cc323a78380c (diff) | |
download | gdb-d1eca1e41ddae8c3cd925be827640de919301432.zip gdb-d1eca1e41ddae8c3cd925be827640de919301432.tar.gz gdb-d1eca1e41ddae8c3cd925be827640de919301432.tar.bz2 |
Taking an undefined function's address in an executable
doesn't always mean you need to define a function symbol on plt code.
If all references are in read-write sections, then using dynamic relocs
is OK.
bfd/
* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Clear
pointer_equality_needed when !readonly_dynrelocs.
* elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Likewise.
ld/testsuite/
* ld-powerpc/ambiguousv1.d: Match symbol table too.
* ld-powerpc/ambiguousv2.d: Likewise.
* ld-powerpc/ambiguousv1b.d: New.
* ld-powerpc/ambiguousv2b.d: New.
* ld-powerpc/powerpc.exp: Run new tests.
Diffstat (limited to 'bfd/elf32-ppc.c')
-rw-r--r-- | bfd/elf32-ppc.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 0a9c8f9..e20e804 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -5506,9 +5506,21 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info, will go to this object, or will remain undefined. */ h->plt.plist = NULL; h->needs_plt = 0; + h->pointer_equality_needed = 0; } else { + /* Taking a function's address in a read/write section + doesn't require us to define the function symbol in the + executable on a global entry stub. A dynamic reloc can + be used instead. */ + if (h->pointer_equality_needed + && !readonly_dynrelocs (h)) + { + h->pointer_equality_needed = 0; + h->non_got_ref = 0; + } + /* After adjust_dynamic_symbol, non_got_ref set in the non-shared case means that we have allocated space in .dynbss for the symbol and thus dyn_relocs for this @@ -5518,12 +5530,12 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info, relocations against this symbol to the PLT entry. Allow dynamic relocs if the reference is weak, and the dynamic relocs will not cause text relocation. */ - if (!h->ref_regular_nonweak - && h->non_got_ref - && h->type != STT_GNU_IFUNC - && !htab->is_vxworks - && !ppc_elf_hash_entry (h)->has_sda_refs - && !readonly_dynrelocs (h)) + else if (!h->ref_regular_nonweak + && h->non_got_ref + && h->type != STT_GNU_IFUNC + && !htab->is_vxworks + && !ppc_elf_hash_entry (h)->has_sda_refs + && !readonly_dynrelocs (h)) h->non_got_ref = 0; } return TRUE; |