Image entry points
An entry point in an image is a location where program execution can start. Although there can be more than one entry point in an image, only one can be specified when linking.
Not every ELF file has to have an entry point. Multiple entry points in a single ELF file are not permitted.
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.