This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to put unrefered variable in the image

Hi, everybogy

I created a simple example project consist of only one source code file main.c, within Keil MDK 3.24 Eval as below.

//*****************************************************

#include <lpc23xx.h>

unsigned int variable0 __attribute__((section("sec_data"), used)) = 0x55AA55AA;

//*****************************************************

int main (void)
{ unsigned int i;

while (1) { i++; }
}

// End of File

And when I compiled and linked the example using a scatter loading descrption file, one warning feedback produced by the linker read like this.

"Prj1.sct(14): warning: L6329W: Pattern *.o(sec_data) only matches removed unused sections."

The warning message above showed that the section sec_data had been removed by linker for the reason of no refered by the source code explicitly.

The scatter description file causing the warning read as below

LR_IROM1 0x00000000 0x00080000
{

ER_IROM1 0x00000000 0x00080000

{

*.o (RESET, +First)

*(InRoot$$Sections)

.ANY (+RO)

}

TABLE 0x40000000 0x20

{

*.o(sec_data)

}

RW_IRAM1 0x40001000 0x00001000

{

.ANY (+RW +ZI)

}

}


How can I restain the unrefered variable variable0 in the last image?
Please give your hand!

Parents Reply Children
  • to : Per Westermar and Andy Neil

    According to Chapter4.5 in Compiler Reference Guide(ARM DUI 0348A) from ARM, the attribute declaration part '__attribute__((section("sec_data"), used))' was used to inform the C compiler not ignore variable0 when compiling, even though it is not refered in source code explicitly.

    The magic value 0x55AA55AA was used for convenient check in memory watching window when debugging.