9.2.2. The base platform linking model

The BPABI model described in Base Platform Application Binary Interface (BPABI) linking model has a fixed memory map. Unfortunately, this prevents users of a non-contiguous memory model from using the BPABI model. In the past, it was possible to use the legacy model (--reloc), however, this model is only partially supported and documented, and moreover uses non ABI-compliant dynamic relocations. Therefore, the BPABI model is not suitable for bare-metal systems that have a fixed static address but need to access some dynamic content.

In RVCT 4.0 and later a new --base_platform option exists, which merges the features of the BPABI and legacy models. This means that users of a non-contiguous memory model can link dynamically and also describe their memory layout using a scatter-loading description file. Not only is it possible to describe the memory map of the executable image, but it is also possible to describe the memory map of the shared library. Being able to describe the memory layout allows the user to give extra information to the dynamic linker. The following example scatter-loading description file below shows a critical code section being placed at address 0x9000 (fast memory), and a non-critical code section being placed at address 0x10000 (slow memory). This scatter-file describes the ideal memory layout for different sections within a shared library. The RELOC scatter-loading attribute informs armlink that the sections are relocatable and that the linker must generate dynamic relocations for any module trying to access these sections.

LR1 0x9000 RELOC
{
    FAST_MEMORY +0
    {
        ; place critical function here
    }
}

LR2 0x10000 RELOC
{
    SLOW_MEMORY +0
    {
        ; place non-critical function here
    }
}

The dynamic linker can use this extra information to place each section appropriately. If another module already exists at the address described in the scatter-file, and it is undesirable to overwrite that module, the dynamic linker loads the relevant section to the next most suitable address. If there is no more memory available at all, then the dynamic linker has to unload or overwrite an existing, low priority module, and reload it again later if required.

The examples/example_9-2 directory, provided as part of this application note, shows how to build a shared library targeted at the Base Platform linking model. Additionally, many more example scatter-files for the Base Platform model are available in:

ARM Compiler toolchain Using the Linker.

Copyright © 2010 ARM. All rights reserved.ARM DAI 0242A
Non-ConfidentialID011411