| 1 |
#include "common.h" |
| 2 |
|
| 3 |
|
| 4 |
__hidden volatile uint32_t hidden; |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
__weak volatile uint32_t weak __section(".data.weak"); |
| 9 |
|
| 10 |
|
| 11 |
__section("socket") int set_vars() { |
| 12 |
hidden = 0xbeef1; |
| 13 |
weak = 0xbeef2; |
| 14 |
return 0; |
| 15 |
} |
| 16 |
|
| 17 |
volatile uint32_t var_bss __section(".bss"); |
| 18 |
__section("socket") int get_bss() { |
| 19 |
return var_bss; |
| 20 |
} |
| 21 |
volatile uint32_t var_data __section(".data"); |
| 22 |
__section("socket") int get_data() { |
| 23 |
return var_data; |
| 24 |
} |
| 25 |
volatile const uint32_t var_rodata __section(".rodata"); |
| 26 |
__section("socket") int get_rodata() { |
| 27 |
return var_rodata; |
| 28 |
} |
| 29 |
|
| 30 |
struct var_struct_t { |
| 31 |
uint64_t a; |
| 32 |
uint64_t b; |
| 33 |
}; |
| 34 |
volatile struct var_struct_t var_struct __section(".data.struct"); |
| 35 |
__section("socket") int check_struct() { |
| 36 |
return var_struct.a == 0xa && var_struct.b == 0xb; |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
struct var_struct_pad_t { |
| 41 |
uint32_t a; |
| 42 |
uint64_t b; |
| 43 |
uint16_t c; |
| 44 |
uint8_t d[5]; |
| 45 |
uint64_t e; |
| 46 |
}; |
| 47 |
volatile struct var_struct_pad_t var_struct_pad __section(".data.struct"); |
| 48 |
__section("socket") int check_struct_pad() { |
| 49 |
return var_struct_pad.a == 0xa && var_struct_pad.b == 0xb && var_struct_pad.c == 0xc && var_struct_pad.d[0] == 0xd && var_struct_pad.e == 0xe; |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
volatile uint8_t var_array[8192] __section(".data.array"); |
| 55 |
__section("socket") int check_array() { |
| 56 |
return var_array[sizeof(var_array) - 1] == 0xff; |
| 57 |
} |
| 58 |
|
| 59 |
volatile uint32_t var_atomic __section(".data.atomic"); |
| 60 |
__section("socket") int add_atomic() { |
| 61 |
__sync_fetch_and_add(&var_atomic, 1); |
| 62 |
return 0; |
| 63 |
} |