Fix a segfault when creating an import library with 0 exports.
authorJeremy Drake <sourceware-bugzilla@jdrake.com>
Fri, 11 Sep 2020 16:51:16 +0000 (17:51 +0100)
committerNick Clifton <nickc@redhat.com>
Fri, 11 Sep 2020 16:51:16 +0000 (17:51 +0100)
PR 26588
* emultempl/pe.em (_finish): Only generate a import library if not
exporting relocs.
* emultempl/pep.em: Likewise.

ld/ChangeLog
ld/emultempl/pe.em
ld/emultempl/pep.em

index 3b9a42669722b5d469bab3dc639e7c9c1baab05f..d81ebcc6c0101c83dba60704a438818a6b1ac43b 100644 (file)
@@ -1,3 +1,10 @@
+2020-09-11  Jeremy Drake  <sourceware-bugzilla@jdrake.com>
+
+       PR 26588
+       * emultempl/pe.em (_finish): Only generate a import library if not
+       exporting relocs.
+       * emultempl/pep.em: Likewise.
+
 2020-09-10  Siddhesh Poyarekar  <siddesh.poyarekar@arm.com>
 
        * testsuite/ld-aarch64/emit-relocs-560.d: Expect error instead
index 9d2097f486ab75aedee41c324c54c973db3ff259..055d08d1849c5e8095aef2059ec115043636aeac 100644 (file)
@@ -1996,7 +1996,8 @@ gld_${EMULATION_NAME}_finish (void)
     )
     {
       pe_dll_fill_sections (link_info.output_bfd, &link_info);
-      if (command_line.out_implib_filename)
+      if (command_line.out_implib_filename
+          && pe_def_file->num_exports != 0)
        pe_dll_generate_implib (pe_def_file, command_line.out_implib_filename,
                                &link_info);
     }
index 7d9395168d2a505c61c787c45162d7f93e095ed1..f161cce2b5f16a5162c48544ff709cba94510d40 100644 (file)
@@ -1823,7 +1823,8 @@ gld_${EMULATION_NAME}_finish (void)
          && pep_def_file->num_exports != 0))
     {
       pep_dll_fill_sections (link_info.output_bfd, &link_info);
-      if (command_line.out_implib_filename)
+      if (command_line.out_implib_filename
+          && pep_def_file->num_exports != 0)
        pep_dll_generate_implib (pep_def_file,
                                 command_line.out_implib_filename, &link_info);
     }