[PATCH][GOLD] Tune stub group size.

Doug Kwan (關振德) dougkwan@google.com
Mon Jun 7 23:58:00 GMT 2010


Hi,

    This patch changes the default stub group size, which was
originally copied from the ARM back-end in bfd.  Gold is slightly less
efficient in sharing stubs.  The ARM back-end in bfd uses a different
type of stub than requested if the existing stub is compatible.  Gold
right now cannot do that, so we need to reserve more space.  I also
restrict the stub group size to be less than 1M when fixing the
cortex-A8 workaround since this is the branch range for long
conditional branch.

-Doug

2010-06-07  Doug Kwan  <dougkwan@google.com>

        * arm.cc (Target_arm::do_relax): Reserve more space for stubs.
        Restrict stub-group size to be within long conditional branch
        range when working around cortex-A8 erratum.
-------------- next part --------------
Index: gold/arm.cc
===================================================================
RCS file: /cvs/src/src/gold/arm.cc,v
retrieving revision 1.106
diff -u -u -p -r1.106 arm.cc
--- gold/arm.cc	26 May 2010 03:33:59 -0000	1.106
+++ gold/arm.cc	7 Jun 2010 23:56:22 -0000
@@ -10844,12 +10844,6 @@ Target_arm<big_endian>::do_relax(
       bool stubs_always_after_branch = stub_group_size_param < 0;
       section_size_type stub_group_size = abs(stub_group_size_param);
 
-      // The Cortex-A8 erratum fix depends on stubs not being in the same 4K
-      // page as the first half of a 32-bit branch straddling two 4K pages.
-      // This is a crude way of enforcing that.
-      if (this->fix_cortex_a8_)
-	stubs_always_after_branch = true;
-
       if (stub_group_size == 1)
 	{
 	  // Default value.
@@ -10859,14 +10853,24 @@ Target_arm<big_endian>::do_relax(
 	  // fixing cortex-a8 errata, the branch range has to be even smaller,
 	  // since wide conditional branch has a range of +-1MB only.
 	  //
-	  // This value is 24K less than that, which allows for 2025
+	  // This value is 48K less than that, which allows for 4096
 	  // 12-byte stubs.  If we exceed that, then we will fail to link.
 	  // The user will have to relink with an explicit group size
 	  // option.
-	  if (this->fix_cortex_a8_)
-	    stub_group_size = 1024276;
-	  else
-	    stub_group_size = 4170000;
+	    stub_group_size = 4145152;
+	}
+
+      // The Cortex-A8 erratum fix depends on stubs not being in the same 4K
+      // page as the first half of a 32-bit branch straddling two 4K pages.
+      // This is a crude way of enforcing that.  In addition, long conditional
+      // branches of THUMB-2 have a range of +-1M.  If we are fixing cortex-A8
+      // erratum, limit the group size to  (1M - 12k) to avoid unreachable
+      // cortex-A8 stubs from long conditional branches.
+      if (this->fix_cortex_a8_)
+	{
+	  stubs_always_after_branch = true;
+	  const section_size_type cortex_a8_group_size = 1024 * (1024 - 12);
+	  stub_group_size = std::max(stub_group_size, cortex_a8_group_size);
 	}
 
       group_sections(layout, stub_group_size, stubs_always_after_branch);


More information about the Binutils mailing list