[binutils-gdb] Another PE SEC_HAS_CONTENTS test

Alan Modra amodra@sourceware.org
Tue Feb 28 00:07:29 GMT 2023


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

commit 3f316bf83bc59299e96e1395793e6493d3ab9581
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Feb 27 14:49:10 2023 +1030

    Another PE SEC_HAS_CONTENTS test
    
    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:
---
 bfd/peXXigen.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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 =


More information about the Binutils-cvs mailing list