From f4ee774866fe6de983e8984a2fc33f0b0bd0697f Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Thu, 26 Apr 2018 23:38:46 +0200 Subject: [PATCH] Set up a stack I forgot to actually set up a stack for the program but strangely it (mostly) worked - probably due to inlining. --- arm.ld | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arm.ld b/arm.ld index c4178126..1879a919 100644 --- a/arm.ld +++ b/arm.ld @@ -26,6 +26,14 @@ SECTIONS /* used by the startup to initialize data */ _sidata = LOADADDR(.data); + /* Put the stack at the bottom of RAM, so that the application will + * crash on stack overflow instead of silently corrupting memory. + * See: http://blog.japaric.io/stack-overflow-protection/ */ + .stack : + { + KEEP(*(.stack)) + } >RAM + /* This is the initialized data section The program executes knowing that the data is in the RAM but the loader puts the initial values in the FLASH (inidata).