This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] Fix segfault when .plt section does not exist
- From: Palmer Dabbelt <palmer at dabbelt dot com>
- To: binutils at sourceware dot org
- Cc: Andrew Waterman <andrew at sifive dot com>
- Cc: Palmer Dabbelt <palmer at dabbelt dot com>
- Date: Tue, 24 Jan 2017 12:34:35 -0800
- Subject: [PATCH] Fix segfault when .plt section does not exist
- Authentication-results: sourceware.org; auth=none
- References: <20170124203435.20490-1-palmer@dabbelt.com>
From: Andrew Waterman <andrew@sifive.com>
bfd/ChangeLog
2017-01-09 Andrew Waterman <andrew@sifive.com>
* elfnn-riscv.c (riscv_elf_finish_dynamic_sections): Check that
PLT section data exists before modifying it.
Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com>
---
bfd/ChangeLog | 5 +++++
bfd/elfnn-riscv.c | 5 +++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index c26ab49..c76ac91 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2017-01-24 Andrew Waterman <andrew@sifive.com>
+
+ * elfnn-riscv.c (riscv_elf_finish_dynamic_sections): Check that
+ PLT section data exists before modifying it.
+
2017-01-24 Maciej W. Rozycki <macro@imgtec.com>
PR ld/20828
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 320d318..a82b564 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -2504,8 +2504,9 @@ riscv_elf_finish_dynamic_sections (bfd *output_bfd,
bfd_put_32 (output_bfd, plt_header[i], splt->contents + 4*i);
}
- elf_section_data (splt->output_section)->this_hdr.sh_entsize
- = PLT_ENTRY_SIZE;
+ if (elf_section_data (splt->output_section) != NULL)
+ elf_section_data (splt->output_section)->this_hdr.sh_entsize
+ = PLT_ENTRY_SIZE;
}
if (htab->elf.sgotplt)
--
2.10.2