From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id AEF743858D3C for ; Tue, 18 Oct 2022 08:12:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AEF743858D3C 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 (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29I86fvM029439 for ; Tue, 18 Oct 2022 08:12:10 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=XnAFM0oplACj6i3SNrFjY0YAF57WphDY7VfETWTeUic=; b=sfiR+CDyemF8KzJbxtwR2gNXSA0iMvCU5oRnp4y4i+A19Qc9aJBu6ZxhY0ZUeOH7ihvZ IDrbKD2icXvZ/tkx8JuF1WiKamMefv9PqXyvrfCnijAGpHzfsvXyAomno02a563UoX1i 2lUd2drzSL/VtfuCXr7T5md0+TTR2XinofwgknuJ2RbTqX4JdqmEJ+RxI30icNwfacrV yEXLUbj5TvpY9pEB6G8IpRxlgKL5noPzLlyykIROSPpAVx+97Wfji8UuSLW2rh2/Jc5x UXWBEMsflJ92jZL1dcVEkPlJmH8WTFTzeYsje38VYfTT48C3/Py4yXnuU29wyFP94Ivl 6g== Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3k9r4a8enq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 18 Oct 2022 08:12:10 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 29I85Bu9030288 for ; Tue, 18 Oct 2022 08:12:08 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma03ams.nl.ibm.com with ESMTP id 3k7mg94srr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 18 Oct 2022 08:12:08 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29I8C6TT7406326 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 18 Oct 2022 08:12:06 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1590911C04C for ; Tue, 18 Oct 2022 08:12:06 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E2A8111C04A for ; Tue, 18 Oct 2022 08:12:05 +0000 (GMT) Received: from li-ecc9ffcc-3485-11b2-a85c-e633c5126265.fritz.box (unknown [9.171.37.192]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Tue, 18 Oct 2022 08:12:05 +0000 (GMT) From: Andreas Krebbel To: binutils@sourceware.org Subject: [PATCH 1/1] IBM zSystems: Issue error for *DBL relocs on misaligned symbols Date: Tue, 18 Oct 2022 10:12:05 +0200 Message-Id: <20221018081205.17880-1-krebbel@linux.ibm.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: soE7oshO_tulRSXpQZ-VRR5TwhpXBPox X-Proofpoint-ORIG-GUID: soE7oshO_tulRSXpQZ-VRR5TwhpXBPox X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-18_01,2022-10-17_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 adultscore=0 mlxlogscore=713 clxscore=1015 bulkscore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210180046 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_H2,SPF_HELO_NONE,SPF_PASS,TXREP 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: Relocs like PC32DBL require a right shift of the symbol value. There is no situation where dropping symbol value bits with the right shift is a good thing. Hence we now issue an error to detect such problems. --- bfd/elf64-s390.c | 18 ++++++++++++++++++ ld/testsuite/ld-s390/reloccheck-1.d | 5 +++++ ld/testsuite/ld-s390/reloccheck-1.s | 14 ++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 ld/testsuite/ld-s390/reloccheck-1.d create mode 100644 ld/testsuite/ld-s390/reloccheck-1.s diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index c1ed3d619d6..fa4497181fe 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -3056,6 +3056,24 @@ elf_s390_relocate_section (bfd *output_bfd, || r_type == R_390_PLT24DBL) rel->r_offset--; + /* Issue an error if the right shift implied by the relocation + would drop bits from the symbol value. */ + if (howto->rightshift + && (relocation & (((bfd_vma)1 << howto->rightshift) - 1))) + { + _bfd_error_handler + /* xgettext:c-format */ + (_("%pB(%pA+%#" PRIx64 "): " + "misaligned symbol `%s' (%#" PRIx64 ") for relocation %s"), + input_bfd, + input_section, + (uint64_t) rel->r_offset, + h->root.root.string, + (uint64_t)relocation, + howto->name); + return false; + } + if (r_type == R_390_20 || r_type == R_390_GOT20 || r_type == R_390_GOTPLT20 diff --git a/ld/testsuite/ld-s390/reloccheck-1.d b/ld/testsuite/ld-s390/reloccheck-1.d new file mode 100644 index 00000000000..00c568cffa1 --- /dev/null +++ b/ld/testsuite/ld-s390/reloccheck-1.d @@ -0,0 +1,5 @@ +#as: -m64 -mzarch -march=z900 +#ld: -m elf64_s390 -e start -static +#error: .*misaligned symbol.* + +There are no relocations in this file. diff --git a/ld/testsuite/ld-s390/reloccheck-1.s b/ld/testsuite/ld-s390/reloccheck-1.s new file mode 100644 index 00000000000..6c932bdfb0c --- /dev/null +++ b/ld/testsuite/ld-s390/reloccheck-1.s @@ -0,0 +1,14 @@ + .machinemode zarch + .machine "z900" +.text + .align 8 +.globl start + .type start, @function +start: + larl %r1, test +.globl test +.data + .align 4 + .byte 23 +test: + .zero 4 -- 2.37.3