dummy commit before egcs merge
[deliverable/binutils-gdb.git] / ld / lexsup.c
index 52ec448d66be87258312ebd834a86ebf4f6fa41b..3a03f2038872c2c504c515987249ef1e2f4c66e9 100644 (file)
@@ -111,6 +111,8 @@ int parsing_defsym = 0;
 #define OPTION_WHOLE_ARCHIVE           (OPTION_SPLIT_BY_FILE + 1)
 #define OPTION_WRAP                    (OPTION_WHOLE_ARCHIVE + 1)
 #define OPTION_FORCE_EXE_SUFFIX                (OPTION_WRAP + 1)
+#define OPTION_GC_SECTIONS             (OPTION_FORCE_EXE_SUFFIX + 1)
+#define OPTION_NO_GC_SECTIONS          (OPTION_GC_SECTIONS + 1)
 
 /* The long options.  This structure is used for both the option
    parsing and the help text.  */
@@ -163,6 +165,12 @@ static const struct ld_option ld_options[] =
       'F', N_("SHLIB"), N_("Filter for shared object symbol table"), TWO_DASHES },
   { {NULL, no_argument, NULL, '\0'},
       'g', NULL, N_("Ignored"), ONE_DASH },
+  { {"gc-sections", no_argument, NULL, OPTION_GC_SECTIONS},
+      '\0', NULL, N_("Remove unused sections on certain targets"),
+      TWO_DASHES },
+  { {"no-gc-sections", no_argument, NULL, OPTION_NO_GC_SECTIONS},
+      '\0', NULL, N_("(Don't) Remove unused sections on certain targets"),
+      TWO_DASHES },
   { {"gpsize", required_argument, NULL, 'G'},
       'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
       TWO_DASHES },
@@ -396,11 +404,35 @@ parse_args (argc, argv)
            || ! isdigit ((unsigned char) argv[i + 1][0])))
       argv[i] = (char *) "--shared";
 
+  /* Because we permit long options to start with a single dash, and
+     we have a --library option, and the -l option is conventionally
+     used with an immediately following argument, we can have bad
+     results if somebody tries to use -l with a library whose name
+     happens to start with "ibrary", as in -li.  We avoid problems by
+     simply turning -l into --library.  This means that users will
+     have to use two dashes in order to use --library, which is OK
+     since that's how it is documented.
+
+     FIXME: It's possible that this problem can arise for other short
+     options as well, although the user does always have the recourse
+     of adding a space between the option and the argument.  */
+  for (i = 1; i < argc; i++)
+    {
+      if (argv[i][0] == '-'
+         && argv[i][1] == 'l'
+         && argv[i][2] != '\0')
+       {
+         char *n;
+
+         n = (char *) xmalloc (strlen (argv[i]) + 20);
+         sprintf (n, "--library=%s", argv[i] + 2);
+         argv[i] = n;
+       }
+    }
+
   last_optind = -1;
   while (1)
     {
-      /* getopt_long_only is like getopt_long, but '-' as well as '--' can
-        indicate a long option.  */
       int longind;
       int optc;
 
@@ -417,6 +449,8 @@ parse_args (argc, argv)
          last_optind = optind;
        }
 
+      /* getopt_long_only is like getopt_long, but '-' as well as '--'
+        can indicate a long option.  */
       optc = getopt_long_only (argc, argv, shortopts, longopts, &longind);
 
       if (optc == -1)
@@ -549,6 +583,9 @@ parse_args (argc, argv)
        case 'g':
          /* Ignore.  */
          break;
+       case OPTION_GC_SECTIONS:
+         command_line.gc_sections = true;
+         break;
        case OPTION_HELP:
          help ();
          xexit (0);
@@ -578,6 +615,9 @@ parse_args (argc, argv)
          config.magic_demand_paged = false;
          config.dynamic_link = false;
          break;
+       case OPTION_NO_GC_SECTIONS:
+         command_line.gc_sections = false;
+         break;
        case OPTION_NO_KEEP_MEMORY:
          link_info.keep_memory = false;
          break;
@@ -675,7 +715,10 @@ parse_args (argc, argv)
          link_info.strip = strip_all;
          break;
        case OPTION_SHARED:
-         link_info.shared = true;
+         if (config.has_shared)
+           link_info.shared = true;
+         else
+           einfo (_("%P%F: -shared not supported\n"));
          break;
        case 'h':               /* Used on Solaris.  */
        case OPTION_SONAME:
@@ -968,6 +1011,7 @@ help ()
        }
     }
 
+  /* xgettext:c-format */
   printf (_("%s: supported targets:"), program_name);
   targets = bfd_target_list ();
   for (pp = targets; *pp != NULL; pp++)
@@ -975,8 +1019,15 @@ help ()
   free (targets);
   printf ("\n");
 
+  /* xgettext:c-format */
   printf (_("%s: supported emulations: "), program_name);
   ldemul_list_emulations (stdout);
   printf ("\n");
+
+  /* xgettext:c-format */
+  printf (_("%s: emulation specific options:\n"), program_name);
+  ldemul_list_emulation_options (stdout);
+  printf ("\n");
+  
   printf (_("\nReport bugs to bug-gnu-utils@gnu.org\n"));
 }
This page took 0.025594 seconds and 4 git commands to generate.