Skip to content

Commit

Permalink
Test for .bss, .rodata, and .data sections
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Jowett <[email protected]>
  • Loading branch information
Alan-Jowett authored and elazarg committed Dec 18, 2024
1 parent b1ec1a2 commit f022799
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Binary file modified build/global_variable.o
Binary file not shown.
7 changes: 7 additions & 0 deletions src/global_variable.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,18 @@
// to prevent the compiler from optimizing them away and must accessed
// using atomic operations to avoid race conditions.

// Global variables with initial value of 0 are put into .bss section.
static volatile uint32_t global_var = 0;
static volatile uint32_t global_var_2 = 0;
// Global const variables are put into .rodata section.
static volatile const uint32_t global_const_var = 10;
// Global variables with initial value are put into .data section.
static volatile uint32_t global_array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

int func(void* ctx) {
__sync_fetch_and_add(&global_var, 1);
__sync_fetch_and_add(&global_var_2, 2);
global_array[0] = global_const_var;

return 0;
}

0 comments on commit f022799

Please sign in to comment.