From a91fe718f5c7465080d5bd254c288cf6593e6419 Mon Sep 17 00:00:00 2001 From: Sergio Mazzola Date: Tue, 8 Oct 2024 11:54:03 +0200 Subject: [PATCH] Sw: Add test for stack pointer corruption --- sw/tests/testSp.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 sw/tests/testSp.c diff --git a/sw/tests/testSp.c b/sw/tests/testSp.c new file mode 100644 index 0000000..96832a8 --- /dev/null +++ b/sw/tests/testSp.c @@ -0,0 +1,24 @@ +// Copyright 2024 ETH Zurich and University of Bologna. +// Licensed under the Apache License, Version 2.0, see LICENSE for details. +// SPDX-License-Identifier: Apache-2.0 +// +// Sergio Mazzola + +// Test stack pointer corruption + +#include +#include + +int main() { + volatile int32_t a = 0; + + for (volatile int32_t i = 0; i < 5; i++) { + a += i; + } + + if (a == 10) { + return 0x7fffffff; + } else { + return 0xabcdef00; + } +}