Reputation: 319
I could not find a clear answer to a very specific problem, even after reading several manual pages and guides. I work on a linker script for the tool chain mentioned in the title. During the development I was tying to link a static library (archived, .a) to a location in my RAM. I could not accomplish this task by handling it like a regular .o file as in the following example:
SECTIONS {
outputa 0x10000 :
{
all.o
foo.o (.input1)
}
outputb :
{
foo.o (.input2)
foo1.o (.input1)
}
outputc :
{
*(.input1)
*(.input2)
}
}
After a long journey, I found a hint in another Question. That lead me to my current solution:
...
.ramlib : ALIGN(4)
{
*liblpcspifilib_M3.a: (*);
} > RamLoc40 AT>MFlashA512
...
Please note the colon syntax. This will link all contents of liblpcspifilib
as a block to the Ram. However without the ":" it won't link anything. Even after I found out how to solve the issue, I could not find any other information about that behaviour.
Can anyone explain this to me?
Upvotes: 3
Views: 136
Reputation: 18299
For some reason this information is hard to find in the official GNU docs, so I assume it is some kind of extension. Here on page 50 is telling us:
You can also specify files within archives by writing a pattern matching the archive, a colon, then the pattern matching the file, with no whitespace around the colon.
‘archive:file’ matches file within archive ‘archive:’ matches the whole archive ‘:file’ matches file but not one in an archive
Upvotes: 1