aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Krebbel <krebbel@linux.vnet.ibm.com>2017-07-28 18:35:36 +0200
committerAndreas Krebbel <krebbel@linux.vnet.ibm.com>2017-07-28 18:35:36 +0200
commit04a3789c7b49d4566d180e55e203859b4555890e (patch)
tree4576ff5e2045d7f4059a8e20bbc6e1bc4eb6bbcd
parent7d9f1d21e004afa2f1350f880ef4b94f92f4b671 (diff)
downloadgdb-04a3789c7b49d4566d180e55e203859b4555890e.zip
gdb-04a3789c7b49d4566d180e55e203859b4555890e.tar.gz
gdb-04a3789c7b49d4566d180e55e203859b4555890e.tar.bz2
S/390: Fix segfault when linking -shared -nostartfiles
Regression-tested on s390x. bfd/ChangeLog: 2017-07-28 Andreas Krebbel <krebbel@linux.vnet.ibm.com> Backport from mainline 2017-07-28 Andreas Krebbel <krebbel@linux.vnet.ibm.com> * elf32-s390.c (elf_s390_finish_dynamic_sections): Add NULL pointer check for htab->elf.irelplt. * elf64-s390.c (elf_s390_finish_dynamic_sections): Likewise.
-rw-r--r--bfd/ChangeLog9
-rw-r--r--bfd/elf32-s390.c4
-rw-r--r--bfd/elf64-s390.c8
3 files changed, 18 insertions, 3 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index a81b982..496a5ca 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,12 @@
+2017-07-28 Andreas Krebbel <krebbel@linux.vnet.ibm.com>
+
+ Backport from mainline
+ 2017-07-28 Andreas Krebbel <krebbel@linux.vnet.ibm.com>
+
+ * elf32-s390.c (elf_s390_finish_dynamic_sections): Add NULL
+ pointer check for htab->elf.irelplt.
+ * elf64-s390.c (elf_s390_finish_dynamic_sections): Likewise.
+
2017-07-25 Tristan Gingold <gingold@adacore.com>
* version.m4: Bump version to 2.28.2
diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
index ddb6f5b..7f22ae1 100644
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -3930,7 +3930,9 @@ elf_s390_finish_dynamic_sections (bfd *output_bfd,
break;
case DT_PLTRELSZ:
- dyn.d_un.d_val = htab->elf.srelplt->size + htab->elf.irelplt->size;
+ dyn.d_un.d_val = htab->elf.srelplt->size;
+ if (htab->elf.irelplt)
+ dyn.d_un.d_val += htab->elf.irelplt->size;
break;
}
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index fbbf8d6..a59777c 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -3729,7 +3729,9 @@ elf_s390_finish_dynamic_sections (bfd *output_bfd,
break;
case DT_PLTRELSZ:
- dyn.d_un.d_val = htab->elf.srelplt->size + htab->elf.irelplt->size;
+ dyn.d_un.d_val = htab->elf.srelplt->size;
+ if (htab->elf.irelplt)
+ dyn.d_un.d_val += htab->elf.irelplt->size;
break;
case DT_RELASZ:
@@ -3740,7 +3742,9 @@ elf_s390_finish_dynamic_sections (bfd *output_bfd,
linker script arranges for .rela.plt to follow all
other relocation sections, we don't have to worry
about changing the DT_RELA entry. */
- dyn.d_un.d_val -= htab->elf.srelplt->size + htab->elf.irelplt->size;
+ dyn.d_un.d_val -= htab->elf.srelplt->size;
+ if (htab->elf.irelplt)
+ dyn.d_un.d_val -= htab->elf.irelplt->size;
break;
}