ld: Output Section Address

1 
1 3.6.3 Output Section Address
1 ----------------------------
1 
1 The ADDRESS is an expression for the VMA (the virtual memory address) of
1 the output section.  This address is optional, but if it is provided
1 then the output address will be set exactly as specified.
1 
1    If the output address is not specified then one will be chosen for
1 the section, based on the heuristic below.  This address will be
1 adjusted to fit the alignment requirement of the output section.  The
1 alignment requirement is the strictest alignment of any input section
1 contained within the output section.
1 
1    The output section address heuristic is as follows:
1 
1    * If an output memory REGION is set for the section then it is added
1      to this region and its address will be the next free address in
1      that region.
1 
1    * If the MEMORY command has been used to create a list of memory
1      regions then the first region which has attributes compatible with
1      the section is selected to contain it.  The section's output
11      address will be the next free address in that region; ⇒
      MEMORY.
1 
1    * If no memory regions were specified, or none match the section then
1      the output address will be based on the current value of the
1      location counter.
1 
1 For example:
1 
1      .text . : { *(.text) }
1 
1 and
1 
1      .text : { *(.text) }
1 
1 are subtly different.  The first will set the address of the '.text'
1 output section to the current value of the location counter.  The second
1 will set it to the current value of the location counter aligned to the
1 strictest alignment of any of the '.text' input sections.
1 
1    The ADDRESS may be an arbitrary expression; ⇒Expressions.  For
1 example, if you want to align the section on a 0x10 byte boundary, so
1 that the lowest four bits of the section address are zero, you could do
1 something like this:
1      .text ALIGN(0x10) : { *(.text) }
1 This works because 'ALIGN' returns the current location counter aligned
1 upward to the specified value.
1 
1    Specifying ADDRESS for a section will change the value of the
1 location counter, provided that the section is non-empty.  (Empty
1 sections are ignored).
1