diff options
author | dzwdz | 2021-09-12 15:07:26 +0200 |
---|---|---|
committer | dzwdz | 2021-09-12 15:07:26 +0200 |
commit | e4e4007fbbeede6f9a59dab6327f0ef3a4675801 (patch) | |
tree | 13da6d7ed29aadc442124ca32a290aee1403ee68 /src/init | |
parent | 1bf901c803bff3393d0cc9dfe76fc9f025cecb1c (diff) |
init: allocate bss at runtime
Diffstat (limited to 'src/init')
-rw-r--r-- | src/init/linker.ld | 2 | ||||
-rw-r--r-- | src/init/main.c | 14 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/init/linker.ld b/src/init/linker.ld index a59308d..efb44fd 100644 --- a/src/init/linker.ld +++ b/src/init/linker.ld @@ -17,9 +17,11 @@ SECTIONS { *(.data) } + _bss_start = .; .bss BLOCK(4K) : ALIGN(4K) { *(COMMON) *(.bss) } + _bss_end = .; } diff --git a/src/init/main.c b/src/init/main.c index dc5a975..78576aa 100644 --- a/src/init/main.c +++ b/src/init/main.c @@ -6,28 +6,28 @@ #define argify(str) str, sizeof(str) - 1 #define log(str) _syscall_write(tty_fd, argify(str)) -__attribute__((section("text"))) -int tty_fd; +extern char _bss_start; // provided by the linker +extern char _bss_end; -int test; +int tty_fd; void fs_test(void); int main(void) { + // allocate bss + _syscall_memflag(&_bss_start, &_bss_end - &_bss_start, MEMFLAG_PRESENT); + tty_fd = _syscall_open("/tty", sizeof("/tty") - 1); if (tty_fd < 0) _syscall_exit(argify("couldn't open tty")); log(" opened /tty "); - _syscall_memflag(&test, sizeof(int), MEMFLAG_PRESENT); - test = 0; // would cause a pagefault without the memflag call - fs_test(); _syscall_exit(argify("my job here is done.")); } void fs_test(void) { - static char buf[64] __attribute__((section("text"))); + static char buf[64]; int len = 64; handle_t front, back, file; front = _syscall_fs_create(&back); |