From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 495 invoked by alias); 22 Jul 2011 11:21:07 -0000 Received: (qmail 474 invoked by uid 22791); 22 Jul 2011 11:21:05 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,MSGID_MULTIPLE_AT,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from service87.mimecast.com (HELO service87.mimecast.com) (94.185.240.25) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Fri, 22 Jul 2011 11:20:37 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Fri, 22 Jul 2011 12:20:34 +0100 Received: from e103039 ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 22 Jul 2011 12:20:33 +0100 From: "James Greenhalgh" To: Subject: [Patch ARM Gas] - strexh/strexb warn for bad addressing modes. Date: Fri, 22 Jul 2011 20:16:00 -0000 Message-ID: <000601cc4861$5df11510$19d33f30$@greenhalgh@arm.com> MIME-Version: 1.0 X-MC-Unique: 111072212203406301 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0007_01CC4869.BFB57D10" X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2011-07/txt/msg00193.txt.bz2 This is a multi-part message in MIME format. ------=_NextPart_000_0007_01CC4869.BFB57D10 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-length: 788 Hi, This patch fixes an issue with strex[b/h] in thumb mode. strex[b/h] do not support an addressing mode with writeback. This fault was caught correctly in ARM mode but was undiagnosed under thumb. Instructions of the form: STREXH r0, r1, [r2, #+0x00]! will now produce a "BAD_ADDR_MODE" error. This matches their behaviour under ARM. Tested using make check without regression. James Greenhalgh gas/ 2011-07-22 James Greenhalgh * config/tc-arm.c (do_t_strexbh): New. (insns): Update accordingly. gas/testsuite/ 2011-07-22 James Greenhalgh * gas/arm/strex-bad-t.d: New testcase. * gas/arm/strex-bad-t.s: Likewise. * gas/arm/strex-bad-t.l: Likewise. * gas/arm/strex-t.s: Likewise. * gas/arm/strex-t.d: Likewise. ------=_NextPart_000_0007_01CC4869.BFB57D10 Content-Type: text/x-patch; name=0001-Patch-ARM-Gas-strexh-strexb-warn-for-bad-addressing-.patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Patch-ARM-Gas-strexh-strexb-warn-for-bad-addressing-.patch" Content-length: 5206 diff --git gas/config/tc-arm.c gas/config/tc-arm.c index 1592322..800a6ff 100644 --- gas/config/tc-arm.c +++ gas/config/tc-arm.c @@ -8484,6 +8484,21 @@ do_strex (void) } =20 static void +do_t_strexbh (void) +{ + constraint (!inst.operands[2].isreg || !inst.operands[2].preind + || inst.operands[2].postind || inst.operands[2].writeback + || inst.operands[2].immisreg || inst.operands[2].shifted + || inst.operands[2].negative, + BAD_ADDR_MODE); + + constraint (inst.operands[0].reg =3D=3D inst.operands[1].reg + || inst.operands[0].reg =3D=3D inst.operands[2].reg, BAD_OVERLAP); + + do_rm_rd_rn (); +} + +static void do_strexd (void) { constraint (inst.operands[1].reg % 2 !=3D 0, @@ -17499,9 +17514,9 @@ static const struct asm_opcode insns[] =3D TCE("ldrexh", 1f00f9f, e8d00f5f, 2, (RRnpc_npcsp, RRnpcb), rd_rn, rd_rn), TCE("strexb", 1c00f90, e8c00f40, 3, (RRnpc_npcsp, RRnpc_npcsp, ADDR), - strex, rm_rd_rn), + strex, t_strexbh), TCE("strexh", 1e00f90, e8c00f50, 3, (RRnpc_npcsp, RRnpc_npcsp, ADDR), - strex, rm_rd_rn),=20 + strex, t_strexbh), TUF("clrex", 57ff01f, f3bf8f2f, 0, (), noargs, noargs), =20 #undef ARM_VARIANT diff --git gas/testsuite/gas/arm/strex-bad-t.d gas/testsuite/gas/arm/strex-= bad-t.d new file mode 100644 index 0000000..f5ec4c5 --- /dev/null +++ gas/testsuite/gas/arm/strex-bad-t.d @@ -0,0 +1,3 @@ +# name: Bad addressing modes STREXH/STREXB. - THUMB +# error-output: strex-bad-t.l + diff --git gas/testsuite/gas/arm/strex-bad-t.l gas/testsuite/gas/arm/strex-= bad-t.l new file mode 100644 index 0000000..a490096 --- /dev/null +++ gas/testsuite/gas/arm/strex-bad-t.l @@ -0,0 +1,24 @@ +[^:]*: Assembler messages: +[^:]*:7: Error: r15 not allowed here -- `strexh r0,r1,#0x04' +[^:]*:8: Error: instruction does not accept this addressing mode -- `strex= h r0,r1,\[r2\],#0x04' +[^:]*:9: Error: instruction does not accept this addressing mode -- `strex= h r0,r1,\[r2,#\+0x00\]!' +[^:]*:10: Error: instruction does not accept this addressing mode -- `stre= xh r0,r1,\[r2,r3\]' +[^:]*:11: Error: registers may not be the same -- `strexh r0,r0,\[r1]' +[^:]*:12: Error: instruction does not accept this addressing mode -- `stre= xh r0,r1,\[r2,#-0x04\]' +[^:]*:13: Error: r15 not allowed here -- `strexh r0,r1,\[r15\]' +[^:]*:14: Error: r13 not allowed here -- `strexh r0,r13,\[r1\]' +[^:]*:15: Error: r15 not allowed here -- `strexh r0,r15,\[r1\]' +[^:]*:16: Error: r13 not allowed here -- `strexh r13,r0,\[r1\]' +[^:]*:17: Error: r15 not allowed here -- `strexh r15,r0,\[r1\]' +[^:]*:21: Error: r15 not allowed here -- `strexb r0,r1,#0x04' +[^:]*:22: Error: instruction does not accept this addressing mode -- `stre= xb r0,r1,\[r2\],#0x04' +[^:]*:23: Error: instruction does not accept this addressing mode -- `stre= xb r0,r1,\[r2,#\+0x00\]!' +[^:]*:24: Error: instruction does not accept this addressing mode -- `stre= xb r0,r1,\[r2,r3\]' +[^:]*:25: Error: registers may not be the same -- `strexb r0,r0,\[r1]' +[^:]*:26: Error: instruction does not accept this addressing mode -- `stre= xb r0,r1,\[r2,#-0x04\]' +[^:]*:27: Error: r15 not allowed here -- `strexb r0,r1,\[r15\]' +[^:]*:28: Error: r13 not allowed here -- `strexb r0,r13,\[r1\]' +[^:]*:29: Error: r15 not allowed here -- `strexb r0,r15,\[r1\]' +[^:]*:30: Error: r13 not allowed here -- `strexb r13,r0,\[r1\]' +[^:]*:31: Error: r15 not allowed here -- `strexb r15,r0,\[r1\]' + diff --git gas/testsuite/gas/arm/strex-bad-t.s gas/testsuite/gas/arm/strex-= bad-t.s new file mode 100644 index 0000000..1466ca5 --- /dev/null +++ gas/testsuite/gas/arm/strex-bad-t.s @@ -0,0 +1,32 @@ +.syntax unified + +.thumb + +@ strexh + +strexh r0, r1, #0x04 +strexh r0, r1, [r2], #0x04 +strexh r0, r1, [r2, #+0x00]! +strexh r0, r1, [r2, r3] +strexh r0, r0, [r1] +strexh r0, r1, [r2, #-0x04] +strexh r0, r1, [r15] +strexh r0, r13, [r1] +strexh r0, r15, [r1] +strexh r13, r0, [r1] +strexh r15, r0, [r1] + +@ strexb + +strexb r0, r1, #0x04 +strexb r0, r1, [r2], #0x04 +strexb r0, r1, [r2, #+0x00]! +strexb r0, r1, [r2, r3] +strexb r0, r0, [r1] +strexb r0, r1, [r2, #-0x04] +strexb r0, r1, [r15] +strexb r0, r13, [r1] +strexb r0, r15, [r1] +strexb r13, r0, [r1] +strexb r15, r0, [r1] + diff --git gas/testsuite/gas/arm/strex-t.d gas/testsuite/gas/arm/strex-t.d new file mode 100644 index 0000000..04b5d0b --- /dev/null +++ gas/testsuite/gas/arm/strex-t.d @@ -0,0 +1,13 @@ +# name: STREXH/STREXB. - Thumb +#objdump: -dr --prefix-address --show-raw-insn + +.*: +file format .*arm.* + +Disassembly of section \.text: +0+00 <[^>]+> e8c2 1f50 strexh r0, r1, \[r2\] +0+04 <[^>]+> e8c2 1f50 strexh r0, r1, \[r2\] +0+08 <[^>]+> e8cd 1f50 strexh r0, r1, \[sp\] +0+0c <[^>]+> e8c2 1f40 strexb r0, r1, \[r2\] +0+10 <[^>]+> e8c2 1f40 strexb r0, r1, \[r2\] +0+14 <[^>]+> e8cd 1f40 strexb r0, r1, \[sp\] + diff --git gas/testsuite/gas/arm/strex-t.s gas/testsuite/gas/arm/strex-t.s new file mode 100644 index 0000000..d8cddfc --- /dev/null +++ gas/testsuite/gas/arm/strex-t.s @@ -0,0 +1,10 @@ +.syntax unified +.thumb + strexh r0, r1, [r2] + strexh r0, r1, [r2, #+0x00] + strexh r0, r1, [r13] + + strexb r0, r1, [r2] + strexb r0, r1, [r2, #+0x00] + strexb r0, r1, [r13] += ------=_NextPart_000_0007_01CC4869.BFB57D10--