Patch from Thomas de Lellis to implement --section-start
[deliverable/binutils-gdb.git] / ld / lexsup.c
index f8388acf8fc6ae6630b132fdcbe8d2cf75c49a92..2869d494903d5a404b2c4d8660adb1f1098eb170 100644 (file)
@@ -1,5 +1,5 @@
 /* Parse options for the GNU linker.
-   Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 1999
+   Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000
    Free Software Foundation, Inc.
 
 This file is part of GLD, the Gnu Linker.
@@ -123,6 +123,7 @@ int parsing_defsym = 0;
 #define OPTION_NO_UNDEFINED            (OPTION_MPC860C0 + 1)
 #define OPTION_INIT                     (OPTION_NO_UNDEFINED + 1)
 #define OPTION_FINI                     (OPTION_INIT + 1)
+#define OPTION_SECTION_START           (OPTION_FINI + 1)
 
 /* The long options.  This structure is used for both the option
    parsing and the help text.  */
@@ -203,6 +204,8 @@ static const struct ld_option ld_options[] =
       'O', NULL, N_("Optimize output file"), ONE_DASH },
   { {"Qy", no_argument, NULL, OPTION_IGNORE},
       '\0', NULL, N_("Ignored for SVR4 compatibility"), ONE_DASH },
+  { {"emit-relocs", no_argument, NULL, 'q'},
+      'q', NULL, "Generate relocations in final output", TWO_DASHES },
   { {"relocateable", no_argument, NULL, 'r'},
       'r', NULL, N_("Generate relocateable output"), TWO_DASHES },
   { {NULL, no_argument, NULL, '\0'},
@@ -334,6 +337,8 @@ static const struct ld_option ld_options[] =
       '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES },
   { {"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT},
       '\0', NULL, N_("Use same format as native linker"), TWO_DASHES },
+  { {"section-start", required_argument, NULL, OPTION_SECTION_START},
+      '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"), TWO_DASHES },
   { {"Tbss", required_argument, NULL, OPTION_TBSS},
       '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH },
   { {"Tdata", required_argument, NULL, OPTION_TDATA},
@@ -516,6 +521,9 @@ parse_args (argc, argv)
       switch (optc)
        {
        default:
+         fprintf (stderr,
+                  _("%s: use the --help option for usage information\n"),
+                  program_name);
          xexit (1);
        case 1:                 /* File name.  */
          lang_add_input_file (optarg, lang_input_file_is_file_enum,
@@ -713,6 +721,9 @@ parse_args (argc, argv)
        case OPTION_OFORMAT:
          lang_add_output_format (optarg, (char *) NULL, (char *) NULL, 0);
          break;
+       case 'q':
+         link_info.emitrelocations = true;
+         break;
        case 'i':
        case 'r':
          link_info.relocateable = true;
@@ -833,6 +844,39 @@ parse_args (argc, argv)
          parser_input = input_script;
          yyparse ();
          break;
+       case OPTION_SECTION_START:
+         {
+           char *optarg2;
+
+           /* Check for <something>=<somthing>...  */
+           optarg2 = strchr (optarg, '=');
+           if (optarg2 == NULL)
+             {
+               fprintf (stderr,
+                        _("%s: Invalid argument to option \"--section-start\"\n"),
+                        program_name);
+               xexit (1);
+             }
+
+           optarg2 ++;
+           
+           /* So far so good.  Are all the args present?  */
+           if ((*optarg == '\0') || (*optarg2 == '\0'))
+             {
+               fprintf (stderr,
+                        _("%s: Missing argument(s) to option \"--section-start\"\n"),
+                        program_name);
+               xexit (1);
+             }
+
+           optarg2[-1] = '\0';
+
+           /* Then set it...  */
+           set_section_start (optarg, optarg2);
+           
+           optarg2[-1] = '=';
+         }
+         break;
        case OPTION_TBSS:
          set_section_start (".bss", optarg);
          break;
@@ -874,7 +918,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 1997 Free Software Foundation, Inc.\n"));
+         printf (_("Copyright 2000 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"));
@@ -951,7 +995,7 @@ the GNU General Public License.  This program has absolutely no warranty.\n"));
              ignored.  Someday we should handle it correctly.  FIXME.  */
          break;
        case OPTION_SPLIT_BY_RELOC:
-         config.split_by_reloc = atoi (optarg);
+         config.split_by_reloc = strtoul (optarg, NULL, 0);
          break; 
        case OPTION_SPLIT_BY_FILE:
          config.split_by_file = true;
@@ -1047,8 +1091,8 @@ static void
 set_section_start (sect, valstr)
      char *sect, *valstr;
 {
-  char *end;
-  unsigned long val = strtoul (valstr, &end, 16);
+  const char *end;
+  bfd_vma val = bfd_scan_vma (valstr, &end, 16);
   if (*end)
     einfo (_("%P%F: invalid hex number `%s'\n"), valstr);
   lang_section_start (sect, exp_intop (val));
@@ -1159,6 +1203,6 @@ help ()
   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"));
+
+  printf (_("Report bugs to %s\n"), REPORT_BUGS_TO);
 }
This page took 0.02679 seconds and 4 git commands to generate.