Checking the startup file provided as an example in the GNU ARM toolchain, I couldnt understand one thing. Code snippets provided here are taken from examples included in GNU ARM Embedded Toolchain files downloaded from your website. Code compiles and everything seems to be good.I am wondering why its written this way, why you are using same names for example?I am wondering why my linker is not complaining about multiple definition error for `__StackTop` and `__StackLimit`. Here is the part of the file `startup_ARMCM0.S`
.syntax unified .arch armv6-m .section .stack .align 3 #ifdef __STACK_SIZE .equ Stack_Size, _*emphasized text*_STACK_SIZE #else .equ Stack_Size, 0xc00 #endif .globl __StackTop .globl __StackLimit __StackLimit: .space Stack_Size .size __StackLimit, . - __StackLimit __StackTop: .size __StackTop, . - __StackTop
.stack_dummy (COPY): { *(.stack*) } > RAM /* Set stack top to end of RAM, and stack limit move down by * size of stack_dummy section */ __StackTop = ORIGIN(RAM) + LENGTH(RAM); __StackLimit = __StackTop - SIZEOF(.stack_dummy); PROVIDE(__stack = __StackTop);
While checking linker documentation, it was written that, given the example:
SECTIONS { .text : { *(.text) _etext = .; PROVIDE(etext = .); } }