]> pd.if.org Git - zos/blobdiff - link64.ld
kernel startup and linker script
[zos] / link64.ld
diff --git a/link64.ld b/link64.ld
new file mode 100644 (file)
index 0000000..f70d97a
--- /dev/null
+++ b/link64.ld
@@ -0,0 +1,70 @@
+KERNEL_VMA = 0xFFFFFFFF80000000 ;
+KERNEL_LMA = 0x100000 ;
+
+ENTRY(_multiboot_entry)
+SECTIONS
+{
+       . = KERNEL_LMA;
+
+       .bootstrap :
+       {
+               boot32.o ( .multiboot )
+               boot32.o (.text)
+               boot32.o (.data)
+       }
+
+       . += KERNEL_VMA; /* += so that the code can just run, might be able to "org" the code */
+
+       .text : AT(ADDR(.text) - KERNEL_VMA)
+       {
+               _code = .;
+               *(EXCLUDE_FILE(*boot32.o) .text)
+               *(.rodata*)
+               . = ALIGN(4096);
+       }
+
+       .data : AT(ADDR(.data) - KERNEL_VMA)
+       {
+               _data = .;
+               *(EXCLUDE_FILE(*boot32.o) .data)
+               . = ALIGN(8);
+
+               _kernel_vma = .;
+               QUAD(KERNEL_VMA);
+               . += 8;
+               _kernel_end = .;
+               QUAD(KERNEL_END);
+               . += 8;
+               _kernel_phys_end = .;
+               QUAD(KERNEL_PHYS_END);
+               . += 8;
+               _kernel_size = .;
+               QUAD(KERNEL_SIZE);
+               . += 8;
+
+               . = ALIGN(4096);
+       }
+
+       .bss : AT(ADDR(.bss) - KERNEL_VMA)
+       {
+               _bss = .;
+               *(.bss)
+
+               /*
+               * You usually need to include generated COMMON symbols
+               * under kernel BSS section or use gcc's -fno-common
+               */
+
+               *(COMMON)
+               . = ALIGN(4096);
+       }
+
+       KERNEL_SIZE = . - KERNEL_VMA - KERNEL_LMA;
+       KERNEL_PHYS_END = . - KERNEL_VMA;
+       KERNEL_END = .;
+
+       /DISCARD/ :
+       {
+               *(.comment)
+       }
+}