misc: Make sure relocatable kernels work
This commit is contained in:
parent
faae7a002c
commit
13f3ee0932
BIN
limine-pxe.bin
BIN
limine-pxe.bin
Binary file not shown.
BIN
limine.bin
BIN
limine.bin
Binary file not shown.
BIN
stage2.map
BIN
stage2.map
Binary file not shown.
@ -134,9 +134,6 @@ int elf_bits(struct file_handle *fd) {
|
||||
}
|
||||
|
||||
static int elf64_apply_relocations(struct file_handle *fd, struct elf64_hdr *hdr, void *buffer, uint64_t vaddr, size_t size, uint64_t slide) {
|
||||
if (hdr->type != ET_DYN)
|
||||
return 0; // Nothing to do if the ELF is not relocatable
|
||||
|
||||
// Find RELA sections
|
||||
for (uint16_t i = 0; i < hdr->sh_num; i++) {
|
||||
struct elf64_shdr section;
|
||||
|
@ -257,7 +257,8 @@ void memmap_alloc_range(uint64_t base, uint64_t length, uint32_t type) {
|
||||
|
||||
if (base < 0x100000) {
|
||||
// We don't do allocations below 1 MiB
|
||||
panic("Attempt to allocate memory below 1 MiB");
|
||||
panic("Attempt to allocate memory below 1 MiB (%X-%X)",
|
||||
base, base + length);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < memmap_entries; i++) {
|
||||
|
@ -5,10 +5,10 @@ CFLAGS = -O2
|
||||
LD = ld
|
||||
QEMU = qemu-system-x86_64
|
||||
QEMUFLAGS = -m 1G -enable-kvm -cpu host
|
||||
LDINTERNALFLAGS := -Tlinker.ld -static -nostdlib -no-pie
|
||||
LDINTERNALFLAGS := -Tlinker.ld -nostdlib -pie -z max-page-size=0x1000
|
||||
INTERNALCFLAGS := -I../stivale -I. -ffreestanding -fno-stack-protector \
|
||||
-fno-pic -fomit-frame-pointer -mno-80387 -mno-mmx -mno-3dnow -mno-sse \
|
||||
-mno-sse2 -masm=intel -mcmodel=kernel
|
||||
-fpic -fpie -fomit-frame-pointer -mno-red-zone -mno-80387 -mno-mmx -mno-3dnow -mno-sse \
|
||||
-mno-sse2 -masm=intel
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
|
@ -35,3 +35,13 @@ KERNEL_CMDLINE=Woah! Another example!
|
||||
|
||||
MODULE_PATH=bios://:1/boot/bg.bmp
|
||||
MODULE_STRING=yooooo
|
||||
|
||||
:Stivale2 Test (KASLR)
|
||||
|
||||
PROTOCOL=stivale2
|
||||
RESOLUTION=640x480x16
|
||||
KERNEL_PATH=bios://:1/boot/test.elf
|
||||
KERNEL_CMDLINE=Woah! Another example!
|
||||
|
||||
MODULE_PATH=bios://:1/boot/bg.bmp
|
||||
MODULE_STRING=yooooo
|
||||
|
@ -1,5 +1,12 @@
|
||||
ENTRY(stivale_main)
|
||||
|
||||
PHDRS {
|
||||
none PT_NULL FLAGS(0);
|
||||
text PT_LOAD FLAGS((1 << 2) | (1 << 0) /* Readable | Executable */);
|
||||
data PT_LOAD FLAGS((1 << 2) | (1 << 1) /* Readable | Writeable */);
|
||||
rodata PT_LOAD FLAGS((1 << 2) /* Readable */);
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = 0xffffffff80100000;
|
||||
@ -7,7 +14,7 @@ SECTIONS
|
||||
.stivalehdr ALIGN(4K) :
|
||||
{
|
||||
KEEP(*(.stivalehdr))
|
||||
}
|
||||
}:none
|
||||
|
||||
.stivale2hdr ALIGN(4K) :
|
||||
{
|
||||
@ -17,17 +24,17 @@ SECTIONS
|
||||
.text ALIGN(4K) :
|
||||
{
|
||||
KEEP(*(.text*))
|
||||
}
|
||||
}:text
|
||||
|
||||
.rodata ALIGN(4K) :
|
||||
{
|
||||
KEEP(*(.rodata*))
|
||||
}
|
||||
}:rodata
|
||||
|
||||
.data ALIGN(4K) :
|
||||
{
|
||||
KEEP(*(.data*))
|
||||
}
|
||||
}:data
|
||||
|
||||
.bss ALIGN(4K) :
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ struct stivale2_header header2 = {
|
||||
.tags = (uint64_t)&framebuffer_request
|
||||
};
|
||||
|
||||
void ap_entry(struct stivale2_smp_info *s) {
|
||||
static void ap_entry(struct stivale2_smp_info *s) {
|
||||
e9_printf("AP %u started", s->lapic_id);
|
||||
for (;;);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user