Another PE SEC_HAS_CONTENTS test
authorAlan Modra <amodra@gmail.com>
Mon, 27 Feb 2023 04:19:10 +0000 (14:49 +1030)
committerAlan Modra <amodra@gmail.com>
Tue, 28 Feb 2023 00:07:12 +0000 (10:37 +1030)
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.

bfd/peXXigen.c

index 43f3a83743c64b52f16b14d958233004b63c2d68..d59a97f0d1110fa3af686f61add4ef6de0f86e79 100644 (file)
@@ -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 =