Linking 32bit bootstrap with 64bit kernel
Posted: Wed Oct 12, 2011 7:47 am
Hey everybody,
I'm trying to run my kernel in long mode. I have my own simple bootloader that initializes Pmode and load kernel.
The file (entry.S) is responsible to setup Lmode structures, and drop to 64bit kernel code. However I have some problems with linking entry.S with rest of the files. Attempts that was made so far:
1) Compile entry.S with -m64 flag. Problem that it contains instructions like "movl %eax, %cr4" which is mandatory in Pmode, but fails to compile with -m64 flag.
2) Compile entry.S with -m32 flag and 'objcopy -O elf64-x86-64' it. Then 'ld' fails with
I feel that there are something small that i'm missing (probably some flag), but can't figure it out. How it should be done?
I'm trying to run my kernel in long mode. I have my own simple bootloader that initializes Pmode and load kernel.
The file (entry.S) is responsible to setup Lmode structures, and drop to 64bit kernel code. However I have some problems with linking entry.S with rest of the files. Attempts that was made so far:
1) Compile entry.S with -m64 flag. Problem that it contains instructions like "movl %eax, %cr4" which is mandatory in Pmode, but fails to compile with -m64 flag.
2) Compile entry.S with -m32 flag and 'objcopy -O elf64-x86-64' it. Then 'ld' fails with
Code: Select all
ld: obj/kern/entry.o: bad relocation section name `.rel.text'
obj/kern/entry.o: could not read symbols: File format not recognized