This is the mail archive of the binutils-cvs@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]

[binutils-gdb] Fix seg-fault when running garbage collection on coff binaries.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=147d994bcdd36a177e49e7b6ac8d9c1f7b4cdcf5

commit 147d994bcdd36a177e49e7b6ac8d9c1f7b4cdcf5
Author: Nick Clifton <nickc@redhat.com>
Date:   Wed Jul 27 10:49:32 2016 +0100

    Fix seg-fault when running garbage collection on coff binaries.
    
    	PR ld/20401
    	* coffgen.c (fini_reloc_cookie_rels): Check for the extistence
    	of the coff_section_data before using it.

Diff:
---
 bfd/ChangeLog | 7 +++++++
 bfd/coffgen.c | 8 +++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 0779178..ba48136 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2016-07-27  Ozkan Sezer  <sezeroz@gmail.com>
+	    Nick Clifton  <nickc@redhat.com>
+
+	PR ld/20401
+	* coffgen.c (fini_reloc_cookie_rels): Check for the extistence
+	of the coff_section_data before using it.
+
 2016-07-26  Maciej W. Rozycki  <macro@imgtec.com>
 
 	* elfxx-mips.c (mips_elf_calculate_relocation): Handle branches
diff --git a/bfd/coffgen.c b/bfd/coffgen.c
index 56864ca..75512fb 100644
--- a/bfd/coffgen.c
+++ b/bfd/coffgen.c
@@ -2691,7 +2691,13 @@ static void
 fini_reloc_cookie_rels (struct coff_reloc_cookie *cookie,
 			asection *sec)
 {
-  if (cookie->rels && coff_section_data (NULL, sec)->relocs != cookie->rels)
+  if (cookie->rels
+      /* PR 20401.  The relocs may not have been cached, so check first.
+	 If the relocs were loaded by init_reloc_cookie_rels() then this
+	 will be the case.  FIXME: Would performance be improved if the
+	 relocs *were* cached ?  */
+      && coff_section_data (NULL, sec)
+      && coff_section_data (NULL, sec)->relocs != cookie->rels)
     free (cookie->rels);
 }


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