Placing sections
The default configuration file that you selected places all predefined sections in memory, but there are situations when you might want to modify this. For example, if you want to place the section that holds constant symbols in the CONSTANT region instead of in the default place. In this case, use the place in directive, for example:
/* Place sections with readonly content in the ROM region */
place in ROM {readonly};
/* Place the constant symbols in the CONSTANT region */
place in CONSTANT {readonly section .rodata};Note
Placing a section—used by the IAR build tools—in a different memory which use a different way of referring to its content, will fail.
For the result of each placement directive after linking, inspect the placement summary in the map file (the command line option ‑‑map).
Placing a section at a specific address in memory
To place a section at a specific address in memory, use the place at directive, for example:
/* Place section .vectors at address 0 */
place at address Mem:0x0 {readonly section .vectors};Placing a section first or last in a region
To place a section first or last in a region is similar, for example:
/* Place section .vectors at start of ROM */
place at start of ROM {readonly section .vectors};Declare and place your own sections
To declare new sections—in addition to the ones used by the IAR build tools—to hold specific parts of your code or data, use mechanisms in the compiler and assembler. For example:
/* Place a variable in that section. */ const short MyVariable @ "MYOWNSECTION" = 0xF0F0;
This is the corresponding example in assembler language:
name createSection
section MYOWNSECTION:CONST ; Create a section,
; and fill it with
dc16 0xF0F0 ; constant bytes.
endTo place your new section, the original place in ROM {readonly}; directive is sufficient.
However, to place the section MyOwnSection explicitly, update the linker configuration file with a place in directive, for example:
/* Place MyOwnSection in the ROM region */
place in ROM {readonly section MyOwnSection};