2007-01-19 H.J. Lu  <hongjiu.lu@intel.com>

	* NEWS: Mention --default-script/-dT.

	* ld.h (args_type): Add a default_script field.

	* ld.texinfo: Document --default-script/-dT.

	* ldmain.c (main): Handle command_line.default_script.

	* lexsup.c (option_values): Add OPTION_DEFAULT_SCRIPT.
	(ld_options): Add entries for --default-script and -dT.
	(parse_args): Handle --default-script/-dT.

ld/testsuite/

2007-01-19 H.J. Lu  <hongjiu.lu@intel.com>

	* ld-scripts/default-script.exp: New file.
	* ld-scripts/default-script.s: Likewise.
	* ld-scripts/default-script.t: Likewise.
	* ld-scripts/default-script1.d: Likewise.
	* ld-scripts/default-script2.d: Likewise.
	* ld-scripts/default-script3.d: Likewise.
	* ld-scripts/default-script4.d: Likewise.
This commit is contained in:
H.J. Lu 2007-01-19 14:51:27 +00:00
parent 2429decf93
commit 14be856495
14 changed files with 125 additions and 1 deletions

View File

@ -1,3 +1,17 @@
2007-01-19 H.J. Lu <hongjiu.lu@intel.com>
* NEWS: Mention --default-script/-dT.
* ld.h (args_type): Add a default_script field.
* ld.texinfo: Document --default-script/-dT.
* ldmain.c (main): Handle command_line.default_script.
* lexsup.c (option_values): Add OPTION_DEFAULT_SCRIPT.
(ld_options): Add entries for --default-script and -dT.
(parse_args): Handle --default-script/-dT.
2007-01-16 H.J. Lu <hongjiu.lu@intel.com>
PR ld/3831

View File

@ -1,4 +1,8 @@
-*- text -*-
* Add a new command line option '--default-script=FILE' or '-dT FILE'
which specifies a replacement for the built in, default linker
script.
* ELF: Add -Bsymbolic-functions, --dynamic-list-cpp-new, which puts C++
operator new and delete on the dynamic list, and --dynamic-list-data,
builtin list for --dynamic-list, which puts global data symbols on the

View File

@ -191,6 +191,9 @@ typedef struct {
.exports sections. */
char *version_exports_section;
/* Default linker script. */
char *default_script;
/* If TRUE (the default) check section addresses, once compute,
fpor overlaps. */
bfd_boolean check_section_addresses;

View File

@ -856,6 +856,22 @@ the current directory, @code{ld} looks for it in the directories
specified by any preceding @samp{-L} options. Multiple @samp{-T}
options accumulate.
@kindex -dT @var{script}
@kindex --default-script=@var{script}
@cindex script files
@item -dT @var{scriptfile}
@itemx --default-script=@var{scriptfile}
Use @var{scriptfile} as the default linker script. @xref{Scripts}.
This option is similar to the @option{--script} option except that
processing of the script is delayed until after the rest of the
command line has been processed. This allows options placed after the
@option{--default-script} option on the command line to affect the
behaviour of the linker script, which can be important when the linker
command line cannot be directly controlled by the user. (eg because
the command line is being constructed by another tool, such as
@samp{gcc}).
@kindex -u @var{symbol}
@kindex --undefined=@var{symbol}
@cindex undefined symbol

View File

@ -388,6 +388,16 @@ main (int argc, char **argv)
the -L's in argv have been processed. */
set_scripts_dir ();
/* If we have not already opened and parsed a linker script,
try the default script from command line first. */
if (saved_script_handle == NULL
&& command_line.default_script != NULL)
{
ldfile_open_command_file (command_line.default_script);
parser_input = input_script;
yyparse ();
}
/* If we have not already opened and parsed a linker script
read the emulation's appropriate default script. */
if (saved_script_handle == NULL)

View File

@ -159,7 +159,8 @@ enum option_values
OPTION_WARN_UNRESOLVED_SYMBOLS,
OPTION_ERROR_UNRESOLVED_SYMBOLS,
OPTION_WARN_SHARED_TEXTREL,
OPTION_REDUCE_MEMORY_OVERHEADS
OPTION_REDUCE_MEMORY_OVERHEADS,
OPTION_DEFAULT_SCRIPT
};
/* The long options. This structure is used for both the option
@ -282,6 +283,10 @@ static const struct ld_option ld_options[] =
't', NULL, N_("Trace file opens"), TWO_DASHES },
{ {"script", required_argument, NULL, 'T'},
'T', N_("FILE"), N_("Read linker script"), TWO_DASHES },
{ {"default-script", required_argument, NULL, OPTION_DEFAULT_SCRIPT},
'\0', N_("FILE"), N_("Read default linker script"), TWO_DASHES },
{ {"dT", required_argument, NULL, OPTION_DEFAULT_SCRIPT},
'\0', NULL, NULL, ONE_DASH },
{ {"undefined", required_argument, NULL, 'u'},
'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"),
TWO_DASHES },
@ -1149,6 +1154,9 @@ parse_args (unsigned argc, char **argv)
parser_input = input_script;
yyparse ();
break;
case OPTION_DEFAULT_SCRIPT:
command_line.default_script = optarg;
break;
case OPTION_SECTION_START:
{
char *optarg2;

View File

@ -1,3 +1,13 @@
2007-01-19 H.J. Lu <hongjiu.lu@intel.com>
* ld-scripts/default-script.exp: New file.
* ld-scripts/default-script.s: Likewise.
* ld-scripts/default-script.t: Likewise.
* ld-scripts/default-script1.d: Likewise.
* ld-scripts/default-script2.d: Likewise.
* ld-scripts/default-script3.d: Likewise.
* ld-scripts/default-script4.d: Likewise.
2007-01-18 H.J. Lu <hongjiu.lu@intel.com>
PR ld/1283

View File

@ -0,0 +1,25 @@
# Test --default-script/-dT
# Copyright 2007
# Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
set test_list [lsort [glob -nocomplain $srcdir/$subdir/default-script*.d]]
foreach t $test_list {
# We need to strip the ".d", but can leave the dirname.
verbose [file rootname $t]
run_dump_test [file rootname $t]
}

View File

@ -0,0 +1,3 @@
.text
text:
.long 0

View File

@ -0,0 +1,7 @@
_START = DEFINED(_START) ? _START : 0x9000000;
SECTIONS
{
. = _START;
.text : {*(.text)}
/DISCARD/ : {*(*)}
}

View File

@ -0,0 +1,6 @@
# source: default-script.s
# ld: -defsym _START=0x8000000 -T default-script.t
# nm: -n
0*8000000 . _START
0*8000000 t text

View File

@ -0,0 +1,6 @@
# source: default-script.s
# ld: -T default-script.t -defsym _START=0x8000000
# nm: -n
0*8000000 . _START
0*9000000 t text

View File

@ -0,0 +1,6 @@
# source: default-script.s
# ld: -defsym _START=0x8000000 -dT default-script.t
# nm: -n
0*8000000 . _START
0*8000000 t text

View File

@ -0,0 +1,6 @@
# source: default-script.s
# ld: --default-script default-script.t -defsym _START=0x8000000
# nm: -n
0*8000000 . _START
0*8000000 t text