Strange linker behavior or broken map file in case of assembler memory arrays allocated using .skip or .space
Hi,
I am using GCC ARM Embedded 4.7 update 4. I am using the standard assembler start-up file templates from ARM CMSIS 4.2 (CMSIS-
The system heap and system stack are allocated as follows (only stack is shown, heap is very similar; stripped down inactive conditional switches):
.syntax unified
.arch armv7-m
.section .stack
.align 3
.equ Stack_Size, __STACK_SIZE
.globl __StackTop
.globl __StackLimit
__StackLimit:
.space Stack_Size
.size __StackLimit, . - __StackLimit
__StackTop:
.size __StackTop, . - __StackTop
The linker script is again the same basic setup from CMSIS (stripped down comments):
.heap (COPY):
{
__HeapBase = .;
__end__ = .;
end = __end__;
KEEP(*(.heap*))
__HeapLimit = .;
} > RAM
.stack_dummy (COPY):
{
KEEP(*(.stack*))
} > RAM
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
__StackLimit = __StackTop - SIZEOF(
PROVIDE(__stack = __StackTop);
The produced map file for such a configuration with base default RAM memory region (no fancy changes, or anything special) looks as follows:
.heap 0x20003730 0x358
*(.heap*)
.heap 0x20003730 0x358 build/startup.o
.stack_dummy 0x20003730 0x100
*(.stack)
.stack 0x20003730 0x100 build/startup.o
Why does the .heap and .stack_dummy sections start from the same address?
__HeapLimit is correctly set by using the "." variable which is the actual location pointer used by ld. So based on the linker script above ld should not reset the location pointer back to the address of __HeapBase when the actual location is already at __HeapLimit.
The issue seems to be somehow related to the assembler start-up code and the use of the .space (same as .skip) keyword to allocate space for an array in assembly.
Do you know what could be the problem? Or how to overcome the issue without switching to the C implementation of the startup file from ARM CMSIS? The __StackTop and __StackLimit symbols are correctly set I know, but as soon as I would want to relocate the system heap or the system stack to somewhere else it really causes problems...
Thanks in advance for your kind response.
Best regards,
Tamas
_
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Tamas Kleiber
- Solved:
- Last query:
- Last reply: