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]

Re: RFC: PATCH: PR gas/12049: Unnecessary relaxation


On Fri, Oct 22, 2010 at 12:44:21PM -0700, H.J. Lu wrote:
> Your fix doesn't handle the new testcase in
> 
> http://sourceware.org/bugzilla/show_bug.cgi?id=12049

The comment says it all.

	PR gas/12049
	* write.c (relax_frag): Don't allow forward branches to temporarily
	becomde backward branches.

Index: gas/write.c
===================================================================
RCS file: /cvs/src/src/gas/write.c,v
retrieving revision 1.134
diff -u -p -r1.134 write.c
--- gas/write.c	19 Oct 2010 12:14:23 -0000	1.134
+++ gas/write.c	23 Oct 2010 11:55:01 -0000
@@ -2163,6 +2163,13 @@ relax_frag (segT segment, fragS *fragP, 
 	  if (stretch < 0
 	      || sym_frag->region == fragP->region)
 	    target += stretch;
+	  /* If we get here we know we have a forward branch.  This
+	     relax pass may have stretched previous instructions so
+	     far that omitting STRETCH would make the branch
+	     negative.  Don't allow this in case the negative reach is
+	     large enough to require a larger branch instruction.  */
+	  else if (target < address)
+	    target = fragP->fr_next->fr_address + stretch;
 	}
     }
 

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