Code goes like this:
Code: Select all
void init_gdt()
{
gdtp.limit = (sizeof(struct gdt_gate) * 5) - 1;
gdtp.base = &gdt_entries;
gdt_set_entry(0, 0, 0, NULL_SEGMENT, 0);
gdt_set_entry(1, 0,SEGMENT_LIMIT, KRNL_CODE_SEGMENT, 0xCF);
gdt_set_entry(2, 0,SEGMENT_LIMIT, KRNL_DATA_SEGMENT, 0xCF);
gdt_set_entry(3, 0,SEGMENT_LIMIT, USER_CODE_SEGMENT, 0xCF);
gdt_set_entry(4, 0,SEGMENT_LIMIT, USER_DATA_SEGMENT, 0xCF);
__asm__ __volatile__("lgdt (%0) ": :"p" ((&gdtp)));
}
Code: Select all
nasm -f aout boot.asm -o output/boot.o
gcc -Wall -O -finline-functions -fno-builtin -I./include -c -o output/hal/init.o hal/x86/init.c
gcc -Wall -O -finline-functions -fno-builtin -I./include -c -o output/hal/gdt.o hal/x86/descriptors/gdt.c
ld -T link.ld -o krnl32.exe output\boot.o output\hal\init.o output\hal\gdt.o
Any idea of the causing problem.output/hal/gdt.o<.text+0x157>:gdt.c: undefined reference to '$_gdtp'