Stack Canary Check
Implement a lightweight stack canary mechanism for a bare-metal task. Place a known pattern at the low end of the task stack and provide a checker that reports corruption.
Constraints
- Canary pattern is 0xDEADBEEF repeated over 4 words.
- `void canary_init(uint32_t *stack_base)` writes the pattern.
- `int canary_check(const uint32_t *stack_base)` returns 0 if intact, -1 if any word differs.
- Must not modify the stack in canary_check.
- No dynamic memory, no libc.
1#include <stdint.h>2 3#define CANARY_WORDS 44 5void canary_init(uint32_t *stack_base);6int canary_check(const uint32_t *stack_base);