need help compiling source

Programming, for all ages and all languages.
Post Reply
beyondsociety

need help compiling source

Post by beyondsociety »

I need some help compiling my sources. I have four files that I need to link together and run. My code is set up like this:

Bootsector - > Second stage loader - > third stage - > c kernel.

I have tried compiling but it won't work. Can somebody give me a example on how to compile more than just two files. Any help would be appreciated.

By the way, I using the DJGPP port of gcc tools for Windows.
jrfritz

Re:need help compiling source

Post by jrfritz »

Well:

gcc -c somefile.c -o somefile.o
nasm -f coff someasm.asm -o someasm.o

Look in my install.sh for LD and objectcopy commands. There are ports for object copy.
beyondsociety

Re:need help compiling source

Post by beyondsociety »

Tom, your install.h doesn't help me. I have a bootsector that loads my second stage loader. How would I compile them together? The second-stage loader loads into pmode and jumps to 0x1000. I then have another file load my c kernel.

I compiled my source but when I run it in bochs I get this error:

Code: Select all

00000237336i[BIOS ] FATAL: Not a bootable disk
00000237635p[BIOS ] >>PANIC<< BIOS panic at rombios.c, line 1550
This is how I am compiling my code:

Code: Select all

nasm -f aout -o mboot.o mboot.o
nasm -f aout -o mloader.o mloader.o
ld -Ttext=0x1000 --oformat binary -o boot.bin mboot.o mloader.o

gcc -ffreestanding -c kernel.c -o kernel.o
nasm -f aout load.asm -o load.o

ld -Ttext=0x1000 --oformat binary -o kernel32.bin kernel.o load.o 
makeboot test.img boot.bin kernel32.bin
I have a feeling that I'm not compiling my code right. Can anybody help me.
Berserk

Re:need help compiling source

Post by Berserk »

Hi,

Why do you want to link them together??

And why the heck do you have a third stage loader?? You could've put it all in the Second Stage Loader!

Cya.
beyondsociety

Re:need help compiling source

Post by beyondsociety »

Code: Select all

Why do you want to link them together??
I don't know what I was thinking. I actually only want to link the second-stage loader with the c kernel.

Code: Select all

And why the heck do you have a third stage loader?? You could've put it all in the Second Stage Loader!
I don't know what I was thinking. I will do that as it will save me some headache. Thanks for the help.
jrfritz

Re:need help compiling source

Post by jrfritz »

Here's what I did:

Bootloader, sets pmode, gdt, loads 2nd stage loader with C kernel.

2nd loader:

new bigger GDT with more power
externel functions

Kernel linked with 2nd loader:
Your stuff.
jrfritz

Re:need help compiling source

Post by jrfritz »

But a seperat 2nd stage loader and a 3rd linked with kernel gives you more flexibility, but causes more bugs and probs.
beyondsociety

Re:need help compiling source

Post by beyondsociety »

I've already figured that out Tom ;D

If your not too busy, can you help me with objcopy?
jrfritz

Re:need help compiling source

Post by jrfritz »

Yea...how come the command line info in install.sh doesn't help? ( need to open it up with Wordpad...not notepad)
beyondsociety

Re:need help compiling source

Post by beyondsociety »

Opening up your install.sh file in wordpad is no problem. What I don't understand is the different command-line options you are using.

I've tried to look at the gnu manuals and its like trying to pull gum out of your hair.

So your help would be appreciated.
beyondsociety

Re:need help compiling source

Post by beyondsociety »

Sorry about that Tom. I figured out my problem. I'm at school right now, so I won't be able to test it till later.

If I still have problems, I send you a reply for help. ;)
jrfritz

Re:need help compiling source

Post by jrfritz »

I don't even know the options i'm typing in!

At least it just works for me...
Post Reply