Page 1 of 1

problem with grub

Posted: Sat Apr 19, 2008 11:51 pm
by asdfgh
i compile with these instructions in cygwin ..
gcc -c -m32 -B /home/vivek/os/kernel -Wall -nostdlib -nostartfiles -nostdinc -std=gnu99 *.c
as --32 startk.s -o startk.so
ld -m i386pe -T linker.ld startk.so *.o -o kernel


when i boot with bochs it shows unrecognized executable format

Posted: Sat Apr 19, 2008 11:59 pm
by piranha
Try linking with 'ld -m elf_i386 -T linker.ld startk.so *.o -o kernel'

-JL

Posted: Sun Apr 20, 2008 12:16 am
by asdfgh
it shows
ld : unrecognized emulation mode elf_i386
try i386pe

Posted: Sun Apr 20, 2008 12:40 am
by cyr1x
Do you have included the AOUT kludge in the multiboot header?

this is the cde..

Posted: Sun Apr 20, 2008 1:53 am
by asdfgh
.global _loader # making entry point visible to linker

# setting up the Multiboot header - see GRUB docs for details
.set ALIGN, 1<<0 # align loaded modules on page boundaries
.set MEMINFO, 1<<1 # provide memory map
.set FLAGS, ALIGN | MEMINFO # this is the Multiboot 'flag' field
.set MAGIC, 0x1BADB002 # 'magic number' lets bootloader find the header
.set CHECKSUM, -(MAGIC + FLAGS) # checksum required

.align 4
.long MAGIC
.long FLAGS
.long CHECKSUM

# reserve initial kernel stack space
.set STACKSIZE, 0x4000 # that is, 16k.
.comm stack, STACKSIZE, 32 # reserve 16k stack on a quadword boundary

_loader:
mov $(stack + STACKSIZE), %esp # set up the stack
push %eax # Multiboot magic number
push %ebx # Multiboot data structure

call kmain # call kernel proper
hlt # halt machine should kernel retur

Posted: Sun Apr 20, 2008 5:48 am
by asdfgh
it still gives unrecogoised format

Posted: Sun Apr 20, 2008 10:19 am
by Combuster
for starters, build a GCC Cross-Compiler instead of using that ugly cygwin thing.

Posted: Sun Apr 20, 2008 12:34 pm
by froseph
Do you understand the meaning of the errors? If you don't understand the basics behind the error messages you are getting, you need to learn a lot more before you set off on your journey. Perhaps you should start with freestanding the parameters you are passing to your tools and the code itself.

It's possible to make a pe kernel.

Posted: Sun Apr 20, 2008 2:04 pm
by JamesM
It's possible to make a pe kernel.
But difficult.

Posted: Fri May 02, 2008 8:11 am
by crackcell
Maybe you are compile your kernel on a x86_64 OS?

That's just my situation.

I sovled this problem by downloading a i386 ld and using it instead of the x64 one.

I renamed the i386 ld into 386-ld, so I use this to link my kernel:

386-ld -Tlink.ld -o kernel.img x.o .xx.o xxx.o

That works perfectly.