diff options
author | Himbeer <himbeerserverde@gmail.com> | 2024-03-26 13:09:34 +0100 |
---|---|---|
committer | Himbeer <himbeerserverde@gmail.com> | 2024-03-26 13:09:34 +0100 |
commit | 2d217382f258285d9b513eed4c3d53667e2b04eb (patch) | |
tree | 57b05fe0d426fc72d4a47ca5a08ce8119c1bf91d | |
parent | 6aecb564dd79777c5a67db478e023180e16e3803 (diff) |
add linker script
-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_*) } +} |