...
Thanks,
Lster
OS Development In Linux (GCC And LD Problems)
OS Development In Linux (GCC And LD Problems)
Last edited by Lprogster on Tue Oct 23, 2007 11:23 am, edited 2 times in total.
- AndrewAPrice
- Member
- Posts: 2309
- Joined: Mon Jun 05, 2006 11:00 pm
- Location: USA (and Australia)
Re: OS Development In Linux (GCC And LD Problems)
That kernel is only a few kilobytes. Because you're not using grub, you'll have to change the memory address of the kernel. It sounds like your GCC hasn't been built with required the executable formats (the tutorial loads the kernel at the 1MB mark, so GCC is probably getting confused and inserting 1MB of random junk before your code).Lprogster wrote:Hi all
As well as developing my OS in Windows, I would like to start a new OS in Linux. As when starting my first OS, I decided to start with this one at http://osdever.net/bkerndev/Docs/whatsleft.htm . (Scroll down to the bit 'Get the whole tutorial...' for the OS archive)
However I am having problems compiling it. There is a batch script with it which is used to compile it. I create my own '.sh' script with the equivalent commands and run it. I then use 'cat' to join it to my boot sector and it produces a 1MB kernel that Qemu tells me is invalid.
Here is my script; please dont run it as it may be unsafe!
It should be noted my boot sector has already been made (in Windows) and does work. I am using the provided link script and source code.Code: Select all
cd /home/lster/Desktop/bkerndev/Sources nasm -f aout -o start.o start.asm gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o main.o main.c gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o scrn.o scrn.c gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o gdt.o gdt.c gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o idt.o idt.c gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o isrs.o isrs.c gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o irq.o irq.c gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o timer.o timer.c gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o kb.o kb.c ld -T link.ld -o kernel.bin start.o main.o scrn.o gdt.o idt.o isrs.o irq.o timer.o kb.o cat ./bootsect.bin ./kernel.bin > ./a.img
Any ideas? (Tell me if you need more info.)
Thanks,
Lster
That happened to me once.. My old GCC didn't support ELF, and when I compiled my kernel, it outputted a text file as if GCC literally 'ran' the kernel. The text file contents were like:
Code: Select all
Kernel now starting.........
Init keyboard.. DONE
Init floppy.. DONE
Enabling ints.. DONE
Login:
My OS is Perception.
Hi again all
I decided it is best to find out if there is something wrong with my kernel.
...
When Qemu runs a.img it prints '1' in the top left corner, but doesn't print the '2' next to it. Qemu doesn't hang like it did with my last kernel, though.
Any ideas?![Cool 8)](./images/smilies/icon_cool.gif)
Thank you,
Lster
I decided it is best to find out if there is something wrong with my kernel.
...
When Qemu runs a.img it prints '1' in the top left corner, but doesn't print the '2' next to it. Qemu doesn't hang like it did with my last kernel, though.
Any ideas?
![Cool 8)](./images/smilies/icon_cool.gif)
Thank you,
Lster
Last edited by Lprogster on Tue May 08, 2007 8:34 am, edited 1 time in total.
- Combuster
- 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:
If you have tried bochs, it spits out warnings: partial read returns 9/512. This is due to the floppy image being not a multiple of 512 bytes in size. In contrast, Qemu does not clean up after you and just loads whatever it seems fit.
Solution: pad your second file to a 512 byte boundary
Better solution: Make sure your floppy image is always the full 1.44M in size.
Solution: pad your second file to a 512 byte boundary
Better solution: Make sure your floppy image is always the full 1.44M in size.