[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: loader modules jumping back to kernel
From: |
Yoshinori K. Okuji |
Subject: |
Re: loader modules jumping back to kernel |
Date: |
Sun, 20 Jul 2008 11:09:02 +0200 |
User-agent: |
KMail/1.9.9 |
On Sunday 20 July 2008 01:06:22 Robert Millan wrote:
> Anyone recalls the reason our loaders had to jump back to kernel
> (startup.S) to do the final part of the load?
Not all of them should do that, but it might be more convenient. I look at one
by one:
- The chainloader needs to get back the original state (e.g. A20 disabled), so
the final code must be located at below 1MB. Since the address of the startup
code is well known, it is easier to use.
- The linux loader does not have to overwrite the startup code, but other
regions can be. So it is easier to use.
- The multiboot loader had, historically speaking, a limitation that it may
not load an OS image below 1MB. So it was easier to use. But I don't remember
if this limitation is still present in the current implementation.
> IIRC this causes trouble when the loadee chose an address that precisely
> overwrites the loader, which is garanteed to happen when GRUB is loading
> itself, AFAICT.
Sure. My recommendation is, in case where you might overwrite that part, that
you should write relocatable code (which is rather easy for simple code on
i386) at anywhere (it could be in the startup), find out a safe region when
loading an OS image, copy the code to the safe region, and finalize the
bootstrap in that code (e.g. relocating the OS image, initializing registers,
and jumping to it). On i386, we have a reserved region to temporarily load an
OS image for the very reason, so this is not difficult.
Regards,
Okuji