* elf64-ppc.c (ppc64_elf_check_relocs): Don't set has_14bit_branch
authorAlan Modra <amodra@gmail.com>
Fri, 18 Nov 2005 04:52:57 +0000 (04:52 +0000)
committerAlan Modra <amodra@gmail.com>
Fri, 18 Nov 2005 04:52:57 +0000 (04:52 +0000)
on branches to same section.

bfd/ChangeLog
bfd/elf64-ppc.c

index c4519f2..49da6eb 100644 (file)
@@ -1,3 +1,8 @@
+2005-11-18  Alan Modra  <amodra@bigpond.net.au>
+
+       * elf64-ppc.c (ppc64_elf_check_relocs): Don't set has_14bit_branch
+       on branches to same section.
+
 2005-11-17  Randolph Chung  <tausq@debian.org>
 
        * elf64-hppa.c (elf64_hppa_object_p): Recognize corefiles under
index d15c772..65b9c21 100644 (file)
@@ -4507,7 +4507,24 @@ ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
        case R_PPC64_REL14:
        case R_PPC64_REL14_BRTAKEN:
        case R_PPC64_REL14_BRNTAKEN:
-         htab->has_14bit_branch = 1;
+         {
+           asection *dest = NULL;
+
+           /* Heuristic: If jumping outside our section, chances are
+              we are going to need a stub.  */
+           if (h != NULL)
+             {
+               /* If the sym is weak it may be overridden later, so
+                  don't assume we know where a weak sym lives.  */
+               if (h->root.type == bfd_link_hash_defined)
+                 dest = h->root.u.def.section;
+             }
+           else
+             dest = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
+                                               sec, r_symndx);
+           if (dest != sec)
+             htab->has_14bit_branch = 1;
+         }
          /* Fall through.  */
 
        case R_PPC64_REL24: