Page 1 of 2
Grub+elf-kernel
Posted: Mon Jan 13, 2003 1:47 pm
by eL JeDi
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
Re:Grub+elf-kernel
Posted: Mon Jan 13, 2003 1:53 pm
by jrfritz
THATS EXACTLY WHAT HAPPENS TO ME!
Re:Grub+elf-kernel
Posted: Mon Jan 13, 2003 2:00 pm
by eL JeDi
well, we're in a trouble!!!!! ;D
Re:Grub+elf-kernel
Posted: Mon Jan 13, 2003 2:01 pm
by Guest
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.
Re:Grub+elf-kernel
Posted: Mon Jan 13, 2003 2:02 pm
by jrfritz
Re:Grub+elf-kernel
Posted: Mon Jan 13, 2003 2:48 pm
by df
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.
aout kludge not needed on ELF files.
Re:Grub+elf-kernel
Posted: Mon Jan 13, 2003 10:30 pm
by Chris Giese
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.
Re:Grub+elf-kernel
Posted: Tue Jan 14, 2003 3:03 am
by DarylD
Yes, I was having this problem early on too. Its definately relating to linker scripts.
Daryl.
Re:Grub+elf-kernel
Posted: Tue Jan 14, 2003 8:30 am
by jrfritz
Wow, Chris Giese was here!
Re:Grub+elf-kernel
Posted: Tue Jan 14, 2003 7:24 pm
by Xeon
Change '.text virt' to '.text phys' and it should work.
Re:Grub+elf-kernel
Posted: Thu Jan 16, 2003 5:08 pm
by eL JeDi
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?
Re:Grub+elf-kernel
Posted: Thu Jan 16, 2003 5:11 pm
by eL JeDi
[attachment deleted by admin]
Re:Grub+elf-kernel
Posted: Sat Jan 18, 2003 10:48 am
by eL JeDi
could it be my GTD?
Iv'e tried only load kernel asm. And even not all... but it resets too.
Thanks
Re:Grub+elf-kernel
Posted: Sat Jan 18, 2003 2:43 pm
by K.J.
Why such a complicated linker script? All you should need is something simple like this:
Code: Select all
OUTPUT_FORMAT("elf32-i386")
ENTRY(start)
SECTIONS
{
.text 0x100000 : {
*(.text)
}
.data : {
*(.data)
}
.bss :
{
*(.bss)
}
}
K.J.
Re:Grub+elf-kernel
Posted: Sat Jan 18, 2003 7:23 pm
by jrfritz
But that doesn't work....