From patchwork Tue Oct 18 08:12:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Krebbel X-Patchwork-Id: 3999 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1834475wrs; Tue, 18 Oct 2022 01:12:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5cImLf4Hc7+5QHW65zQaOKaHKjq3hpdK5MznCh0pm3UJPwn9Zq+s6/thxOeQ5WLmmVsxh5 X-Received: by 2002:a05:6402:4441:b0:454:8a74:5459 with SMTP id o1-20020a056402444100b004548a745459mr1493167edb.155.1666080740298; Tue, 18 Oct 2022 01:12:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666080740; cv=none; d=google.com; s=arc-20160816; b=nWfFpo4Wi3bgVZd82fO0tbiOSQAmUsWZGUFf3VjUvZiuZtOPtEoebhdi3T259kTKZ0 lMD5FkftjS+4EsQ835nwIw17Tp8pai919aenYJGNrDqVE6v7b7TCQAChFx/2VO3J+edK tXUp4d88yaqrqbANxB9PhPSGv0XfHi0VqGRtP0KbskYJGX+Rr3U5ZHlSb1amTjQNUtN+ 1tM8H/rPm0oJ1e5kyEeTBNxkYl5r5VDKqaDuyALTtPicmBaby3lmJ8eY+1Mqe8pw/V4S AL4/2Z0mBx1/3Pj163sYv4+nTqjmSvw/pVGqGb1CbJn4s+jpKLwC/pbHXpDq9DdxCMaM yb9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=XnAFM0oplACj6i3SNrFjY0YAF57WphDY7VfETWTeUic=; b=oGSqASK7zDYG8WVfvHV+VMrr8VFPorDCqPVDHCe24Lfgl61SYrlySS8hbs+KJkkzb0 4f87QuBpsWwA8HyGAzO+7TPz98FTcLsr81is67bzIvzFQi5XQFA5iIytWc1gTc1iM5qG vlSDufWgPIDAQgCiJe2qSO8299Uo876WlGsQiB9KgXqRJTvRgOEi9PaWsD8uWt9H3o6K 1Qth1jltPzyPYAf+S5fCnr6boayiRACDA8Ez+hdGodF8VHlYxM2BBMygcJm/Qqxu5duo GUL1oi4HR0kHvDasEi8d/XbO359zPlcqJaH3tDxlRKB2ElS7n3lanQfk7BkBD+sC7K+g HTNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=GB0T2PGg; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id w9-20020aa7da49000000b0044e6b43f044si10647652eds.267.2022.10.18.01.12.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Oct 2022 01:12:20 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=GB0T2PGg; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4CC043858291 for ; Tue, 18 Oct 2022 08:12:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4CC043858291 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666080739; bh=XnAFM0oplACj6i3SNrFjY0YAF57WphDY7VfETWTeUic=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=GB0T2PGgezmaKtbH2mKZvES2rmtBJ8hocl+QIWzT8zXiyK/lLQVuv2Qa02nAU6leV DStWNcG6dU6aVMCXx5aBStUYTrtQHGtP2wwFhzUggKlg8ikR7EQyv1rvBrAElSj9Ox Czf1BLHuQcUZHwQlddSNU8mdx/cZUFB2ZYjxVek4= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org 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 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 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) 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 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 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-Patchwork-Original-From: Andreas Krebbel via Binutils From: Andreas Krebbel Reply-To: Andreas Krebbel Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747012278229008274?= X-GMAIL-MSGID: =?utf-8?q?1747012278229008274?= 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