IDT doesn't work when part of the .data section gets loaded above 0xa0000. I am using GRUB. I have set up my own GDT.
Source code here.Changing line 6 of kernel.ld from 0x80000 to anything above 0x9c160 will cause the CPU to jump to 0xe05b on "int $3" instead of the correct interrupt handler. I tried linking the kernel way higher (at 4M and 100M) and it doesn't work as well.
Code:
OUTPUT_ARCH(i386)
ENTRY(_start)
SECTIONS
{
. = 0x80000; // Changing to anything above 0x9c160 will cause part of the .data section to go above 0xa0000.
.text : { *(.multiboot) *(.text) }
.data ALIGN(4096) : { *(.data .rodata*) }
.bss ALIGN(4096) : { *(.bss) }
}
I imagine 0xe05b is a GRUB interrupt handler. I want to know if that is an issue with my linker script, or if I am missing something with the GRUB setup. Also, I would like to know where I can learn more about linking the kernel/linkers in general.
My environment:
Code:
i386-elf-gcc (GCC) 9.1.0
GNU i386-elf-ld (GNU Binutils) 2.32
qemu-system-i386 version 4.0.0
grub-mkrescue (GRUB) 2.03.6~manjaro
xorriso 1.5.0