From 33bc3446d237a95f1bbf9d5d70a170fa4c4241cd Mon Sep 17 00:00:00 2001 From: EmulatedSeasons <89668582+EmulatedSeasons@users.noreply.github.com> Date: Mon, 6 May 2024 23:00:36 -0400 Subject: Improved makefile a bit more and got it working with the other files --- kernel/arch/x86_64/linker.ld | 78 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 kernel/arch/x86_64/linker.ld (limited to 'kernel/arch/x86_64/linker.ld') diff --git a/kernel/arch/x86_64/linker.ld b/kernel/arch/x86_64/linker.ld new file mode 100644 index 0000000..5724ecf --- /dev/null +++ b/kernel/arch/x86_64/linker.ld @@ -0,0 +1,78 @@ +OUTPUT_FORMAT(elf64-x86-64) +OUTPUT_ARCH(i386:x86-64) + +/* Excecution entry point symbol */ +ENTRY(_start) + +PHDRS +{ + requests PT_LOAD FLAGS((1 << 1) | (1 << 2)); /* Write + Read */ + text PT_LOAD FLAGS((1 << 0) | (1 << 2)); /* Execute + Read */ + rodata PT_LOAD FLAGS((1 << 2)); /* Read only */ + data PT_LOAD FLAGS((1 << 1) | (1 << 2)); /* Write + Read */ + dynamic PT_DYNAMIC FLAGS((1 << 1) | (1 << 2)); /* Dynamic PHDR for relocations */ +} + +SECTIONS +{ + /* Places kernel in the top 2GiB of the address space */ + . = 0xffffffff80000000; + + /* Used to get the beginning and end address of the kernel */ + __kernel_begin = .; + + .requests : { + KEEP(*(.requests_start_marker)) + KEEP(*(.requests)) + KEEP(*(.requests_end_marker)) + } :requests + + . += CONSTANT(MAXPAGESIZE); + + /* code. multiboot header comes first */ + .text : { + *(.text .text.*) + } :text + + . += CONSTANT(MAXPAGESIZE); + + /* read only data */ + .rodata : { + *(. .rodata.*) + } :rodata + + /* init array symbols used to get start and end address of the array */ + .init_array : { + __init_array = .; + *(.init_array .init_array.*) + __init_array_end = .; + } :rodata + + . += CONSTANT(MAXPAGESIZE); + + /* read write data (initialized) */ + .data : { + *(.data .data.*) + } :data + + /* Dynamic section for relocations, both in its own PHDR and inside data PHDR */ + .dynamic : { + *(.dynamic) + } :data :dynamic + + . += CONSTANT(MAXPAGESIZE); + + /* read write data (uninitialized) and stack */ + .bss : { + *(.bss .bss.*) + *(COMMON) + } :data + + /* Discard .note.* and .eh_frame since they may cause issues on some hosts */ + /DISCARD/ : { + *(.eh_frame) + *(.note .note.*) + } + + __kernel_end = .; +} \ No newline at end of file -- cgit v1.2.3-70-g09d2