BSP and Device Driver Development Guide
An embedded systems programmer must be much more aware of the placement of their executable image in memory than the average applications programmer. A program destined to be embedded as well as the target system have some specific properties that must be taken into account. Embedded machines often mean average performances and small memory usage. It is the memory usage that concerns us when examining the linker command file.
Two types of memories have to be distinguished:
Even though RAM and ROM can be found in every personal computer, one generally doesn't care about them. In a personal computer, a program is nearly always stored on disk and executed in RAM. Things are a bit different for embedded targets: the target will execute the program each time it is rebooted or switched on. The application program is stored in non-volatile memory such as ROM, PROM, EEPROM, or Flash. On the other hand, data processing occurs in RAM.
This leads us to the structure of an embedded program. In rough terms, an embedded program is made of sections. It is the responsibility of the application programmer to place these sections in the appropriate place in target memory. To make this clearer, if using the COFF object file format on the Motorola m68k family of microprocessors, the following sections will be present:
.text
) section:
is the program's code and it should not be modified.
This section may be placed in ROM.
.bss
) section:
holds uninitialized variables of the program. It can stay in RAM.
.data
) section:
holds the initialized program data which may be modified during the
program's life. This means they have to be in RAM.
On the other hand, these variables must be set to predefined values, and
those predefined values have to be stored in ROM.
NOTE: Many programs and support libraries unknowingly assume that the
.bss
section and, possibly, the application heap are initialized
to zero at program start. This is not required by the ISO/ANSI C Standard
but is such a common requirement that most BSPs do this.
That brings us up to the notion of the image of an executable: it consists of the set of the sections that together constitute the application.
BSP and Device Driver Development Guide
Copyright © 1988-2000 OAR Corporation