How does loader(8) decide where to load the kernel?

Marcel Moolenaar marcel at xcllnt.net
Thu May 10 12:32:37 UTC 2012


On May 8, 2012, at 1:32 AM, Tim Kientzle wrote:
>>> On i386, amd64, powerpc, and arm,  loadimage subtracts
>>> the dest value from the address declared in the actual ELF
>>> headers so that the kernel always gets loaded into low memory.
>>> (there's some intermediate bit-twiddling I'm glossing over, but
>>> this is the general idea).
>> 
>> The bit twiddling is supposed to be the equivalent of subtracting
>> KERNBASE from the load address.  On both i386 and amd64, there is
>> a direct mapping of the kernel text such that KERNBASE maps address
>> 0, etc.  By default on i386 KERNBASE is 0xc0000000.
> 
> Exactly my problem.  This all assumes that you're loading
> the kernel into low memory.
> 
> On the AM3358, the DRAM starts at 0x8000 0000
> on boot, so I'm trying to find a clean way to convince
> the loader's ELF code to put the kernel there.

Look at what I did for ia64. All that frobbing should be done
in the machine specific implementation of arch_copyin, arch_copyout
and arch_readin. It's a kluge to do it in elf_loadimage.

FYI,

-- 
Marcel Moolenaar
marcel at xcllnt.net




More information about the freebsd-hackers mailing list