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]

PowerPC32 linker relaxation


This aims to make life a little easier for people building large
PowerPC binaries where the PLT is out of reach for 24-bit branches.

	* emultempl/ppc32elf.em (ppc_before_allocation): Turn on
	linker relaxation if it might be necessary.

Index: ld/emultempl/ppc32elf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/ppc32elf.em,v
retrieving revision 1.18
diff -u -p -r1.18 ppc32elf.em
--- ld/emultempl/ppc32elf.em	15 Feb 2008 09:03:02 -0000	1.18
+++ ld/emultempl/ppc32elf.em	10 Jul 2009 08:09:17 -0000
@@ -112,7 +112,40 @@ ppc_before_allocation (void)
 	    }
 	}
     }
+
   gld${EMULATION_NAME}_before_allocation ();
+
+  /* Turn on relaxation if executable sections have addresses that
+     might make branches overflow.  */
+  if (!command_line.relax)
+    {
+      bfd_vma low = (bfd_vma) -1;
+      bfd_vma high = 0;
+      asection *o;
+
+      /* Run lang_size_sections (if not already done).  */
+      if (expld.phase != lang_mark_phase_enum)
+	{
+	  expld.phase = lang_mark_phase_enum;
+	  expld.dataseg.phase = exp_dataseg_none;
+	  one_lang_size_sections_pass (NULL, FALSE);
+	  lang_reset_memory_regions ();
+	}
+
+      for (o = link_info.output_bfd->sections; o != NULL; o = o->next)
+	{
+	  if ((o->flags & (SEC_ALLOC | SEC_CODE)) != (SEC_ALLOC | SEC_CODE))
+	    continue;
+	  if (o->size == 0)
+	    continue;
+	  if (low > o->vma)
+	    low = o->vma;
+	  if (high < o->vma + o->size - 1)
+	    high = o->vma + o->size - 1;
+	}
+      if (high > low && high - low > (1 << 25) - 1)
+	command_line.relax = TRUE;
+    }
 }
 
 EOF

-- 
Alan Modra
Australia Development Lab, IBM


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