2.5. Linking the application

Linker options

The linker must also be passed a number of options to successfully create a Linux executable.


This instructs the linker to use System V library linkage


Normally the linker will automatically add a reference to the library entry point function __main. However, as we will be using the GNU C library startup code the __main function will not be required and we do not need this reference. This switch instructs the linker not to add the reference.


This instructs the linker not to add a special reference to the standard C++ initialization function __cpp_initialize__aeabi_() when an object file contains global C++ objects whose constructors must be called at startup. We instead use the GNU C library equivalent, __libc_csu_init(), to perform this initialization as part of the standard GNU application startup code, and no special linker reference is required.


You must specify the paths to the GNU libraries. In a typical CodeSourcery installation, you are likely to need:


Prevents the search on the RVCT libraries. See section 3.1.3 for further details.

‑‑entry _start

Your image must have its entry point set to the GNU C library initialization code.

‑‑keep *(.init), ‑‑keep *(.fini), ‑‑keep *(.init_array), ‑‑keep *(.fini_array)

These options instruct the linker not to remove the C++ global constructor and destructor tables.


The linker should also be given the path to the dynamic linker that Linux will look for when executing the application. If you do not specify a dynamic linker at build time, or the specified linker is missing, you can manually call a dynamic linker at run-time. For example:

> /libeabi/ld-linux.so.3 /opt/bin/eabi/application

Optional linker switches


This can be used to specify the location of the shared libraries required. Please note this is only available in RVCT 3.0 SP1 (build 586 and later).

Further details of the linker command-line switches specific to building Linux applications can be found in section 6.2 of the RVCT 3.0 Linker and Utilities Guide.

Linking with the library objects

With the correct library paths in place, the GNU libraries should be linked with your application. A full list including a discussion of the functions included is given in section 3.2.

Copyright © 2005-2006. All rights reserved.DAI0150B