ld using physical address for symbol, instead of relative
Posted: Mon Aug 24, 2009 9:42 am
I've managed to find a workaround for this problem, but I'd rather have a solution. I'm writing this from work so I don't have my exact code handy.
My basic kernel (not really a kernel) is leaded by Grub, which sets up a basic GDT for a flat memory model, loads my "kernel", and begins executing it. In my code, I establish another basic GDT, load it with lgdt, then execute a far jump to set up my new CS.
I have MY_SECTION separate so that I can have my code segment set up starting at that point. The above code works great, except I would love to be able to write "jmp CS_SEL:main" and allow the linker to figure things out. However, the linker assigns main 0x300000, which is the location of my segment in physical memory, but really I would prefer main to be zero.
Perhaps this can't be done. I could have sworn I've read something in the binutils ld manual about this, but I can't seem to find it, or anything else about this on the net.
My basic kernel (not really a kernel) is leaded by Grub, which sets up a basic GDT for a flat memory model, loads my "kernel", and begins executing it. In my code, I establish another basic GDT, load it with lgdt, then execute a far jump to set up my new CS.
Code: Select all
lgdt my_gdt ; This is the pointer to the new gdt
jmp CS_SEL:0 ; make the jump (CS_SEL is a segment selector)
section MY_SECTION
main:
mov ds,DS_SEL
;etc....
Perhaps this can't be done. I could have sworn I've read something in the binutils ld manual about this, but I can't seem to find it, or anything else about this on the net.