Can't link

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
Tom

Can't link

Post by Tom »

There is a problem with linking my kernel.
When I don't link it, it works. But when I do link it. Nothing happens when my kernel boots.

I have NASM 0.98
in linux i type this to compile & link & put it on a floppy:

nasm -f aout -o asmkernel.o asmkernel.asm
ld asmkernel.o -o asmkernel.bin -oformat binary -Ttext=0x100000

Is there anything I'm doing wrong?
Thank you
K.J.

Re:Can't link

Post by K.J. »

Using a linker script should fix your problem. There is an example linker script here:
http://osdev.neopages.net/tutorials/mysuggestions.php

Hope that helps,
K.J.
Tom

Re:Can't link

Post by Tom »

I tried that one alredy. But it didn't work.

My kernel is only a assembly bootsector.
I'm trying to make it link so I can soon ad in C code.

www.sourceforge.net/projects/fritzos

Is my OS development page. Please help
Thank you
frank

Re:Can't link

Post by frank »

aout is an ELF format ... ofcourse that doesn't work. :)
it should be flat binary ..
use this line:

nasm fileasm.asm -f bin

then dd to load it to your disk (jep your using a unix-like os :))
dd if=fileasm seek=0 of=/dev/disk

(seek = sectors to skip, /dev/disk is your disk)
frank

Re:Can't link

Post by frank »

woops I did not read well :-[

but object files (for ld) must be 32 bit, so I don't think that's gonna work...
(I figured that out while I was trying to make 2 object files, 1 asm , 1 c, well that doesn't work )
Tom

Re:Can't link

Post by Tom »

Thank you, but how do I make my object file a 32-bit one? I need to link so I can add protected mode C code later.

Tom

If you need to see my code to know what i'm doing, download Prekernel0-1.zip at www.sourceforge.net/projects/fritzos
frank

Re:Can't link

Post by frank »

It is always 32bit... that's what object files are...
(which means, if it does work, it will reboot, since your stil in realmode)
32bit mode codes use eax,ebx,ecx,edx.. which makes your cpu crash

Make a flat binary file
(nasm file.asm -f bin)
which loads in your kernel,switches to pmode and then jumps to your C kernel.

See my code:
http://www.mega-tokyo.com/forum/index.p ... eadid=1119

Unfortanly, it does not work fine yet.. (I can't print a character in C)

Good luck :)
Tom

Re:Can't link

Post by Tom »

;) Thank you:D I should of realized that :-[ DUH.
And thank you for replying so fast ;D
frank

Re:Can't link

Post by frank »

it does load an asm code now, working on the C code...
K.J.

Re:Can't link

Post by K.J. »

32bit mode codes use eax,ebx,ecx,edx.. which makes your cpu crash
Ermm... no. You can use the extended registers in real mode code also. It's going beyond the 1 meg mark that crashes it(without the A20 enabled that is).

K.J.
frank

Re:Can't link

Post by frank »

>nasm -f aout -o asmkernel.o asmkernel.asm>
>ld asmkernel.o -o asmkernel.bin -oformat binary -Ttext=0x100000
>
>Is there anything I'm doing wrong?
>Thank you

it shoukd be in bin file..
the second line doesn't put it on a floppy, use dd for that.


nasm kern.asm -f bin
dd if=kern of=/dev/fd0

:)
Post Reply