This is the mail archive of the binutils@sources.redhat.com 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]

Re: Stub group default for hppa elf


On Fri, Feb 07, 2003 at 11:12:44AM -0500, John David Anglin wrote:
> I'm changing the stub group default from 1 to -1.  Various link errors
> have been reported in linking C++ applications where the branch distance
> to the stub group is too far, indicating the stub group has overflowed
> or is incorrectly ordered.  I haven't had a chance to fully investigate
> but changing the default corrects the problem.
> 
> 	* hppaelf.em (group_size): Change default to -1.

This change doesn't directly address the stub overflow problem, but
changes stub section placement to always be before the branches into
the stubs.  ie. you've gone from

======
code group A
======
stubs for A + B
======
code group B
======

to

======
stubs for A
======
code group A
======
stubs for B
======
code group B
======

Of course, the chances are that "stubs for A + B" is roughly the size
of "stubs for A" plus "stubs for B" (may be smaller than the sum due
to merging of duplicate stubs).  ie. a default of 1 tends to make stub
sections twice as large as a default of -1, and that is why changing
the default helps.

I think the following patch is more appropriate, but will leave
reverting your patch to you.  The only real reason to always place
stubs before their associated code section is when you're doing
conditional branches to a stub and you want to control branch
prediction.

	* elf32-hppa.c (elf32_hppa_size_stubs): Double the size left for
	stubs if !stubs_always_before_branch.

Index: bfd/elf32-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-hppa.c,v
retrieving revision 1.93
diff -u -p -r1.93 elf32-hppa.c
--- bfd/elf32-hppa.c	8 Jan 2003 02:19:23 -0000	1.93
+++ bfd/elf32-hppa.c	8 Feb 2003 00:53:20 -0000
@@ -2901,11 +2901,22 @@ elf32_hppa_size_stubs (output_bfd, stub_
   if (stub_group_size == 1)
     {
       /* Default values.  */
-      stub_group_size = 7680000;
-      if (htab->has_17bit_branch || htab->multi_subspace)
-	stub_group_size = 240000;
-      if (htab->has_12bit_branch)
-	stub_group_size = 7500;
+      if (stubs_always_before_branch)
+	{
+	  stub_group_size = 7680000;
+	  if (htab->has_17bit_branch || htab->multi_subspace)
+	    stub_group_size = 240000;
+	  if (htab->has_12bit_branch)
+	    stub_group_size = 7500;
+	}
+      else
+	{
+	  stub_group_size = 6971392;
+	  if (htab->has_17bit_branch || htab->multi_subspace)
+	    stub_group_size = 217856;
+	  if (htab->has_12bit_branch)
+	    stub_group_size = 6808;
+	}
     }
 
   group_sections (htab, stub_group_size, stubs_always_before_branch);

-- 
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]