diff options
author | Alan Modra <amodra@gmail.com> | 2015-03-24 17:37:57 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2015-07-10 19:57:35 +0930 |
commit | 9840593abe08cdea2f5686c0be174a813bb2d146 (patch) | |
tree | 8739ecedc1e06c49f2971a8871c4b00eeaab9052 | |
parent | 9c5f5d8f2684eb6ef678e97fd902539671324eb5 (diff) | |
download | gdb-9840593abe08cdea2f5686c0be174a813bb2d146.zip gdb-9840593abe08cdea2f5686c0be174a813bb2d146.tar.gz gdb-9840593abe08cdea2f5686c0be174a813bb2d146.tar.bz2 |
Make powerpc bfd ld reloc overflow vs undefined symbols match gold
* elf64-ppc.c (ppc64_elf_relocate_section): Report overflow to
stubs, even those for undefined weak symbols. Otherwise, don't
report relocation overflow on branches to undefined strong
symbols. Fix memory leak.
* elf32-ppc.c (ppc_elf_relocate_section): Don't report relocation
overflow on branches to undefined strong symbols.
-rw-r--r-- | bfd/ChangeLog | 11 | ||||
-rw-r--r-- | bfd/elf32-ppc.c | 34 | ||||
-rw-r--r-- | bfd/elf64-ppc.c | 31 |
3 files changed, 36 insertions, 40 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index d994eac..be6f3ec 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,14 @@ +2015-07-10 Alan Modra <amodra@gmail.com> + + Apply from master + 2015-03-24 Alan Modra <amodra@gmail.com> + * elf64-ppc.c (ppc64_elf_relocate_section): Report overflow to + stubs, even those for undefined weak symbols. Otherwise, don't + report relocation overflow on branches to undefined strong + symbols. Fix memory leak. + * elf32-ppc.c (ppc_elf_relocate_section): Don't report relocation + overflow on branches to undefined strong symbols. + 2015-06-23 Jiong Wang <jiong.wang@arm.com> Apply from master: diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 5a37fdb..d0559d1 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -9247,30 +9247,20 @@ ppc_elf_relocate_section (bfd *output_bfd, if (r == bfd_reloc_overflow) { overflow: - if (warned) - continue; - if (h != NULL - && h->root.type == bfd_link_hash_undefweak - && howto->pc_relative) + /* On code like "if (foo) foo();" don't report overflow + on a branch to zero when foo is undefined. */ + if (!warned + && !(h != NULL + && (h->root.type == bfd_link_hash_undefweak + || h->root.type == bfd_link_hash_undefined) + && is_branch_reloc (r_type))) { - /* Assume this is a call protected by other code that - detect the symbol is undefined. If this is the case, - we can safely ignore the overflow. If not, the - program is hosed anyway, and a little warning isn't - going to help. */ - - continue; + if (!((*info->callbacks->reloc_overflow) + (info, (h ? &h->root : NULL), sym_name, + howto->name, rel->r_addend, + input_bfd, input_section, rel->r_offset))) + return FALSE; } - - if (! (*info->callbacks->reloc_overflow) (info, - (h ? &h->root : NULL), - sym_name, - howto->name, - rel->r_addend, - input_bfd, - input_section, - rel->r_offset)) - return FALSE; } else { diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index fde5215..55bf5b2 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -14824,26 +14824,21 @@ ppc64_elf_relocate_section (bfd *output_bfd, if (r == bfd_reloc_overflow) { - if (warned) - continue; - if (h != NULL - && h->elf.root.type == bfd_link_hash_undefweak - && howto->pc_relative) + /* On code like "if (foo) foo();" don't report overflow + on a branch to zero when foo is undefined. */ + if (!warned + && (reloc_dest == DEST_STUB + || !(h != NULL + && (h->elf.root.type == bfd_link_hash_undefweak + || h->elf.root.type == bfd_link_hash_undefined) + && is_branch_reloc (r_type)))) { - /* Assume this is a call protected by other code that - detects the symbol is undefined. If this is the case, - we can safely ignore the overflow. If not, the - program is hosed anyway, and a little warning isn't - going to help. */ - - continue; + if (!((*info->callbacks->reloc_overflow) + (info, &h->elf.root, sym_name, + reloc_name, orig_rel.r_addend, + input_bfd, input_section, rel->r_offset))) + return FALSE; } - - if (!((*info->callbacks->reloc_overflow) - (info, &h->elf.root, sym_name, - reloc_name, orig_rel.r_addend, - input_bfd, input_section, rel->r_offset))) - return FALSE; } else { |