You copied the Doc URL to your clipboard.

Methods of placing functions and data at specific addresses

Normally, the compiler produces RO, RW and ZI sections from a single source file. These regions contain all the code and data from the source file. To place a single function or data item at a fixed address, you must enable the linker to process the function or data separately from the rest of the input files.

The linker has two methods that enable you to place a section at a specific address:

  • You can create a scatter file that defines an execution region at the required address with a section description that selects only one section.

  • For a specially-named section the linker can get the placement address from the section name. These specially-named sections are called __at sections.

To place a function or variable at a specific address it must be placed in its own section. There are several ways to do this:

  • Place the function or data item in its own source file.

  • Use __attribute__((section("name"))) to place functions and variables in a named section.

  • Use the AREA directive from assembly language. In assembly code, the smallest locatable unit is an AREA.

  • Use the -ffunction_sections compiler option to generate one ELF section for each function in the source file.

    This option results in a small increase in code size for some functions because it reduces the potential for sharing addresses, data, and string literals between functions. However, this can help to reduce the final image size overall by enabling the linker to remove unused functions when you specify armlink --remove.

Was this page helpful? Yes No