aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2021-11-18 07:54:34 -0800
committerH.J. Lu <hjl.tools@gmail.com>2021-11-18 07:58:52 -0800
commit7c80aab93666727965c2d5d6e17b1338d88293e0 (patch)
treeafa7fa215c740c62255a2b2580804d466d8055b7 /bfd
parenta0cfd0ca0ea26f157957c42b359b750c6f53d4bf (diff)
downloadgdb-7c80aab93666727965c2d5d6e17b1338d88293e0.zip
gdb-7c80aab93666727965c2d5d6e17b1338d88293e0.tar.gz
gdb-7c80aab93666727965c2d5d6e17b1338d88293e0.tar.bz2
elf/x86: Issue an error on discarded output .plt section
Issue an error, instead of crash, on discarded output .plt section. bfd/ PR ld/28597 * elf32-i386.c (elf_i386_finish_dynamic_sections): Issue an error on discarded output .plt section. * elf64-x86-64.c (elf_x86_64_finish_dynamic_sections): Likewise. ld/ PR ld/28597 * testsuite/ld-elf/pr28597.d: New file. * testsuite/ld-elf/pr28597.s: Likewise. * testsuite/ld-elf/pr28597.t: Likewise.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/elf32-i386.c8
-rw-r--r--bfd/elf64-x86-64.c8
2 files changed, 16 insertions, 0 deletions
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 9a9e48b..0d7f290 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -4017,6 +4017,14 @@ elf_i386_finish_dynamic_sections (bfd *output_bfd,
if (htab->elf.splt && htab->elf.splt->size > 0)
{
+ if (bfd_is_abs_section (htab->elf.splt->output_section))
+ {
+ info->callbacks->einfo
+ (_("%F%P: discarded output section: `%pA'\n"),
+ htab->elf.splt);
+ return false;
+ }
+
/* UnixWare sets the entsize of .plt to 4, although that doesn't
really seem like the right value. */
elf_section_data (htab->elf.splt->output_section)
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index dc416a7..25e2bb1 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -4677,6 +4677,14 @@ elf_x86_64_finish_dynamic_sections (bfd *output_bfd,
if (htab->elf.splt && htab->elf.splt->size > 0)
{
+ if (bfd_is_abs_section (htab->elf.splt->output_section))
+ {
+ info->callbacks->einfo
+ (_("%F%P: discarded output section: `%pA'\n"),
+ htab->elf.splt);
+ return false;
+ }
+
elf_section_data (htab->elf.splt->output_section)
->this_hdr.sh_entsize = htab->plt.plt_entry_size;