diff options
Diffstat (limited to 'na/arch/riscv/kernel/lumeos.lds.S')
| -rw-r--r-- | na/arch/riscv/kernel/lumeos.lds.S | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/na/arch/riscv/kernel/lumeos.lds.S b/na/arch/riscv/kernel/lumeos.lds.S index ca5218f..9bd083b 100644 --- a/na/arch/riscv/kernel/lumeos.lds.S +++ b/na/arch/riscv/kernel/lumeos.lds.S @@ -38,12 +38,33 @@ ENTRY(_start) PROVIDE(__global_pointer$ = . + 0x800); \ *(.sdata .sdata.*) -/* ===== RISC-V: early page table + per-CPU boot stacks in .bss ===== */ +/* ===== RISC-V: page-table storage + per-CPU boot stacks in .bss ===== + * + * Linux RISC-V layout (arch/riscv/kernel/vmlinux.lds.S): + * early_pg_dir — first early page table built by setup_vm, + * used for the rest of boot after MMU enable + * trampoline_pg_dir — single-page table used only during the SATP + * switch from physical to higher-half VA; its + * identity + virt mappings of _start must both + * be valid in the same instruction window + * fixmap_pg_dir — covers the FIXADDR_START range used by the + * early console (UART MMIO before kernel page + * table proper is built) + * + * All three are allocated here so head.S can take their addresses without + * a C definition; their PA == VA mapping covers them during setup_vm. + */ #define ARCH_BSS_EXTRA \ - /* Early page table: 4KB aligned, used by entry.S before VMM */ \ . = ALIGN(4096); \ - early_pgdir = .; \ + early_pg_dir = .; \ + . += 4096; \ + trampoline_pg_dir = .; \ + . += 4096; \ + fixmap_pg_dir = .; \ . += 4096; \ + /* Legacy name retained for any caller still referencing it; */ \ + /* points at the same first 4 KiB as early_pg_dir. */ \ + early_pgdir = early_pg_dir; \ /* Per-CPU boot stacks: 8KB per CPU, max 8 CPUs */ \ . = ALIGN(4096); \ boot_stack = .; \ @@ -65,16 +86,27 @@ SECTIONS { . = ALIGN(4096); - RODATA_SECTION + /* .rela.dyn lives between .text and .rodata so it ends up in the + * read-only PT_LOAD segment. Mirrors Linux vmlinux.lds.S where + * .rela.dyn sits at the tail of init data, just before RO_DATA. */ + RELA_DYN_SECTION . = ALIGN(4096); - RELOC_SECTION + RODATA_SECTION . = ALIGN(4096); DATA_SECTION + . = ALIGN(8); + + /* .got lives right after .data in the RW PT_LOAD. All other + * dynamic-linker artefacts (.plt, .dynamic, .dynsym, .dynstr, + * .hash, .gnu.hash, .interp, .dynbss) are discarded by the + * DISCARDS macro — mirrors Linux arch/riscv/kernel/vmlinux.lds.S. */ + GOT_SECTION + . = ALIGN(4096); /* End of file-backed image (BSS follows as NOBITS) */ |
