problem 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
asdfgh
Member
Member
Posts: 42
Joined: Fri Apr 18, 2008 9:14 pm

problem with grub

Post 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
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Post by piranha »

Try linking with 'ld -m elf_i386 -T linker.ld startk.so *.o -o kernel'

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
asdfgh
Member
Member
Posts: 42
Joined: Fri Apr 18, 2008 9:14 pm

Post by asdfgh »

it shows
ld : unrecognized emulation mode elf_i386
try i386pe
cyr1x
Member
Member
Posts: 207
Joined: Tue Aug 21, 2007 1:41 am
Location: Germany

Post by cyr1x »

Do you have included the AOUT kludge in the multiboot header?
asdfgh
Member
Member
Posts: 42
Joined: Fri Apr 18, 2008 9:14 pm

this is the cde..

Post 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
asdfgh
Member
Member
Posts: 42
Joined: Fri Apr 18, 2008 9:14 pm

Post by asdfgh »

it still gives unrecogoised format
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

for starters, build a GCC Cross-Compiler instead of using that ugly cygwin thing.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
froseph
Posts: 3
Joined: Sun Apr 13, 2008 3:05 pm

Post 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.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

It's possible to make a pe kernel.
But difficult.
User avatar
crackcell
Posts: 7
Joined: Sat Mar 22, 2008 3:41 am
Location: Wuhan University

Post 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.
Post Reply