This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix segfault when .plt section does not exist


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]