I want to use an address named _end from the linker.ld file in main.c.
I know this address to be atleast 0x80000000. But when importing it like this extern char _end; in main.c and printing it I only get 17.
The linker.ld file is something like this :
SECTIONS {
. = 0x80000000;
/*some more code and sections (doesnt matter)*/
_end = .;
}
Does anyone why this is happening or how I should import _end?
Thx in advance, jip.
>Solution :
It is a symbol only. You can only get its reference. You do not "import it"
extern char _end;
void foo(void)
{
printf("%u", (unsigned)&_end);
}
or
extern char _end[];
void foo(void)
{
printf("%u", (unsigned)_end);
}
For those who will complain about format and conversion. It is likely to be STM32 and nano library for this MCU does not support %zu and %p and sizeof(int) == sizeof(char *)