GRUB and Multiboot Kernel?
Posted: Thu Oct 29, 2009 11:30 pm
I have an (*.iso) file that contains GRUB and my kernel binary file. I have one option in my menu.lst file:
If I try mounting the ISO in an emulator, I receive "Error 13" from GRUB.
mbchk kernel.bin returns:
Here's the output if I add -M after linking all of the files:
http://pastebin.com/m470c3d41
Does the output file that defines multibooting need to be read within the first 8 KBs of the kernel binary?
Here is my build.sh file:
Multiboot definition:
Hopefully the above is legible, and logical of what I'm attempting to do. Is it possible to rearrange my build.sh file to ensure that the multiboot definition is loaded within the first 8 KBs of the binary? Or, if that's not the issue, what could be the issue in the huge mess above?
Thanks!
Code: Select all
kernel /boot/main/kernel.bin
mbchk kernel.bin returns:
Code: Select all
kernel.bin: No Multiboot header.
http://pastebin.com/m470c3d41
Code: Select all
Allocating common symbols
Common symbol size file
textmemptr 0x4 screen_display.o
Memory Configuration
Name Origin Length Attributes
*default* 0x0000000000000000 0xffffffffffffffff
Linker script and memory map
0x0000000000100000 phys = 0x100000
.rodata.str1.1 0x0000000000000000 0x13
.rodata.str1.1
0x0000000000000000 0x13 main.o
.text 0x0000000000100000 0x1000
0x0000000000100000 code = .
*(.text)
.text 0x0000000000100000 0x38 start.o
0x0000000000100000 start
0x000000000010000c mboot
.text 0x0000000000100038 0xb4 main.o
0x0000000000100038 memcpy
0x0000000000100060 memset
0x0000000000100083 memsetw
0x00000000001000a4 strlen
0x00000000001000bd readPortData
0x00000000001000c4 sendPortData
0x00000000001000d0 main
*fill* 0x00000000001000ec 0x4 00
.text 0x00000000001000f0 0x26b screen_display.o
0x00000000001000f0 settextcolor
0x0000000000100108 move_csr
0x0000000000100170 cls
0x00000000001001d2 init_video
0x00000000001001e8 scroll
0x000000000010026b drawChar
0x000000000010032a drawText
*(.rodata)
0x0000000000101000 . = ALIGN (0x1000)
*fill* 0x000000000010035b 0xca5 00
.data 0x0000000000101000 0x1000
0x0000000000101000 data = .
*(.data)
.data 0x0000000000101000 0x0 start.o
.data 0x0000000000101000 0x0 main.o
.data 0x0000000000101000 0x4 screen_display.o
0x0000000000101000 attrib
0x0000000000102000 . = ALIGN (0x1000)
*fill* 0x0000000000101004 0xffc 00
.bss 0x0000000000102000 0x3004
0x0000000000102000 bss = .
*(.bss)
.bss 0x0000000000102000 0x2000 start.o
.bss 0x0000000000104000 0x0 main.o
.bss 0x0000000000104000 0x8 screen_display.o
0x0000000000104000 csr_x
0x0000000000104004 csr_y
0x0000000000105000 . = ALIGN (0x1000)
*fill* 0x0000000000104008 0xff8 00
COMMON 0x0000000000105000 0x4 screen_display.o
0x0000000000105000 textmemptr
0x0000000000105004 end = .
LOAD start.o
LOAD main.o
LOAD screen_display.o
OUTPUT(kernel.bin binary)
.comment 0x0000000000000000 0x48
.comment 0x0000000000000000 0x24 main.o
.comment 0x0000000000000024 0x24 screen_display.o
.note.GNU-stack
0x0000000000000000 0x0
.note.GNU-stack
0x0000000000000000 0x0 main.o
.note.GNU-stack
0x0000000000000000 0x0 screen_display.o
Here is my build.sh file:
Code: Select all
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 screen_display.o screen_display.c
ld -T link.ld -o kernel.bin start.o main.o screen_display.o
wait
Code: Select all
ALIGN 4
global mboot
mboot:
MULTIBOOT_PAGE_ALIGN equ 1<<0
MULTIBOOT_MEMORY_INFO equ 1<<1
MULTIBOOT_AOUT_KLUDGE equ 1<<16
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE
MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
EXTERN code, bss, end
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM
dd mboot
dd code
dd bss
dd end
dd start
Thanks!