4

GNU's linker obtains the ARM Cortex's stack pointer value from the linker script, and places that value in the first location of the interrupt vector table.

I note that most of my scripts use the symbol _estack to define the "end of stack" (memory region--which is actually the "top of the stack"), which is also the value the linker uses to populate the vector table's MSP location in the final linked image.

Is _estack the (required) symbol the linker uses to generate the MSP? Or, is there another symbol or mechanism GNU's linker uses/can use?

CMiller
  • 51
  • 4

1 Answers1

1

Apparently, there is no special behavior of the GNU linker in obtaining the MSP value: the value is used in the CMSIS-defined vector table, provided by the micro vendor, and defined in the startup file (startup_stm32F303xc.s in my project):

/******************************************************************************
*
* The minimal vector table for a Cortex M4. Note that the proper constructs
* must be placed on this to ensure that it ends up at physical address
* 0x0000.0000.
*
*******************************************************************************/
   .section  .isr_vector,"a",%progbits
  .type  g_pfnVectors, %object
  .size  g_pfnVectors, .-g_pfnVectors


g_pfnVectors:
    .word   _estack
    .word   Reset_Handler
    .word   NMI_Handler
    ...

I had assumed the linker somehow obtained the MSP value (_estack) from the linker script. It is the assembly, however, that simply stubs the value of _estack, which the linker later resolves. Nothing cryptic--just a plain old table of initialized data, placed by the linker at the appropriate address for the microprocessor.

I suppose _estack is simply the canonical symbol used by CMSIS-based projects and linker scripts.

CMiller
  • 51
  • 4