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]

[PATCH]: Fix bogus overflow warnings from SH .byte directives


Hi Guys,

  The attached file "too_large.s" is a distilled version of a gcc
  compiled test case that triggers a problem with the SH port of GAS.
  When assembled it generates these error messages for some .byte
  directives:

  too_large.s:6: Error: value of 310 too large for field of 1 bytes at 256
  too_large.s:7: Error: value of 298 too large for field of 1 bytes at 257
  too_large.s:8: Error: value of 260 too large for field of 1 bytes at 258
  too_large.s:9: Error: value of 286 too large for field of 1 bytes at 259

  The values are in fact OK.  The problem is that the SH backend has
  computed the correct value and checked its range, but it has not
  told the generic code about this.

  There are two possible ways to solve this problem.  Either the SH
  backend can return the correct value to the generic code, which will
  then range check it again.  Or it can just tell the generic code
  that the (wrong) value that it has has already been range checked
  and that it does not need to be checked again.  I have gone for the
  latter method.

Cheers
  Nick

gas/ChangeLog
2006-07-12  Nick Clifton  <nickc@redhat.com>

	* config/tc-sh.c (md_apply_fix): Do not allow the generic code in
	fixup_segment() to repeat a range check on a value that have
	already been checked here.

gas/testsuite/ChangeLog
2006-07-12  Nick Clifton  <nickc@redhat.com>

	* gas/sh/basic.exp: Run "too_large" dump test.
	* gas/sh/too_large.s: New test file.  Check that .byte directives
	do not generate a bogus overflow message.
	* gas/sh/too_large.s: New test control file.

Index: gas/config/tc-sh.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-sh.c,v
retrieving revision 1.117
diff -c -3 -p -r1.117 tc-sh.c
*** gas/config/tc-sh.c	7 Jun 2006 11:27:58 -0000	1.117
--- gas/config/tc-sh.c	12 Jul 2006 08:51:53 -0000
*************** md_apply_fix (fixS *fixP, valueT *valP, 
*** 4080,4085 ****
--- 4080,4090 ----
      }
    if (max != 0 && (val < min || val > max))
      as_bad_where (fixP->fx_file, fixP->fx_line, _("offset out of range"));
+   else if (max != 0)
+     /* Stop the generic code from trying to overlow check the value as well.
+        It may not have the correct value anyway, as we do not store val back
+        into *valP.  */
+     fixP->fx_no_overflow = 1;
  
    if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0)
      fixP->fx_done = 1;
Index: gas/testsuite/gas/sh/basic.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/sh/basic.exp,v
retrieving revision 1.22
diff -c -3 -p -r1.22 basic.exp
*** gas/testsuite/gas/sh/basic.exp	6 Oct 2005 11:44:07 -0000	1.22
--- gas/testsuite/gas/sh/basic.exp	12 Jul 2006 08:50:45 -0000
*************** if [istarget sh*-*-*] then {
*** 167,172 ****
--- 167,174 ----
  
  	# Test --allow-reg-prefix.
  	run_dump_test "reg-prefix"
+ 
+ 	run_dump_test "too_large"
      }
  }
  
*** /dev/null	2006-07-11 09:23:37.519856808 +0100
--- gas/testsuite/gas/sh/too_large.s	2006-07-11 18:30:22.000000000 +0100
***************
*** 0 ****
--- 1,39 ----
+ 	.file	"too_large.c"
+ 	.text
+ 	nop
+ 	.align 8
+ .L307:
+ 	.byte	.L302-.L307
+ 	.byte	.L303-.L307
+ 	.byte	.L304-.L307
+ 	.byte	.L305-.L307
+ .L304:
+ 	mov.l	.L318,r1	
+ 	jsr	@r1	
+ 	mov	r8,r4	
+ 	lds	r0,fpul	
+ 	fsts	fpul,fr1	
+ 	flds	fr1,fpul	
+ 	sts	fpul,r0	
+ 	mov	r14,r15	
+ 	lds.l	@r15+,pr	
+ 	mov.l	@r15+,r14	
+ 	mov.l	@r15+,r8	
+ 	rts	
+ 	nop	
+ .L305:
+ 	mov.l	.L319,r7	
+ 	jsr	@r7	
+ 	mov	r8,r4	
+ 	lds	r0,fpul	
+ 	bra	.L307	
+ 	fsts	fpul,fr1	
+ .L303:
+ 	mov.l	.L320,r6	
+ 	jsr	@r6	
+ 	mov	r8,r4	
+ 	lds	r0,fpul	
+ 	bra	.L307	
+ 	fsts	fpul,fr1	
+ .L302:
+ 	mov.l	.L321,r5	
*** /dev/null	2006-07-11 09:23:37.519856808 +0100
--- gas/testsuite/gas/sh/too_large.d	2006-07-12 09:49:21.000000000 +0100
***************
*** 0 ****
--- 1,9 ----
+ #name: Check for bogus overflow errors in .byte directives
+ #as: -big -relax -isa=sh4a
+ #nm: -n
+ 
+ [ 	]*U \.L318
+ [ 	]*U \.L319
+ [ 	]*U \.L320
+ [ 	]*U \.L321
+ 0+00100 t \.L307

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