Question about ADDR(SECTION) of ld in document

Cao jin
Wed Oct 31 13:04:00 GMT 2018

(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:

     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
          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?

Cao jin

More information about the Binutils mailing list