[Prev][Next][Index][Thread]
Re: oskit how to boot
Hi,
Yeah, ld is a bit of a bitch to get into, but well worth it - I've managed to get a good grasp of it (with a lot of trial and error). Let me know what you are trying and I will see if I can help you at all.
If this is any use, for my OS I use a link script like this -
I first of all run it through cpp, which replaces KERNEL_LOAD_LOC with where the kernel is loaded (0x100000), and KERNEL_EXEC_LOC with where the kernel is executed from.
In my code the entry.o (an assembler module) is run first, and it moves the code from where grub loaded it, to where I want it to run from,
it then jumps to the next location in the new memory location.
Regards,
Martin McCann
/* --------------------------------------------------------------------------
layout.LD, ld configuration file for kernel Written By Martin McCann
Version 1.0a, 16/01/2002 lurcher@novusrota.eclipse.co.uk
--------------------------------------------------------------------------
Defines the layout of the kernel binary file. Some values are taken from
configuration files, so the cpp needs to be run on them first.
----------------------------------------------------------------------- */
#define LD
#include <config.h>
OUTPUT_FORMAT(binary)
ENTRY(__entry)
MEMORY {
emem (rwx) : ORIGIN = KERNEL_EXEC_LOC, LENGTH = 16k
lmem (rwx) : ORIGIN = KERNEL_LOAD_LOC, LENGTH = 16K
}
SECTIONS {
.entry KERNEL_LOAD_LOC :
{ entry.o } > lmem AT > lmem
__stext = .;
.kernel KERNEL_EXEC_LOC :
{ *(.text)
*(.data)
*(.rodata) } > emem AT > lmem
__eodata = KERNEL_LOAD_LOC + SIZEOF(.entry) + SIZEOF(.kernel);
.bss : { *(.bss) } > emem AT > lmem
__eobss = __eodata + SIZEOF(.bss) ;
}
On Friday 17 May 2002 07:53, you wrote:
> I assume from this you want to know how to create your own multi-boot
> loadable kernel - Grub will either load an ELF excecutable (I never got
> this working, though I didn't try to hard), or a plain binary.
>
> > To load a plain binary you need to have the multiboot header in the first
> > 8192 bytes of the image file - if you have grub installed 'info
> > multiboot' will give you the specification you need. They also have a
> > very minimal example kernel to get started.
>
> <<<<<
>
> I think I have a rudamentary grasp of the multiboot header, however I
> don't know how to use those blasted GNU tools (or any other) to do it...
>
> I have a printout of the ld documentation right here but I can hardly
> make heads or tails of it. =((( I don't think it was intended for
> humans...
References: