I'm trying to write a bootloader for a kernel. At the moment i'm loading the GDT with assembly but I want to write some C code to generate the GDT(and the IDT) The problem is that the boot sector is always loaded at address 0x7c00 so I need a way to offset my labels with that address. If I assemble to a bin file I can just use [org 0x7c00] but I want to assemble the bootloader to an object file(Which org is not supported in this format by NASM) so that I can use external symbols. Without org, I have this in my assembly code:
gdt_descriptor:
dw gdt_end - gdt_start - 1
dd gdt_start
.
.
.
lgdt [gdt_descriptor]
when assembled looks like:
lgdt 0x71
when it should be
lgdt 0x7c71
The table itself is also wrong as the gdt start location does not take into account the offset.
Save for manually adding the offset myself(Which there would be a bunch of places I would have to), is there any directive I can use to set the start address?
edit: Changed from 0xc700 to 0x7c00