misc: Misc elsewhere and multiboot-related bug fixes
This commit is contained in:
parent
215bf87993
commit
3d65bfb9b9
@ -829,9 +829,9 @@ bool elf32_load_elsewhere(uint8_t *elf, uint64_t *entry_point,
|
||||
entry_adjusted = true;
|
||||
}
|
||||
|
||||
(*ranges[cur_entry]).elsewhere = (uintptr_t)elsewhere;
|
||||
(*ranges[cur_entry]).target = phdr->p_paddr;
|
||||
(*ranges[cur_entry]).length = phdr->p_memsz;
|
||||
(*ranges)[cur_entry].elsewhere = (uintptr_t)elsewhere;
|
||||
(*ranges)[cur_entry].target = phdr->p_paddr;
|
||||
(*ranges)[cur_entry].length = phdr->p_memsz;
|
||||
|
||||
cur_entry++;
|
||||
}
|
||||
@ -903,9 +903,9 @@ bool elf64_load_elsewhere(uint8_t *elf, uint64_t *entry_point,
|
||||
entry_adjusted = true;
|
||||
}
|
||||
|
||||
(*ranges[cur_entry]).elsewhere = (uintptr_t)elsewhere;
|
||||
(*ranges[cur_entry]).target = phdr->p_paddr;
|
||||
(*ranges[cur_entry]).length = phdr->p_memsz;
|
||||
(*ranges)[cur_entry].elsewhere = (uintptr_t)elsewhere;
|
||||
(*ranges)[cur_entry].target = phdr->p_paddr;
|
||||
(*ranges)[cur_entry].length = phdr->p_memsz;
|
||||
|
||||
cur_entry++;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ retry:
|
||||
if (!flexible_target) {
|
||||
return false;
|
||||
}
|
||||
*target = top;
|
||||
*target = ALIGN_UP(top, 4096);
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
|
@ -177,6 +177,8 @@ bool multiboot2_load(char *config, char* cmdline) {
|
||||
}
|
||||
}
|
||||
|
||||
struct elf_section_hdr_info *section_hdr_info = NULL;
|
||||
|
||||
struct elsewhere_range *ranges;
|
||||
uint64_t ranges_count;
|
||||
|
||||
@ -217,14 +219,16 @@ bool multiboot2_load(char *config, char* cmdline) {
|
||||
|
||||
switch (bits) {
|
||||
case 32:
|
||||
if (elf32_load_elsewhere(kernel, &e, &ranges, &ranges_count))
|
||||
if (!elf32_load_elsewhere(kernel, &e, &ranges, &ranges_count))
|
||||
panic(true, "multiboot2: ELF32 load failure");
|
||||
|
||||
section_hdr_info = elf32_section_hdr_info(kernel);
|
||||
break;
|
||||
case 64: {
|
||||
if (elf64_load_elsewhere(kernel, &e, &ranges, &ranges_count))
|
||||
if (!elf64_load_elsewhere(kernel, &e, &ranges, &ranges_count))
|
||||
panic(true, "multiboot2: ELF64 load failure");
|
||||
|
||||
section_hdr_info = elf64_section_hdr_info(kernel);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -236,19 +240,6 @@ bool multiboot2_load(char *config, char* cmdline) {
|
||||
}
|
||||
}
|
||||
|
||||
struct elf_section_hdr_info *section_hdr_info = NULL;
|
||||
int bits = elf_bits(kernel);
|
||||
|
||||
switch (bits) {
|
||||
case 32:
|
||||
section_hdr_info = elf32_section_hdr_info(kernel);
|
||||
break;
|
||||
case 64: {
|
||||
section_hdr_info = elf64_section_hdr_info(kernel);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
size_t modules_size = 0;
|
||||
size_t n_modules;
|
||||
|
||||
|
@ -16,6 +16,7 @@ multiboot_reloc_stub:
|
||||
; EDX = ranges count
|
||||
|
||||
.code:
|
||||
mov esp, .mini_stack_top
|
||||
|
||||
push edi
|
||||
push esi
|
||||
@ -53,5 +54,9 @@ multiboot_reloc_stub:
|
||||
|
||||
ret
|
||||
|
||||
.mini_stack:
|
||||
times 3 dq 0
|
||||
.mini_stack_top:
|
||||
|
||||
global multiboot_reloc_stub_end
|
||||
multiboot_reloc_stub_end:
|
||||
|
@ -18,20 +18,19 @@ INTERNAL_LD_FLAGS_MULTIBOOT2 := \
|
||||
-Tmultiboot2.ld \
|
||||
-nostdlib \
|
||||
-zmax-page-size=0x1000 \
|
||||
-static \
|
||||
--no-dynamic-linker \
|
||||
-static
|
||||
|
||||
INTERNAL_LD_FLAGS_MULTIBOOT1 := \
|
||||
-Tmultiboot.ld \
|
||||
-nostdlib \
|
||||
-zmax-page-size=0x1000 \
|
||||
-static \
|
||||
--no-dynamic-linker \
|
||||
-static
|
||||
|
||||
INTERNALCFLAGS := \
|
||||
-I. \
|
||||
-I.. \
|
||||
-std=c11 \
|
||||
-g \
|
||||
-ffreestanding \
|
||||
-fno-stack-protector \
|
||||
-fpie \
|
||||
@ -43,26 +42,44 @@ INTERNALCFLAGS := \
|
||||
-mno-sse2 \
|
||||
-mno-red-zone
|
||||
|
||||
INTERNALCFLAGS_MB := \
|
||||
-I. \
|
||||
-I.. \
|
||||
-I../common/protos \
|
||||
-std=c11 \
|
||||
-m32 \
|
||||
-g \
|
||||
-ffreestanding \
|
||||
-fno-stack-protector \
|
||||
-fno-pie \
|
||||
-fno-pic \
|
||||
-mabi=sysv \
|
||||
-mno-80387 \
|
||||
-mno-mmx \
|
||||
-mno-3dnow \
|
||||
-mno-sse \
|
||||
-mno-sse2
|
||||
|
||||
all: test.elf multiboot2.elf multiboot.elf
|
||||
|
||||
test.elf: limine.o e9print.o memory.o
|
||||
$(LD) $^ $(LDFLAGS) $(INTERNALLDFLAGS) -o $@
|
||||
|
||||
multiboot2.elf: multiboot2_trampoline.o
|
||||
$(CC) $(CFLAGS) $(INTERNALCFLAGS) -I../common/protos -m32 -c multiboot2.c -o multiboot2.o
|
||||
$(CC) $(CFLAGS) $(INTERNALCFLAGS) -m32 -c e9print.c -o e9print.o
|
||||
$(CC) $(CFLAGS) $(INTERNALCFLAGS_MB) -c multiboot2.c -o multiboot2.o
|
||||
$(CC) $(CFLAGS) $(INTERNALCFLAGS_MB) -c e9print.c -o e9print.o
|
||||
$(LD) $^ multiboot2.o e9print.o $(LDFLAGS) $(INTERNAL_LD_FLAGS_MULTIBOOT2) -m elf_i386 -o $@
|
||||
|
||||
multiboot.elf: multiboot_trampoline.o
|
||||
$(CC) $(CFLAGS) $(INTERNALCFLAGS) -I../common/protos -m32 -c multiboot.c -o multiboot.o
|
||||
$(CC) $(CFLAGS) $(INTERNALCFLAGS) -m32 -c e9print.c -o e9print.o
|
||||
$(CC) $(CFLAGS) $(INTERNALCFLAGS_MB) -c multiboot.c -o multiboot.o
|
||||
$(CC) $(CFLAGS) $(INTERNALCFLAGS_MB) -c e9print.c -o e9print.o
|
||||
$(LD) $^ multiboot.o e9print.o $(LDFLAGS) $(INTERNAL_LD_FLAGS_MULTIBOOT1) -m elf_i386 -o $@
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) $(INTERNALCFLAGS) -c $< -o $@
|
||||
|
||||
%.o: %.asm
|
||||
nasm -felf32 $< -o $@
|
||||
nasm -felf32 -F dwarf -g $< -o $@
|
||||
|
||||
clean:
|
||||
rm -rf test.elf limine.o e9print.o memory.o
|
||||
|
@ -1,7 +1,7 @@
|
||||
ENTRY(_start)
|
||||
|
||||
SECTIONS {
|
||||
. = 0x1000;
|
||||
. = 0x10000;
|
||||
|
||||
.boot :
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user