From f13b26eeb4f9afba3a1aed2516655b34139979aa Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Tue, 27 Apr 2021 19:02:17 +0200 Subject: Making kernel Higher-Half --- src/linker.ld | 49 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-) (limited to 'src/linker.ld') diff --git a/src/linker.ld b/src/linker.ld index 89e4909..7d7c3a6 100644 --- a/src/linker.ld +++ b/src/linker.ld @@ -1,30 +1,45 @@ -ENTRY(_start) OUTPUT_FORMAT(elf64-x86-64) +ENTRY(_start) -SECTIONS { +__kernel_vma = 0xFFFFFFFF80000000; +__boot_pma = 1M; +__stack_pma = 0x3FFFFF; +__stack_size = 4096; +__userspace_pma = 0x400000; - . = 1M; +PHDRS +{ + boot PT_LOAD; + kernel PT_LOAD; +} - .text : ALIGN(4) +SECTIONS { + . = __boot_pma; + .boot ALIGN(4096) : { *boot.o(.multiboot) *boot.o(.text) - *(.text) - } - .rodata : ALIGN(4) - { - *(.rodata) - } - .data : ALIGN(4) + *trampoline.o(.text .text.* .data .data.* .rodata .rodata.* .bss) + + } :boot + + . += __kernel_vma; + .text ALIGN(4096) : AT(ADDR(.text)-__kernel_vma) { - *(.data) - } - .bss : ALIGN(4) + *boot.o(.multiboot) + *boot.o(.text) + *(.text .text.*) + *(.rodata .rodata.*) + *(.data .data.*) + }:kernel + .bss ALIGN(4096) : AT(ADDR(.bss)-__kernel_vma) { - _bss_start = .; + __bss_start = .; *(.bss); - _bss_end = .; + __bss_end = .; *(COMMON); - } + ASSERT( (. - ABSOLUTE(__kernel_vma)) < (ABSOLUTE(__stack_pma)-ABSOLUTE(__stack_size)), "No room for stack !!"); + }:kernel + /DISCARD/ : { *(.eh_frame) *(.comment) *(.note*) } } \ No newline at end of file -- cgit v1.2.3