misc: Unwind both .data and .bss

This commit is contained in:
mintsuki 2021-12-12 18:40:27 +01:00
parent 2f66e0f23a
commit 88cd9dca7e
10 changed files with 31 additions and 27 deletions

View File

@ -81,16 +81,12 @@ void entry(uint8_t boot_drive, int boot_from) {
term_notready();
{
struct rm_regs r = {0};
r.eax = 0x0003;
rm_int(0x10, &r, &r);
current_video_mode = -1;
outb(0x3d4, 0x0a);
outb(0x3d5, 0x20);
}
init_e820();
init_memmap();

View File

@ -39,9 +39,10 @@ SECTIONS
}
.stage3.data : {
*(.data*)
*(.rodata*)
*(.full_map*)
data_begin = .;
*(.data*)
limine_sys_size = . - 0x8000;
}
@ -54,6 +55,7 @@ SECTIONS
*(COMMON)
*(.bss*)
bss_end = .;
data_end = .;
}
.symtab 0 : {

View File

@ -39,9 +39,10 @@ SECTIONS
}
.stage3.data : {
*(.data*)
*(.rodata*)
*(.full_map*)
data_begin = .;
*(.data*)
limine_sys_size = . - 0x8000;
}
@ -54,6 +55,7 @@ SECTIONS
*(COMMON)
*(.bss*)
bss_end = .;
data_end = .;
}
.symtab 0 : {

View File

@ -39,9 +39,10 @@ SECTIONS
}
.stage3.data : {
*(.data*)
*(.rodata*)
full_map = .;
data_begin = .;
*(.data*)
limine_sys_size = . - 0x8000;
}
@ -54,6 +55,7 @@ SECTIONS
*(COMMON)
*(.bss*)
bss_end = .;
data_end = .;
}
.symtab 0 : {

View File

@ -23,8 +23,9 @@ SECTIONS
}
.stage2.data : {
*.s2.o(.data*)
*.s2.o(.rodata*)
data_begin = .;
*.s2.o(.data*)
stage2_map = .;
stage3_common = .;
full_map = .;
@ -49,6 +50,7 @@ SECTIONS
*(COMMON)
*(.bss*)
bss_end = .;
data_end = .;
}
.symtab 0 : {

View File

@ -38,17 +38,17 @@ SECTIONS
*(.rodata*)
*(.got.plt)
*(.got)
data_begin = .;
*(.data*)
*(.sdata)
/* the EFI loader doesn't seem to like a .bss section, so we stick
it all into .data: */
bss_begin = .;
*(.sbss)
*(.scommon)
*(.dynbss)
*(.bss)
*(COMMON)
bss_end = .;
data_end = .;
*(.rel.local)
*(.full_map*)
}

View File

@ -36,21 +36,21 @@ SECTIONS
.data :
{
*(.rodata*)
*(.got.plt)
*(.got)
data_begin = .;
*(.data)
*(.data1)
*(.data.*)
*(.sdata)
*(.got.plt)
*(.got)
/* the EFI loader doesn't seem to like a .bss section, so we stick
it all into .data: */
bss_begin = .;
*(.sbss)
*(.scommon)
*(.dynbss)
*(.bss)
*(COMMON)
bss_end = .;
data_end = .;
*(.full_map*)
}
.note.gnu.build-id : { *(.note.gnu.build-id) }

View File

@ -36,21 +36,21 @@ SECTIONS
.data :
{
*(.rodata*)
*(.got.plt)
*(.got)
data_begin = .;
*(.data)
*(.data1)
*(.data.*)
*(.sdata)
*(.got.plt)
*(.got)
/* the EFI loader doesn't seem to like a .bss section, so we stick
it all into .data: */
bss_begin = .;
*(.sbss)
*(.scommon)
*(.dynbss)
*(.bss)
*(COMMON)
bss_end = .;
data_end = .;
full_map = .;
}
.note.gnu.build-id : { *(.note.gnu.build-id) }

View File

@ -38,17 +38,17 @@ SECTIONS
*(.rodata*)
*(.got.plt)
*(.got)
data_begin = .;
*(.data*)
*(.sdata)
/* the EFI loader doesn't seem to like a .bss section, so we stick
it all into .data: */
bss_begin = .;
*(.sbss)
*(.scommon)
*(.dynbss)
*(.bss)
*(COMMON)
bss_end = .;
data_end = .;
*(.rel.local)
full_map = .;
}

View File

@ -578,10 +578,10 @@ 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_bss;
static uint8_t *rewound_data;
extern symbol bss_begin;
extern symbol bss_end;
extern symbol data_begin;
extern symbol data_end;
bool *bad_config = NULL;
@ -591,18 +591,18 @@ static void _menu(bool timeout_enabled) {
bad_config = ext_mem_alloc(1);
}
size_t bss_size = (uintptr_t)bss_end - (uintptr_t)bss_begin;
size_t data_size = (uintptr_t)data_end - (uintptr_t)data_begin;
if (rewound_memmap != NULL) {
memcpy(bss_begin, rewound_bss, bss_size);
memcpy(data_begin, rewound_data, data_size);
memcpy(memmap, rewound_memmap, rewound_memmap_entries * sizeof(struct e820_entry_t));
memmap_entries = rewound_memmap_entries;
} else {
rewound_bss = ext_mem_alloc(bss_size);
rewound_data = ext_mem_alloc(data_size);
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_bss, bss_begin, bss_size);
memcpy(rewound_data, data_begin, data_size);
}
if (*bad_config == false) {