From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 2B0263858010 for ; Wed, 4 May 2022 10:36:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2B0263858010 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 244ATpmY005594 for ; Wed, 4 May 2022 10:36:56 GMT Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3fuqspg54q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 04 May 2022 10:36:55 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 244AYP4t012134 for ; Wed, 4 May 2022 10:36:53 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma05fra.de.ibm.com with ESMTP id 3frvr8mdby-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 04 May 2022 10:36:53 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 244Aao8P44826986 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 May 2022 10:36:50 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 17ECB4C044; Wed, 4 May 2022 10:36:50 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D293C4C040; Wed, 4 May 2022 10:36:49 +0000 (GMT) Received: from heavy.ibmuc.com (unknown [9.171.50.79]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 4 May 2022 10:36:49 +0000 (GMT) From: Ilya Leoshkevich To: Andreas Krebbel Cc: binutils@sourceware.org, Ilya Leoshkevich Subject: [PATCH v2] IBM zSystems: Accept (. - 0x100000000) PCRel32 operands Date: Wed, 4 May 2022 12:36:48 +0200 Message-Id: <20220504103648.1724970-1-iii@linux.ibm.com> X-Mailer: git-send-email 2.35.1 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: rRyk3xvOBjdYa9xQ4jg0CJTADxOTO9fI X-Proofpoint-GUID: rRyk3xvOBjdYa9xQ4jg0CJTADxOTO9fI Content-Transfer-Encoding: 8bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-04_03,2022-05-04_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=575 impostorscore=0 clxscore=1015 priorityscore=1501 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 bulkscore=0 adultscore=0 lowpriorityscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205040070 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 May 2022 10:36:58 -0000 as does not accept instructions like brasl %r0,.-0x100000000, because of two problems with the generic overflow check: 1. PCRel32 operands are signed, but are treated as unsigned. 2. The allowed range for these operands is [-(1 << 32), (1 << 32) - 1], and not [-(1 << 31), (1 << 31) - 1]. Fix both by disabling the generic overflow check - it's not needed, because s390_insert_operand () performs its own. gas/ChangeLog: * config/tc-s390.c (md_gather_operands): Set fx_no_overflow. * testsuite/gas/s390/s390.exp: Add zarch-z900-err. * testsuite/gas/s390/esa-z900.d: New test. * testsuite/gas/s390/esa-z900.s: New test. * testsuite/gas/s390/zarch-z900-err.l: New test. * testsuite/gas/s390/zarch-z900-err.s: New test. --- v1: https://sourceware.org/pipermail/binutils/2022-May/120634.html v1 -> v2: Use fx_no_overflow. gas/config/tc-s390.c | 14 +++++++++----- gas/testsuite/gas/s390/esa-z900.d | 6 +++++- gas/testsuite/gas/s390/esa-z900.s | 4 ++++ gas/testsuite/gas/s390/s390.exp | 1 + gas/testsuite/gas/s390/zarch-z900-err.l | 3 +++ gas/testsuite/gas/s390/zarch-z900-err.s | 4 ++++ 6 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 gas/testsuite/gas/s390/zarch-z900-err.l create mode 100644 gas/testsuite/gas/s390/zarch-z900-err.s diff --git a/gas/config/tc-s390.c b/gas/config/tc-s390.c index 4af635beac3..4fd4f1f0693 100644 --- a/gas/config/tc-s390.c +++ b/gas/config/tc-s390.c @@ -1619,6 +1619,7 @@ md_gather_operands (char *str, md_apply_fix. */ for (i = 0; i < fc; i++) { + fixS *fixP; if (fixups[i].opindex < 0) { @@ -1633,7 +1634,6 @@ md_gather_operands (char *str, if (fixups[i].reloc != BFD_RELOC_UNUSED) { reloc_howto_type *reloc_howto; - fixS *fixP; int size; reloc_howto = bfd_reloc_type_lookup (stdoutput, fixups[i].reloc); @@ -1661,10 +1661,14 @@ md_gather_operands (char *str, fixP->fx_pcrel_adjust = operand->shift / 8; } else - fix_new_exp (frag_now, f - frag_now->fr_literal, 4, &fixups[i].exp, - (operand->flags & S390_OPERAND_PCREL) != 0, - ((bfd_reloc_code_real_type) - (fixups[i].opindex + (int) BFD_RELOC_UNUSED))); + fixP = fix_new_exp (frag_now, f - frag_now->fr_literal, 4, + &fixups[i].exp, + (operand->flags & S390_OPERAND_PCREL) != 0, + ((bfd_reloc_code_real_type) + (fixups[i].opindex + (int) BFD_RELOC_UNUSED))); + /* s390_insert_operand () does the range checking. */ + if (operand->flags & S390_OPERAND_PCREL) + fixP->fx_no_overflow = 1; } return str; } diff --git a/gas/testsuite/gas/s390/esa-z900.d b/gas/testsuite/gas/s390/esa-z900.d index 42f408b624f..86db0641e95 100644 --- a/gas/testsuite/gas/s390/esa-z900.d +++ b/gas/testsuite/gas/s390/esa-z900.d @@ -52,6 +52,10 @@ Disassembly of section .text: .*: c0 f4 00 00 00 00 [ ]*jg 102 .*: c0 65 00 00 00 00 [ ]*brasl %r6,108 .*: c0 65 00 00 00 00 [ ]*brasl %r6,10e +.*: c0 65 80 00 00 00 [ ]*brasl %r6,114 +.*: c0 65 80 00 00 00 [ ]*brasl %r6,11a +.*: c0 65 7f ff ff ff [ ]*brasl %r6,11e +.*: c0 65 7f ff ff ff [ ]*brasl %r6,124 .*: 01 0b [ ]*tam .*: 01 0c [ ]*sam24 .*: 01 0d [ ]*sam31 @@ -62,7 +66,7 @@ Disassembly of section .text: .*: b9 97 00 69 [ ]*dlr %r6,%r9 .*: b9 98 00 69 [ ]*alcr %r6,%r9 .*: b9 99 00 69 [ ]*slbr %r6,%r9 -.*: c0 60 00 00 00 00 [ ]*larl %r6,136 +.*: c0 60 00 00 00 00 [ ]*larl %r6,14e .*: e3 65 af ff 00 1e [ ]*lrv %r6,4095\(%r5,%r10\) .*: e3 65 af ff 00 1f [ ]*lrvh %r6,4095\(%r5,%r10\) .*: e3 65 af ff 00 3e [ ]*strv %r6,4095\(%r5,%r10\) diff --git a/gas/testsuite/gas/s390/esa-z900.s b/gas/testsuite/gas/s390/esa-z900.s index 7a006168f9e..74bbf612cd9 100644 --- a/gas/testsuite/gas/s390/esa-z900.s +++ b/gas/testsuite/gas/s390/esa-z900.s @@ -46,6 +46,10 @@ foo: brul . brasl %r6,. jasl %r6,. + brasl %r6,.-0x100000000 + jasl %r6,.-0x100000000 + brasl %r6,.+0xfffffffe + jasl %r6,.+0xfffffffe tam sam24 sam31 diff --git a/gas/testsuite/gas/s390/s390.exp b/gas/testsuite/gas/s390/s390.exp index d03555a7aef..356fba95885 100644 --- a/gas/testsuite/gas/s390/s390.exp +++ b/gas/testsuite/gas/s390/s390.exp @@ -20,6 +20,7 @@ if [expr [istarget "s390-*-*"] || [istarget "s390x-*-*"]] then { # } run_dump_test "zarch-z900" "{as -m64}" + run_list_test "zarch-z900-err" "-march=z900" run_dump_test "zarch-z990" "{as -m64} {as -march=z990}" run_list_test "zarch-z990-symbol-lay" "-m64 -march=z990" run_dump_test "zarch-z9-109" "{as -m64} {as -march=z9-109}" diff --git a/gas/testsuite/gas/s390/zarch-z900-err.l b/gas/testsuite/gas/s390/zarch-z900-err.l new file mode 100644 index 00000000000..72994192095 --- /dev/null +++ b/gas/testsuite/gas/s390/zarch-z900-err.l @@ -0,0 +1,3 @@ +.*: Assembler messages: +.*:3: Error: operand out of range \(fffffffefffffffe not between 0 and 4294967294\) +.*:4: Error: operand out of range \(0000000100000000 not between 0 and 4294967294\) diff --git a/gas/testsuite/gas/s390/zarch-z900-err.s b/gas/testsuite/gas/s390/zarch-z900-err.s new file mode 100644 index 00000000000..96fef2a487c --- /dev/null +++ b/gas/testsuite/gas/s390/zarch-z900-err.s @@ -0,0 +1,4 @@ +.text +foo: + brasl %r6,.-0x100000002 + brasl %r6,.+0x100000000 -- 2.35.1