Don't try to read past end of info buffer, and correct test results.
[deliverable/binutils-gdb.git] / ld / lexsup.c
index eb1fc2d86dda7582e799348cee578a1f395d6f16..3664a85c64b8b0abfd78270fa851535d29037ab6 100644 (file)
@@ -1,5 +1,6 @@
 /* Parse options for the GNU linker.
-   Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000
+   Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+   2001
    Free Software Foundation, Inc.
 
 This file is part of GLD, the Gnu Linker.
@@ -236,8 +237,8 @@ static const struct ld_option ld_options[] =
       'T', N_("FILE"), N_("Read linker script"), TWO_DASHES },
   { {"undefined", required_argument, NULL, 'u'},
       'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"), TWO_DASHES },
-  { {"unique", no_argument, NULL, OPTION_UNIQUE},
-      '\0', NULL, N_("Don't merge orphan sections with the same name"), TWO_DASHES },
+  { {"unique", optional_argument, NULL, OPTION_UNIQUE},
+      '\0', N_("[=SECTION]"), N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES },
   { {"Ur", no_argument, NULL, OPTION_UR},
       '\0', NULL, N_("Build global constructor/destructor tables"), ONE_DASH },
   { {"version", no_argument, NULL, OPTION_VERSION},
@@ -543,14 +544,22 @@ parse_args (argc, argv)
 
       /* getopt_long_only is like getopt_long, but '-' as well as '--'
         can indicate a long option.  */
+      opterr = 0;
       optc = getopt_long_only (argc, argv, shortopts, longopts, &longind);
-      if (optc == -1)
-       optc = getopt_long (argc, argv, shortopts, really_longopts, &longind);
+      if (optc == '?')
+       {
+         --optind;
+         optc = getopt_long (argc, argv, shortopts, really_longopts, &longind);
+       }
 
       if (optc == -1)
        break;
+
       switch (optc)
        {
+       case '?':
+         fprintf (stderr, _("%s: unrecognized option '%s'\n"),
+                  program_name, argv[optind - 1]);
        default:
          fprintf (stderr,
                   _("%s: use the --help option for usage information\n"),
@@ -957,7 +966,10 @@ parse_args (argc, argv)
          ldlang_add_undef (optarg);
          break;
        case OPTION_UNIQUE:
-         config.unique_orphan_sections = true;
+         if (optarg != NULL)
+           lang_add_unique (optarg);
+         else
+           config.unique_orphan_sections = true;
          break;
        case OPTION_VERBOSE:
          ldversion (1);
@@ -975,7 +987,7 @@ parse_args (argc, argv)
        case OPTION_VERSION:
          /* This output is intended to follow the GNU standards document.  */
          printf ("GNU ld %s\n", ld_program_version);
-         printf (_("Copyright 2000 Free Software Foundation, Inc.\n"));
+         printf (_("Copyright 2001 Free Software Foundation, Inc.\n"));
          printf (_("\
 This program is free software; you may redistribute it under the terms of\n\
 the GNU General Public License.  This program has absolutely no warranty.\n"));
This page took 0.030149 seconds and 4 git commands to generate.