When all constant and code sections as well as data sections can be allocated consecutively, the
PRM file used to assemble the example above can be defined as the following listing displays.
Listing: PRM file
LINK test.abs/* Name of the executable file generated. */
NAMES test.o /* Name of the object file in the application */
END
SECTIONS
/* READ_ONLY memory area. */
MY_ROM = READ_ONLY 0x8000 TO 0xFDFF;
/* READ_WRITE memory area. */
MY_RAM = READ_WRITE 0x0100 TO 0x023F;
END
PLACEMENT
/* Relocatable variable sections are allocated in MY_RAM. */
DEFAULT_RAM, dataSec , SSTACK INTO MY_RAM;
/* Relocatable code and constant sections are allocated in MY_ROM. */
DEFAULT_ROM, constSec INTO MY_ROM;
END
INIT entry /* entry is the entry point to the application. */
VECTOR ADDRESS 0xFFFE entry /* Initialization for Reset vector.*/
The linker PRM file contains at least:
- The name of the absolute file (LINK command).
- The name of the object files which should be linked (NAMES command).
- The specification of a memory area where the sections containing variables must be allocated. At least the predefined DEFAULT_RAM section (or its ELF alias .data) must be placed there (SECTIONS and PLACEMENT commands).
- The specification of a memory area where the sections containing code or constants must be allocated. At least, the predefined DEFAULT_ROM section (or its ELF alias .text) must be placed there (SECTIONS and PLACEMENT commands).
- Constants sections should be defined in the ROM memory area in the PLACEMENT section (otherwise, they are allocated in RAM).
- The specification of the application entry point (INIT command).
- The definition of the reset vector (VECTOR ADDRESS command).
According to the PRM file above:
- the dataSec section will be allocated starting at 0x0080.
- the codeSec section will be allocated starting at 0x0B00.
- the constSec section will be allocated next to the codeSec section.