diff options
-rw-r--r-- | ld/ChangeLog | 16 | ||||
-rw-r--r-- | ld/NEWS | 3 | ||||
-rw-r--r-- | ld/emultempl/pe.em | 8 | ||||
-rw-r--r-- | ld/emultempl/pep.em | 6 | ||||
-rw-r--r-- | ld/ld.texinfo | 5 | ||||
-rw-r--r-- | ld/pe-dll.c | 12 | ||||
-rw-r--r-- | ld/pe-dll.h | 4 | ||||
-rw-r--r-- | ld/pep-dll.c | 1 | ||||
-rw-r--r-- | ld/pep-dll.h | 4 |
9 files changed, 49 insertions, 10 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 89c6052..f755793 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,19 @@ +2009-10-16 Dimitry Gorbachev <d.g.gorbachev@gmail.com> + + * 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 <schwab@linux-m68k.org> * ldlex.l (yy_input): Remove second argument and return the value @@ -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 788818d..d233bd1 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -196,7 +196,8 @@ fragment <<EOF #define OPTION_OUT_DEF (OPTION_SUPPORT_OLD_CODE + 1) #define OPTION_EXPORT_ALL (OPTION_OUT_DEF + 1) #define OPTION_EXCLUDE_SYMBOLS (OPTION_EXPORT_ALL + 1) -#define OPTION_KILL_ATS (OPTION_EXCLUDE_SYMBOLS + 1) +#define OPTION_EXCLUDE_ALL_SYMBOLS (OPTION_EXCLUDE_SYMBOLS + 1) +#define OPTION_KILL_ATS (OPTION_EXCLUDE_ALL_SYMBOLS + 1) #define OPTION_STDCALL_ALIASES (OPTION_KILL_ATS + 1) #define OPTION_ENABLE_STDCALL_FIXUP (OPTION_STDCALL_ALIASES + 1) #define OPTION_DISABLE_STDCALL_FIXUP (OPTION_ENABLE_STDCALL_FIXUP + 1) @@ -276,6 +277,7 @@ gld${EMULATION_NAME}_add_options {"output-def", required_argument, NULL, OPTION_OUT_DEF}, {"export-all-symbols", no_argument, NULL, OPTION_EXPORT_ALL}, {"exclude-symbols", required_argument, NULL, OPTION_EXCLUDE_SYMBOLS}, + {"exclude-all-symbols", no_argument, NULL, OPTION_EXCLUDE_ALL_SYMBOLS}, {"exclude-libs", required_argument, NULL, OPTION_EXCLUDE_LIBS}, {"exclude-modules-for-implib", required_argument, NULL, OPTION_EXCLUDE_MODULES_FOR_IMPLIB}, {"kill-at", no_argument, NULL, OPTION_KILL_ATS}, @@ -389,6 +391,7 @@ gld_${EMULATION_NAME}_list_options (FILE *file) fprintf (file, _(" --disable-stdcall-fixup Don't link _sym to _sym@nn\n")); fprintf (file, _(" --enable-stdcall-fixup Link _sym to _sym@nn without warnings\n")); fprintf (file, _(" --exclude-symbols sym,sym,... Exclude symbols from automatic export\n")); + fprintf (file, _(" --exclude-all-symbols Exclude all symbols from automatic export\n")); fprintf (file, _(" --exclude-libs lib,lib,... Exclude libraries from automatic export\n")); fprintf (file, _(" --exclude-modules-for-implib mod,mod,...\n")); fprintf (file, _(" Exclude objects, archive members from auto\n")); @@ -669,6 +672,9 @@ gld${EMULATION_NAME}_handle_option (int optc) case OPTION_EXCLUDE_SYMBOLS: pe_dll_add_excludes (optarg, EXCLUDESYMS); break; + case OPTION_EXCLUDE_ALL_SYMBOLS: + pe_dll_exclude_all_symbols = 1; + break; case OPTION_EXCLUDE_LIBS: pe_dll_add_excludes (optarg, EXCLUDELIBS); break; diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em index 90af020..ff0c589 100644 --- a/ld/emultempl/pep.em +++ b/ld/emultempl/pep.em @@ -158,6 +158,7 @@ enum options OPTION_OUT_DEF, OPTION_EXPORT_ALL, OPTION_EXCLUDE_SYMBOLS, + OPTION_EXCLUDE_ALL_SYMBOLS, OPTION_KILL_ATS, OPTION_STDCALL_ALIASES, OPTION_ENABLE_STDCALL_FIXUP, @@ -227,6 +228,7 @@ gld${EMULATION_NAME}_add_options {"output-def", required_argument, NULL, OPTION_OUT_DEF}, {"export-all-symbols", no_argument, NULL, OPTION_EXPORT_ALL}, {"exclude-symbols", required_argument, NULL, OPTION_EXCLUDE_SYMBOLS}, + {"exclude-all-symbols", no_argument, NULL, OPTION_EXCLUDE_ALL_SYMBOLS}, {"exclude-libs", required_argument, NULL, OPTION_EXCLUDE_LIBS}, {"exclude-modules-for-implib", required_argument, NULL, OPTION_EXCLUDE_MODULES_FOR_IMPLIB}, {"kill-at", no_argument, NULL, OPTION_KILL_ATS}, @@ -334,6 +336,7 @@ gld_${EMULATION_NAME}_list_options (FILE *file) fprintf (file, _(" --disable-stdcall-fixup Don't link _sym to _sym@nn\n")); fprintf (file, _(" --enable-stdcall-fixup Link _sym to _sym@nn without warnings\n")); fprintf (file, _(" --exclude-symbols sym,sym,... Exclude symbols from automatic export\n")); + fprintf (file, _(" --exclude-all-symbols Exclude all symbols from automatic export\n")); fprintf (file, _(" --exclude-libs lib,lib,... Exclude libraries from automatic export\n")); fprintf (file, _(" --exclude-modules-for-implib mod,mod,...\n")); fprintf (file, _(" Exclude objects, archive members from auto\n")); @@ -609,6 +612,9 @@ gld${EMULATION_NAME}_handle_option (int optc) case OPTION_EXCLUDE_SYMBOLS: pep_dll_add_excludes (optarg, EXCLUDESYMS); break; + case OPTION_EXCLUDE_ALL_SYMBOLS: + pep_dll_exclude_all_symbols = 1; + break; case OPTION_EXCLUDE_LIBS: pep_dll_add_excludes (optarg, EXCLUDELIBS); break; diff --git a/ld/ld.texinfo b/ld/ld.texinfo index 21ff9cd..4899d61 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -2224,6 +2224,11 @@ Specifies a list of symbols which should not be automatically exported. The symbol names may be delimited by commas or colons. [This option is specific to the i386 PE targeted port of the linker] +@kindex --exclude-all-symbols +@item --exclude-all-symbols +Specifies no symbols should be automatically exported. +[This option is specific to the i386 PE targeted port of the linker] + @kindex --file-alignment @item --file-alignment Specify the file alignment. Sections in the file will always begin at diff --git a/ld/pe-dll.c b/ld/pe-dll.c index f615b2d..ce5d6a3 100644 --- a/ld/pe-dll.c +++ b/ld/pe-dll.c @@ -149,6 +149,7 @@ static void add_bfd_to_link (bfd *, const char *, struct bfd_link_info *); def_file * pe_def_file = 0; int pe_dll_export_everything = 0; +int pe_dll_exclude_all_symbols = 0; int pe_dll_do_default_excludes = 1; int pe_dll_kill_ats = 0; int pe_dll_stdcall_aliases = 0; @@ -664,14 +665,15 @@ process_def_file_and_drectve (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info * } } - /* If we are not building a DLL, when there are no exports - we do not build an export table at all. */ - if (!pe_dll_export_everything && pe_def_file->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 932bc81..a5ae9fb 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 8f7cc99..3d8882d 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 5840cce..7d441ea 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 */ |