From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7806) id 477503858D33; Tue, 10 Jan 2023 13:48:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 477503858D33 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Stefan Schulze Frielinghaus To: bfd-cvs@sourceware.org Subject: [binutils-gdb] IBM zSystems: Fix offset relative to static TLS X-Act-Checkin: binutils-gdb X-Git-Author: Stefan Schulze Frielinghaus X-Git-Refname: refs/heads/master X-Git-Oldrev: 18737d14799d609054994987dd75631430637a99 X-Git-Newrev: aefebe82dc89711384b85329daa48d04c1d3a45b Message-Id: <20230110134822.477503858D33@sourceware.org> Date: Tue, 10 Jan 2023 13:48:22 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jan 2023 13:48:22 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Daefebe82dc89= 711384b85329daa48d04c1d3a45b commit aefebe82dc89711384b85329daa48d04c1d3a45b Author: Stefan Schulze Frielinghaus Date: Tue Jan 10 14:34:16 2023 +0100 IBM zSystems: Fix offset relative to static TLS =20 For local exec TLS relocations of the form foo@NTPOFF+x the addend was ignored. =20 bfd/ChangeLog: =20 * 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. =20 ld/ChangeLog: =20 * testsuite/ld-s390/reloctlsle-1.d: New test. * testsuite/ld-s390/reloctlsle-1.s: New test. Diff: --- 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(-) 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/rel= octlsle-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=3Dz900 +#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/rel= octlsle-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