aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Schulze Frielinghaus <stefansf@linux.ibm.com>2023-01-10 14:53:20 +0100
committerStefan Schulze Frielinghaus <stefansf@linux.ibm.com>2023-01-10 14:53:20 +0100
commit4e3ee240162d369f841829ad0bc11248e4faac70 (patch)
treecdc68f4d9f69a5ba731cb4c40c189fcb20a9ffaa
parentcab2aac95461f81ec8b22dcd65247531cbd2069c (diff)
downloadfsf-binutils-gdb-4e3ee240162d369f841829ad0bc11248e4faac70.zip
fsf-binutils-gdb-4e3ee240162d369f841829ad0bc11248e4faac70.tar.gz
fsf-binutils-gdb-4e3ee240162d369f841829ad0bc11248e4faac70.tar.bz2
IBM zSystems: Fix offset relative to static TLS
For local exec TLS relocations of the form foo@NTPOFF+x the addend was ignored. 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. (cherry picked from commit aefebe82dc89711384b85329daa48d04c1d3a45b)
-rw-r--r--bfd/elf32-s390.c4
-rw-r--r--bfd/elf64-s390.c4
-rw-r--r--ld/testsuite/ld-s390/reloctlsle-1.d6
-rw-r--r--ld/testsuite/ld-s390/reloctlsle-1.s14
4 files changed, 24 insertions, 4 deletions
diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
index 45b4581..6f9f4cf 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 c1ed3d6..4530197 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 0000000..a24c3d6
--- /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 0000000..c8f351d
--- /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