From 7ed7e6cb11e3693b65a108b27c139d95c5b533c0 Mon Sep 17 00:00:00 2001 From: Yannis Huber Date: Tue, 7 Jul 2020 09:37:00 +0200 Subject: [PATCH] risc-v: disable linker relaxations during gp init --- src/device/riscv/start.S | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/device/riscv/start.S b/src/device/riscv/start.S index eee57fee..25217b35 100644 --- a/src/device/riscv/start.S +++ b/src/device/riscv/start.S @@ -9,7 +9,12 @@ _start: // Load the globals pointer. The program will load pointers relative to this // register, so it must be set to the right value on startup. // See: https://gnu-mcu-eclipse.github.io/arch/riscv/programmer/#the-gp-global-pointer-register + // Linker relaxations must be disabled to avoid the initialization beign + // relaxed with an uninitialized global pointer: mv gp, gp + .option push + .option norelax la gp, __global_pointer$ + .option pop // Jump to runtime.main call main