summaryrefslogtreecommitdiff
path: root/sys/arch/aarch64/conf/link.ld
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-04-02 09:38:22 -0400
committerIan Moffett <ian@osmora.org>2025-04-02 09:38:22 -0400
commit753666a333bb9ff0b8410cd729b9d06df85e0013 (patch)
tree169aa8b4307c65430e0da1b062cce858cfc2d7e7 /sys/arch/aarch64/conf/link.ld
parentd81f6b1d2cfcae0f90f2394b44cbdf03dcc0c69b (diff)
kernel/aarch64: Add initial AARCH64 portaarch64
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/arch/aarch64/conf/link.ld')
-rw-r--r--sys/arch/aarch64/conf/link.ld75
1 files changed, 75 insertions, 0 deletions
diff --git a/sys/arch/aarch64/conf/link.ld b/sys/arch/aarch64/conf/link.ld
new file mode 100644
index 0000000..c64cec3
--- /dev/null
+++ b/sys/arch/aarch64/conf/link.ld
@@ -0,0 +1,75 @@
+/* Tell the linker that we want an aarch64 ELF64 output file */
+OUTPUT_FORMAT(elf64-littleaarch64)
+OUTPUT_ARCH(aarch64)
+
+/* We want the symbol main to be our entry point */
+ENTRY(main)
+
+/* Define the program headers we want so the bootloader gives us the right */
+/* MMU permissions */
+PHDRS
+{
+ 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
+{
+ /* We wanna be placed in the topmost 2GiB of the address space, for optimisations */
+ /* and because that is what the Limine spec mandates. */
+ /* Any address in this region will do, but often 0xffffffff80000000 is chosen as */
+ /* that is the beginning of the region. */
+ . = 0xffffffff80000000;
+
+ .text : {
+ *(.text .text.*)
+ } :text
+
+ /* Move to the next memory page for .rodata */
+ . += CONSTANT(MAXPAGESIZE);
+
+ .rodata : {
+ *(.rodata .rodata.*)
+ } :rodata
+
+ .drivers : {
+ __drivers_init_start = .;
+ *(.drivers .drivers)
+ __drivers_init_end = .;
+ } :rodata
+
+ /* Move to the next memory page for .data */
+ . += CONSTANT(MAXPAGESIZE);
+
+ .data : {
+ *(.data .data.*)
+ } :data
+
+ /* Dynamic section for relocations, both in its own PHDR and inside data PHDR */
+ .dynamic : {
+ *(.dynamic)
+ } :data :dynamic
+
+ /* NOTE: .bss needs to be the last thing mapped to :data, otherwise lots of */
+ /* unnecessary zeros will be written to the binary. */
+ /* If you need, for example, .init_array and .fini_array, those should be placed */
+ /* above this. */
+ .bss : {
+ *(.bss .bss.*)
+ *(COMMON)
+ } :data
+
+ /* -- Cache line alignment -- */
+ . = ALIGN(64);
+ .data.cacheline_aligned : {
+ *(.data.cacheline_aligned)
+ }
+
+ /* Discard .note.* and .eh_frame since they may cause issues on some hosts. */
+ /DISCARD/ : {
+ *(.eh_frame)
+ *(.note .note.*)
+ }
+}