Image entry points
An entry point in an image is the location that is loaded into the PC. It is the location where program execution starts. Although there can be more than one entry point in an image, you can specify only one when linking.
Not every ELF file has to have an entry point. Multiple entry points in a single ELF file are not permitted.
NoteFor embedded Cortex-M programs, the program starts at whatever value is loaded into the PC from the Reset vector. Typically, the Reset vector points to the CMSIS
Types of entry point
There are two distinct types of entry point:
- Initial entry point
The initial entry point for an image is a single value that is stored in the ELF header file. For programs loaded into RAM by an operating system or boot loader, the loader starts the image execution by transferring control to the initial entry point in the image.
An image can have only one initial entry point. The initial entry point can be, but is not required to be, one of the entry points set by the
- Entry points set by the
You can select one of many possible entry points for an image. An image can have only one entry point.
You create entry points in objects with the
ENTRYdirective in an assembler file. In embedded systems, typical use of this directive is to mark code that is entered through the processor exception vectors, such as RESET, IRQ, and FIQ.
The directive marks the output code section with an
ENTRYkeyword that instructs the linker not to remove the section when it performs unused section elimination.
For C and C++ programs, the
__main()function in the C library is also an entry point.
If an embedded image is to be used by a loader, it must have a single initial entry point specified in the header. Use the
--entrycommand-line option to select the entry point.
The initial entry point for an image
There can be only one initial entry point for an image, otherwise linker warning
L6305W is output.
The initial entry point must meet the following conditions:
The image entry point must always lie within an execution region.
The execution region must not overlay another execution region, and must be a root execution region. That is, where the load address is the same as the execution address.
If you do not use the
--entry option to specify the initial entry point
If the input objects contain only one entry point set by the
ENTRYdirective, the linker uses that entry point as the initial entry point for the image.
The linker generates an image that does not contain an initial entry point when either:
More than one entry point has been specified by using the
No entry point has been specified by using the
For embedded applications with ROM at zero use
--entry , or optionally
for processors that are using high vectors.