Keil Logo

Linker Location Controls

One method of referencing explicit memory locations using C variables is to declare the variables in a stand-alone C module and use the linker location directives to locate them at an absolute memory address.

In the following example, the alarm_control structure is defined containing the variables to locate.

.
.
.
struct alarm_st  {
  unsigned int alarm_number;
  unsigned char enable flag;
  unsigned int time_delay;
  unsigned char status;
 };

struct alarm_st alarm_control;
.
.
.

The CARM Compiler generates an object file for ALMCTRL.C and includes a segment for variables. Since alarm_control is the only variable declared in this module, it is the only variable in the DATA segment. The name of the segment is ?DT0?ALMCTRL. If the NOINIT directive was used the section is named ?DTN?ALMCTRL.

The LARM Linker can locate a segment at a specific address. The following example shows how to locate the ?DT0?ALMCTRL segment starting at address 0x00108000.

LA ... almctrl.obj SEGMENTS(?DT0?ALMCTRL(0x00108000)) ...

The SEGMENTS linker directive instructs the linker to locate the section named ?DT0?ALMCTRL at address 0x00108000. Refer to the LARM Linker User's Guide for more information.

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.