cross/binutils-*: upgrade to 2.38-r2

This commit is contained in:
Oliver Smith 2022-05-23 08:04:17 +02:00
parent 1f4d5ba114
commit 6375f8b134
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
9 changed files with 609 additions and 3 deletions

View file

@ -4,7 +4,7 @@
pkgname=binutils-aarch64
pkgver=2.38
pkgrel=1
pkgrel=2
pkgdesc="Tools necessary to build programs for aarch64 targets"
url="https://www.gnu.org/software/binutils/"
makedepends="gettext libtool autoconf automake bison texinfo"
@ -17,6 +17,8 @@ source="https://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.xz
0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
binutils-mips-disable-assert.patch
binutils-ppc-fix-machine-options.patch
binutils-s390x-1.patch
binutils-s390x-2.patch
"
builddir="$srcdir/binutils-$pkgver"
@ -79,4 +81,6 @@ f55cf2e0bf82f97583a1abe10710e4013ecf7d64f1da2ef8659a44a06d0dd8beaf58dab98a183488
70ec22bd72ef6dddecfd970613387dd4a8cdc8730dd3cbf03d5a0c3a7c4d839383167bb06dad21bf7c235329fd44b5dc4aefe762f68544f17155cf002bf1be4a 0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
609cd90d8b334eb309f586b17b9d335a08d3dbb6def7c3eb5c010028fcb681674031e5b9d853aa7a39a50304356a86afc184b85562b3f228f8197f4d29395c8f binutils-mips-disable-assert.patch
27ea91e0e406e2ed464fd692cf92a07e338781789f2d968c8b95d9d5545985056a6f7f500df3952e5ab42165db28b741aa33d6b717e880b11a2e41fe406b13c4 binutils-ppc-fix-machine-options.patch
a9efe2689624865f0ff33d4776a5bd295bcad6484bdd38d0ca490fea43691c4933ab33d17478851998eef12922dbf83d6c3225bb1f8faf92a1367d086390f7d3 binutils-s390x-1.patch
0e291df80ad279005265634014d0935d2c115a5ed708d25407094b7ad4ddf267d1fb7fcbcb2d9ad73bd305b4e3974628b820bd1f249f56c095e4896872434cc9 binutils-s390x-2.patch
"

View file

@ -0,0 +1,147 @@
From 82a5bb730a16f8c7962568030268e784b4fb42c8 Mon Sep 17 00:00:00 2001
From: Stefan Liebler <stli@linux.ibm.com>
Date: Thu, 28 Apr 2022 14:29:58 +0200
Subject: [PATCH] s390: Avoid dynamic TLS relocs in PIE
No dynamic relocs are needed for TLS defined in an executable, the
TP relative offset is known at link time.
Fixes
FAIL: Build pr22263-1
bfd/
PR ld/22263
* elf64-s390.c (elf_s390_tls_transition): Use bfd_link_dll
instead of bfd_link_pic for TLS.
(elf_s390_check_relocs): Likewise.
(allocate_dynrelocs): Likewise.
(elf_s390_relocate_section): Likewise.
(cherry picked from commit 26b1426577b5dcb32d149c64cca3e603b81948a9)
---
bfd/elf64-s390.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index e780efa7181..00ee386baab 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -774,7 +774,7 @@ elf_s390_tls_transition (struct bfd_link_info *info,
int r_type,
int is_local)
{
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
return r_type;
switch (r_type)
@@ -1026,7 +1026,7 @@ elf_s390_check_relocs (bfd *abfd,
case R_390_TLS_GOTIE20:
case R_390_TLS_GOTIE64:
case R_390_TLS_IEENT:
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
info->flags |= DF_STATIC_TLS;
/* Fall through */
@@ -1107,7 +1107,7 @@ elf_s390_check_relocs (bfd *abfd,
if (r_type == R_390_TLS_LE64 && bfd_link_pie (info))
break;
- if (!bfd_link_pic (info))
+ if (!bfd_link_dll (info))
break;
info->flags |= DF_STATIC_TLS;
/* Fall through */
@@ -1571,7 +1571,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h,
to R_390_TLS_LE64 requiring no TLS entry. For GOTIE12 and IEENT
we can save the dynamic TLS relocation. */
if (h->got.refcount > 0
- && !bfd_link_pic (info)
+ && !bfd_link_dll (info)
&& h->dynindx == -1
&& elf_s390_hash_entry(h)->tls_type >= GOT_TLS_IE)
{
@@ -2662,7 +2662,7 @@ elf_s390_relocate_section (bfd *output_bfd,
/* Relocations for tls literal pool entries. */
case R_390_TLS_IE64:
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
{
Elf_Internal_Rela outrel;
asection *sreloc;
@@ -2690,7 +2690,7 @@ elf_s390_relocate_section (bfd *output_bfd,
else if (h != NULL)
{
tls_type = elf_s390_hash_entry(h)->tls_type;
- if (!bfd_link_pic (info) && h->dynindx == -1 && tls_type >= GOT_TLS_IE)
+ if (!bfd_link_dll (info) && h->dynindx == -1 && tls_type >= GOT_TLS_IE)
r_type = R_390_TLS_LE64;
}
if (r_type == R_390_TLS_GD64 && tls_type >= GOT_TLS_IE)
@@ -2801,14 +2801,14 @@ elf_s390_relocate_section (bfd *output_bfd,
if (local_got_offsets == NULL)
abort();
off = local_got_offsets[r_symndx];
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
goto emit_tls_relocs;
}
else
{
off = h->got.offset;
tls_type = elf_s390_hash_entry(h)->tls_type;
- if (bfd_link_pic (info) || h->dynindx != -1 || tls_type < GOT_TLS_IE)
+ if (bfd_link_dll (info) || h->dynindx != -1 || tls_type < GOT_TLS_IE)
goto emit_tls_relocs;
}
@@ -2825,7 +2825,7 @@ elf_s390_relocate_section (bfd *output_bfd,
break;
case R_390_TLS_LDM64:
- if (! bfd_link_pic (info))
+ if (! bfd_link_dll (info))
/* The literal pool entry this relocation refers to gets ignored
by the optimized code of the local exec model. Do nothing
and the value will turn out zero. */
@@ -2900,7 +2900,7 @@ elf_s390_relocate_section (bfd *output_bfd,
continue;
case R_390_TLS_LDO64:
- if (bfd_link_pic (info) || (input_section->flags & SEC_DEBUGGING))
+ if (bfd_link_dll (info) || (input_section->flags & SEC_DEBUGGING))
relocation -= dtpoff_base (info);
else
/* When converting LDO to LE, we must negate. */
@@ -2922,7 +2922,7 @@ elf_s390_relocate_section (bfd *output_bfd,
if (r_type == R_390_TLS_LOAD)
{
- if (!bfd_link_pic (info) && (h == NULL || h->dynindx == -1))
+ if (!bfd_link_dll (info) && (h == NULL || h->dynindx == -1))
{
/* IE->LE transition. Four valid cases:
lg %rx,(0,%ry) -> sllg %rx,%ry,0
@@ -2972,7 +2972,7 @@ elf_s390_relocate_section (bfd *output_bfd,
invalid_tls_insn (input_bfd, input_section, rel);
return false;
}
- if (!bfd_link_pic (info) && (h == NULL || h->dynindx == -1))
+ if (!bfd_link_dll (info) && (h == NULL || h->dynindx == -1))
{
/* GD->LE transition.
brasl %r14,__tls_get_addr@plt -> brcl 0,. */
@@ -2991,7 +2991,7 @@ elf_s390_relocate_section (bfd *output_bfd,
}
else if (r_type == R_390_TLS_LDCALL)
{
- if (!bfd_link_pic (info))
+ if (!bfd_link_dll (info))
{
unsigned int insn0, insn1;
--
2.27.0

View file

@ -0,0 +1,51 @@
From 9a01457e02e7bb594ff9a9ac62a38c909e2e3083 Mon Sep 17 00:00:00 2001
From: Stefan Liebler <stli@linux.ibm.com>
Date: Thu, 28 Apr 2022 14:30:55 +0200
Subject: [PATCH] s390: Add DT_JMPREL pointing to .rela.[i]plt with static-pie
In static-pie case, there are IRELATIVE-relocs in
.rela.iplt (htab->irelplt), which will later be grouped
to .rela.plt. On s390, the IRELATIVE relocations are
always located in .rela.iplt - even for non-static case.
Ensure that DT_JMPREL, DT_PLTRELA, DT_PLTRELASZ is added
to the dynamic section even if htab->srelplt->size == 0.
See _bfd_elf_add_dynamic_tags in bfd/elflink.c.
bfd/
elf64-s390.c (elf_s390_size_dynamic_sections):
Enforce DT_JMPREL via htab->elf.dt_jmprel_required.
(cherry picked from commit d942d8db12adf4c9e5c7d9ed6496a779ece7149e)
---
bfd/elf64-s390.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index 00ee386baab..0b851f7ac0e 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -1876,7 +1876,20 @@ elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
else if (startswith (bfd_section_name (s), ".rela"))
{
if (s->size != 0 && s != htab->elf.srelplt)
- relocs = true;
+ {
+ relocs = true;
+ if (s == htab->elf.irelplt)
+ {
+ /* In static-pie case, there are IRELATIVE-relocs in
+ .rela.iplt (htab->irelplt), which will later be grouped
+ to .rela.plt. On s390, the IRELATIVE relocations are
+ always located in .rela.iplt - even for non-static case.
+ Ensure that DT_JMPREL, DT_PLTRELA, DT_PLTRELASZ is added
+ to the dynamic section even if htab->srelplt->size == 0.
+ See _bfd_elf_add_dynamic_tags in bfd/elflink.c. */
+ htab->elf.dt_jmprel_required = true;
+ }
+ }
/* We use the reloc_count field as a counter if we need
to copy relocs into the output file. */
--
2.27.0

View file

@ -4,7 +4,7 @@
pkgname=binutils-armhf
pkgver=2.38
pkgrel=1
pkgrel=2
pkgdesc="Tools necessary to build programs for armhf targets"
url="https://www.gnu.org/software/binutils/"
makedepends="gettext libtool autoconf automake bison texinfo"
@ -17,6 +17,8 @@ source="https://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.xz
0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
binutils-mips-disable-assert.patch
binutils-ppc-fix-machine-options.patch
binutils-s390x-1.patch
binutils-s390x-2.patch
"
builddir="$srcdir/binutils-$pkgver"
@ -79,4 +81,6 @@ f55cf2e0bf82f97583a1abe10710e4013ecf7d64f1da2ef8659a44a06d0dd8beaf58dab98a183488
70ec22bd72ef6dddecfd970613387dd4a8cdc8730dd3cbf03d5a0c3a7c4d839383167bb06dad21bf7c235329fd44b5dc4aefe762f68544f17155cf002bf1be4a 0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
609cd90d8b334eb309f586b17b9d335a08d3dbb6def7c3eb5c010028fcb681674031e5b9d853aa7a39a50304356a86afc184b85562b3f228f8197f4d29395c8f binutils-mips-disable-assert.patch
27ea91e0e406e2ed464fd692cf92a07e338781789f2d968c8b95d9d5545985056a6f7f500df3952e5ab42165db28b741aa33d6b717e880b11a2e41fe406b13c4 binutils-ppc-fix-machine-options.patch
a9efe2689624865f0ff33d4776a5bd295bcad6484bdd38d0ca490fea43691c4933ab33d17478851998eef12922dbf83d6c3225bb1f8faf92a1367d086390f7d3 binutils-s390x-1.patch
0e291df80ad279005265634014d0935d2c115a5ed708d25407094b7ad4ddf267d1fb7fcbcb2d9ad73bd305b4e3974628b820bd1f249f56c095e4896872434cc9 binutils-s390x-2.patch
"

View file

@ -0,0 +1,147 @@
From 82a5bb730a16f8c7962568030268e784b4fb42c8 Mon Sep 17 00:00:00 2001
From: Stefan Liebler <stli@linux.ibm.com>
Date: Thu, 28 Apr 2022 14:29:58 +0200
Subject: [PATCH] s390: Avoid dynamic TLS relocs in PIE
No dynamic relocs are needed for TLS defined in an executable, the
TP relative offset is known at link time.
Fixes
FAIL: Build pr22263-1
bfd/
PR ld/22263
* elf64-s390.c (elf_s390_tls_transition): Use bfd_link_dll
instead of bfd_link_pic for TLS.
(elf_s390_check_relocs): Likewise.
(allocate_dynrelocs): Likewise.
(elf_s390_relocate_section): Likewise.
(cherry picked from commit 26b1426577b5dcb32d149c64cca3e603b81948a9)
---
bfd/elf64-s390.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index e780efa7181..00ee386baab 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -774,7 +774,7 @@ elf_s390_tls_transition (struct bfd_link_info *info,
int r_type,
int is_local)
{
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
return r_type;
switch (r_type)
@@ -1026,7 +1026,7 @@ elf_s390_check_relocs (bfd *abfd,
case R_390_TLS_GOTIE20:
case R_390_TLS_GOTIE64:
case R_390_TLS_IEENT:
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
info->flags |= DF_STATIC_TLS;
/* Fall through */
@@ -1107,7 +1107,7 @@ elf_s390_check_relocs (bfd *abfd,
if (r_type == R_390_TLS_LE64 && bfd_link_pie (info))
break;
- if (!bfd_link_pic (info))
+ if (!bfd_link_dll (info))
break;
info->flags |= DF_STATIC_TLS;
/* Fall through */
@@ -1571,7 +1571,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h,
to R_390_TLS_LE64 requiring no TLS entry. For GOTIE12 and IEENT
we can save the dynamic TLS relocation. */
if (h->got.refcount > 0
- && !bfd_link_pic (info)
+ && !bfd_link_dll (info)
&& h->dynindx == -1
&& elf_s390_hash_entry(h)->tls_type >= GOT_TLS_IE)
{
@@ -2662,7 +2662,7 @@ elf_s390_relocate_section (bfd *output_bfd,
/* Relocations for tls literal pool entries. */
case R_390_TLS_IE64:
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
{
Elf_Internal_Rela outrel;
asection *sreloc;
@@ -2690,7 +2690,7 @@ elf_s390_relocate_section (bfd *output_bfd,
else if (h != NULL)
{
tls_type = elf_s390_hash_entry(h)->tls_type;
- if (!bfd_link_pic (info) && h->dynindx == -1 && tls_type >= GOT_TLS_IE)
+ if (!bfd_link_dll (info) && h->dynindx == -1 && tls_type >= GOT_TLS_IE)
r_type = R_390_TLS_LE64;
}
if (r_type == R_390_TLS_GD64 && tls_type >= GOT_TLS_IE)
@@ -2801,14 +2801,14 @@ elf_s390_relocate_section (bfd *output_bfd,
if (local_got_offsets == NULL)
abort();
off = local_got_offsets[r_symndx];
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
goto emit_tls_relocs;
}
else
{
off = h->got.offset;
tls_type = elf_s390_hash_entry(h)->tls_type;
- if (bfd_link_pic (info) || h->dynindx != -1 || tls_type < GOT_TLS_IE)
+ if (bfd_link_dll (info) || h->dynindx != -1 || tls_type < GOT_TLS_IE)
goto emit_tls_relocs;
}
@@ -2825,7 +2825,7 @@ elf_s390_relocate_section (bfd *output_bfd,
break;
case R_390_TLS_LDM64:
- if (! bfd_link_pic (info))
+ if (! bfd_link_dll (info))
/* The literal pool entry this relocation refers to gets ignored
by the optimized code of the local exec model. Do nothing
and the value will turn out zero. */
@@ -2900,7 +2900,7 @@ elf_s390_relocate_section (bfd *output_bfd,
continue;
case R_390_TLS_LDO64:
- if (bfd_link_pic (info) || (input_section->flags & SEC_DEBUGGING))
+ if (bfd_link_dll (info) || (input_section->flags & SEC_DEBUGGING))
relocation -= dtpoff_base (info);
else
/* When converting LDO to LE, we must negate. */
@@ -2922,7 +2922,7 @@ elf_s390_relocate_section (bfd *output_bfd,
if (r_type == R_390_TLS_LOAD)
{
- if (!bfd_link_pic (info) && (h == NULL || h->dynindx == -1))
+ if (!bfd_link_dll (info) && (h == NULL || h->dynindx == -1))
{
/* IE->LE transition. Four valid cases:
lg %rx,(0,%ry) -> sllg %rx,%ry,0
@@ -2972,7 +2972,7 @@ elf_s390_relocate_section (bfd *output_bfd,
invalid_tls_insn (input_bfd, input_section, rel);
return false;
}
- if (!bfd_link_pic (info) && (h == NULL || h->dynindx == -1))
+ if (!bfd_link_dll (info) && (h == NULL || h->dynindx == -1))
{
/* GD->LE transition.
brasl %r14,__tls_get_addr@plt -> brcl 0,. */
@@ -2991,7 +2991,7 @@ elf_s390_relocate_section (bfd *output_bfd,
}
else if (r_type == R_390_TLS_LDCALL)
{
- if (!bfd_link_pic (info))
+ if (!bfd_link_dll (info))
{
unsigned int insn0, insn1;
--
2.27.0

View file

@ -0,0 +1,51 @@
From 9a01457e02e7bb594ff9a9ac62a38c909e2e3083 Mon Sep 17 00:00:00 2001
From: Stefan Liebler <stli@linux.ibm.com>
Date: Thu, 28 Apr 2022 14:30:55 +0200
Subject: [PATCH] s390: Add DT_JMPREL pointing to .rela.[i]plt with static-pie
In static-pie case, there are IRELATIVE-relocs in
.rela.iplt (htab->irelplt), which will later be grouped
to .rela.plt. On s390, the IRELATIVE relocations are
always located in .rela.iplt - even for non-static case.
Ensure that DT_JMPREL, DT_PLTRELA, DT_PLTRELASZ is added
to the dynamic section even if htab->srelplt->size == 0.
See _bfd_elf_add_dynamic_tags in bfd/elflink.c.
bfd/
elf64-s390.c (elf_s390_size_dynamic_sections):
Enforce DT_JMPREL via htab->elf.dt_jmprel_required.
(cherry picked from commit d942d8db12adf4c9e5c7d9ed6496a779ece7149e)
---
bfd/elf64-s390.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index 00ee386baab..0b851f7ac0e 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -1876,7 +1876,20 @@ elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
else if (startswith (bfd_section_name (s), ".rela"))
{
if (s->size != 0 && s != htab->elf.srelplt)
- relocs = true;
+ {
+ relocs = true;
+ if (s == htab->elf.irelplt)
+ {
+ /* In static-pie case, there are IRELATIVE-relocs in
+ .rela.iplt (htab->irelplt), which will later be grouped
+ to .rela.plt. On s390, the IRELATIVE relocations are
+ always located in .rela.iplt - even for non-static case.
+ Ensure that DT_JMPREL, DT_PLTRELA, DT_PLTRELASZ is added
+ to the dynamic section even if htab->srelplt->size == 0.
+ See _bfd_elf_add_dynamic_tags in bfd/elflink.c. */
+ htab->elf.dt_jmprel_required = true;
+ }
+ }
/* We use the reloc_count field as a counter if we need
to copy relocs into the output file. */
--
2.27.0

View file

@ -4,7 +4,7 @@
pkgname=binutils-armv7
pkgver=2.38
pkgrel=1
pkgrel=2
pkgdesc="Tools necessary to build programs for armv7 targets"
url="https://www.gnu.org/software/binutils/"
makedepends="gettext libtool autoconf automake bison texinfo"
@ -17,6 +17,8 @@ source="https://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.xz
0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
binutils-mips-disable-assert.patch
binutils-ppc-fix-machine-options.patch
binutils-s390x-1.patch
binutils-s390x-2.patch
"
builddir="$srcdir/binutils-$pkgver"
@ -79,4 +81,6 @@ f55cf2e0bf82f97583a1abe10710e4013ecf7d64f1da2ef8659a44a06d0dd8beaf58dab98a183488
70ec22bd72ef6dddecfd970613387dd4a8cdc8730dd3cbf03d5a0c3a7c4d839383167bb06dad21bf7c235329fd44b5dc4aefe762f68544f17155cf002bf1be4a 0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
609cd90d8b334eb309f586b17b9d335a08d3dbb6def7c3eb5c010028fcb681674031e5b9d853aa7a39a50304356a86afc184b85562b3f228f8197f4d29395c8f binutils-mips-disable-assert.patch
27ea91e0e406e2ed464fd692cf92a07e338781789f2d968c8b95d9d5545985056a6f7f500df3952e5ab42165db28b741aa33d6b717e880b11a2e41fe406b13c4 binutils-ppc-fix-machine-options.patch
a9efe2689624865f0ff33d4776a5bd295bcad6484bdd38d0ca490fea43691c4933ab33d17478851998eef12922dbf83d6c3225bb1f8faf92a1367d086390f7d3 binutils-s390x-1.patch
0e291df80ad279005265634014d0935d2c115a5ed708d25407094b7ad4ddf267d1fb7fcbcb2d9ad73bd305b4e3974628b820bd1f249f56c095e4896872434cc9 binutils-s390x-2.patch
"

View file

@ -0,0 +1,147 @@
From 82a5bb730a16f8c7962568030268e784b4fb42c8 Mon Sep 17 00:00:00 2001
From: Stefan Liebler <stli@linux.ibm.com>
Date: Thu, 28 Apr 2022 14:29:58 +0200
Subject: [PATCH] s390: Avoid dynamic TLS relocs in PIE
No dynamic relocs are needed for TLS defined in an executable, the
TP relative offset is known at link time.
Fixes
FAIL: Build pr22263-1
bfd/
PR ld/22263
* elf64-s390.c (elf_s390_tls_transition): Use bfd_link_dll
instead of bfd_link_pic for TLS.
(elf_s390_check_relocs): Likewise.
(allocate_dynrelocs): Likewise.
(elf_s390_relocate_section): Likewise.
(cherry picked from commit 26b1426577b5dcb32d149c64cca3e603b81948a9)
---
bfd/elf64-s390.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index e780efa7181..00ee386baab 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -774,7 +774,7 @@ elf_s390_tls_transition (struct bfd_link_info *info,
int r_type,
int is_local)
{
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
return r_type;
switch (r_type)
@@ -1026,7 +1026,7 @@ elf_s390_check_relocs (bfd *abfd,
case R_390_TLS_GOTIE20:
case R_390_TLS_GOTIE64:
case R_390_TLS_IEENT:
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
info->flags |= DF_STATIC_TLS;
/* Fall through */
@@ -1107,7 +1107,7 @@ elf_s390_check_relocs (bfd *abfd,
if (r_type == R_390_TLS_LE64 && bfd_link_pie (info))
break;
- if (!bfd_link_pic (info))
+ if (!bfd_link_dll (info))
break;
info->flags |= DF_STATIC_TLS;
/* Fall through */
@@ -1571,7 +1571,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h,
to R_390_TLS_LE64 requiring no TLS entry. For GOTIE12 and IEENT
we can save the dynamic TLS relocation. */
if (h->got.refcount > 0
- && !bfd_link_pic (info)
+ && !bfd_link_dll (info)
&& h->dynindx == -1
&& elf_s390_hash_entry(h)->tls_type >= GOT_TLS_IE)
{
@@ -2662,7 +2662,7 @@ elf_s390_relocate_section (bfd *output_bfd,
/* Relocations for tls literal pool entries. */
case R_390_TLS_IE64:
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
{
Elf_Internal_Rela outrel;
asection *sreloc;
@@ -2690,7 +2690,7 @@ elf_s390_relocate_section (bfd *output_bfd,
else if (h != NULL)
{
tls_type = elf_s390_hash_entry(h)->tls_type;
- if (!bfd_link_pic (info) && h->dynindx == -1 && tls_type >= GOT_TLS_IE)
+ if (!bfd_link_dll (info) && h->dynindx == -1 && tls_type >= GOT_TLS_IE)
r_type = R_390_TLS_LE64;
}
if (r_type == R_390_TLS_GD64 && tls_type >= GOT_TLS_IE)
@@ -2801,14 +2801,14 @@ elf_s390_relocate_section (bfd *output_bfd,
if (local_got_offsets == NULL)
abort();
off = local_got_offsets[r_symndx];
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
goto emit_tls_relocs;
}
else
{
off = h->got.offset;
tls_type = elf_s390_hash_entry(h)->tls_type;
- if (bfd_link_pic (info) || h->dynindx != -1 || tls_type < GOT_TLS_IE)
+ if (bfd_link_dll (info) || h->dynindx != -1 || tls_type < GOT_TLS_IE)
goto emit_tls_relocs;
}
@@ -2825,7 +2825,7 @@ elf_s390_relocate_section (bfd *output_bfd,
break;
case R_390_TLS_LDM64:
- if (! bfd_link_pic (info))
+ if (! bfd_link_dll (info))
/* The literal pool entry this relocation refers to gets ignored
by the optimized code of the local exec model. Do nothing
and the value will turn out zero. */
@@ -2900,7 +2900,7 @@ elf_s390_relocate_section (bfd *output_bfd,
continue;
case R_390_TLS_LDO64:
- if (bfd_link_pic (info) || (input_section->flags & SEC_DEBUGGING))
+ if (bfd_link_dll (info) || (input_section->flags & SEC_DEBUGGING))
relocation -= dtpoff_base (info);
else
/* When converting LDO to LE, we must negate. */
@@ -2922,7 +2922,7 @@ elf_s390_relocate_section (bfd *output_bfd,
if (r_type == R_390_TLS_LOAD)
{
- if (!bfd_link_pic (info) && (h == NULL || h->dynindx == -1))
+ if (!bfd_link_dll (info) && (h == NULL || h->dynindx == -1))
{
/* IE->LE transition. Four valid cases:
lg %rx,(0,%ry) -> sllg %rx,%ry,0
@@ -2972,7 +2972,7 @@ elf_s390_relocate_section (bfd *output_bfd,
invalid_tls_insn (input_bfd, input_section, rel);
return false;
}
- if (!bfd_link_pic (info) && (h == NULL || h->dynindx == -1))
+ if (!bfd_link_dll (info) && (h == NULL || h->dynindx == -1))
{
/* GD->LE transition.
brasl %r14,__tls_get_addr@plt -> brcl 0,. */
@@ -2991,7 +2991,7 @@ elf_s390_relocate_section (bfd *output_bfd,
}
else if (r_type == R_390_TLS_LDCALL)
{
- if (!bfd_link_pic (info))
+ if (!bfd_link_dll (info))
{
unsigned int insn0, insn1;
--
2.27.0

View file

@ -0,0 +1,51 @@
From 9a01457e02e7bb594ff9a9ac62a38c909e2e3083 Mon Sep 17 00:00:00 2001
From: Stefan Liebler <stli@linux.ibm.com>
Date: Thu, 28 Apr 2022 14:30:55 +0200
Subject: [PATCH] s390: Add DT_JMPREL pointing to .rela.[i]plt with static-pie
In static-pie case, there are IRELATIVE-relocs in
.rela.iplt (htab->irelplt), which will later be grouped
to .rela.plt. On s390, the IRELATIVE relocations are
always located in .rela.iplt - even for non-static case.
Ensure that DT_JMPREL, DT_PLTRELA, DT_PLTRELASZ is added
to the dynamic section even if htab->srelplt->size == 0.
See _bfd_elf_add_dynamic_tags in bfd/elflink.c.
bfd/
elf64-s390.c (elf_s390_size_dynamic_sections):
Enforce DT_JMPREL via htab->elf.dt_jmprel_required.
(cherry picked from commit d942d8db12adf4c9e5c7d9ed6496a779ece7149e)
---
bfd/elf64-s390.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index 00ee386baab..0b851f7ac0e 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -1876,7 +1876,20 @@ elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
else if (startswith (bfd_section_name (s), ".rela"))
{
if (s->size != 0 && s != htab->elf.srelplt)
- relocs = true;
+ {
+ relocs = true;
+ if (s == htab->elf.irelplt)
+ {
+ /* In static-pie case, there are IRELATIVE-relocs in
+ .rela.iplt (htab->irelplt), which will later be grouped
+ to .rela.plt. On s390, the IRELATIVE relocations are
+ always located in .rela.iplt - even for non-static case.
+ Ensure that DT_JMPREL, DT_PLTRELA, DT_PLTRELASZ is added
+ to the dynamic section even if htab->srelplt->size == 0.
+ See _bfd_elf_add_dynamic_tags in bfd/elflink.c. */
+ htab->elf.dt_jmprel_required = true;
+ }
+ }
/* We use the reloc_count field as a counter if we need
to copy relocs into the output file. */
--
2.27.0