diff --git a/decompressor/linker.ld b/decompressor/linker.ld index 4170047b..ba0cca48 100644 --- a/decompressor/linker.ld +++ b/decompressor/linker.ld @@ -1,4 +1,5 @@ OUTPUT_FORMAT(elf32-i386) +OUTPUT_ARCH(i386) ENTRY(_start) SECTIONS @@ -6,34 +7,34 @@ SECTIONS . = 0x70000; .text : { - KEEP(*(.entry*)) - *(.text*) + *(.entry) + *(.text .text.*) } .rodata : { - *(.rodata*) + *(.rodata .rodata.*) } .data : { - *(.data*) + *(.data .data.*) } .bss : { bss_begin = .; *(COMMON) - *(.bss*) + *(.bss .bss.*) bss_end = .; } - .symtab : { + .symtab 0 : { *(.symtab) } - .strtab : { + .strtab 0 : { *(.strtab) } - .shstrtab : { + .shstrtab 0 : { *(.shstrtab) } diff --git a/stage23/linker.ld b/stage23/linker.ld index 47f1a4ca..63fc7179 100644 --- a/stage23/linker.ld +++ b/stage23/linker.ld @@ -1,4 +1,5 @@ OUTPUT_FORMAT(elf32-i386) +OUTPUT_ARCH(i386) ENTRY(_start) SECTIONS @@ -6,15 +7,15 @@ SECTIONS . = 0x8000; .entry : { - *(.entry*) + *(.entry) } .realmode : { - *(.realmode*) + *(.realmode) } .stage2.text : { - *.s2.o(.text*) + *.s2.o(.text .text.*) } .stage2.build-id : { @@ -23,14 +24,17 @@ SECTIONS } .stage2.data : { - *.s2.o(.data*) - *.s2.o(.rodata*) + *.s2.o(.no_unwind) + s2_data_begin = .; + *.s2.o(.data .data.*) + s2_data_end = .; + *.s2.o(.rodata .rodata.*) *(.stage2_map) } .stage3.text : { stage3_addr = .; - *(.text*) + *(.text .text.*) } .stage3.build-id : { @@ -39,11 +43,11 @@ SECTIONS } .stage3.data : { - *(.rodata*) - *(.full_map*) - *(.no_unwind*) + *(.rodata .rodata.*) + *(.full_map) + *(.no_unwind) data_begin = .; - *(.data*) + *(.data .data.*) limine_sys_size = . - 0x8000; } @@ -54,7 +58,7 @@ SECTIONS .bss : { bss_begin = .; *(COMMON) - *(.bss*) + *(.bss .bss.*) bss_end = .; data_end = .; } diff --git a/stage23/linker_dbg.ld b/stage23/linker_dbg.ld index 6049592c..3d57d417 100644 --- a/stage23/linker_dbg.ld +++ b/stage23/linker_dbg.ld @@ -1,4 +1,5 @@ OUTPUT_FORMAT(elf32-i386) +OUTPUT_ARCH(i386) ENTRY(_start) SECTIONS @@ -6,15 +7,15 @@ SECTIONS . = 0x8000; .entry : { - *(.entry*) + *(.entry) } .realmode : { - *(.realmode*) + *(.realmode) } .stage2.text : { - *.s2.o(.text*) + *.s2.o(.text .text.*) } .stage2.build-id : { @@ -23,14 +24,17 @@ SECTIONS } .stage2.data : { - *.s2.o(.data*) - *.s2.o(.rodata*) + *.s2.o(.no_unwind) + s2_data_begin = .; + *.s2.o(.data .data.*) + s2_data_end = .; + *.s2.o(.rodata .rodata.*) *(.stage2_map) } .stage3.text : { stage3_addr = .; - *(.text*) + *(.text .text.*) } .stage3.build-id : { @@ -39,11 +43,11 @@ SECTIONS } .stage3.data : { - *(.rodata*) - *(.full_map*) - *(.no_unwind*) + *(.rodata .rodata.*) + *(.full_map) + *(.no_unwind) data_begin = .; - *(.data*) + *(.data .data.*) limine_sys_size = . - 0x8000; } @@ -54,7 +58,7 @@ SECTIONS .bss : { bss_begin = .; *(COMMON) - *(.bss*) + *(.bss .bss.*) bss_end = .; data_end = .; } diff --git a/stage23/linker_nomap.ld b/stage23/linker_nomap.ld index 37fa1bc3..7c1dad41 100644 --- a/stage23/linker_nomap.ld +++ b/stage23/linker_nomap.ld @@ -1,4 +1,5 @@ OUTPUT_FORMAT(elf32-i386) +OUTPUT_ARCH(i386) ENTRY(_start) SECTIONS @@ -6,15 +7,15 @@ SECTIONS . = 0x8000; .entry : { - *(.entry*) + *(.entry) } .realmode : { - *(.realmode*) + *(.realmode) } .stage2.text : { - *.s2.o(.text*) + *.s2.o(.text .text.*) } .stage2.build-id : { @@ -23,14 +24,17 @@ SECTIONS } .stage2.data : { - *.s2.o(.data*) - *.s2.o(.rodata*) + *.s2.o(.no_unwind) + s2_data_begin = .; + *.s2.o(.data .data.*) + s2_data_end = .; + *.s2.o(.rodata .rodata.*) *(.stage2_map) } .stage3.text : { stage3_addr = .; - *(.text*) + *(.text .text.*) } .stage3.build-id : { @@ -39,11 +43,11 @@ SECTIONS } .stage3.data : { - *(.rodata*) + *(.rodata .rodata.*) full_map = .; - *(.no_unwind*) + *(.no_unwind) data_begin = .; - *(.data*) + *(.data .data.*) limine_sys_size = . - 0x8000; } @@ -54,7 +58,7 @@ SECTIONS .bss : { bss_begin = .; *(COMMON) - *(.bss*) + *(.bss .bss.*) bss_end = .; data_end = .; } diff --git a/stage23/linker_stage2only.ld b/stage23/linker_stage2only.ld index eb61d100..6cc725f7 100644 --- a/stage23/linker_stage2only.ld +++ b/stage23/linker_stage2only.ld @@ -1,4 +1,5 @@ OUTPUT_FORMAT(elf32-i386) +OUTPUT_ARCH(i386) ENTRY(_start) SECTIONS @@ -6,15 +7,15 @@ SECTIONS . = 0x8000; .entry : { - *(.entry*) + *(.entry) } .realmode : { - *(.realmode*) + *(.realmode) } .stage2.text : { - *.s2.o(.text*) + *.s2.o(.text .text.*) } .stage2.build-id : { @@ -23,10 +24,11 @@ SECTIONS } .stage2.data : { - *.s2.o(.rodata*) - *.s2.o(.no_unwind*) - data_begin = .; - *.s2.o(.data*) + *.s2.o(.no_unwind) + s2_data_begin = .; + *.s2.o(.data .data.*) + s2_data_end = .; + *.s2.o(.rodata .rodata.*) stage2_map = .; stage3_common = .; full_map = .; @@ -35,6 +37,7 @@ SECTIONS getchar = .; menu = .; stage3_addr = .; + data_begin = .; } .stage3.build-id : { @@ -49,7 +52,7 @@ SECTIONS .bss : { bss_begin = .; *(COMMON) - *(.bss*) + *(.bss .bss.*) bss_end = .; data_end = .; } diff --git a/stage23/menu.c b/stage23/menu.c index a7c82a90..b978fd7e 100644 --- a/stage23/menu.c +++ b/stage23/menu.c @@ -581,24 +581,43 @@ void menu(__attribute__((unused)) bool timeout_enabled) { static struct e820_entry_t *rewound_memmap = NULL; static size_t rewound_memmap_entries = 0; static uint8_t *rewound_data; +#if bios == 1 +static uint8_t *rewound_s2_data; +#endif extern symbol data_begin; extern symbol data_end; +#if bios == 1 +extern symbol s2_data_begin; +extern symbol s2_data_end; +#endif __attribute__((noreturn, used)) static void _menu(bool timeout_enabled) { size_t data_size = (uintptr_t)data_end - (uintptr_t)data_begin; +#if bios == 1 + size_t s2_data_size = (uintptr_t)s2_data_end - (uintptr_t)s2_data_begin; +#endif if (rewound_memmap != NULL) { memcpy(data_begin, rewound_data, data_size); +#if bios == 1 + memcpy(s2_data_begin, rewound_s2_data, s2_data_size); +#endif memcpy(memmap, rewound_memmap, rewound_memmap_entries * sizeof(struct e820_entry_t)); memmap_entries = rewound_memmap_entries; } else { rewound_data = ext_mem_alloc(data_size); +#if bios == 1 + rewound_s2_data = ext_mem_alloc(s2_data_size); +#endif rewound_memmap = ext_mem_alloc(256 * sizeof(struct e820_entry_t)); memcpy(rewound_memmap, memmap, memmap_entries * sizeof(struct e820_entry_t)); rewound_memmap_entries = memmap_entries; memcpy(rewound_data, data_begin, data_size); +#if bios == 1 + memcpy(rewound_s2_data, s2_data_begin, s2_data_size); +#endif } if (bad_config == false) {