Files
k-os/crates/adapter-riscv/linker.ld

63 lines
1.5 KiB
Plaintext

OUTPUT_ARCH(riscv)
/* The kernel runs in the upper half: linked at its physical load address
plus PHYS_OFFSET (mmu::PHYS_OFFSET), loaded at the physical address.
Firmware jumps to the physical entry with the MMU off; _start switches
to the high mapping before any Rust code runs. */
PHYS_OFFSET = 0xFFFFFFC000000000;
LOAD_ADDRESS = 0x80200000;
ENTRY(_start_phys)
/* Every boundary below is page aligned: the kernel maps each range with
its own permissions (W^X), see mmu::init_kernel_page_table. */
SECTIONS {
. = PHYS_OFFSET + LOAD_ADDRESS;
_text_start = .;
.text : AT(ADDR(.text) - PHYS_OFFSET) {
*(.text.entry)
*(.text .text.*)
}
. = ALIGN(4096);
_text_end = .;
.rodata : AT(ADDR(.rodata) - PHYS_OFFSET) {
*(.rodata .rodata.*)
*(.srodata .srodata.*)
}
.eh_frame : AT(ADDR(.eh_frame) - PHYS_OFFSET) {
*(.eh_frame)
}
. = ALIGN(4096);
_rodata_end = .;
.data : AT(ADDR(.data) - PHYS_OFFSET) {
*(.data .data.*)
*(.sdata .sdata.*)
}
. = ALIGN(4096);
.bss : AT(ADDR(.bss) - PHYS_OFFSET) {
_bss_start = .;
*(.bss .bss.*)
*(.sbss .sbss.*)
_bss_end = .;
}
/* Left unmapped, so overflowing the kernel stack faults instead of
silently overwriting .bss. */
. = ALIGN(4096);
_stack_guard = .;
. += 4096;
_stack_bottom = .;
. += 0x80000;
_stack_top = .;
_heap_start = .;
}
_start_phys = _start - PHYS_OFFSET;