This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Linker script question and/or bug
- From: Michael Eager <eager at eagercon dot com>
- To: binutils at sourceware dot org
- Date: Wed, 20 Dec 2006 10:47:14 -0800
- Subject: Linker script question and/or bug
I want to write a linker script which specifies
the start address using symbol specified on the command
line, but which will have a default value if it isn't specified.
Something like the following excerpt:
_START = DEFINED(_START) ? _START : 0xF0000000;
SECTIONS
{
. = _START
.text :
{
. . .
}
. . .
}
This works if the symbol is defined before the linker
script, but not if it is in the other order:
Works: ld -defsym _START=0x8000000 -Tscript.ld
Fails: ld -Tscript.ld -defsym _START=0x8000000
This is because the linker script is parsed as soon
as the -T option is seen, rather than after all command
line options are processed. This is a problem because
gcc doesn't treat the default linker script the same
as one specified as a linker option: the default
linker script is passed early on the command line,
while options specified by -Wl,... are tagged on at
the end of the command line.
Is there another way to write a linker script to have
the same result?
Should parsing the linker script be moved after
all command line args have been seen? The processing
of default scripts is done after all command line
args are processed. It would seem that a user-specified
linker script should be processed in the same place.
--
Michael Eager eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306 650-325-8077