build: BIOS linker scripts adjustments

This commit is contained in:
mintsuki 2021-12-19 01:08:34 +01:00
parent 56d964ae32
commit 08bd89fbcc
6 changed files with 83 additions and 48 deletions

View File

@ -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)
}

View File

@ -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 = .;
}

View File

@ -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 = .;
}

View File

@ -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 = .;
}

View File

@ -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 = .;
}

View File

@ -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) {