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 518743858D32 for ; Mon, 3 Jul 2023 18:10:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 518743858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 363HqOs9013899 for ; Mon, 3 Jul 2023 18:10:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=2lDr7yNUCWpq0gZskYnz5JhGxjqnWj1fsh/B1rrK4BA=; b=CJeKSOschG28cFxD//TLnxu+bpvU5rf9fYMGiE3mhmYbalZS4lH0ytX3hG+y0MM2z/eg ouglBIb+dfQlP3mwyxOtAhsgxBgc7B21SSCQhrG1AaPVR++4Px0xUJvawpW6bHB3VB9p //FALGPOxIP9junXjLopprrD9PWTL4qA0xTDSpPvZFGmGoilJ4/OJyAhHNWoYm/y3WQ8 HAFh2dfkhuF4+9mwobWBmeXu2CHVzrk/izloTvGHKt3wvQpK3CNvZAbwLsI1JyKJDcFo PqbKrjw3p7QeKxgxPygOaPdQzGJWJp3DnuhtTvvdbGTgH3z+4DWU7maJDDMtnOmQDg1M wQ== Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rm33t0bad-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 03 Jul 2023 18:10:58 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 363GLNgF003348 for ; Mon, 3 Jul 2023 18:10:55 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma06fra.de.ibm.com (PPS) with ESMTPS id 3rjbdds4he-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 03 Jul 2023 18:10:55 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 363IArwk14811812 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 3 Jul 2023 18:10:53 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4E93E20043 for ; Mon, 3 Jul 2023 18:10:53 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1A65020040 for ; Mon, 3 Jul 2023 18:10:53 +0000 (GMT) Received: from li-ecc9ffcc-3485-11b2-a85c-e633c5126265.fritz.box (unknown [9.179.2.17]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP for ; Mon, 3 Jul 2023 18:10:53 +0000 (GMT) From: Andreas Krebbel To: binutils@sourceware.org Subject: [Committed] IBM Z: Fix pcrel relocs for symA-symB expressions Date: Mon, 3 Jul 2023 20:10:52 +0200 Message-ID: <20230703181052.41059-1-krebbel@linux.ibm.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: iXMDcBpXXwMkxxNWV7TvfYLU7deV0FOU X-Proofpoint-ORIG-GUID: iXMDcBpXXwMkxxNWV7TvfYLU7deV0FOU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-03_13,2023-06-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1015 suspectscore=0 priorityscore=1501 impostorscore=0 mlxscore=0 malwarescore=0 mlxlogscore=786 spamscore=0 bulkscore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307030164 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The code in md_apply_fix which tries to deduce from the operand type which reloc to apply currently does the wrong thing for absolute relocs which have been re-written by fixup_segment as pc-relative to implement a subtraction of a local and an external symbol. In all these cases we wrongly emit an absolute reloc because we ignore the fx_pcrel flag in md_apply_fix. However, only for the last one we actually support a pc relative relocation of the proper size and can implement it accordingly. For the other 3 we have to issue an error. foo: cli 0(%r2),undef-foo la %r2,undef-foo(%r2) lay %r2,undef-foo(%r2) lhi %r2,undef-foo No testsuite regressions. Applied to mainline. --- gas/config/tc-s390.c | 14 ++++++++++---- gas/testsuite/gas/s390/esa-reloc.d | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gas/config/tc-s390.c b/gas/config/tc-s390.c index 955851946f9..765a9a2e6bd 100644 --- a/gas/config/tc-s390.c +++ b/gas/config/tc-s390.c @@ -2291,25 +2291,25 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) We are only prepared to turn a few of the operands into relocs. */ fixP->fx_offset = value; - if (operand->bits == 12 && operand->shift == 20) + if (operand->bits == 12 && operand->shift == 20 && !fixP->fx_pcrel) { fixP->fx_size = 2; fixP->fx_where += 2; fixP->fx_r_type = BFD_RELOC_390_12; } - else if (operand->bits == 12 && operand->shift == 36) + else if (operand->bits == 12 && operand->shift == 36 && !fixP->fx_pcrel) { fixP->fx_size = 2; fixP->fx_where += 4; fixP->fx_r_type = BFD_RELOC_390_12; } - else if (operand->bits == 20 && operand->shift == 20) + else if (operand->bits == 20 && operand->shift == 20 && !fixP->fx_pcrel) { fixP->fx_size = 4; fixP->fx_where += 2; fixP->fx_r_type = BFD_RELOC_390_20; } - else if (operand->bits == 8 && operand->shift == 8) + else if (operand->bits == 8 && operand->shift == 8 && !fixP->fx_pcrel) { fixP->fx_size = 1; fixP->fx_where += 1; @@ -2334,6 +2334,12 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) fixP->fx_offset += 2; fixP->fx_pcrel_adjust = 2; } + else if (fixP->fx_pcrel) + { + fixP->fx_r_type = BFD_RELOC_16_PCREL; + fixP->fx_offset += 2; + fixP->fx_pcrel_adjust = 2; + } else fixP->fx_r_type = BFD_RELOC_16; } diff --git a/gas/testsuite/gas/s390/esa-reloc.d b/gas/testsuite/gas/s390/esa-reloc.d index c9da92870d5..0b13cb626a6 100644 --- a/gas/testsuite/gas/s390/esa-reloc.d +++ b/gas/testsuite/gas/s390/esa-reloc.d @@ -23,7 +23,7 @@ Disassembly of section .text: 22: a7 08 00 00 [ ]*lhi %r0,0 [ ]*24: R_390_GOT16 test_R_390_GOT16 26: a7 08 00 00 [ ]*lhi %r0,0 -[ ]*28: R_390_16 test_R_390_PC16\+0x26 +[ ]*28: R_390_PC16 test_R_390_PC16\+0x28 2a: a7 e5 00 00 [ ]*bras %r14,2a [ ]*2c: R_390_PC16DBL test_R_390_PC16DBL\+0x2 2e: a7 e5 00 00 [ ]*bras %r14,2e -- 2.41.0