From 2927aacaee356e861452258500e0b7ace0449977 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Fri, 16 Oct 2009 15:15:39 +0000 Subject: [PATCH] * emultempl/pe.em (OPTION_EXCLUDE_ALL_SYMBOLS): New macro. (gld${EMULATION_NAME}_add_options): Add new --exclude-all-symbols option to exclude all symbols from automatic export. (gld_${EMULATION_NAME}_list_options): Describe it. (gld${EMULATION_NAME}_handle_option): Handle it. * emultempl/pep.em: Likewise to all the above. * pe-dll.c (pe_dll_exclude_all_symbols): New variable. (process_def_file_and_drectve): Use it. * pe-dll.h (pe_dll_exclude_all_symbols): Declare. * pep-dll.c (pep_dll_exclude_all_symbols): Define pep_ alias. * pep-dll.h (pe_dll_exclude_all_symbols): Declare. * NEWS: Mention the new feature. * ld.texinfo: Document the new command line switch. --- ld/ChangeLog | 16 ++++++++++++++++ ld/NEWS | 3 +++ ld/emultempl/pe.em | 8 +++++++- ld/emultempl/pep.em | 6 ++++++ ld/ld.texinfo | 5 +++++ ld/pe-dll.c | 12 +++++++----- ld/pe-dll.h | 4 ++-- ld/pep-dll.c | 1 + ld/pep-dll.h | 4 ++-- 9 files changed, 49 insertions(+), 10 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 89c60527f98..f755793f551 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,19 @@ +2009-10-16 Dimitry Gorbachev + + * emultempl/pe.em (OPTION_EXCLUDE_ALL_SYMBOLS): New macro. + (gld${EMULATION_NAME}_add_options): Add new --exclude-all-symbols option + to exclude all symbols from automatic export. + (gld_${EMULATION_NAME}_list_options): Describe it. + (gld${EMULATION_NAME}_handle_option): Handle it. + * emultempl/pep.em: Likewise to all the above. + * pe-dll.c (pe_dll_exclude_all_symbols): New variable. + (process_def_file_and_drectve): Use it. + * pe-dll.h (pe_dll_exclude_all_symbols): Declare. + * pep-dll.c (pep_dll_exclude_all_symbols): Define pep_ alias. + * pep-dll.h (pe_dll_exclude_all_symbols): Declare. + * NEWS: Mention the new feature. + * ld.texinfo: Document the new command line switch. + 2009-10-14 Andreas Schwab * ldlex.l (yy_input): Remove second argument and return the value diff --git a/ld/NEWS b/ld/NEWS index 86b74cf497c..76b674972c0 100644 --- a/ld/NEWS +++ b/ld/NEWS @@ -1,5 +1,8 @@ -*- text -*- +* Add --exlcude-all-symbols option to PE based linkers. This prevents all + symbols from automatically being exported. + * Add support for the Renesas RX processor. Changes in 2.20: diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index 788818d657f..d233bd1f9b0 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -196,7 +196,8 @@ fragment <num_exports == 0 - && info->executable) + /* If we are building an executable and there is nothing + to export, we do not build an export table at all. */ + if (info->executable && pe_def_file->num_exports == 0 + && (!pe_dll_export_everything || pe_dll_exclude_all_symbols)) return; /* Now, maybe export everything else the default way. */ - if (pe_dll_export_everything || pe_def_file->num_exports == 0) + if ((pe_dll_export_everything || pe_def_file->num_exports == 0) + && !pe_dll_exclude_all_symbols) { for (b = info->input_bfds; b; b = b->link_next) { diff --git a/ld/pe-dll.h b/ld/pe-dll.h index 932bc81e562..a5ae9fb508e 100644 --- a/ld/pe-dll.h +++ b/ld/pe-dll.h @@ -29,6 +29,7 @@ extern def_file *pe_def_file; extern int pe_dll_export_everything; +extern int pe_dll_exclude_all_symbols; extern int pe_dll_do_default_excludes; extern int pe_dll_kill_ats; extern int pe_dll_stdcall_aliases; @@ -67,7 +68,6 @@ extern void pe_create_import_fixup extern bfd_boolean pe_bfd_is_dll (bfd *); extern void pe_output_file_set_long_section_names - (bfd *abfd); - + (bfd *); #endif /* PE_DLL_H */ diff --git a/ld/pep-dll.c b/ld/pep-dll.c index 8f7cc99513a..3d8882dcb41 100644 --- a/ld/pep-dll.c +++ b/ld/pep-dll.c @@ -29,6 +29,7 @@ #define pe_dll_compat_implib pep_dll_compat_implib #define pe_dll_extra_pe_debug pep_dll_extra_pe_debug #define pe_dll_export_everything pep_dll_export_everything +#define pe_dll_exclude_all_symbols pep_dll_exclude_all_symbols #define pe_dll_do_default_excludes pep_dll_do_default_excludes #define pe_dll_kill_ats pep_dll_kill_ats #define pe_dll_stdcall_aliases pep_dll_stdcall_aliases diff --git a/ld/pep-dll.h b/ld/pep-dll.h index 5840ccede53..7d441ea22a0 100644 --- a/ld/pep-dll.h +++ b/ld/pep-dll.h @@ -29,6 +29,7 @@ extern def_file * pep_def_file; extern int pep_dll_export_everything; +extern int pep_dll_exclude_all_symbols; extern int pep_dll_do_default_excludes; extern int pep_dll_kill_ats; extern int pep_dll_stdcall_aliases; @@ -54,7 +55,6 @@ extern void pep_walk_relocs_of_symbol (struct bfd_link_info *, const char *, int (*) (arelent *, asection *)); extern void pep_create_import_fixup (arelent * rel, asection *, bfd_vma); extern bfd_boolean pep_bfd_is_dll (bfd *); -extern void pep_output_file_set_long_section_names - (bfd *abfd); +extern void pep_output_file_set_long_section_names (bfd *); #endif /* PEP_DLL_H */ -- 2.30.2