Linker script question and/or bug

Michael Eager eager@eagercon.com
Mon Dec 25 09:34:00 GMT 2006


Nick Clifton wrote:
> Hi Michael,
>> 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.
> 
> Why not pass the linker script name as a gcc command line option as 
> well.  ie:
> 
>   gcc -Wl,-defym,_START=0x800000 -Wl,-Tscript.ld

That works.   But if you specify the options in the
reverse order, it fails.

I'll post a patch which moves processing user-specified
linker scripts to the same place as default linker scripts.

-- 
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077



More information about the Binutils mailing list