Date: Mon, 7 May 2012 09:57:03 -0400 From: John Baldwin <jhb@freebsd.org> To: freebsd-hackers@freebsd.org Cc: arm@freebsd.org, Tim Kientzle <kientzle@freebsd.org> Subject: Re: How does loader(8) decide where to load the kernel? Message-ID: <201205070957.03842.jhb@freebsd.org> In-Reply-To: <3B2A320B-3ADE-4F48-B94E-4F0886178251@freebsd.org> References: <3B2A320B-3ADE-4F48-B94E-4F0886178251@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Saturday, May 05, 2012 1:06:13 am Tim Kientzle wrote: > I have ubldr loading the ELF kernel on BeagleBone and am now > trying to untangle some of the hacks I used to get this working. > > Unfortunately, there's one area of the common loader(8) code > that I really don't understand: How does sys/boot/common/load_elf.c > determine the physical address at which to load the kernel? > > __elfN(loadfile) has the following comment: > > [The file] will be stored at (dest). > > But that's not really true. For starters, loadfile maps dest > through archsw.arch_loadaddr. (This mechanism seems > to only be used on ia64 and pc98, though the result is > later discarded on those platforms.) > > Loadfile then passes the value to loadimage which does > very strange things: > > 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. -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201205070957.03842.jhb>