SLAU131V October 2004 – February 2020
The dot operator (.) is used to define symbols at link-time with a particular address inside of an output section. It is interpreted like a PC. Whatever the current offset within the current section is, that is the value associated with the dot. Consider an output section specification within a SECTIONS directive:
outsect:
{
s1.c.obj(.text)
end_of_s1 = .;
start_of_s2 = .;
s2.c.obj(.text)
end_of_s2 = .;
}
This statement creates three symbols:
Suppose there is padding between s1.c.obj and s2.c.obj created as a result of alignment. Then start_of_s2 is not really the start address of the .text section in s2.c.obj, but it is the address before the padding needed to align the .text section in s2.c.obj. This is due to the linker's interpretation of the dot operator as the current PC. It is also true because the dot operator is evaluated independently of the input sections around it.
Another potential problem in the above example is that end_of_s2 may not account for any padding that was required at the end of the output section. You cannot reliably use end_of_s2 as the end address of the output section. One way to get around this problem is to create a dummy section immediately after the output section in question. For example:
GROUP
{
outsect:
{
start_of_outsect = .;
...
}
dummy: { size_of_outsect = . - start_of_outsect; }
}