From patchwork Tue Jan 10 13:35:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schulze Frielinghaus X-Patchwork-Id: 41470 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2750519wrt; Tue, 10 Jan 2023 05:37:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXtK4jttmEZd+gKDUGjdPmVPp+A7HQGq3mOEi5S98q+Obkp8dX9WI0IfcO29Cv4iP/YozlAC X-Received: by 2002:a05:6402:f04:b0:46d:ca42:2e59 with SMTP id i4-20020a0564020f0400b0046dca422e59mr65457729eda.11.1673357855365; Tue, 10 Jan 2023 05:37:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673357855; cv=none; d=google.com; s=arc-20160816; b=iBPgD0SsqEIJrkzuGiLTKllm0uLk0lWjJLXMvTE3aGYO5BKOFiKslv8/n4ZYca1Yc8 ciV6cqByyZUn18pxRVemoUPNenZDI7EvRFfrlKMB01hiIdRTKJoUOAN5qcUo0SK2uRhF RE7khnr4hrY0HSip1dtyJIMV1eCSU1tOsV7kbb3IF7HR6J0Sv0sJSyCf56TJdmdi8iWt 6EidYKiuIzVuEEUxBwtDPkBCRYjwSTgXaXGr2hIPio9sQuHtJ4jocBQNIDHuQ7/vQYdl TkwGrI5bqBKJsaOODP6IGf3vt137MOdGIyMBEkeusQ5mg/1Kak2+3tjjCYIJNySm6v3f x2Xg== 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:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=4XSaaZbLbrz0+bHUIi/UwhhZVtiB+zD2mJ17OYajM3A=; b=pMOyRpJBxZ3b2XM3Dv5zJt2Z3S9GIxh7OJv/1WVVMI2sHWlqIWUSrGPmHRa9CHkmS2 qr/+I9Sfpim6mUOhSZ9nACkUOBLIhTGSmb0AtU+feIDBMSKKCG0rHwZqdKE7+NyvXOoJ fvferZVskWcjrn3KYxG5vOjuTgiixI6gShmiTOFWJQQEGSN1t21lWhNbI0JmiJIPlIjD CsgnsK6J1Ppc8Il09SeYFZ83CG+QKGDWbmIczvDqJdZuAiaw3TMvoWg0bNedGdVEbncr dSlrlZlqBHKRmEQzX7abPkEbWpi4Kwg2uoROf272AhaJ3Ng8vHFgNDA64xwdr7O4EJam nckg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=opaXJ7i9; 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id z23-20020a50cd17000000b004844ab28115si11044833edi.547.2023.01.10.05.37.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 05:37:35 -0800 (PST) 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=opaXJ7i9; 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 EDB00385841E for ; Tue, 10 Jan 2023 13:37:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EDB00385841E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673357854; bh=4XSaaZbLbrz0+bHUIi/UwhhZVtiB+zD2mJ17OYajM3A=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=opaXJ7i9obPDnjMTWlMpoLjtV9lnz63WZmB0WwaGIfKViG4zVNoETPgIdmnrrueOj 0B8gCvdyea3EiVOnU1Tt4gR2xsPJUKLwr1fwM8FZTgr/MF8PWHuE2fsbAinz5m8fYm BfRhEEGfi5pQFrkSdJj4+WfEs9bDW/fpWmaLxPnc= 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 93E273858005 for ; Tue, 10 Jan 2023 13:37:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 93E273858005 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30ACcVLf007433 for ; Tue, 10 Jan 2023 13:37:25 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 3n15rk53y4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 10 Jan 2023 13:37:24 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30A89VJh024687 for ; Tue, 10 Jan 2023 13:37:23 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma03ams.nl.ibm.com (PPS) with ESMTPS id 3my0c6mwk8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 10 Jan 2023 13:37:22 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30ADbJ4453150086 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Jan 2023 13:37:19 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 41EC920040; Tue, 10 Jan 2023 13:37:19 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2B82C20049; Tue, 10 Jan 2023 13:37:19 +0000 (GMT) Received: from t8345026.lnxne.boe (unknown [9.152.108.100]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTPS; Tue, 10 Jan 2023 13:37:19 +0000 (GMT) To: krebbel@linux.ibm.com, binutils@sourceware.org Cc: Stefan Schulze Frielinghaus Subject: [PATCH] IBM zSystems: Fix offset relative to static TLS Date: Tue, 10 Jan 2023 14:35:35 +0100 Message-Id: <20230110133534.5295-1-stefansf@linux.ibm.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: dYbMp66jB60eXtRGptoE7bcoRxK51rDJ X-Proofpoint-GUID: dYbMp66jB60eXtRGptoE7bcoRxK51rDJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-10_04,2023-01-10_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 impostorscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301100084 X-Spam-Status: No, score=-8.4 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: Stefan Schulze Frielinghaus via Binutils From: Stefan Schulze Frielinghaus Reply-To: Stefan Schulze Frielinghaus 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?1754642886419811083?= X-GMAIL-MSGID: =?utf-8?q?1754642886419811083?= For local exec TLS relocations of the form foo@NTPOFF+x the addend was ignored. Build and tested on s390x. Ok for mainline and branches 2.{39,40}? bfd/ChangeLog: * elf32-s390.c (elf_s390_relocate_section): Honor addend for R_390_TLS_LE32. * elf64-s390.c (elf_s390_relocate_section): Honor addend for R_390_TLS_LE64. ld/ChangeLog: * testsuite/ld-s390/reloctlsle-1.d: New test. * testsuite/ld-s390/reloctlsle-1.s: New test. --- bfd/elf32-s390.c | 4 ++-- bfd/elf64-s390.c | 4 ++-- ld/testsuite/ld-s390/reloctlsle-1.d | 6 ++++++ ld/testsuite/ld-s390/reloctlsle-1.s | 14 ++++++++++++++ 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 ld/testsuite/ld-s390/reloctlsle-1.d create mode 100644 ld/testsuite/ld-s390/reloctlsle-1.s diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index 061307d6c3b..9496b1472d6 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -2706,7 +2706,7 @@ elf_s390_relocate_section (bfd *output_bfd, /* This relocation gets optimized away by the local exec access optimization. */ BFD_ASSERT (! unresolved_reloc); - bfd_put_32 (output_bfd, -tpoff (info, relocation), + bfd_put_32 (output_bfd, -tpoff (info, relocation) + rel->r_addend, contents + rel->r_offset); continue; } @@ -2901,7 +2901,7 @@ elf_s390_relocate_section (bfd *output_bfd, else { BFD_ASSERT (! unresolved_reloc); - bfd_put_32 (output_bfd, -tpoff (info, relocation), + bfd_put_32 (output_bfd, -tpoff (info, relocation) + rel->r_addend, contents + rel->r_offset); } continue; diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index 5279660f8f5..bcf59032c41 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -2714,7 +2714,7 @@ elf_s390_relocate_section (bfd *output_bfd, /* This relocation gets optimized away by the local exec access optimization. */ BFD_ASSERT (! unresolved_reloc); - bfd_put_64 (output_bfd, -tpoff (info, relocation), + bfd_put_64 (output_bfd, -tpoff (info, relocation) + rel->r_addend, contents + rel->r_offset); continue; } @@ -2907,7 +2907,7 @@ elf_s390_relocate_section (bfd *output_bfd, else { BFD_ASSERT (! unresolved_reloc); - bfd_put_64 (output_bfd, -tpoff (info, relocation), + bfd_put_64 (output_bfd, -tpoff (info, relocation) + rel->r_addend, contents + rel->r_offset); } continue; diff --git a/ld/testsuite/ld-s390/reloctlsle-1.d b/ld/testsuite/ld-s390/reloctlsle-1.d new file mode 100644 index 00000000000..a24c3d60c25 --- /dev/null +++ b/ld/testsuite/ld-s390/reloctlsle-1.d @@ -0,0 +1,6 @@ +#as: -m64 -mzarch -march=z900 +#ld: -m elf64_s390 -static +#readelf: -x .data + +Hex dump of section '.data': + 0x[0-9a-f]+ ffffffff fffffff0 ffffffff fffffff8 ................ diff --git a/ld/testsuite/ld-s390/reloctlsle-1.s b/ld/testsuite/ld-s390/reloctlsle-1.s new file mode 100644 index 00000000000..c8f351dd6e6 --- /dev/null +++ b/ld/testsuite/ld-s390/reloctlsle-1.s @@ -0,0 +1,14 @@ + .text + .globl _start +_start: + larl %r0,bar + + .section .tbss,"awT",@nobits + .align 8 +foo: .zero 8 + .zero 8 + + .data + .align 8 + .quad foo@NTPOFF +bar: .quad foo@NTPOFF+8