Make powerpc bfd ld reloc overflow vs undefined symbols match gold
authorAlan Modra <amodra@gmail.com>
Tue, 24 Mar 2015 07:07:57 +0000 (17:37 +1030)
committerAlan Modra <amodra@gmail.com>
Tue, 24 Mar 2015 07:12:36 +0000 (17:42 +1030)
* 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.

bfd/ChangeLog
bfd/elf32-ppc.c
bfd/elf64-ppc.c

index 060db14b309bcae19651a98207256468c98e4d52..512452caf9e484b4004a694e1fbeca7da05147d1 100644 (file)
@@ -1,3 +1,12 @@
+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-03-23  Keith Seitz  <keiths@redhat.com>
 
        * elfnn-aarch64.c (_bfd_aarch64_create_or_find_stub_sec): Add
index d61d75e329def396dae859ae782e367e178c8450..b96dbc8faadce847a006c87173e314bd8f88adb1 100644 (file)
@@ -9250,30 +9250,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
            {
index 60f8b6ec2463f747ea8ef20dbdf27faf94760139..e7e8820deeb31ef9327b3daea1fbaa86580062bb 100644 (file)
@@ -14837,26 +14837,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
            {
This page took 0.038742 seconds and 4 git commands to generate.