Skip to content

Commit

Permalink
[contrib][linux-kernel] Fix stack detection for newer gcc
Browse files Browse the repository at this point in the history
Newer gcc versions were getting smart and omitting the `memset()`.
Get around this issue by outlining the `memset()` into a different
function. This test is still hacky, but it works...
  • Loading branch information
terrelln committed Dec 13, 2022
1 parent b0bcbbf commit e767d5c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion contrib/linux-kernel/test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,14 @@ static void __attribute__((noinline)) use(void *x) {
asm volatile("" : "+r"(x));
}

static void __attribute__((noinline)) fill_stack(void) {
memset(g_stack, 0x33, 8192);
}

static void __attribute__((noinline)) set_stack(void) {

char stack[8192];
g_stack = stack;
memset(g_stack, 0x33, 8192);
use(g_stack);
}

Expand All @@ -208,6 +211,7 @@ static void __attribute__((noinline)) check_stack(void) {

static void test_stack_usage(test_data_t const *data) {
set_stack();
fill_stack();
test_f2fs();
test_btrfs(data);
test_decompress_unzstd(data);
Expand Down

0 comments on commit e767d5c

Please sign in to comment.