From 51dee44b37c4254e6b6a016b062c23b8e1f9ca33 Mon Sep 17 00:00:00 2001 From: Jeremy Drake Date: Wed, 30 Sep 2020 10:50:46 +0100 Subject: [PATCH] After preventing creating an import library for an exe when there are no exports, to avoid a crash, it turned out that some projects expected to be able to create an import library for a dll with no exports, so more closely match the condition to the condition around initializing the dll name. PR 26588 * emultempl/pe.em (_finish): Generate an import library for DLLs, even if they have no exports. * emultempl/pep.em (_finish): Likewise. --- ld/ChangeLog | 7 +++++++ ld/emultempl/pe.em | 3 ++- ld/emultempl/pep.em | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 5cf876a0665..369252761cc 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,10 @@ +2020-09-30 Jeremy Drake + + PR 26588 + * emultempl/pe.em (_finish): Generate an import library for DLLs, + even if they have no exports. + * emultempl/pep.em (_finish): Likewise. + 2020-09-28 Alan Modra * testsuite/ld-powerpc/tlsget.d, diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index 22993c53753..00db3d0e852 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -1997,7 +1997,8 @@ gld_${EMULATION_NAME}_finish (void) { pe_dll_fill_sections (link_info.output_bfd, &link_info); if (command_line.out_implib_filename - && pe_def_file->num_exports != 0) + && (pe_def_file->num_exports != 0 + || bfd_link_pic (&link_info))) pe_dll_generate_implib (pe_def_file, command_line.out_implib_filename, &link_info); } diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em index b0a047143a0..2f4bdfb9fa2 100644 --- a/ld/emultempl/pep.em +++ b/ld/emultempl/pep.em @@ -1824,7 +1824,8 @@ gld_${EMULATION_NAME}_finish (void) { pep_dll_fill_sections (link_info.output_bfd, &link_info); if (command_line.out_implib_filename - && pep_def_file->num_exports != 0) + && (pep_def_file->num_exports != 0 + || bfd_link_pic (&link_info))) pep_dll_generate_implib (pep_def_file, command_line.out_implib_filename, &link_info); } -- 2.30.2