ld script expression - wrong result when mixing constants & symbols
Hi there
Hopefully I'm not doing something dumb here and overlooking it but I get odd/wrong results when I mix constants and symbols in my linker script and would be grateful for any help/advice that anybody can provide...
When I used this:
RAM_START_ADDRESS = 0x20000000; /* Must be the same value MEMORY region ram ORIGIN above. */
RAM_SIZE = 64k; /* Must be the same value MEMORY region ram LENGTH above. */
MAIN_STACK_SIZE = 8k; /* Cortex main stack size. */
PROCESS_STACK_SIZE = 4k; /* Cortex process stack size (only available with OS extensions).*/
...
.bss :
{
__bss_start__ = . ;
_sbss = .;
*(.shbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(0x10);
__bss_end__ = .;
_end = .;
__end = _end;
_ebss = .;
PROVIDE(end = .);
} >ram
.heap :
{
__heap_start__ = .;
. += (RAM_START_ADDRESS + RAM_SIZE - PROCESS_STACK_SIZE - MAIN_STACK_SIZE - _end); /* PROBLEM HERE! */
. = ALIGN(0x10);
_eheap = .;
} >ram
I get this in the map file:
.heap 0x200017b0 0x6000fda0
*fill* 0x200017b0 0x6000fda0
And the program fails to link:
'Building target: test.elf'
'Invoking: Cross ARM C Linker'
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -g3 -T ../CMSIS/
c:/users/
c:/users/
collect2.exe: error: ld returned 1 exit status
make: *** [test.elf] Error 1
The increment of the current location at the "PROBLEM HERE" line seems to be wrong. Because when I use this (i.e. literal integer value of _end instead of the symbol):
.heap :
{
__heap_start__ = .;
/* . += (RAM_START_ADDRESS + RAM_SIZE - PROCESS_STACK_SIZE - MAIN_STACK_SIZE - _end); */
. += (RAM_START_ADDRESS + RAM_SIZE - PROCESS_STACK_SIZE - MAIN_STACK_SIZE - 0x200017b0);
. = ALIGN(0x10);
_eheap = .;
} >ram
I get this and the program links fine:
.heap 0x200017b0 0xb850
*fill* 0x200017b0 0xb850
Any ideas?
If any further info is required let me know.
Thanks a lot for your attention.
Regards
TM
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Thomas Preud'homme
- Solved:
- Last query:
- Last reply: