Cao jin
2018-10-31 13:01:45 UTC
Hi,
(Please CC me when reply because I didn't subcribe)
I am learning linker script recently via reading the GUN linker
document. I find one piece of words confusing me, not sure if it is an
error in document. In "3.10.9 Builtin Functions" of `info ld`, there is:
'ADDR(SECTION)'
Return the address (VMA) of the named SECTION. Your script must
previously have defined the location of that section. In the
following example, 'start_of_output_1', 'symbol_1' and 'symbol_2'
are assigned equivalent values, except that 'symbol_1' will be
relative to the '.output1' section while the other two will be
absolute:
SECTIONS { ...
.output1 :
{
start_of_output_1 = ABSOLUTE(.);
...
}
.output :
{
symbol_1 = ADDR(.output1);
symbol_2 = start_of_output_1;
}
... }
My intuition tell me the symbol_1's value is relative to the ".output"
section, not ".output1", which is also the offset inside ".output", and
symbol_2's value is the same as symbol_1.
Why is that?
Sincerely,
Cao jin
(Please CC me when reply because I didn't subcribe)
I am learning linker script recently via reading the GUN linker
document. I find one piece of words confusing me, not sure if it is an
error in document. In "3.10.9 Builtin Functions" of `info ld`, there is:
'ADDR(SECTION)'
Return the address (VMA) of the named SECTION. Your script must
previously have defined the location of that section. In the
following example, 'start_of_output_1', 'symbol_1' and 'symbol_2'
are assigned equivalent values, except that 'symbol_1' will be
relative to the '.output1' section while the other two will be
absolute:
SECTIONS { ...
.output1 :
{
start_of_output_1 = ABSOLUTE(.);
...
}
.output :
{
symbol_1 = ADDR(.output1);
symbol_2 = start_of_output_1;
}
... }
My intuition tell me the symbol_1's value is relative to the ".output"
section, not ".output1", which is also the offset inside ".output", and
symbol_2's value is the same as symbol_1.
Why is that?
Sincerely,
Cao jin