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.
Translating my C kernel to C++
Translating my C kernel to C++
Sorry, i used gcc, now gxx. Developing in Windows XP environment. GCC version is 3.03, gxx version 3.02, ld version 2.11.2.
RE:Translating my C kernel to C++
Have you tried striping the binary?
strip kernel
Assuming your distribution has a strip command... all Linux distribs do.
Cheers,
Jeff
strip kernel
Assuming your distribution has a strip command... all Linux distribs do.
Cheers,
Jeff
RE:Translating my C kernel to C++
Now linkin works, i'm at different computer now, i can later post ld parameters what made i to work, if you want to. Still got weird problems. First it run well, then i removed big table ~100KB and it doesn't work any more...
RE:Translating my C kernel to C++
Now I know where the bug is but don't know how to fix it. Crash is caused by:
__inline__ unsigned char peekb(USHORT Seg, ULONG Off)
{ unsigned char RetVal;
__asm__ __volatile__ ("movw %w1, %%fs \n.byte 0x64 \nmovb (%k2),%w0"
: "=r" (RetVal)
: "rm" (Seg), "r" (Off));
return(RetVal);
}
Bochs says "Prefetch: Running in bogus memory". I've tried to use function without __inline__ & __volatile__ but it doesn't help...
__inline__ unsigned char peekb(USHORT Seg, ULONG Off)
{ unsigned char RetVal;
__asm__ __volatile__ ("movw %w1, %%fs \n.byte 0x64 \nmovb (%k2),%w0"
: "=r" (RetVal)
: "rm" (Seg), "r" (Off));
return(RetVal);
}
Bochs says "Prefetch: Running in bogus memory". I've tried to use function without __inline__ & __volatile__ but it doesn't help...