Can't load kernel with bochs
Posted: Fri Jun 03, 2005 10:47 am
Hi,
I would like to load my kernel with grub (Version 0.94) and I would be able to compile my kernel as ELF and as flat binary. ELF works fine but flat binary not. If I try to load my kernel with bochs it says that's unsupported file type. I check my kernel with mbchk, the output is:
my _start.asm like this:
the kernel is linked with the command:
ld --omagic --oformat binary -T link.ld *.o -o /root/os/kernelv0.2/kernel
I would like to load my kernel with grub (Version 0.94) and I would be able to compile my kernel as ELF and as flat binary. ELF works fine but flat binary not. If I try to load my kernel with bochs it says that's unsupported file type. I check my kernel with mbchk, the output is:
my linkerscript looks like this:linux:~/os/kernelv0.2 # mbchk ./kernel
./kernel: The Multiboot header is found at the offset 8.
./kernel: Page alignment is turned off.
./kernel: Memory information is turned on.
./kernel: Address fields is turned on.
./kernel: header_addr is less than load_addr (0x100008 > 0x100047).
Code: Select all
/* Link.ld */
ENTRY(start)
SECTIONS
{
.text 0x100000 :
{
*(.text)
code = .; _code = .; __code = .;
. = ALIGN(4096);
}
.data :
{
*(.data)
data = .; _data = .; __data = .;
. = ALIGN(4096);
}
.bss :
{
*(.bss)
bss = .; _bss = .; __bss = .;
. = ALIGN(4096);
}
end = .; _end = .; __end = .;
}
Code: Select all
[BITS 32]
[GLOBAL start]
[EXTERN _code]
[EXTERN _bss]
[EXTERN _end]
[EXTERN _main]
start:
jmp _start
MULTIBOOT_MAGIC equ 0x1BADB002
MULTIBOOT_MEMORY_INFO equ 1 << 1
%ifndef _ELF
MULTIBOOT_AOUT_KLUDGE equ 1 << 16
MULTIBOOT_FLAGS equ MULTIBOOT_MEMORY_INFO|MULTIBOOT_AOUT_KLUDGE
%else
MULTIBOOT_FLAGS equ MULTIBOOT_MEMORY_INFO
%endif
MULTIBOOT_CHECKSUM equ -(MULTIBOOT_MAGIC + MULTIBOOT_FLAGS)
align 4
multiboot_header:
magic dd MULTIBOOT_MAGIC
flags dd MULTIBOOT_FLAGS
checksum dd MULTIBOOT_CHECKSUM
%ifndef _ELF
header_addr dd multiboot_header
load_addr dd _code
load_end_addr dd _bss
bss_end_addr dd _end
entry_addr dd start
%endif
_start:
call _main ; run kernel c code
HALT:
%ifndef _BOCHS
cli
hlt
%endif
jmp HALT
ld --omagic --oformat binary -T link.ld *.o -o /root/os/kernelv0.2/kernel