Page 1 of 1
Can't link
Posted: Wed Aug 07, 2002 3:26 pm
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
Re:Can't link
Posted: Wed Aug 07, 2002 4:42 pm
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.
Re:Can't link
Posted: Wed Aug 07, 2002 5:13 pm
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
Re:Can't link
Posted: Thu Aug 08, 2002 3:06 am
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)
Re:Can't link
Posted: Thu Aug 08, 2002 3:08 am
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 )
Re:Can't link
Posted: Thu Aug 08, 2002 12:11 pm
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
Re:Can't link
Posted: Thu Aug 08, 2002 12:51 pm
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
Re:Can't link
Posted: Thu Aug 08, 2002 2:30 pm
by Tom
Thank you:D I should of realized that :-[ DUH.
And thank you for replying so fast ;D
Re:Can't link
Posted: Thu Aug 08, 2002 2:32 pm
by frank
it does load an asm code now, working on the C code...
Re:Can't link
Posted: Fri Aug 09, 2002 10:33 pm
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.
Re:Can't link
Posted: Sat Aug 10, 2002 6:12 am
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