Kernel won't boot - ld script problems [solved]
Kernel won't boot - ld script problems [solved]
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!
It says it's an unreadable format and I need a new linker script, can anyone help!
- Attachments
-
- link.ld
- The useless script
- (350 Bytes) Downloaded 71 times
Last edited by stinkfly on Tue Jan 01, 2008 4:19 am, edited 1 time in total.
Stinkfly rules... watch out for my os soon
- fontknocker
- Posts: 16
- Joined: Mon Dec 11, 2006 1:49 am
- Location: Canberra, Australia
I don't really know! I've found this in start.asm: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.
Code: Select all
MULTIBOOT_AOUT_KLUDGE equ 1<<16- Attachments
-
- start.asm
- My Start.asm
- (8.98 KiB) Downloaded 34 times
Stinkfly rules... watch out for my os soon
-
Craze Frog
- Member

- Posts: 368
- Joined: Sun Sep 23, 2007 4:52 am
You don't know?
What do you think this code does (together with the line you posted)?
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- fontknocker
- Posts: 16
- Joined: Mon Dec 11, 2006 1:49 am
- Location: Canberra, Australia
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.
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:
Code: Select all
mbchk kernel.binThe other option to avoid the a.out kludge is to use an ELF-based kernel.
- fontknocker
- Posts: 16
- Joined: Mon Dec 11, 2006 1:49 am
- Location: Canberra, Australia
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?
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?
Well.. i did do mbchk and I got:
I'm trying elf....
Code: Select all
stinkfly@stink-laptop:~/OperatingSystem$ mbchk kernel.bin
kernel.bin: No Multiboot header.
Stinkfly rules... watch out for my os soon