3.1.4. Image entry points

An entry point in an image is a location where program execution can start. 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.

There can be only one initial entry point in an image. The initial entry point can be, but is not required to be, one of the entry points set by the ENTRY directive.

Entry points set by the ENTRY directive

These are entry points that are set in the assembly language sources with the ENTRY directive. In embedded systems, this directive is typically used to mark code that is entered through the exception vectors.

Specifying an initial entry point

You can specify an initial entry point with the -entry linker option. You can specify the -entry option only once. See the description in armlink command syntax for more information.

An image must contain an initial entry point if it is to be executed by a loader, such as a boot loader or operating system program loader. For example, an image that is an OS is loaded by the boot loader and entered at the initial entry point specified in the executable file header. After the image is loaded it overwrites the boot loader and becomes the OS. In the case of an operating system, the image contains additional entry points, such as the exception handler addresses.

For embedded applications with ROM at zero use -entry 0x0 (or 0xffff0000 for CPUs that have high vectors).

The initial entry point must meet the following conditions:

  • the image entry point must always lie within an execution region

  • the execution region must be non-overlay, and must be a root region (the load address is the same as the execution address).

If you do not use the -entry option to specify the initial entry point the linker attempts to set one if it can:

  • If you do not use the -entry option and the input objects contain only one entry point set by the ENTRY directive, the linker uses that entry point as the initial entry point for the image.

  • The linker generates an output object that does not contain an initial entry point if you do not use the -entry option and either:

    • more than one entry point has been specified by using the ENTRY directive

    • no entry point has been specified by using the ENTRY directive.

    If the output object does not contain an initial entry point, the linker issues the following warning:

    L6305W: Image does not have an entry point. (Not specified or not set due to multiple choices)
    

Specifying multiple entry points

An embedded image can have multiple entry points. For example, an embedded image typically has entry points that are used by the Reset, IRQ, FIQ, SVC, UNDEF, and ABORT exceptions to transfer control when the image is running.

You can specify multiple entry points in an image with the ENTRY directive. The directive marks the output code section with an ENTRY keyword 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. See RealView Compilation Tools for BREW Assembler Guide for more information on the ENTRY directive.

If an embedded image is to be used by a loader, it must have a single initial entry point specified in the header. See Specifying an initial entry point for more information.

Copyright © 2002 ARM Limited. All rights reserved.ARM DUI 0212A
Non-Confidential