Page 1 of 1
Kernel won't boot - ld script problems [solved]
Posted: Sun Dec 30, 2007 7:12 am
by stinkfly
Hiya, I'm trying to link to kludge a.out format following bkerndev and it's not working - everything will build and stuff, just it won't boot.
It says it's an unreadable format and I need a new linker script, can anyone help!
Posted: Sun Dec 30, 2007 11:16 pm
by fontknocker
Just checking, but in your multiboot header did you mark bit 16 in the flags (the a.out kludge) and provide the load addresses? If I recall those are in Brandon's tutorial anyway but it never hurts to double check.
Posted: Mon Dec 31, 2007 3:08 am
by stinkfly
fontknocker wrote:Just checking, but in your multiboot header did you mark bit 16 in the flags (the a.out kludge) and provide the load addresses? If I recall those are in Brandon's tutorial anyway but it never hurts to double check.
I don't really know! I've found this in start.asm:
Posted: Mon Dec 31, 2007 10:52 am
by Craze Frog
You don't know?
What do you think this code does (together with the line you posted)?
Code: Select all
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE
...
dd MULTIBOOT_HEADER_FLAGS
..
Posted: Tue Jan 01, 2008 12:22 am
by stinkfly
Can, you just help me to get it working? I'm just starting os development, so I don't have many ideas what things are.
Posted: Tue Jan 01, 2008 2:57 am
by fontknocker
GRUB cannot load non-ELF format kernels natively. It needs additional information to load these kernels - this information is provided in the multiboot header. The header includes information on where your code, data and bss sections are as well as where your entry point is located. If the bootloader can't find this information (i.e. it's been put in the wrong place in the output binary or doesn't exist at all) it will complain about an unreadable format.
Definitive Reference Here
Double check your boot.asm with the one provided in the tutorial. Chances are you've forgotten to put in the load addresses. They should go immediately after you output the checksum in the mboot section. To ensure your Multiboot information is all in order after linking run:
I also suggest you study the Multiboot specification so you know exactly how the headers work and why you need to do things the way Brandon describes in his tutorial.
The other option to avoid the a.out kludge is to use an ELF-based kernel.
Posted: Tue Jan 01, 2008 3:27 am
by stinkfly
I don't seem to have a boot.asm, there's only start.asm... but they are headers in there... It looks like it's over to ELF. What would I need to change to get elf?
Posted: Tue Jan 01, 2008 4:02 am
by fontknocker
Sorry, I meant to say start.asm. boot.asm is my own source file, oops. Rather than going to ELF straight up it might be worth finding out what's going wrong; best way to learn is to stuff it all up.
Going to ELF isn't hard; it's just a matter of changing NASM's output to elf (instead of aout) and specifying elf32-i386 as the output format in your linker script (instead of binary).
But before trying that, did you run your kernel image through mbchk? Did it get a clean bill of health?
Posted: Tue Jan 01, 2008 4:10 am
by stinkfly
Well.. i did do mbchk and I got:
Code: Select all
stinkfly@stink-laptop:~/OperatingSystem$ mbchk kernel.bin
kernel.bin: No Multiboot header.
I'm trying elf....
Wahoo!
Posted: Tue Jan 01, 2008 4:18 am
by stinkfly
Yay! Making it elf worked! Hope i can rely on you lot again some time!