Patch from Thomas de Lellis to implement --section-start
authorNick Clifton <nickc@redhat.com>
Mon, 22 May 2000 21:58:40 +0000 (21:58 +0000)
committerNick Clifton <nickc@redhat.com>
Mon, 22 May 2000 21:58:40 +0000 (21:58 +0000)
ld/ChangeLog
ld/NEWS
ld/ld.1
ld/ld.texinfo
ld/lexsup.c

index bdb5df6..801de43 100644 (file)
@@ -1,3 +1,15 @@
+2000-05-22  Thomas de Lellis  <tdel@windriver.com>
+
+        * ld.1: Add documentation for new command line option:
+               --section-start <sectionname>=<sectionorg>
+        This is a generic version of -Ttext etc. which accepts
+        any section name as a parameter instead of just text/data/
+       bss. 
+        * ld.texinfo: More docs.
+        * NEWS: More docs.
+        * lexsup.c: (parse_args): Recognize new command line option.
+       (ld_options): Add new option.
+       
 2000-05-18  H.J. Lu  <hjl@gnu.org>
 
        * lexsup.c (parse_args): `i' == `r', not `q'.
diff --git a/ld/NEWS b/ld/NEWS
index 325d8a8..df6446d 100644 (file)
--- a/ld/NEWS
+++ b/ld/NEWS
@@ -2,6 +2,9 @@
 
 Changes in version 2.10:
 
+* Added command line switch --section-start to set the start address of any
+  specified section. 
+
 * Added ability to emit full relocation information in linked executables,
   enabled by --emit-relocs.  Some post-linkage optimization tools need
   this information in order to be able to correctly identify and perform
diff --git a/ld/ld.1 b/ld/ld.1
index 58516b9..129d91e 100644 (file)
--- a/ld/ld.1
+++ b/ld/ld.1
@@ -39,7 +39,7 @@ ld \- the GNU linker
 .br
 .RB "[\|" "\-defsym\ "\c
 .I symbol\c
-\& = \c
+\&=\c
 .I expression\c
 \&\|]
 .RB "[\|" \-\-demangle "\|]"
@@ -122,6 +122,11 @@ ld \- the GNU linker
 .RB "[\|" "\-T\ "\c
 .I commandfile\c
 \&\|]  
+.RB "[\|" "\-\-section\-start\ "\c
+.I sectionname\c
+\&=\c
+.I sectionorg\c
+\&\|]
 .RB "[\|" "\-Ttext\ "\c
 .I textorg\c
 \&\|] 
@@ -253,8 +258,9 @@ The exceptions\(em\&which may meaningfully be used more than once\(em\&are
 .B \-format\c
 \&), \c
 .B \-defsym\c
-\&,
-\c
+\&, \c
+.B \-\-section\-start\c
+\&, \c
 .B \-L\c
 \&, \c
 .B \-l\c
@@ -454,7 +460,7 @@ specified (\c
 \& has the same effect.
 
 .TP
-.BI "-defsym " "symbol" "\fR = \fP" expression
+.BI "-defsym " "symbol" "\fR=\fP" expression
 Create a global symbol in the output file, containing the absolute
 address given by \c
 .I expression\c
@@ -890,6 +896,20 @@ Similar to
 but creates a new output section for each input file.
 
 .TP
+.BI "--section-start " "sectionname" "\fR=\fP"org
+Locate a section in the output file at the absolute
+address given by \c
+.I org\c
+\&.  \c
+\c
+.I org\c
+\& must be a hexadecimal integer.
+You may use this option as many
+times as necessary to locate multiple sections in the command
+line.  If you need more elaborate expressions, consider
+using the linker command language from a script.
+
+.TP
 .BI "\-Tbss " "org"\c
 .TP
 .BI "\-Tdata " "org"\c
index 1ff0ecb..22684c1 100644 (file)
@@ -1143,6 +1143,18 @@ full debugging information by over 30 percent.  Unfortunately, the SunOS
 trouble).  The @samp{--traditional-format} switch tells @code{ld} to not
 combine duplicate entries.
 
+@kindex --section-start @var{sectionname}=@var{org}
+@item --section-start @var{sectionname}=@var{org}
+Locate a section in the output file at the absolute
+address given by @var{org}.  You may use this option as many
+times as necessary to locate multiple sections in the command
+line.
+@var{org} must be a single hexadecimal integer;
+for compatibility with other linkers, you may omit the leading
+@samp{0x} usually associated with hexadecimal values.  @emph{Note:} there
+should be no white space between @var{sectionname}, the equals
+sign (``@key{=}''), and @var{org}.
+
 @kindex -Tbss @var{org}
 @kindex -Tdata @var{org}
 @kindex -Ttext @var{org}
index 99190e5..2869d49 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},
@@ -841,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;