diff --git a/stage23/lib/blib.h b/stage23/lib/blib.h index 83d1a228..6b200407 100644 --- a/stage23/lib/blib.h +++ b/stage23/lib/blib.h @@ -84,4 +84,6 @@ __attribute__((noreturn)) void stage3_common(void); __attribute__((noreturn)) void common_spinup(void *fnptr, int args, ...); +#define no_unwind __attribute__((section(".no_unwind"))) + #endif diff --git a/stage23/lib/config.c b/stage23/lib/config.c index 182e9f35..3ae11a58 100644 --- a/stage23/lib/config.c +++ b/stage23/lib/config.c @@ -13,9 +13,8 @@ #define SEPARATOR '\n' -extern bool *bad_config; - bool config_ready = false; +no_unwind bool bad_config = false; static char *config_addr; @@ -80,7 +79,7 @@ static bool is_directory(char *buf, size_t limit, case NOT_CHILD: return false; case INDIRECT_CHILD: - *bad_config = true; + bad_config = true; panic(true, "config: Malformed config file. Parentless child."); case DIRECT_CHILD: return true; diff --git a/stage23/lib/config.h b/stage23/lib/config.h index 7f0703d0..9ea2f016 100644 --- a/stage23/lib/config.h +++ b/stage23/lib/config.h @@ -6,6 +6,7 @@ #include extern bool config_ready; +extern bool bad_config; struct menu_entry { char name[64]; diff --git a/stage23/linker.ld b/stage23/linker.ld index 348ba608..47f1a4ca 100644 --- a/stage23/linker.ld +++ b/stage23/linker.ld @@ -41,6 +41,7 @@ SECTIONS .stage3.data : { *(.rodata*) *(.full_map*) + *(.no_unwind*) data_begin = .; *(.data*) limine_sys_size = . - 0x8000; diff --git a/stage23/linker_dbg.ld b/stage23/linker_dbg.ld index de357ff7..6049592c 100644 --- a/stage23/linker_dbg.ld +++ b/stage23/linker_dbg.ld @@ -41,6 +41,7 @@ SECTIONS .stage3.data : { *(.rodata*) *(.full_map*) + *(.no_unwind*) data_begin = .; *(.data*) limine_sys_size = . - 0x8000; diff --git a/stage23/linker_nomap.ld b/stage23/linker_nomap.ld index 29f663a2..37fa1bc3 100644 --- a/stage23/linker_nomap.ld +++ b/stage23/linker_nomap.ld @@ -41,6 +41,7 @@ SECTIONS .stage3.data : { *(.rodata*) full_map = .; + *(.no_unwind*) data_begin = .; *(.data*) limine_sys_size = . - 0x8000; diff --git a/stage23/linker_stage2only.ld b/stage23/linker_stage2only.ld index 3ca08f4f..eb61d100 100644 --- a/stage23/linker_stage2only.ld +++ b/stage23/linker_stage2only.ld @@ -24,6 +24,7 @@ SECTIONS .stage2.data : { *.s2.o(.rodata*) + *.s2.o(.no_unwind*) data_begin = .; *.s2.o(.data*) stage2_map = .; diff --git a/stage23/linker_uefi.ld b/stage23/linker_uefi.ld index fe53bcc4..45e981d2 100644 --- a/stage23/linker_uefi.ld +++ b/stage23/linker_uefi.ld @@ -38,6 +38,7 @@ SECTIONS *(.rodata*) *(.got.plt) *(.got) + *(.no_unwind*) data_begin = .; *(.data*) *(.sdata) diff --git a/stage23/linker_uefi32.ld b/stage23/linker_uefi32.ld index fce652fd..08a26ea3 100644 --- a/stage23/linker_uefi32.ld +++ b/stage23/linker_uefi32.ld @@ -38,6 +38,7 @@ SECTIONS *(.rodata*) *(.got.plt) *(.got) + *(.no_unwind*) data_begin = .; *(.data) *(.data1) diff --git a/stage23/linker_uefi32_nomap.ld b/stage23/linker_uefi32_nomap.ld index 6e0228e2..302f9f10 100644 --- a/stage23/linker_uefi32_nomap.ld +++ b/stage23/linker_uefi32_nomap.ld @@ -38,6 +38,7 @@ SECTIONS *(.rodata*) *(.got.plt) *(.got) + *(.no_unwind*) data_begin = .; *(.data) *(.data1) diff --git a/stage23/linker_uefi_nomap.ld b/stage23/linker_uefi_nomap.ld index fcbceb2a..2caa6d1b 100644 --- a/stage23/linker_uefi_nomap.ld +++ b/stage23/linker_uefi_nomap.ld @@ -38,6 +38,7 @@ SECTIONS *(.rodata*) *(.got.plt) *(.got) + *(.no_unwind*) data_begin = .; *(.data*) *(.sdata) diff --git a/stage23/menu.c b/stage23/menu.c index b23caf6f..a24cf03f 100644 --- a/stage23/menu.c +++ b/stage23/menu.c @@ -583,14 +583,8 @@ static uint8_t *rewound_data; extern symbol data_begin; extern symbol data_end; -bool *bad_config = NULL; - __attribute__((noreturn, used)) static void _menu(bool timeout_enabled) { - if (bad_config == NULL) { - bad_config = ext_mem_alloc(1); - } - size_t data_size = (uintptr_t)data_end - (uintptr_t)data_begin; if (rewound_memmap != NULL) { @@ -605,7 +599,7 @@ static void _menu(bool timeout_enabled) { memcpy(rewound_data, data_begin, data_size); } - if (*bad_config == false) { + if (bad_config == false) { volume_iterate_parts(boot_volume, if (!init_config_disk(_PART)) { boot_volume = _PART;