public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Another PE SEC_HAS_CONTENTS test
@ 2023-02-28  0:04 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2023-02-28  0:04 UTC (permalink / raw)
  To: binutils

I'd skipped this one before, thinking "obfd, that's the linker output
bfd so no need to test".  Wrong, this is objcopy output.

	* peXXigen.c (_bfd_XX_bfd_copy_private_bfd_data_common): Test
	SEC_HAS_CONTENTS before reading section.

diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index 43f3a83743c..d59a97f0d11 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -3041,7 +3041,8 @@ _bfd_XX_bfd_copy_private_bfd_data_common (bfd * ibfd, bfd * obfd)
 	      return false;
 	    }
 
-	  if (bfd_malloc_and_get_section (obfd, section, &data))
+	  if ((section->flags & SEC_HAS_CONTENTS) != 0
+	      && bfd_malloc_and_get_section (obfd, section, &data))
 	    {
 	      unsigned int i;
 	      struct external_IMAGE_DEBUG_DIRECTORY *dd =

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-28  0:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-28  0:04 Another PE SEC_HAS_CONTENTS test Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).