Reputation: 6006
I have two linker scripts: common.ld
which defines some symbols, and app.ld
which positions the sections, using these defines.
If I just cat the two files together, and feed that to ld (via gcc), it works.
If I use the INCLUDE
command:
INCLUDE common.ld
I get the error:
ld.exe: invalid syntax in flags
collect2: ld returned 1 exit status
What do I do wrong? What is a correct statement to include another load script?
From http://www.scoberlin.de/content/media/http/informatik/gcc_docs/ld_3.html#IDX204 :
INCLUDE filename
Include the linker script filename at this point. The file will be searched for in the current directory, and in any directory specified with the -L option. You can nest calls to INCLUDE up to 10 levels deep.
Note: I'm running this on a Windows 7 PC, using arm gcc tools from Code Red, full version:
arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.6.2 20121016 (release) [ARM/embedded-4_6-branch revision 192487
Upvotes: 9
Views: 18518
Reputation: 19965
This one is interesting. Apparently there is a bug in the ld command file lexer. I'm using binutils version 2.24 and had the same problem. One of your included files has a MEMORY command something like
MEMORY
{
rom (rx) : ORIGIN = 0x00000000, LENGTH = 64M
ram (!rx) : ORIGIN = 0x48000000, LENGTH = 32M
}
I think (but haven't proven) that the lexer is returning "!rx" instead of "rx" for the second attribute in an included file. Changing the MEMORY command to
MEMORY
{
rom (rx) : ORIGIN = 0x00000000, LENGTH = 64M
ram (! rx) : ORIGIN = 0x48000000, LENGTH = 32M
}
fixes the problem. I looked at ldlex.l and ldgram.y in the ld sources but couldn't find an obvious error before my eyes started to hurt.
Bug report: https://sourceware.org/bugzilla/show_bug.cgi?id=17900
Upvotes: 11
Reputation: 323
I update my toolchain from arm_eabi-2011.03 to arm-2012.09. then problem appeared. I have to copy the INCLUDEd file to my link script, in order to avoid the "flag" issue.
I wonder how could a new version of toolchain ruined older version functions?
Upvotes: 0
Reputation: 6632
The include syntax should be correct, INCLUDE common.ld
works fine here.
Maybe the Windows version of ld had a bug, or maybe there was something wrong with either one of your linker scripts or the environment?
Upvotes: 1