From cec5d3c68d974cf54d45f36522dc91eca38e006e Mon Sep 17 00:00:00 2001
From: Sam Tebbs <samuel.tebbs@gmail.com>
Date: Tue, 2 Jun 2020 18:41:54 +0100
Subject: [PATCH] Move linker script

---
 build.zig                              | 6 ++++--
 link.ld => src/kernel/arch/x86/link.ld | 4 ++--
 2 files changed, 6 insertions(+), 4 deletions(-)
 rename link.ld => src/kernel/arch/x86/link.ld (95%)

diff --git a/build.zig b/build.zig
index 1affb53..a9285a9 100644
--- a/build.zig
+++ b/build.zig
@@ -31,7 +31,8 @@ pub fn build(b: *Builder) !void {
     b.default_step.dependOn(&fmt_step.step);
 
     const main_src = "src/kernel/kmain.zig";
-    const constants_path = try fs.path.join(b.allocator, &[_][]const u8{ "src/kernel/arch", arch, "constants.zig" });
+    const arch_root = "src/kernel/arch";
+    const constants_path = try fs.path.join(b.allocator, &[_][]const u8{ arch_root, arch, "constants.zig" });
 
     const build_mode = b.standardReleaseOptions();
     const rt_test = b.option(bool, "rt-test", "enable/disable runtime testing") orelse false;
@@ -41,7 +42,8 @@ pub fn build(b: *Builder) !void {
     exec.setOutputDir(b.cache_root);
     exec.addBuildOption(bool, "rt_test", rt_test);
     exec.setBuildMode(build_mode);
-    exec.setLinkerScriptPath("link.ld");
+    const linker_script_path = try fs.path.join(b.allocator, &[_][]const u8{ arch_root, arch, "link.ld" });
+    exec.setLinkerScriptPath(linker_script_path);
     exec.setTarget(target);
 
     const output_iso = try fs.path.join(b.allocator, &[_][]const u8{ b.exe_dir, "pluto.iso" });
diff --git a/link.ld b/src/kernel/arch/x86/link.ld
similarity index 95%
rename from link.ld
rename to src/kernel/arch/x86/link.ld
index 87c4b43..e797bd1 100644
--- a/link.ld
+++ b/src/kernel/arch/x86/link.ld
@@ -36,8 +36,8 @@ SECTIONS {
 
 	.bss.stack ALIGN(4K) : AT (ADDR(.bss.stack) - KERNEL_ADDR_OFFSET) {
 		KEEP(*(.bss.stack))
-        KERNEL_STACK_END = .;
-    }
+		KERNEL_STACK_END = .;
+	}
 
 	KERNEL_VADDR_END = .;
 	KERNEL_PHYSADDR_END = . - KERNEL_ADDR_OFFSET;