Hi!
I wrote my own bootloader and it works ok loading a plain binary kernel ( Totally written in asm ). But now I want to use C code and I want to know if it's better a BIN or an ELF kernel?
--------
Edit: Another thing , in plain binary files , does the BSS section exist ?
ELF or BIN Kernel???
- Kevin McGuire
- Member
- Posts: 843
- Joined: Tue Nov 09, 2004 12:00 am
- Location: United States
- Contact:
Yes I have C/C++ kernel. My linker script:
It is a little weird at the beginning because when I transfer control to the kernel it is still is real mode.
Code: Select all
ENTRY( kernel_start )
OUTPUT_FORMAT( binary )
SECTIONS
{
. = 0x1000;
startup_start = .;
.start :
{
*(.start)
. = ALIGN( 4096 );
}
startup_end = .;
kernel_start = 0xD0000000;
.text 0xD0000000 + SIZEOF( .start ) : AT( ADDR( .start ) + SIZEOF( .start ) )
{
*(.text)
*(.text.*)
*(.gnu.linkonce.t*)
*(.const*)
*(.ro*)
*(.gnu.linkonce.r*)
. = ALIGN( 4096 );
}
.data ADDR( .text ) + SIZEOF( .text ) : AT( LOADADDR( .text ) + SIZEOF( .text ) )
{
*(.data)
. = ALIGN( 32 );
/* constructors */
__CTOR_LIST__ = .;
/* the number of constructors */
LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
*(SORT(.ctors.*))
*(.ctor)
*(.ctors)
LONG(0)
__CTOR_END__ = .;
. = ALIGN( 32 );
/* deconstructors */
__DTOR_LIST__ = .;
/* number of deconstructors */
LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
*(SORT(.dtors.*))
*(.dtor)
*(.dtors)
LONG(0)
__DTOR_END__ = .;
*(.gnu.linkonce.d*)
}
. = ALIGN( 4096 );
.bss ALIGN( ADDR( .data ) + SIZEOF( .data ), 4096 ): AT( LOADADDR( .data ) + SIZEOF( .data ) )
{
bss_start = ABSOLUTE( . );
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
. = ALIGN( 4096 );
bss_end = ABSOLUTE( . );
bss_length = bss_end - bss_start;
}
kernel_end = .;
kernel_len = kernel_end - kernel_start;
DISCARD :
{
*(.comment)
}
}