* scripttempl/elf.sc (.init): Only do ${INIT_START} and
[binutils-gdb.git] / ld / lexsup.c
index 604eb67c083ce437f38b910e917bacce02c94acb..a018f28d95d9c4573b21b0487de13f58a141c04d 100644 (file)
@@ -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.  */
@@ -336,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},
@@ -718,10 +721,10 @@ parse_args (argc, argv)
        case OPTION_OFORMAT:
          lang_add_output_format (optarg, (char *) NULL, (char *) NULL, 0);
          break;
-       case 'i':
        case 'q':
          link_info.emitrelocations = true;
          break;
+       case 'i':
        case 'r':
          link_info.relocateable = true;
          config.build_constructors = false;
@@ -841,6 +844,44 @@ parse_args (argc, argv)
          parser_input = input_script;
          yyparse ();
          break;
+       case OPTION_SECTION_START:
+         {
+           char *optarg2;
+           char *sec_name;
+           int len;
+
+           /* 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);
+             }
+
+           /* We must copy the section name as set_section_start
+              doesn't do it for us.  */
+           len = optarg2 - optarg;
+           sec_name = xmalloc (len);
+           memcpy (sec_name, optarg, len - 1);
+           sec_name[len - 1] = 0;
+
+           /* Then set it...  */
+           set_section_start (sec_name, optarg2);
+         }
+         break;
        case OPTION_TBSS:
          set_section_start (".bss", optarg);
          break;