Skip to content

Commit 5c4ac74

Browse files
committed
compiler_archs: gcc: Require gcc to retain variable order
1 parent b485fd6 commit 5c4ac74

3 files changed

Lines changed: 11 additions & 10 deletions

File tree

shellblocks/compiler_archs/gcc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def get_gcc_flags(self):
1717
return [
1818
"-nostdlib",
1919
"-ffreestanding",
20+
"-fno-toplevel-reorder",
2021
]
2122

2223
def compile_primitive(self, src_path: str) -> [str]:

shellblocks/src/memset.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
#include "arch/utils.h"
33
#include "memset.h"
44

5-
// Must be the first variable
6-
DECLARE_NOP_END(nop_end);
7-
8-
const u8 items[] REL_ACCESS_STRING = MEMSET_ITEMS;
9-
105
void start(void) {
116
u8 *items_rel;
127

@@ -23,3 +18,8 @@ void start(void) {
2318

2419
JUMP_TO_NOP_END(nop_end);
2520
}
21+
22+
const u8 items[] REL_ACCESS_STRING = MEMSET_ITEMS;
23+
24+
// Must be the last variable
25+
DECLARE_NOP_END(nop_end);

shellblocks/src/print.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
#include "arch/utils.h"
33
#include "print.h"
44

5-
// Must be the first variable
6-
DECLARE_NOP_END(nop_end);
7-
8-
const char print_string[] REL_ACCESS_STRING = PRINT_STRING;
9-
105
void start(void) {
116
void (*print_func)(const char *) = (void (*)(const char *))PRINT_FUNCTION_ADDRESS;
127
char *print_string_rel;
@@ -16,3 +11,8 @@ void start(void) {
1611

1712
JUMP_TO_NOP_END(nop_end);
1813
}
14+
15+
const char print_string[] REL_ACCESS_STRING = PRINT_STRING;
16+
17+
// Must be the last variable
18+
DECLARE_NOP_END(nop_end);

0 commit comments

Comments
 (0)