/*
 * Copyright (c) 2026, Chloe M.
 * Provided under the BSD-3 clause.
 *
 * Description: Kernel linker script
 * Author:      Chloe M.
 */

OUTPUT_FORMAT(elf64-x86-64)
OUTPUT_ARCH(i386:x86-64)
ENTRY(MdBspEntry)

PHDRS {
    text          PT_LOAD    FLAGS((1 << 0) | (1 << 2)) ;
    rodata        PT_LOAD    FLAGS((1 << 2)) ;
    data          PT_LOAD    FLAGS((1 << 1) | (1 << 2)) ;
}

SECTIONS
{
    . = 0xFFFFFFFF80000000;
    __KernelStart = .;

    .text : {
        *(.text .text.*)
    } :text

    . += CONSTANT(MAXPAGESIZE);

    .rodata : {
        *(.rodata .rodata.*)
    } :rodata

    . += CONSTANT(MAXPAGESIZE);

    .driver : {
        __driver_start = .;
        KEEP(*(.driver .driver));
        __driver_end = .;
    }

    . += CONSTANT(MAXPAGESIZE);

    .data : {
        *(.data)
    } :data

    .bss : {
        *(COMMON)
        *(.bss .bss.*)
    } :data

    __KernelEnd = .;
    . += CONSTANT(MAXPAGESIZE);

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