2.5. Linking the application

Linker options

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

‑‑sysv

This instructs the linker to use System V library linkage

‑‑no_startup

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.

‑‑no_ref_cpp_init

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.

‑‑userlibpath=…

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

$(CSL_ROOT)/arm-none-linux-gnueabi/libc/usr/lib
$(CSL_ROOT)/arm-none-linux-gnueabi/libc/lib
$(CSL_ROOT)/arm-none-linux-gnueabi/lib
$(CSL_ROOT)/lib/gcc/arm-none-linux-gnueabi/$(GCC_VNUM)
‑‑no_scanlib

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.

‑‑dynamiclinker=…

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

‑‑rpath=…

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
Non-Confidential