#  Set of temporary fixes for binutils required to make the DJGPP
#  port work.  This patch will be removed as soon as the binutils
#  maintainers have fixed the issue.


	* bfd/coffgen.c (fini_reloc_cookie_rels):  This is an ad-hoc fix for a
	NULL pointer access that causes a SIGSEGV abort.  It has been reported
	in:
	  http://www.delorie.com/archives/browse.cgi?p=djgpp/2016/07/21/14:15:13
	and reported at the bug-binutils mailing list in:
	  http://lists.gnu.org/archive/html/bug-binutils/2016-07/msg00082.html
	  https://sourceware.org/bugzilla/show_bug.cgi?id=20401
	If this is really the right way to fix this issue and if the used linker
	option that has triggered the SIGSEGV is valid for COFF at all can only
	be answered by the binutils maintainers.
	Use the -Wl,--gc-sections linker option at your own risk!!!







diff -aprNU5 binutils-2.26.1.orig/bfd/coffgen.c binutils-2.26.1/bfd/coffgen.c
--- binutils-2.26.1.orig/bfd/coffgen.c	2015-11-13 09:27:40 +0100
+++ binutils-2.26.1/bfd/coffgen.c	2016-07-23 14:39:38 +0200
@@ -2686,11 +2686,11 @@ init_reloc_cookie_rels (struct coff_relo
 
 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 && (!coff_section_data (NULL, sec) || coff_section_data (NULL, sec)->relocs != cookie->rels))
     free (cookie->rels);
 }
 
 /* Initialize the whole of COOKIE for input section SEC.  */
 
