I've spent a month's work on my 32-bit "bootstrap" kernel, and now I think that it's time to start work on the 64-bit "real" one. Hence I grabbed the C++ Barebones tutorial in order to get information on C++ handling and some basic working code that I can tweak later.
However, something horribly wrong seems to be going on, because my final binary image is... guess what... 2 Mo large for a simple "hello world" code !
As Microsoft said, the "wow" starts now !
Could you please help me finding out what's wrong ? I think there's an issue with the linker script, but I don't see what's wrong with it...
Here's stuff that matters in my building script :
Code: Select all
#Compile
CXX=x86_64-elf-g++
LD=x86_64-elf-ld
CXXFLAGS="-Wall -Wextra -Werror -nostdlib -nostartfiles -nodefaultlibs -fno-builtin -fno-exceptions -fno-rtti -fno-stack-protector"
INCLUDES="-I../../arch/x86_64/debug/ -I../../arch/x86_64/include/ -I../../include/"
echo \* Making main kernel...
cd bin/kernel
$CXX -c ../../init/kernel.cpp $CXXFLAGS $INCLUDES
$LD -T ../../support/kernel_linker.lds -o kernel.bin *.o
cd ../..
Code: Select all
char* const vmem = (char *) 0xb8000;
extern "C" int kmain() {
//Okay, everything is ready
vmem[0] = 'R';
return 0;
}
Code: Select all
ENTRY(kmain)
SECTIONS
{
. = 0x200000;
.text :
{
*(.text*)
*(.gnu.linkonce.t*)
}
.rodata ALIGN(4096) :
{
*(.rodata*)
*(.gnu.linkonce.r*)
}
.data ALIGN(4096) :
{
start_ctors = .;
*(.ctor*)
end_ctors = .;
start_dtors = .;
*(.dtor*)
end_dtors = .;
*(.data*)
*(.gnu.linkonce.d*)
}
.bss ALIGN(4096) :
{
*(.COMMON*)
*(.bss*)
*(.gnu.linkonce.b*)
}
/DISCARD/ :
{
*(.comment)
*(.eh_frame) /* You should discard this unless you're implementing runtime support for C++ exceptions. */
}
}
kernel.bin, on the other hand, weights 2.0 Mo, as I stated before. This is what makes me think that the linking step is to blame.
I'm still not very familiar with LD scripts and linking theory, despite having learned a lot about them when writing my previous C kernel, but afaik and according to the LD script doc that I use ( http://sourceware.org/binutils/docs-2.1 ... le-Example )
Code: Select all
. = 0x200000;