LMA != VMA when compiling a kernel

Guillaume Ballet gballet at gmail.com
Sat May 30 13:24:13 UTC 2009


> : Hence, I have been trying to set the ELF file sections' VMAs to
> : something starting with 0xC and the LMAs to something starting with
> : 0x8. It turns out that just setting KERNPHYSADDR and KERNVIRTADDR is
> : not enough >.< If found a way to do this by chaning the script linker
> : and adding AT after each section declaration, and it works fine. But
> : it's tedious, hacky and lots of hardcoded values only work with my
> : platform.
>
> Want to share?

There's not much to share actually: I tried to use the AT keyword in
the script linker. What I did was essentially:

--- conf/ldscript.arm   2009-05-30 14:05:44.000000000 +0000
+++ conf/ldscript.arm.lma       2009-05-30 14:05:24.000000000 +0000
@@ -8,7 +8,7 @@
 {
   /* Read-only sections, merged into text segment: */
   . = KERNVIRTADDR + SIZEOF_HEADERS;
-  .text      : AT(KERNPHYSADDR + SIZEOF_HEADERS)
+  .text      :
   {
     *(.text)
     *(.stub)

Doing so, I was able to change the LMA for the text section. The
problem is that address arithmetic doesn't seem to work that well
inside AT() - so at this moment I am unable to do this for _every_
section. I'm sure it should be possible, but haven't found the time to
study this just yet. I don't think I will investigate this any
further: Indeed, locore.S sets up a temporary TLB system to be able to
access virtual addresses during boot.
If someones knows the syntax to do address calculations inside AT(),
however, I am interested nonetheless :) I was thinking about using
something like MEMORY, but that idea needs some thinking through.

>
> Also, while a secondary boot loader makes sense in the higher end
> booting environment where you have lots of storage (say an SD or CF
> card), it doesn't make so much sense for a more constrained boot a
> ramdisk from flash setup.

I am indeed running from SD card. I face two choices: My first choice
is to load everything with u-boot prior to starting the kernel. The
other one is to have the whole loader(8) facility. Since the first
choice requires some tedious typing in u-boot, I would love to have a
loader(8) script to do all the dirty work for me :D But it can wait.

Cheers,
Guillaume


More information about the freebsd-arm mailing list