bfd/
[deliverable/binutils-gdb.git] / ld / lexsup.c
index 21eb1dc51cfad0e3aae1cce174678276fc9eafea..4da949625da08dbf84dff24a1d6cfb75728a21aa 100644 (file)
@@ -1,6 +1,6 @@
 /* Parse options for the GNU linker.
    Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
 /* Parse options for the GNU linker.
    Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004
+   2001, 2002, 2003, 2004, 2005
    Free Software Foundation, Inc.
 
    This file is part of GLD, the Gnu Linker.
    Free Software Foundation, Inc.
 
    This file is part of GLD, the Gnu Linker.
 
    You should have received a copy of the GNU General Public License
    along with GLD; see the file COPYING.  If not, write to the Free
 
    You should have received a copy of the GNU General Public License
    along with GLD; see the file COPYING.  If not, write to the Free
-   Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.  */
+   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
+   02110-1301, USA.  */
 
 
+#include "config.h"
 #include "bfd.h"
 #include "sysdep.h"
 #include "libiberty.h"
 #include "bfd.h"
 #include "sysdep.h"
 #include "libiberty.h"
@@ -106,6 +107,10 @@ enum option_values
   OPTION_VERSION,
   OPTION_VERSION_SCRIPT,
   OPTION_VERSION_EXPORTS_SECTION,
   OPTION_VERSION,
   OPTION_VERSION_SCRIPT,
   OPTION_VERSION_EXPORTS_SECTION,
+  OPTION_DYNAMIC_LIST,
+  OPTION_DYNAMIC_LIST_CPP_NEW,
+  OPTION_DYNAMIC_LIST_CPP_TYPEINFO,
+  OPTION_DYNAMIC_LIST_DATA,
   OPTION_WARN_COMMON,
   OPTION_WARN_CONSTRUCTORS,
   OPTION_WARN_FATAL,
   OPTION_WARN_COMMON,
   OPTION_WARN_CONSTRUCTORS,
   OPTION_WARN_FATAL,
@@ -123,6 +128,8 @@ enum option_values
   OPTION_FORCE_EXE_SUFFIX,
   OPTION_GC_SECTIONS,
   OPTION_NO_GC_SECTIONS,
   OPTION_FORCE_EXE_SUFFIX,
   OPTION_GC_SECTIONS,
   OPTION_NO_GC_SECTIONS,
+  OPTION_PRINT_GC_SECTIONS,
+  OPTION_NO_PRINT_GC_SECTIONS,
   OPTION_HASH_SIZE,
   OPTION_CHECK_SECTIONS,
   OPTION_NO_CHECK_SECTIONS,
   OPTION_HASH_SIZE,
   OPTION_CHECK_SECTIONS,
   OPTION_NO_CHECK_SECTIONS,
@@ -341,6 +348,8 @@ static const struct ld_option ld_options[] =
     '\0', NULL, NULL, ONE_DASH },
   { {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC},
     '\0', NULL, N_("Bind global references locally"), ONE_DASH },
     '\0', NULL, NULL, ONE_DASH },
   { {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC},
     '\0', NULL, N_("Bind global references locally"), ONE_DASH },
+  { {"Bsymbolic-functions", no_argument, NULL, OPTION_DYNAMIC_LIST_DATA},
+    '\0', NULL, N_("Bind global function references locally"), ONE_DASH },
   { {"check-sections", no_argument, NULL, OPTION_CHECK_SECTIONS},
     '\0', NULL, N_("Check section addresses for overlaps (default)"),
     TWO_DASHES },
   { {"check-sections", no_argument, NULL, OPTION_CHECK_SECTIONS},
     '\0', NULL, N_("Check section addresses for overlaps (default)"),
     TWO_DASHES },
@@ -369,6 +378,12 @@ static const struct ld_option ld_options[] =
   { {"no-gc-sections", no_argument, NULL, OPTION_NO_GC_SECTIONS},
     '\0', NULL, N_("Don't remove unused sections (default)"),
     TWO_DASHES },
   { {"no-gc-sections", no_argument, NULL, OPTION_NO_GC_SECTIONS},
     '\0', NULL, N_("Don't remove unused sections (default)"),
     TWO_DASHES },
+  { {"print-gc-sections", no_argument, NULL, OPTION_PRINT_GC_SECTIONS},
+    '\0', NULL, N_("List removed unused sections on stderr"),
+    TWO_DASHES },
+  { {"no-print-gc-sections", no_argument, NULL, OPTION_NO_PRINT_GC_SECTIONS},
+    '\0', NULL, N_("Do not list removed unused sections"),
+    TWO_DASHES },
   { {"hash-size=<NUMBER>", required_argument, NULL, OPTION_HASH_SIZE},
     '\0', NULL, N_("Set default hash table size close to <NUMBER>"),
     TWO_DASHES },
   { {"hash-size=<NUMBER>", required_argument, NULL, OPTION_HASH_SIZE},
     '\0', NULL, N_("Set default hash table size close to <NUMBER>"),
     TWO_DASHES },
@@ -492,6 +507,14 @@ static const struct ld_option ld_options[] =
      OPTION_VERSION_EXPORTS_SECTION },
     '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
                           "\t\t\t\tSYMBOL as the version."), TWO_DASHES },
      OPTION_VERSION_EXPORTS_SECTION },
     '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
                           "\t\t\t\tSYMBOL as the version."), TWO_DASHES },
+  { {"dynamic-list-data", no_argument, NULL, OPTION_DYNAMIC_LIST_DATA},
+    '\0', NULL, N_("Add data symbols to dynamic list"), TWO_DASHES },
+  { {"dynamic-list-cpp-new", no_argument, NULL, OPTION_DYNAMIC_LIST_CPP_NEW},
+    '\0', NULL, N_("Use C++ operator new/delete dynamic list"), TWO_DASHES },
+  { {"dynamic-list-cpp-typeinfo", no_argument, NULL, OPTION_DYNAMIC_LIST_CPP_TYPEINFO},
+    '\0', NULL, N_("Use C++ typeinfo dynamic list"), TWO_DASHES },
+  { {"dynamic-list", required_argument, NULL, OPTION_DYNAMIC_LIST},
+    '\0', N_("FILE"), N_("Read dynamic list"), TWO_DASHES },
   { {"warn-common", no_argument, NULL, OPTION_WARN_COMMON},
     '\0', NULL, N_("Warn about duplicate common symbols"), TWO_DASHES },
   { {"warn-constructors", no_argument, NULL, OPTION_WARN_CONSTRUCTORS},
   { {"warn-common", no_argument, NULL, OPTION_WARN_COMMON},
     '\0', NULL, N_("Warn about duplicate common symbols"), TWO_DASHES },
   { {"warn-constructors", no_argument, NULL, OPTION_WARN_CONSTRUCTORS},
@@ -665,6 +688,8 @@ parse_args (unsigned argc, char **argv)
        {
        case '?':
          einfo (_("%P: unrecognized option '%s'\n"), argv[last_optind]);
        {
        case '?':
          einfo (_("%P: unrecognized option '%s'\n"), argv[last_optind]);
+         /* Fall through.  */
+
        default:
          einfo (_("%P%F: use the --help option for usage information\n"));
 
        default:
          einfo (_("%P%F: use the --help option for usage information\n"));
 
@@ -809,7 +834,10 @@ parse_args (unsigned argc, char **argv)
          /* Ignore.  */
          break;
        case OPTION_GC_SECTIONS:
          /* Ignore.  */
          break;
        case OPTION_GC_SECTIONS:
-         command_line.gc_sections = TRUE;
+         link_info.gc_sections = TRUE;
+         break;
+       case OPTION_PRINT_GC_SECTIONS:
+         link_info.print_gc_sections = TRUE;
          break;
        case OPTION_HELP:
          help ();
          break;
        case OPTION_HELP:
          help ();
@@ -852,7 +880,10 @@ parse_args (unsigned argc, char **argv)
          demangling = FALSE;
          break;
        case OPTION_NO_GC_SECTIONS:
          demangling = FALSE;
          break;
        case OPTION_NO_GC_SECTIONS:
-         command_line.gc_sections = FALSE;
+         link_info.gc_sections = FALSE;
+         break;
+       case OPTION_NO_PRINT_GC_SECTIONS:
+         link_info.print_gc_sections = FALSE;
          break;
        case OPTION_NO_KEEP_MEMORY:
          link_info.keep_memory = FALSE;
          break;
        case OPTION_NO_KEEP_MEMORY:
          link_info.keep_memory = FALSE;
@@ -1221,6 +1252,33 @@ parse_args (unsigned argc, char **argv)
             .exports sections.  */
          command_line.version_exports_section = optarg;
          break;
             .exports sections.  */
          command_line.version_exports_section = optarg;
          break;
+       case OPTION_DYNAMIC_LIST_DATA:
+         link_info.dynamic_data = TRUE;
+         link_info.dynamic = TRUE;
+         break;
+       case OPTION_DYNAMIC_LIST_CPP_TYPEINFO:
+         lang_append_dynamic_list_cpp_typeinfo ();
+         link_info.dynamic = TRUE;
+         break;
+       case OPTION_DYNAMIC_LIST_CPP_NEW:
+         lang_append_dynamic_list_cpp_new ();
+         link_info.dynamic = TRUE;
+         break;
+       case OPTION_DYNAMIC_LIST:
+         /* This option indicates a small script that only specifies
+            a dynamic list.  Read it, but don't assume that we've
+            seen a linker script.  */
+         {
+           FILE *hold_script_handle;
+
+           hold_script_handle = saved_script_handle;
+           ldfile_open_command_file (optarg);
+           saved_script_handle = hold_script_handle;
+           parser_input = input_dynamic_list;
+           yyparse ();
+         }
+         link_info.dynamic = TRUE;
+         break;
        case OPTION_WARN_COMMON:
          config.warn_common = TRUE;
          break;
        case OPTION_WARN_COMMON:
          config.warn_common = TRUE;
          break;
@@ -1270,7 +1328,7 @@ parse_args (unsigned argc, char **argv)
          link_info.discard = discard_all;
          break;
        case 'Y':
          link_info.discard = discard_all;
          break;
        case 'Y':
-         if (strncmp (optarg, "P,", 2) == 0)
+         if (CONST_STRNEQ (optarg, "P,"))
            optarg += 2;
          if (default_dirlist != NULL)
            free (default_dirlist);
            optarg += 2;
          if (default_dirlist != NULL)
            free (default_dirlist);
@@ -1330,7 +1388,7 @@ parse_args (unsigned argc, char **argv)
          break;
 
        case OPTION_REDUCE_MEMORY_OVERHEADS:
          break;
 
        case OPTION_REDUCE_MEMORY_OVERHEADS:
-         command_line.reduce_memory_overheads = TRUE;
+         link_info.reduce_memory_overheads = TRUE;
          if (config.hash_table_size == 0)
            config.hash_table_size = 1021;
          break;
          if (config.hash_table_size == 0)
            config.hash_table_size = 1021;
          break;
@@ -1441,6 +1499,7 @@ help (void)
 {
   unsigned i;
   const char **targets, **pp;
 {
   unsigned i;
   const char **targets, **pp;
+  int len;
 
   printf (_("Usage: %s [options] file...\n"), program_name);
 
 
   printf (_("Usage: %s [options] file...\n"), program_name);
 
@@ -1450,7 +1509,6 @@ help (void)
       if (ld_options[i].doc != NULL)
        {
          bfd_boolean comma;
       if (ld_options[i].doc != NULL)
        {
          bfd_boolean comma;
-         int len;
          unsigned j;
 
          printf ("  ");
          unsigned j;
 
          printf ("  ");
@@ -1523,6 +1581,10 @@ help (void)
          printf ("%s\n", _(ld_options[i].doc));
        }
     }
          printf ("%s\n", _(ld_options[i].doc));
        }
     }
+  printf (_("  @FILE"));
+  for (len = strlen ("  @FILE"); len < 30; len++)
+    putchar (' ');
+  printf (_("Read options from FILE\n"));
 
   /* Note: Various tools (such as libtool) depend upon the
      format of the listings below - do not change them.  */
 
   /* Note: Various tools (such as libtool) depend upon the
      format of the listings below - do not change them.  */
This page took 0.025745 seconds and 4 git commands to generate.