Hi,
I am trying to develop my own kernel. I am a newbee in kernel programming, so i am taking help of one of the article on Bona Fide OS Development, http://www.osdever.net/bkerndev/index.php. For your information, I am using Fedora Core 1 for development. The rest is same i.e gcc, nasm etc...
I am following the article step by step and building and booting the kernel as soon as I finish up one step to see if everything is going fine. So, when I first created the start.asm and link.ld and build the kernel, it all worked fine. When I created the main.c, called it from start.asm and booted this kernel it gave me a problem. The error was something like this:
[Multiboot-kludge, load_addr = 0x100000....
Error 13: Invalid or unsupported file format
I am not getting why this problem is coming as I have done everything exactly as mentioned in that article. I tried searching on google but could not find anything relevant. If anyone wants to check my code, then you can check it out at:
kernel.asm: http://www.slexy.org/paste/4324
link.ld: http://www.slexy.org/paste/4325
main.c: http://www.slexy.org/paste/4326
system.h: http://www.slexy.org/paste/4327
I will really be thankful if you can help me out that where exactly I am doing wrong.
Need Help in making my own kernel
-
- Posts: 2
- Joined: Sat Aug 04, 2007 11:13 am
- Location: Pune, India
- Contact:
Need Help in making my own kernel
Regards,
Piyush Kansal
(A dream is not what you see in sleep, it is one which keeps you awake whole night)
Piyush Kansal
(A dream is not what you see in sleep, it is one which keeps you awake whole night)
-
- Posts: 2
- Joined: Sat Aug 04, 2007 11:13 am
- Location: Pune, India
- Contact:
Well, I checked my commands again as per your suggestion, tried to twist them a little bit, and I am now able to boot the kernel. I even added the code to print "Hello World !!" and its working fine.
Earlier, I was using following commands:
1. nasm -faout kernel.asm -o kernel.o
2. gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o main.o main.c
3. ld -T link.ld kernel.o main.o -o kernel.bin
This time, I am using the same commands but with 2 modification:
1. I removed the very first line from link.ld, which was OUTPUT_FORMAT("binary")
2. ld -T link.ld kernel.o main.o -o kernel
Well, so this issue to closed now. But I have a second query now. Whats the difference between these two commands:
nasm -faout kernel.asm -o kernel.o and
nasm -felf kernel.asm -o kernel.o
The reason I am asking this question is that currently I have got following kernel code which basically prints "Hello World !!" on the screen:
1. kernel.asm: http://www.slexy.org/paste/4540
2. link.ld: http://www.slexy.org/paste/4541
3. main.c: http://www.slexy.org/paste/4542
4. scrn.c: http://www.slexy.org/paste/4543
5. system.h: http://www.slexy.org/paste/4544
When i am trying to build this code as follows:
1. nasm -faout kernel.asm -o kernel.o
2. gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o main.o main.c
3. gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o scrn.o scrn.c
4. ld -T link.ld kernel.o main.o scrn.o -o kernel
It successfully prints "Hello World !!" on screen on booting the kernel.
But, when I build it like this:
1. nasm -felf kernel.asm -o kernel.o
2. gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o main.o main.c
3. gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o scrn.o scrn.c
4. ld -T link.ld kernel.o main.o scrn.o -o kernel
It gives me an error as follows:
[piyushkansal@localhost 3]$ ld -T link.ld -o kernel kernel.o main.o scrn.o
ld: kernel: Not enough room for program headers, try linking with -N
ld: final link failed: Bad value
[piyushkansal@localhost 3]$
I then used the following command:
ld -N -T link.ld -o kernel kernel.o main.o scrn.o
It got build successfully but when i booted the kernel, it gave me following error:
Error 28: Selected item cannot fit into memory
Earlier, I was using following commands:
1. nasm -faout kernel.asm -o kernel.o
2. gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o main.o main.c
3. ld -T link.ld kernel.o main.o -o kernel.bin
This time, I am using the same commands but with 2 modification:
1. I removed the very first line from link.ld, which was OUTPUT_FORMAT("binary")
2. ld -T link.ld kernel.o main.o -o kernel
Well, so this issue to closed now. But I have a second query now. Whats the difference between these two commands:
nasm -faout kernel.asm -o kernel.o and
nasm -felf kernel.asm -o kernel.o
The reason I am asking this question is that currently I have got following kernel code which basically prints "Hello World !!" on the screen:
1. kernel.asm: http://www.slexy.org/paste/4540
2. link.ld: http://www.slexy.org/paste/4541
3. main.c: http://www.slexy.org/paste/4542
4. scrn.c: http://www.slexy.org/paste/4543
5. system.h: http://www.slexy.org/paste/4544
When i am trying to build this code as follows:
1. nasm -faout kernel.asm -o kernel.o
2. gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o main.o main.c
3. gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o scrn.o scrn.c
4. ld -T link.ld kernel.o main.o scrn.o -o kernel
It successfully prints "Hello World !!" on screen on booting the kernel.
But, when I build it like this:
1. nasm -felf kernel.asm -o kernel.o
2. gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o main.o main.c
3. gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o scrn.o scrn.c
4. ld -T link.ld kernel.o main.o scrn.o -o kernel
It gives me an error as follows:
[piyushkansal@localhost 3]$ ld -T link.ld -o kernel kernel.o main.o scrn.o
ld: kernel: Not enough room for program headers, try linking with -N
ld: final link failed: Bad value
[piyushkansal@localhost 3]$
I then used the following command:
ld -N -T link.ld -o kernel kernel.o main.o scrn.o
It got build successfully but when i booted the kernel, it gave me following error:
Error 28: Selected item cannot fit into memory
Regards,
Piyush Kansal
(A dream is not what you see in sleep, it is one which keeps you awake whole night)
Piyush Kansal
(A dream is not what you see in sleep, it is one which keeps you awake whole night)