+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
-*- 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
.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;
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
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)
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
'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 },
parser_input = input_script;
yyparse ();
break;
+ case OPTION_DEFAULT_SCRIPT:
+ command_line.default_script = optarg;
+ break;
case OPTION_SECTION_START:
{
char *optarg2;
+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
--- /dev/null
+# 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]
+}
+
--- /dev/null
+ .text
+text:
+ .long 0
--- /dev/null
+_START = DEFINED(_START) ? _START : 0x9000000;
+SECTIONS
+{
+ . = _START;
+ .text : {*(.text)}
+ /DISCARD/ : {*(*)}
+}
--- /dev/null
+# source: default-script.s
+# ld: -defsym _START=0x8000000 -T default-script.t
+# nm: -n
+
+0*8000000 . _START
+0*8000000 t text
--- /dev/null
+# source: default-script.s
+# ld: -T default-script.t -defsym _START=0x8000000
+# nm: -n
+
+0*8000000 . _START
+0*9000000 t text
--- /dev/null
+# source: default-script.s
+# ld: -defsym _START=0x8000000 -dT default-script.t
+# nm: -n
+
+0*8000000 . _START
+0*8000000 t text
--- /dev/null
+# source: default-script.s
+# ld: --default-script default-script.t -defsym _START=0x8000000
+# nm: -n
+
+0*8000000 . _START
+0*8000000 t text