summaryrefslogtreecommitdiff
path: root/kernel/arch/aarch64/linker.ld
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/arch/aarch64/linker.ld')
-rw-r--r--kernel/arch/aarch64/linker.ld55
1 files changed, 55 insertions, 0 deletions
diff --git a/kernel/arch/aarch64/linker.ld b/kernel/arch/aarch64/linker.ld
new file mode 100644
index 0000000..4eb0ced
--- /dev/null
+++ b/kernel/arch/aarch64/linker.ld
@@ -0,0 +1,55 @@
+/*
+ * kernel/arch/aarch64/linker.ld
+ *
+ * Linker script for the AArch64 kernel ELF binary.
+ * Loaded at 0x40100000 (typical for QEMU virt machine).
+ *
+ * 4K align is same reason with boot linker scripts - page-aligned sections allow per-section memory protection
+ * TODO: rewrite it after i will add normal paging
+ */
+
+ENTRY(_start)
+
+/*
+ KERNEL_PHYS_BASE - kernel base address, for aarch64 it's 0x40100000 because
+ in QEMU RAM starts at 0x4000000, and we add 1MiB for BIOS data
+*/
+KERNEL_PHYS_BASE = 0x40100000;
+
+SECTIONS
+{
+ . = KERNEL_PHYS_BASE;
+
+ .text ALIGN(4K) : {
+ __text_start = .;
+ *(.text .text.*)
+ __text_end = .;
+ }
+
+ .rodata ALIGN(4K) : {
+ __rodata_start = .;
+ *(.rodata .rodata.*)
+ __rodata_end = .;
+ }
+
+ .data ALIGN(4K) : {
+ __data_start = .;
+ *(.data .data.*)
+ __data_end = .;
+ }
+
+ .bss ALIGN(4K) : {
+ __bss_start = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ __bss_end = .;
+ }
+
+ __kernel_end = .;
+
+ /DISCARD/ : {
+ *(.comment)
+ *(.note.*)
+ *(.eh_frame*)
+ }
+}