Issue
When I am using GCC for ARM operating-system development, I can't use local-variable because the stack wasn't initialized, so how do I tell compiler initialize SP?
Solution
My experience is with the Cortex-M, and as @n-pronouns-m said it is the linker, not the compiler or assembler, that "sets up" the stack. All that is necessary is to place the initial stack pointer value at location 0x0 in program memory. This is typically the (highest RAM address + 4). Since different processors have different amounts of RAM, the proper address is processor dependent and is usually a literal in the linker file.
Answered By - Elliot Alderson Answer Checked By - David Goodson (WPSolving Volunteer)