* emultempl/pe.em (OPTION_EXCLUDE_ALL_SYMBOLS): New macro.
authorNick Clifton <nickc@redhat.com>
Fri, 16 Oct 2009 15:15:39 +0000 (15:15 +0000)
committerNick Clifton <nickc@redhat.com>
Fri, 16 Oct 2009 15:15:39 +0000 (15:15 +0000)
        (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
ld/NEWS
ld/emultempl/pe.em
ld/emultempl/pep.em
ld/ld.texinfo
ld/pe-dll.c
ld/pe-dll.h
ld/pep-dll.c
ld/pep-dll.h

index 89c60527f98ae10bb4bd5f13e697b69fbfd5b0a8..f755793f551399e5872b5ff6f5e140765bed50a5 100644 (file)
@@ -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
diff --git a/ld/NEWS b/ld/NEWS
index 86b74cf497cad18b6d5e3cd0b33a354fc938d233..76b674972c01b4788b8c73b2b622a0e4328679c8 100644 (file)
--- 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:
index 788818d657f171a5bcbe1fbd6aa1d4eaa8b7de7d..d233bd1f9b001a136d97d4257e36b689c2b13610 100644 (file)
@@ -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;
index 90af02052df0eb224857a9657a7d29bb61732864..ff0c589dce49381a9ce8705d1f80312c505652e2 100644 (file)
@@ -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;
index 21ff9cd62990a8e366fb6d8b37660348bd9033d4..4899d613d59454cd31f3b4b6f663fcbcb4f2c64f 100644 (file)
@@ -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
index f615b2d2bfccc209346fefbcef8d20e9f2856516..ce5d6a39fbbf622fefe7e8ee5fb35d26634b5c0c 100644 (file)
@@ -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)
        {
index 932bc81e562622b729edfb9b4b4be00c25bb9ac9..a5ae9fb508ec3014f5535bb9054a04b56c24caa6 100644 (file)
@@ -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 */
index 8f7cc99513a644c9e08ac986d6ad3114df325e60..3d8882dcb41cc0d01d0b43e6b0a80f88ffc72d7f 100644 (file)
@@ -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
index 5840ccede5324d012ba99e5cdd0e4e63e10e470e..7d441ea22a0229931989e4a2878e7629f2032f9e 100644 (file)
@@ -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 */