Absolute Variables and Linking

Special attention is needed if absolute variables are involved in the linker's link process. Unless the absolute object is referenced by the application, the absolute object always links in ELF/DWARF format, not HIWARE format. To force linking, switch off smart linking in the Linker, or use the ENTRIES command in the linker parameter file.

Note: Interrupt vector entries are always linked.

The following example shows linker handling of different absolute variables.

Listing: Linker Handling of Absolute Variables
      char i;         /* zero out            */
      char j = 1;     /* zero out, copy-down */

const char k = 2;     /* download  */

      char I@0x10;    /* no zero out! */

      char J@0x11 = 1;/* copy down    */

const char K@0x12 = 2;/* HIWARE: copy down / ELF: download! */

static       char L@0x13;      /* no zero out! */

static       char M@0x14 = 3;  /* copy down    */

static const char N@0x15 = 4;  /* HIWARE: copy down, ELF: download */

void interrupt 2 MyISRfct(void) {} /* download, always linked! */

  /* vector number two is downloaded with &MyISRfct */

void myfun(char *p) {} /* download */

void main(void) { /* download */

  myfun(&i); myfun(&j); myfun(&k);

  myfun(&I); myfun(&J); myfun(&K);

  myfun(&L); myfun(&M); myfun(&N);

}

Zero out means that the default startup code initializes the variables during startup. Copy down means that the variable is initialized during the default startup. To download means that the memory is initialized while downloading the application.