Skip to content

Commit

Permalink
Linking and linker relaxation fixes (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
DNedic authored May 22, 2024
1 parent 6b1efed commit 1b1e3e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 6 additions & 1 deletion bsp/espressif/esp/src/cpus/espressif-riscv.zig
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ pub const startup_logic = struct {
:
: [eos] "r" (@as(u32, microzig.config.end_of_stack)),
);
asm volatile ("la gp, __global_pointer$");
asm volatile (
\\.option push
\\.option norelax
\\la gp, __global_pointer$
\\.option pop
);
microzig.cpu.setStatusBit(.mtvec, microzig.config.end_of_stack);
root.initialize_system_memories();
microzig_main();
Expand Down
11 changes: 10 additions & 1 deletion build/src/generate_linkerscript.zig
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ pub fn main() !void {
\\ .data :
\\ {
\\ microzig_data_start = .;
\\ *(.rodata*)
\\ *(.sdata*)
\\ *(.data*)
\\ *(.rodata*)
\\ microzig_data_end = .;
\\ } > ram0 AT> flash0
\\
Expand All @@ -137,6 +138,14 @@ pub fn main() !void {
\\
);
}

switch (program_args.cpu_arch) {
.riscv32, .riscv64 => try writer.writeAll(
\\ PROVIDE(__global_pointer$ = microzig_data_start + 0x800);
),
else => {},
}

try writer.writeAll("}\n");

// TODO: Assert that the flash can actually hold all data!
Expand Down

0 comments on commit 1b1e3e6

Please sign in to comment.