# Rumpk Linker Script (RISC-V 64)
# For QEMU virt machine (RISC-V)

ENTRY(_start)

SECTIONS
{
    . = 0x80200000;  /* Standard RISC-V QEMU virt kernel address */
    PROVIDE(__kernel_vbase = .);
    PROVIDE(__kernel_pbase = .);

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

    .rodata : {
        *(.rodata*)
    }

    .data : {
        . = ALIGN(16);
        __global_pointer$ = . + 0x800;
        *(.sdata*)
        *(.sdata.*)
        *(.data*)
    }

    .initrd : {
        _initrd_start = .;
        KEEP(*(.initrd))
        _initrd_end = .;
    }

    .bss : {
        __bss_start = .;
        *(.bss*)
        *(COMMON)
        __bss_end = .;
    }

    .stack (NOLOAD) : {
        . = ALIGN(16);
        . += 0x100000; /* 1MB Stack */
        PROVIDE(__stack_top = .);
    }

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