aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Drake <sourceware-bugzilla@jdrake.com>2020-09-11 17:51:16 +0100
committerNick Clifton <nickc@redhat.com>2020-09-11 17:51:16 +0100
commit9cdc5bacddc3776a455cc918e034b01dfb31c75b (patch)
treeaeef3c49bbbd8d634aa5066575016f04717ff084
parentad570dd76c3578bc5aaae0c2029ff43fd40ef9cd (diff)
downloadgdb-9cdc5bacddc3776a455cc918e034b01dfb31c75b.zip
gdb-9cdc5bacddc3776a455cc918e034b01dfb31c75b.tar.gz
gdb-9cdc5bacddc3776a455cc918e034b01dfb31c75b.tar.bz2
Fix a segfault when creating an import library with 0 exports.
PR 26588 * emultempl/pe.em (_finish): Only generate a import library if not exporting relocs. * emultempl/pep.em: Likewise.
-rw-r--r--ld/ChangeLog7
-rw-r--r--ld/emultempl/pe.em3
-rw-r--r--ld/emultempl/pep.em3
3 files changed, 11 insertions, 2 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 3b9a426..d81ebcc 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -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
diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em
index 9d2097f..055d08d 100644
--- a/ld/emultempl/pe.em
+++ b/ld/emultempl/pe.em
@@ -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);
}
diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em
index 7d93951..f161cce 100644
--- a/ld/emultempl/pep.em
+++ b/ld/emultempl/pep.em
@@ -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);
}