:: commit 50b8ab2c26f0c0e536afe6c0ea5b608b93ebbbd4

mintsuki <mintsuki@protonmail.com> — 2023-08-01 10:06

parents: 2d0752f60c

rv64: Misc relaxation related fixes

diff --git a/common/GNUmakefile b/common/GNUmakefile
index 778f4bf6..2c7473aa 100644
--- a/common/GNUmakefile
+++ b/common/GNUmakefile
@@ -128,7 +128,8 @@ ifeq ($(TARGET),uefi-riscv64)
     endif
 
     override CFLAGS_FOR_TARGET += \
-        -mabi=lp64
+        -mabi=lp64 \
+        -mno-relax
 
     override CPPFLAGS_FOR_TARGET := \
         -I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc' \
diff --git a/common/efi_thunk.asm_uefi_riscv64 b/common/efi_thunk.asm_uefi_riscv64
index f99508b3..2ff58cf5 100644
--- a/common/efi_thunk.asm_uefi_riscv64
+++ b/common/efi_thunk.asm_uefi_riscv64
@@ -3,6 +3,7 @@
 .global efi_main
 .extern uefi_entry
 efi_main:
+.option norelax
         mv      fp, zero
         mv      ra, zero
         j       uefi_entry
diff --git a/common/lib/spinup.asm_riscv64 b/common/lib/spinup.asm_riscv64
index e01f808f..e0e69c6a 100644
--- a/common/lib/spinup.asm_riscv64
+++ b/common/lib/spinup.asm_riscv64
@@ -3,7 +3,7 @@
 
 .global riscv_spinup
 riscv_spinup:
-
+.option norelax
         csrci   sstatus, 0x2
         csrw    sie, zero
         csrw    stvec, zero
diff --git a/common/linker_uefi_riscv64.ld.in b/common/linker_uefi_riscv64.ld.in
index 746b02ba..578a93a5 100644
--- a/common/linker_uefi_riscv64.ld.in
+++ b/common/linker_uefi_riscv64.ld.in
@@ -60,6 +60,8 @@ SECTIONS
 
    data_begin = .;
         *(.data .data.*)
+        *(.sdata .sdata.*)
+        *(.sbss .sbss.*)
         *(.bss .bss.*)
         *(COMMON)
    data_end = .;
diff --git a/common/menu_thunk.asm_riscv64 b/common/menu_thunk.asm_riscv64
index 1427f895..aa9e7254 100644
--- a/common/menu_thunk.asm_riscv64
+++ b/common/menu_thunk.asm_riscv64
@@ -10,6 +10,7 @@ stack_at_first_entry:
 .extern _menu
 
 menu:
+.option norelax
         lla     t0, stack_at_first_entry
         ld      t1, (t0)
         beqz    t1, 1f
diff --git a/common/sys/sbi.asm_riscv64 b/common/sys/sbi.asm_riscv64
index f37c7391..8b5ed71b 100644
--- a/common/sys/sbi.asm_riscv64
+++ b/common/sys/sbi.asm_riscv64
@@ -2,6 +2,7 @@
 
 .global sbicall
 sbicall:
+.option norelax
         mv      t0, a0
         mv      t1, a1
         mv      a0, a2
diff --git a/common/sys/smp_trampoline.asm_riscv64 b/common/sys/smp_trampoline.asm_riscv64
index 24fd30e9..e9e886f8 100644
--- a/common/sys/smp_trampoline.asm_riscv64
+++ b/common/sys/smp_trampoline.asm_riscv64
@@ -2,6 +2,7 @@
 
 .global smp_trampoline_start
 smp_trampoline_start:
+.option norelax
         // The AP begins executing here with the following state:
         //      satp            = 0
         //      sstatus.SIE     = 0
tab: 248 wrap: offon