freebsd-dev/sys/conf
Roger Pau Monné 7e748038cd amd64: set the correct LMA values
The current linker script generates program headers with VMA == LMA:

Entry point 0xffffffff802e7000
There are 6 program headers, starting at offset 64

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0xffffffff80200040 0xffffffff80200040
                 0x0000000000000150 0x0000000000000150  R E    8
  INTERP         0x0000000000000190 0xffffffff80200190 0xffffffff80200190
                 0x000000000000000d 0x000000000000000d  R      1
      [Requesting program interpreter: /red/herring]
  LOAD           0x0000000000000000 0xffffffff80200000 0xffffffff80200000
                 0x00000000010559b0 0x00000000010559b0  R E    200000
  LOAD           0x0000000001056000 0xffffffff81456000 0xffffffff81456000
                 0x0000000000132638 0x000000000052ecf8  RW     200000
  DYNAMIC        0x0000000001056000 0xffffffff81456000 0xffffffff81456000
                 0x00000000000000d0 0x00000000000000d0  RW     8
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RWE    8

This is fine for the FreeBSD loader, because it completely ignores p_paddr
and instead uses p_vaddr with a hardcoded offset. Other loaders however
acknowledge p_paddr (like the Xen ELF loader), in which case they will try
to load the kernel at the wrong place. Fix this by adding an AT keyword to
the first section specifying the physical address, other sections will
follow suit, so it ends up looking like:

Entry point 0xffffffff802e7000
There are 6 program headers, starting at offset 64

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0xffffffff80200040 0x0000000000200040
                 0x0000000000000150 0x0000000000000150  R E    8
  INTERP         0x0000000000000190 0xffffffff80200190 0x0000000000200190
                 0x000000000000000d 0x000000000000000d  R      1
      [Requesting program interpreter: /red/herring]
  LOAD           0x0000000000000000 0xffffffff80200000 0x0000000000200000
                 0x00000000010559b0 0x00000000010559b0  R E    200000
  LOAD           0x0000000001056000 0xffffffff81456000 0x0000000001456000
                 0x0000000000132638 0x000000000052ecf8  RW     200000
  DYNAMIC        0x0000000001056000 0xffffffff81456000 0x0000000001456000
                 0x00000000000000d0 0x00000000000000d0  RW     8
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RWE    8

Tested on bare metal using the native FreeBSD loader and grub2 from TRUEOS.

Sponsored by: Citrix Systems R&D
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D2783
2015-06-26 07:12:17 +00:00
..
config.mk
dtb.mk
files ALTQ FAIRQ discipline import from DragonFLY 2015-06-24 19:16:41 +00:00
files.amd64 Allow DTrace to be compiled-in to the kernel. 2015-06-10 15:53:39 +00:00
files.arm Allow DTrace to be compiled-in to the kernel. 2015-06-10 15:53:39 +00:00
files.arm64 Rename ECAM PCI driver file. 2015-06-12 13:54:25 +00:00
files.i386 Allow DTrace to be compiled-in to the kernel. 2015-06-10 15:53:39 +00:00
files.mips Add in library routines not supplied by gcc-4.9 but required by the kernel. 2015-06-19 01:21:10 +00:00
files.pc98 MFi386: r283407 2015-05-26 14:08:32 +00:00
files.powerpc Allow DTrace to be compiled-in to the kernel. 2015-06-10 15:53:39 +00:00
files.sparc64
kern.mk
kern.opts.mk
kern.post.mk Allow DTrace to be compiled-in to the kernel. 2015-06-10 15:53:39 +00:00
kern.pre.mk Allow DTrace to be compiled-in to the kernel. 2015-06-10 15:53:39 +00:00
kmod_syms.awk
kmod.mk Don't use ${.OBJDIR}/ to qualify target that isn't specified that way 2015-06-15 18:43:32 +00:00
ldscript.amd64 amd64: set the correct LMA values 2015-06-26 07:12:17 +00:00
ldscript.arm
ldscript.arm64
ldscript.i386
ldscript.mips
ldscript.mips.cfe
ldscript.mips.mips64
ldscript.mips.octeon1
ldscript.powerpc
ldscript.powerpc64
ldscript.sparc64
Makefile.amd64
Makefile.arm
Makefile.arm64
Makefile.i386
Makefile.mips
Makefile.pc98
Makefile.powerpc
Makefile.sparc64
makeLINT.mk
makeLINT.sed
newvers.sh
NOTES ALTQ FAIRQ discipline import from DragonFLY 2015-06-24 19:16:41 +00:00
options ALTQ FAIRQ discipline import from DragonFLY 2015-06-24 19:16:41 +00:00
options.amd64
options.arm Add support for getting the memory map from EFI if it has been pased in 2015-05-24 16:11:30 +00:00
options.arm64
options.i386
options.mips
options.pc98
options.powerpc
options.sparc64
systags.sh
WITHOUT_SOURCELESS
WITHOUT_SOURCELESS_HOST
WITHOUT_SOURCELESS_UCODE