diff options
-rw-r--r-- | build.zig | 2 | ||||
-rw-r--r-- | linker.ld | 23 |
2 files changed, 25 insertions, 0 deletions
@@ -32,6 +32,8 @@ pub fn build(b: *std.Build) void { .optimize = optimize, }); + exe.setLinkerScript(std.Build.LazyPath.relative("linker.ld")); + // This declares intent for the executable to be installed into the // standard location when the user invokes the "install" step (the default // step when running `zig build`). diff --git a/linker.ld b/linker.ld new file mode 100644 index 0000000..323eb69 --- /dev/null +++ b/linker.ld @@ -0,0 +1,23 @@ +OUTPUT_ARCH("riscv") + +ENTRY(start) + +PHDRS { + lo_rx PT_LOAD FLAGS (5); /* R-X */ + lo_r PT_LOAD FLAGS (4); /* R-- */ + lo_rw PT_LOAD FLAGS (6); /* RW- */ +} + +SECTIONS { + . = 0x80200000; + .text (0x80200000) : { + *(.text.start) + *(.text .text.*) + } : lo_rx + + .rodata : { *(.rodata .rodata.*) } : lo_r + .data : { *(.data .data.* ) } : lo_rw + .bss : { *(.bss .bss.* ) } : lo_rw + + /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) } +} |