Grub+elf-kernel
Grub+elf-kernel
Hi,
Well, after the few problems i have with the loader on diferents PCs I choose use grub.
My problem is when boot with the FD, i get this message:
kernel /boot/kernel.elf
[Multiboot-elf, <0x20:0x240:0x0>
Error 28: Selected item cannot fit into memory
Here is my kernel header:
mboot:
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM
and this on a .inc file:
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).
the linker script here is:
# Simple way to compile & put on a floppy
OUTPUT_FORMAT("elf32-i386")
ENTRY(start)
virt = 0xC0000000; /* 3 gig */
phys = 0x100000; /* 1 meg */
SECTIONS
{ .text virt : AT(phys)
{ code = .;
*(.text)
. = ALIGN(4096); }
.data : AT(phys + (data - code))
{ data = .;
*(.data)
. = ALIGN(4096); }
.bss : AT(phys + (bss - code))
{ bss = .;
*(.bss)
*(COMMON)
. = ALIGN(4096); }
end = .; }
nasm -f aout common.asm -o common.o
nasm -f aout isr.asm -o isr.o
gcc -c kk.c -o kk.o
ld -T link.ld -N --oformat=elf32-i386 common.o isr.o kk.o -o kernel.elf
dd if=kernel.elf seek=237 of=/dev/fd0
Any idea??
thanks
Well, after the few problems i have with the loader on diferents PCs I choose use grub.
My problem is when boot with the FD, i get this message:
kernel /boot/kernel.elf
[Multiboot-elf, <0x20:0x240:0x0>
Error 28: Selected item cannot fit into memory
Here is my kernel header:
mboot:
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM
and this on a .inc file:
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).
the linker script here is:
# Simple way to compile & put on a floppy
OUTPUT_FORMAT("elf32-i386")
ENTRY(start)
virt = 0xC0000000; /* 3 gig */
phys = 0x100000; /* 1 meg */
SECTIONS
{ .text virt : AT(phys)
{ code = .;
*(.text)
. = ALIGN(4096); }
.data : AT(phys + (data - code))
{ data = .;
*(.data)
. = ALIGN(4096); }
.bss : AT(phys + (bss - code))
{ bss = .;
*(.bss)
*(COMMON)
. = ALIGN(4096); }
end = .; }
nasm -f aout common.asm -o common.o
nasm -f aout isr.asm -o isr.o
gcc -c kk.c -o kk.o
ld -T link.ld -N --oformat=elf32-i386 common.o isr.o kk.o -o kernel.elf
dd if=kernel.elf seek=237 of=/dev/fd0
Any idea??
thanks
Re:Grub+elf-kernel
ive got sumting like:
%include "grub.inc" ; needed for the multiboot header
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Multiboot header for GRUB bootloader. This must be in the first 8K
; of the kernel file. We use the aout kludge so it works with ELF,
; DJGPP COFF, Win32 PE, or other formats.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; these are in the linker script file
EXTERN code, bss, end
ALIGN 4
mboot:
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM
; aout kludge. These must be PHYSICAL addresses
dd mboot
dd code
dd bss
dd end
dd start
the grub.inc file is:
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)
i think u are missin the aout kludge.
ias i develop on win98 and use coff file format and produce binary for the kernel this mite not work but im not sure cuz i havent tested it with elf.
if it does work den let me no so i mite think about using elf as a format for my kernel.
%include "grub.inc" ; needed for the multiboot header
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Multiboot header for GRUB bootloader. This must be in the first 8K
; of the kernel file. We use the aout kludge so it works with ELF,
; DJGPP COFF, Win32 PE, or other formats.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; these are in the linker script file
EXTERN code, bss, end
ALIGN 4
mboot:
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM
; aout kludge. These must be PHYSICAL addresses
dd mboot
dd code
dd bss
dd end
dd start
the grub.inc file is:
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)
i think u are missin the aout kludge.
ias i develop on win98 and use coff file format and produce binary for the kernel this mite not work but im not sure cuz i havent tested it with elf.
if it does work den let me no so i mite think about using elf as a format for my kernel.
Re:Grub+elf-kernel
I found some info from DF to help us:
http://www.mega-tokyo.com/forum/index.php?board=1;action=display;threadid=2492;start=0 - Read near bottom-bottom
http://www.mega-tokyo.com/forum/attachments/uploaded_files/elfdump.txt What are kernels look like
http://www.mega-tokyo.com/forum/index.php?board=1;action=display;threadid=2492;start=0 - Read near bottom-bottom
http://www.mega-tokyo.com/forum/attachments/uploaded_files/elfdump.txt What are kernels look like
Re:Grub+elf-kernel
aout kludge not needed on ELF files.Guest wrote: i think u are missin the aout kludge.
ias i develop on win98 and use coff file format and produce binary for the kernel this mite not work but im not sure cuz i havent tested it with elf.
if it does work den let me no so i mite think about using elf as a format for my kernel.
-- Stu --
Re:Grub+elf-kernel
I think this error happens because the ".rodata" section(s) are not included in the linker script.
You can change the linker script to merge these sections with the code:
...
.text virt : AT(phys)
{ code = .;
*(.text)
*(.rodata*)
. = ALIGN(4096); }
...
GCC 3.x make several ".rodata" sections -- that's why the ".rodata" line has a second wildcard character (*) in it.
You can change the linker script to merge these sections with the code:
...
.text virt : AT(phys)
{ code = .;
*(.text)
*(.rodata*)
. = ALIGN(4096); }
...
GCC 3.x make several ".rodata" sections -- that's why the ".rodata" line has a second wildcard character (*) in it.
Re:Grub+elf-kernel
Yes, I was having this problem early on too. Its definately relating to linker scripts.
Daryl.
Daryl.
Re:Grub+elf-kernel
I made the fix in the script, thanks Chris and xeon.
Now grub doen't show any error message, and load the kernel, but it resets the PC. I spended one week on try to fix it, but i can't.
Here is my new link script:
OUTPUT_FORMAT("elf32-i386")
ENTRY(start)
virt = 0xC0000000; /* 3 gig */
phys = 0x102000; /* 1 meg */
SECTIONS
{
.text phys : AT(phys)
{
code = .;
*(.text)
*(.rodata*)
. = ALIGN(4096);
}
.data : AT(phys + (data - code))
{
data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(phys + (bss - code))
{
bss = .;
*(.bss)
*(COMMON)
. = ALIGN(4096);
}
end = .;
}
and my the asm part of my kernel.
Can anyone help me?
Now grub doen't show any error message, and load the kernel, but it resets the PC. I spended one week on try to fix it, but i can't.
Here is my new link script:
OUTPUT_FORMAT("elf32-i386")
ENTRY(start)
virt = 0xC0000000; /* 3 gig */
phys = 0x102000; /* 1 meg */
SECTIONS
{
.text phys : AT(phys)
{
code = .;
*(.text)
*(.rodata*)
. = ALIGN(4096);
}
.data : AT(phys + (data - code))
{
data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(phys + (bss - code))
{
bss = .;
*(.bss)
*(COMMON)
. = ALIGN(4096);
}
end = .;
}
and my the asm part of my kernel.
Can anyone help me?
Re:Grub+elf-kernel
could it be my GTD?
Iv'e tried only load kernel asm. And even not all... but it resets too.
Thanks
Iv'e tried only load kernel asm. And even not all... but it resets too.
Thanks
Re:Grub+elf-kernel
Why such a complicated linker script? All you should need is something simple like this:
K.J.
Code: Select all
OUTPUT_FORMAT("elf32-i386")
ENTRY(start)
SECTIONS
{
.text 0x100000 : {
*(.text)
}
.data : {
*(.data)
}
.bss :
{
*(.bss)
}
}