This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ppc64 link warning, <section> exceeds stub group size


This warning has been triggering a lot more than I expected,
particularly in PowerPC64 Linux kernel builds.  On investigating, I
found that some of the kernel assembly uses conditional branches to
global labels.  As part of the toolchain support for ELF symbol
resolution rules in shared libs, these branches are given relocations,
even though the branch will likely resolve locally.  Of course, in the
kernel this is always true, so ld shouldn't assume that there might be a
stub on these branches.  And if there is no need for a stub, then we
don't need a small stub group size.

	* elf64-ppc.c (ppc64_elf_check_relocs): Don't set has_14bit_branch
	on branches to same section.

Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.225
diff -u -p -r1.225 elf64-ppc.c
--- bfd/elf64-ppc.c	25 Oct 2005 16:19:06 -0000	1.225
+++ bfd/elf64-ppc.c	18 Nov 2005 04:29:38 -0000
@@ -4507,7 +4507,24 @@ ppc64_elf_check_relocs (bfd *abfd, struc
 	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:


-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]