garage44.eu/jeroen/pinnacle

logclone: git clone https://garage44.eu/jeroen/pinnacle.git

.. /kernel/link/pc.ld

raw

/* A PC (x86-64), booted by PVH or Multiboot2: QEMU's -kernel (or any PVH
 * loader) or GRUB loads this ELF at physical addresses and enters
 * `pvh_start` in 32-bit protected mode, paging off, as the Xen note or the
 * Multiboot2 header (in the file's first 32 KiB, so first) says.
 *
 * The 32-bit start and its page tables run where they lie, at 2 MiB. The
 * rest runs in the top 2 GiB (IMAGE_OFFSET), where the compiler's kernel
 * code model wants it; all of physical memory is mapped again at
 * KERNEL_OFFSET (`mmu`). */
LOAD_ADDRESS = 0x200000;
IMAGE_OFFSET = 0xffffffff80000000;
ENTRY(pvh_start)

SECTIONS
{
    . = LOAD_ADDRESS;
    .boot : {
        KEEP(*(.multiboot2))
        KEEP(*(.text.boot32))
        . = ALIGN(4096);
        KEEP(*(.data.boot32))
    }
    .note : { KEEP(*(.note.Xen)) }

    . = ALIGN(4096);
    . += IMAGE_OFFSET;
    .text : AT(ADDR(.text) - IMAGE_OFFSET) { *(.text .text.*) }
    .rodata : AT(ADDR(.rodata) - IMAGE_OFFSET) ALIGN(8) { *(.rodata .rodata.*) }
    .data : AT(ADDR(.data) - IMAGE_OFFSET) ALIGN(4096) { *(.data .data.*) }
    .bss (NOLOAD) : ALIGN(16) {
        *(.bss .bss.*)
        *(COMMON)
    }
    . = ALIGN(16);
    . += 64K;
    __stack_top = .;
    __kernel_end = .;

    /DISCARD/ : { *(.comment) *(.eh_frame*) *(.note.gnu*) }
}

/* The image from its first byte, the 32-bit start included, as the kernel
 * sees it (`mmu::physical` maps both back). */
__kernel_start = LOAD_ADDRESS + IMAGE_OFFSET;