grub load time crash
grub load time crash
NOTE: im using c++ for my kernel
boots using grub
so i've got my file system module that handles the file system.
I have a file class (with no constructor). When I add a static File to my memory manager, i get a load time crash saying:
root (fd0)
filesystem is fat, using whole disk
kernel /kernel.bin
[multiboot-kludge, loadaddr=0x100000, text-and-data=0xb000
error 13: invalid or unsupported format
any ideas what this could be? i tried swapping it with an array of 1024 ints just to see if it was some size problem, but that worked fine.
boots using grub
so i've got my file system module that handles the file system.
I have a file class (with no constructor). When I add a static File to my memory manager, i get a load time crash saying:
root (fd0)
filesystem is fat, using whole disk
kernel /kernel.bin
[multiboot-kludge, loadaddr=0x100000, text-and-data=0xb000
error 13: invalid or unsupported format
any ideas what this could be? i tried swapping it with an array of 1024 ints just to see if it was some size problem, but that worked fine.
hrmm this is all that is in my File class:
class File
{
// some functions here
char name[256];
unsigned long handle; // handle to the file
unsigned long cursor;
unsigned long fileSize; // size of file
unsigned short flags;
};
then in my memory mgr, i have:
static FS::File sPageFile;
adding this static instance is causing the problem, but i fail to see why/how
class File
{
// some functions here
char name[256];
unsigned long handle; // handle to the file
unsigned long cursor;
unsigned long fileSize; // size of file
unsigned short flags;
};
then in my memory mgr, i have:
static FS::File sPageFile;
adding this static instance is causing the problem, but i fail to see why/how
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
Code: Select all
export PATH=$PATH:/usr/cross/bin
del *.bin
nasm -f elf -o start.o start.asm
g++ -b i586-elf -V 4.0.2 -Wall -O -fno-rtti -fno-exceptions -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o main.o main.cpp
g++ -b i586-elf -V 4.0.2 -Wall -O -fno-rtti -fno-exceptions -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o video.o video.cpp
g++ -b i586-elf -V 4.0.2 -Wall -O -fno-rtti -fno-exceptions -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o gdt.o gdt.cpp
g++ -b i586-elf -V 4.0.2 -Wall -O -fno-rtti -fno-exceptions -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o idt.o idt.cpp
g++ -b i586-elf -V 4.0.2 -Wall -O -fno-rtti -fno-exceptions -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o isrs.o isrs.cpp
g++ -b i586-elf -V 4.0.2 -Wall -O -fno-rtti -fno-exceptions -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o irq.o irq.cpp
g++ -b i586-elf -V 4.0.2 -Wall -O -fno-rtti -fno-exceptions -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o harddrive.o harddrive.cpp
g++ -b i586-elf -V 4.0.2 -Wall -O -fno-rtti -fno-exceptions -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o timer.o timer.cpp
g++ -b i586-elf -V 4.0.2 -Wall -O -fno-rtti -fno-exceptions -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o kb.o kb.cpp
g++ -b i586-elf -V 4.0.2 -Wall -O -fno-rtti -fno-exceptions -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o string.o string.cpp
g++ -b i586-elf -V 4.0.2 -Wall -O -fno-rtti -fno-exceptions -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o memory.o memory.cpp
g++ -b i586-elf -V 4.0.2 -Wall -O -fno-rtti -fno-exceptions -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o system.o system.cpp
g++ -b i586-elf -V 4.0.2 -Wall -O -fno-rtti -fno-exceptions -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o command.o command.cpp
g++ -b i586-elf -V 4.0.2 -Wall -O -fno-rtti -fno-exceptions -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o smbios.o smbios.cpp
g++ -b i586-elf -V 4.0.2 -Wall -O -fno-rtti -fno-exceptions -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o pci.o pci.cpp
g++ -b i586-elf -V 4.0.2 -Wall -O -fno-rtti -fno-exceptions -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o fat32.o fat32.cpp
g++ -b i586-elf -V 4.0.2 -Wall -O -fno-rtti -fno-exceptions -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o svga.o svga.cpp
i586-elf-ld -T link.ld -o kernel.bin start.o main.o timer.o video.o gdt.o idt.o isrs.o irq.o kb.o string.o memory.o system.o harddrive.o command.o smbios.o pci.o fat32.o svga.o
del *.o
OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
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)
. = ALIGN(4096);
}
end = .;
}
objdump on kernel.bin says its un recognised format
ENTRY(start)
phys = 0x00100000;
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)
. = ALIGN(4096);
}
end = .;
}
objdump on kernel.bin says its un recognised format
If you are using C++, it looks like your .ctors and .dtors sections are missing from the link script. You will need to manually run the constructors and destructors for global and static objects. Try looking at http://www.osdever.net/tutorials/pdf/cpp_kernel.pdf.
HTH
Adam
HTH
Adam
supagu wrote:Code: Select all
nasm -f elf -o start.o start.asm g++ -b i586-elf -V 4.0.2 -Wall -O -fno-rtti -fno-exceptions -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o main.o main.cpp [snip] i586-elf-ld -T link.ld -o kernel.bin start.o main.o timer.o video.o gdt.o idt.o isrs.o irq.o kb.o string.o memory.o system.o harddrive.o command.o smbios.o pci.o fat32.o svga.o
Let me get this straight...supagu wrote:OUTPUT_FORMAT("binary")
- You use GRUB as your bootloader.
- You're using what looks like an ELF cross-compiler + ELF ld. You instruct NASM to produce ELF output.
- You use that toolchain link your kernel into raw binary format (with the multiboot "aout kludge").
Try changing the OUTPUT_FORMAT to an ELF variant (possibly most easily done by just omitting it, as it's probably the default for that toolchain) and disabling the "kludge" flag in the multiboot header. See if that fixes it.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
GRUB may support both ELF and Multiboot, but other loaders may not necessarily do so (and support only one, or even neither). Hence choosing multiboot is a perfectly valid decision. Besides, many tutorials target multiboot rather than elf. Changing targets now will only cause more problems rather than solving any.Any particular reason for that last one? (GRUB should load ELF executables just fine, without needing the kludge)
Try changing the OUTPUT_FORMAT to an ELF variant (possibly most easily done by just omitting it, as it's probably the default for that toolchain) and disabling the "kludge" flag in the multiboot header. See if that fixes it.