aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2000-05-22 21:58:40 +0000
committerNick Clifton <nickc@redhat.com>2000-05-22 21:58:40 +0000
commit176355da9935d29e302b00cef227c2c9946492c3 (patch)
treeb359ee540423bdf84b39452b0ee7183e9dd7599e
parent5110c57e8e960ab73903ff4e3e1a13fe42012a1f (diff)
downloadgdb-176355da9935d29e302b00cef227c2c9946492c3.zip
gdb-176355da9935d29e302b00cef227c2c9946492c3.tar.gz
gdb-176355da9935d29e302b00cef227c2c9946492c3.tar.bz2
Patch from Thomas de Lellis to implement --section-start
-rw-r--r--ld/ChangeLog12
-rw-r--r--ld/NEWS3
-rw-r--r--ld/ld.128
-rw-r--r--ld/ld.texinfo12
-rw-r--r--ld/lexsup.c36
5 files changed, 87 insertions, 4 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index bdb5df6..801de43 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -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
--- 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
--- 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
diff --git a/ld/ld.texinfo b/ld/ld.texinfo
index 1ff0ecb..22684c1 100644
--- a/ld/ld.texinfo
+++ b/ld/ld.texinfo
@@ -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}
diff --git a/ld/lexsup.c b/ld/lexsup.c
index 99190e5..2869d49 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -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;