From 98a96df7f5938a32fadf599ce5430be00c8d7282 Mon Sep 17 00:00:00 2001
From: Christopher Faylor <me+cygwin@cgf.cx>
Date: Fri, 17 Oct 2003 03:30:27 +0000
Subject: [PATCH] * peXXigen.c (_bfd_XXi_swap_aouthdr_out): Don't calculate
 image size for sections which lack size info.

---
 bfd/ChangeLog  | 5 +++++
 bfd/peXXigen.c | 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index be335464668..751d2a7529e 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2003-10-16  Pavel Roskin  <proski@gnu.org>
+
+	* peXXigen.c (_bfd_XXi_swap_aouthdr_out): Don't calculate image size
+	for sections which lack size info.
+
 2003-10-17  Danny Smith  <dannysmith@users.sourceforge.net>
 
 	* configure.host: Add __USE_MINGW_FSEEK to HDEFINES for
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index ea98befa1ad..cd0a91c5aac 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -674,7 +674,9 @@ _bfd_XXi_swap_aouthdr_out (abfd, in, out)
 	   5.0 link.exe) where the file size of the .data segment is
 	   quite small compared to the virtual size.  Without this
 	   fix, strip munges the file.  */
-	isize += SA (FA (pei_section_data (abfd, sec)->virt_size));
+	if (coff_section_data (abfd, sec) != NULL
+	    && pei_section_data (abfd, sec) != NULL)
+	  isize += SA (FA (pei_section_data (abfd, sec)->virt_size));
       }
 
     aouthdr_in->dsize = dsize;