Laoding an ELF64 kernel object with GRUB

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
hurrikam
Posts: 6
Joined: Fri Aug 12, 2005 11:00 pm

Laoding an ELF64 kernel object with GRUB

Post by hurrikam »

I'm having problem running a simple test ASM module, compiled with YASM for x86-64 arch (I'll call it CORE.asm), assembled with the following command line:

yasm -a x86 -m amd64 -f elf CORE.asm -o entry.o

then linked with LD specifying:

ld -m elf_x86_64 -T link.ld -o kernel.bin entry.o

where "link.d" is my LD linker script. If in the script I specify an output object format using OUTPUT_FORMAT(elf32-i386), then the resulting kernel.bin image is correctly loaded (and running) with GRUB (although it should be a problem when trying to link together with 64 bits code segment needed to swith into long mode. I think so).

But if I specify OUTPUT_FORMAT(elf64-x86-64) then Grub doesn't recognize it and can't load it. Note that however the entry code segment in the CORE.asm module uses "BITS 32" directive in order to be x86 architecture compatible as GRUB initially activate standard 32 bits protected mode before loading the kernel image and passing it execution control.

Has anybody any suggestion or experimented already about?

Thanks,

Hurrikam
hurrikam
Posts: 6
Joined: Fri Aug 12, 2005 11:00 pm

Re: Laoding an ELF64 kernel object with GRUB

Post by hurrikam »

Problem solved (...thanks froggey)

Hurrikam
Post Reply