From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1116 invoked by alias); 12 Jul 2006 09:00:30 -0000 Received: (qmail 1107 invoked by uid 22791); 12 Jul 2006 09:00:29 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 12 Jul 2006 09:00:25 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id k6C90Nhg012967 for ; Wed, 12 Jul 2006 05:00:23 -0400 Received: from pobox.surrey.redhat.com (pobox.surrey.redhat.com [172.16.10.17]) by int-mx1.corp.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id k6C90KcH021730 for ; Wed, 12 Jul 2006 05:00:22 -0400 Received: from localhost.localdomain.redhat.com (vpn-68-14.surrey.redhat.com [10.32.68.14]) by pobox.surrey.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id k6C90IAE003609 for ; Wed, 12 Jul 2006 10:00:18 +0100 To: binutils@sourceware.org Subject: [PATCH]: Fix bogus overflow warnings from SH .byte directives From: Nick Clifton Date: Wed, 12 Jul 2006 09:00:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2006-07/txt/msg00152.txt.bz2 --=-=-= Content-length: 1571 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 * 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 * 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. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=tc-sh.c.patch Content-length: 846 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; --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=basic.exp.patch Content-length: 1636 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 --=-=-=--