Patch from Thomas de Lellis to implement --section-start

This commit is contained in:
Nick Clifton 2000-05-22 21:58:40 +00:00
parent 5110c57e8e
commit 176355da99
5 changed files with 87 additions and 4 deletions

View 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'.

View File

@ -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

28
ld/ld.1
View File

@ -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
@ -889,6 +895,20 @@ Similar to
.B \-split\-by\-reloc
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

View 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}

View 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;