I want to get the address of the end of my program and check the compilation / linker time, if I have enough space, after the code to post some random data at runtime.
But since the characters provided by the PROVIDE keyword are similar to regular variables in C code, I cannot verify it at compile time.
In the script builder, I have a symbol:
PROVIDE (__data_end_rom = _etext + SIZEOF (.data));
Therefore, I can use this character to get the address of the end of my code:
extern u16 __data_end_rom;
I can calculate the available memory if I assume that the end address is 0xffff:
#define AVAILABLE_MEM (0Xffff - &__data_end_rom)
And I thought to check the available memory with _Static_assert (cond, message) provided in gcc 4.6
_Static_assert(SIZE_I_WANT_TO_ASSURE <= AVAILABLE_MEM, "NOT ENOUGH MEMORY!!!");
My problem: the macro AVAILABLE_MEM is not calculated at compile time, so I get the error:
error: expression in static assertion is not constant
Is it possible to specify the address __data_end_rom directly on the label or in another way?
I know that I cannot get it at compile time, because the character will just be bound at the time of the linker, so is there a way to make the linker fail?
I could check this directly in the script linker, but I don't want to do this because SIZE_I_WANT_TO_ASSURE is another macro computed from other macros in the configuration header.