Linker script ASSERT syntax errors

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by OldManVimes on Sun Feb 01 08:51:45 MST 2015
Hello Support,

I think I have found a small issue with the managed linker scripts. I was trying to use the ASSERT statement using the one from the CRP as an example. Here's the CRP snippet that LPCXpresso 7.4 generates.

/* Code Read Protect data */
. = 0x000002FC ;
ASSERT(!(__CRP_WORD_START__ == __CRP_WORD_END__), "Linker CRP Enabled, but no CRP_WORD provided within application");
/* End of Code Read Protect */

Note the semi colon at the rear of the ASSERT. So I copied that line into my non managed linker script in order to create a check for clashes in the heap and stack, like so:

PROVIDE(_pvHeapStart = .);
PROVIDE(_pvHeapLimit = __top_local_sram - 0x2000);
ASSERT(_pvHeapStart <= (_pvHeapLimit - 0x1000), "Not enough ram for specified heap and stack")
PROVIDE(_vStackTop = __top_local_sram - 32);

Note that the ASSERT has no semi colon. The reason being that I kept getting syntax errors from ld when one was there. I guess the difference is caused by the fact that the CRP one is at the end of a section, whereas mine has an additional PROVIDE statement following the ASSERT. The GNU ld manual states that ASSERT has no semi colon, but a PROVIDE does.

So if you agree then you can improve the managed script generation by not appending a semi colon behind ASSERT statements. It would have saved me a good 15 minutes of not understanding why my ASSERT did not parse as valid.

Kind regards,