The structure of an image is defined by the:
number of its constituent regions and output sections
positions in memory of these regions and sections when the image is loaded
positions in memory of these regions and sections when the image executes.
Each link stage has a different view of the image:
- ELF object file view (linker input)
The ELF object file view comprises input sections. The ELF object file can be:
a relocatable file that holds code and data suitable for linking with other object files to create an executable or a shared object file
an executable file that holds a program suitable for execution
a shared object file that holds code and data in the following contexts:
the linker processes the file with other relocatable and shared object files to create another object file
the dynamic linker combines the file with an executable file and other shared objects to create a process image.
- Linker view
The linker has two views for the address space of a program that become distinct in the presence of overlaid, position-independent, and relocatable program fragments (code or data):
The load address of a program fragment is the target address that the linker expects an external agent such as a program loader, dynamic linker, or debugger to copy the fragment from the ELF file. This might not be the address at which the fragment executes.
The execution address of a program fragment is the target address where the linker expects the fragment to reside whenever it participates in the execution of the program.
If a fragment is position-independent or relocatable, its execution address can vary during execution.
- ELF image file view (linker output)
The ELF image file view comprises Program Segments and output sections:
a load region corresponds to a Program Segment
an execution region corresponds to up to three output sections:
One or more execution regions make up a load region.
With armlink, the maximum size of a Program Segment is 2GB.
When describing a memory view:
the term root region is used to describe a region that has the same load and execution addresses
load regions are equivalent to ELF segments.
The following figure shows the relationship between the views at each link stage: