--
-- Link the kernel (CPU Driver)
--
-linkKernel :: Options -> [String] -> [String] -> String -> HRule
-linkKernel opts objs libs name =
+linkKernel :: Options -> [String] -> [String] -> String -> String -> HRule
+linkKernel opts objs libs name driverType=
let linkscript = "/kernel/" ++ name ++ ".lds"
kernelmap = "/kernel/" ++ name ++ ".map"
kasmdump = "/kernel/" ++ name ++ ".asm"
Rule [ Str "cpp",
NStr "-I", NoDep SrcTree "src" "/kernel/include/arch/armv8",
Str "-D__ASSEMBLER__",
- Str "-P", In SrcTree "src" "/kernel/arch/armv8/linker.lds.in",
+ Str "-P", In SrcTree "src"
+ ("/kernel/arch/armv8/"++driverType++".lds.in"),
Out arch linkscript
],
-- Produce a stripped binary
| optArch opts == "k1om" = K1om.linkKernel opts objs [libraryPath opts l | l <- libs ] ("/sbin" </> name)
| optArch opts == "x86_32" = X86_32.linkKernel opts objs [libraryPath opts l | l <- libs ] ("/sbin" </> name)
| optArch opts == "armv7" = ARMv7.linkKernel opts objs [libraryPath opts l | l <- libs ] name driverType
- | optArch opts == "armv8" = ARMv8.linkKernel opts objs [libraryPath opts l | l <- libs ] name
+ | optArch opts == "armv8" = ARMv8.linkKernel opts objs [libraryPath opts l | l <- libs ] name driverType
| otherwise = Rule [ Str ("Error: Can't link kernel for '" ++ (optArch opts) ++ "'") ]
--
--- /dev/null
+/*
+ * Copyright (c) 2007, 2008, 2016, ETH Zurich.
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached LICENSE file. If
+ * you do not find this file, copies can be found by writing to: ETH Zurich
+ * D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group.
+ */
+
+#include <offsets.h>
+
+OUTPUT_FORMAT("elf64-littleaarch64")
+OUTPUT_ARCH("aarch64")
+
+ENTRY(boot_entry_bsp)
+
+PHDRS {
+ load PT_LOAD ;
+ dynamic PT_DYNAMIC ;
+ note PT_NOTE ;
+}
+
+SECTIONS {
+ /* This is a relocatable executable, its actual link address is
+ * irrelevant. */
+ . = 0x0;
+ . = ALIGN(4k);
+
+ .text : {
+ *(.text);
+ *(.text.unlikely);
+ } :load
+
+ .rodata . :
+ {
+ *(.rodata);
+ *(.rodata.*);
+ }
+
+ .data . :
+ {
+ *(.data);
+ *(.data.*);
+ }
+
+ .bss . :
+ {
+ *(.bss);
+ }
+
+ .got . :
+ {
+ got_base = .;
+ *(.got);
+ *(.got.plt);
+ }
+
+ .rela.dyn . :
+ {
+ *(.rela.dyn);
+ }
+
+ .dynamic . :
+ {
+ *(.dynamic);
+ } :load :dynamic
+
+ .note.gnu.build-id . :
+ {
+ *(.note.gnu.build-id);
+ }
+
+ /***** These sections get discarded *****/
+ /DISCARD/ :
+ {
+ /* Discard exception handler frames and headers -- we don't use em */
+ *(.eh_frame);
+ *(.eh_frame_hdr);
+ *(.dynsym);
+ *(.dynstr);
+ *(.hash);
+ *(.interp);
+ }
+}
OUTPUT_FORMAT("elf64-littleaarch64")
OUTPUT_ARCH("aarch64")
-ENTRY(boot_entry_bsp)
+ENTRY(arch_init)
PHDRS {
load PT_LOAD ;