Translating my C kernel to C++
Posted: Thu Dec 11, 2003 12:00 am
I'll try to translate my kernel to C++ but I have little problem(problem size ~155kb
. Everything is OK except
that when I link my files, size of kernel grows very much. Object file sizes are 42.5kb total, but after
linking kernel image is 189kb. I use gcc, ld, aout, output format is binary. LD parameters are -nostdlib -g -Tkernel/kernel.ld.
Compiling options are -c -ffreestanding -nostdlib -fno-builtin -fno-rtti -fno-exceptions -Ikernel/include.
Linker file(kernel.ld) looks like this:
OUTPUT_FORMAT("binary")
ENTRY(_start)
SECTIONS
{
.text 0xC0000000 : /* 3.5 gig */
{
/* kernel code */
code = .; _code = .; __code = .;
*(.text)
. = ALIGN(4096);
ecode = .; _ecode = .; __ecode = .;
/* discardable kernel code */
dcode = .; _dcode = .; __dcode = .;
*(.dtext)
. = ALIGN(4096);
edcode = .; _edcode = .; __edcode = .;
}
.data :
{
/* kernel data */
data = .; _data = .; __data = .;
*(.data)
. = ALIGN(4096);
edata = .; _edata = .; __edata = .;
/* discardable kernel data */
ddata = .; _ddata = .; __ddata = .;
*(.ddata)
. = ALIGN(4096);
eddata = .; _eddata = .; __eddata = .;
}
.bss :
{
/* kernel BSS */
bss = .; _bss = .; __bss = .;
*(.bss)
/* *(COMMON) */
. = ALIGN(4096);
ebss = .; _ebss = .; __ebss = .;
/* discardable kernel BSS */
dbss = .; _dbss = .; __dbss = .;
*(.dbss)
. = ALIGN(4096);
edbss = .; _edbss = .; __edbss = .;
}
end = .; _end = .; __end = .;
}
When i was compiling in C, size of whole floppy image was 48kb, including 512b boot loader & 18KB system loader...
And of course, Bochs now whines "Third (13) exception with no resolution". There is nop in start of my boiler plate,
and i can find it from the start of the kernel image. Sorry for bad english.
![Smile :)](./images/smilies/icon_smile.gif)
that when I link my files, size of kernel grows very much. Object file sizes are 42.5kb total, but after
linking kernel image is 189kb. I use gcc, ld, aout, output format is binary. LD parameters are -nostdlib -g -Tkernel/kernel.ld.
Compiling options are -c -ffreestanding -nostdlib -fno-builtin -fno-rtti -fno-exceptions -Ikernel/include.
Linker file(kernel.ld) looks like this:
OUTPUT_FORMAT("binary")
ENTRY(_start)
SECTIONS
{
.text 0xC0000000 : /* 3.5 gig */
{
/* kernel code */
code = .; _code = .; __code = .;
*(.text)
. = ALIGN(4096);
ecode = .; _ecode = .; __ecode = .;
/* discardable kernel code */
dcode = .; _dcode = .; __dcode = .;
*(.dtext)
. = ALIGN(4096);
edcode = .; _edcode = .; __edcode = .;
}
.data :
{
/* kernel data */
data = .; _data = .; __data = .;
*(.data)
. = ALIGN(4096);
edata = .; _edata = .; __edata = .;
/* discardable kernel data */
ddata = .; _ddata = .; __ddata = .;
*(.ddata)
. = ALIGN(4096);
eddata = .; _eddata = .; __eddata = .;
}
.bss :
{
/* kernel BSS */
bss = .; _bss = .; __bss = .;
*(.bss)
/* *(COMMON) */
. = ALIGN(4096);
ebss = .; _ebss = .; __ebss = .;
/* discardable kernel BSS */
dbss = .; _dbss = .; __dbss = .;
*(.dbss)
. = ALIGN(4096);
edbss = .; _edbss = .; __edbss = .;
}
end = .; _end = .; __end = .;
}
When i was compiling in C, size of whole floppy image was 48kb, including 512b boot loader & 18KB system loader...
And of course, Bochs now whines "Third (13) exception with no resolution". There is nop in start of my boiler plate,
and i can find it from the start of the kernel image. Sorry for bad english.