This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Question about ADDR(SECTION) of ld in document


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]