summaryrefslogtreecommitdiff
path: root/ld/pe-dll.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2016-03-22 12:25:08 +0000
committerNick Clifton <nickc@redhat.com>2016-03-22 12:25:08 +0000
commit4153b6dbb0f38a16fd5b583761aa811212fbb9a5 (patch)
treed658cb18fecbd0a8691b62fed5924d583108b3a9 /ld/pe-dll.c
parenta97fbc7e3ca781b8d95ed8591c6ee65f2d8a798a (diff)
Improve COFF/PE linker garbage collection by preventing the removal of sections containing exported symbols.
PR ld/19803 * ldlang.c (lang_add_gc_name): New function. Adds the provided symbol name to the list of gc symbols. (lang_process): Call lang_add_gc_name with entry_symbol_default if entry_symbol.name is NULL. Use lang_add_gc_name to add the init and fini function names. * pe-dll.c (process_def_file_and_drectve): Add exported names to the gc symbol list. * testsuite/ld-pe/pr19803.s: Do not export _testval symbol. * testsuite/ld-pe/pr19803.d: Tweak expected output.
Diffstat (limited to 'ld/pe-dll.c')
-rw-r--r--ld/pe-dll.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/ld/pe-dll.c b/ld/pe-dll.c
index a2792e8f94..a2806473da 100644
--- a/ld/pe-dll.c
+++ b/ld/pe-dll.c
@@ -897,6 +897,9 @@ process_def_file_and_drectve (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *
char *int_name = pe_def_file->exports[i].internal_name;
char *name;
+ /* PR 19803: Make sure that any exported symbol does not get garbage collected. */
+ lang_add_gc_name (int_name);
+
name = xmalloc (strlen (int_name) + 2);
if (pe_details->underscored && int_name[0] != '@')
{