Skip to content

Commit c1f6eff

Browse files
bjdooks-ctpalmer-dabbelt
authored andcommitted
riscv: add as-options for modules with assembly compontents
When trying to load modules built for RISC-V which include assembly files the kernel loader errors with "unexpected relocation type 'R_RISCV_ALIGN'" due to R_RISCV_ALIGN relocations being generated by the assembler. The R_RISCV_ALIGN relocations can be removed at the expense of code space by adding -mno-relax to gcc and as. In commit 7a8e7da ("RISC-V: Fixes to module loading") -mno-relax is added to the build variable KBUILD_CFLAGS_MODULE. See [1] for more info. The issue is that when kbuild builds a .S file, it invokes gcc with the -mno-relax flag, but this is not being passed through to the assembler. Adding -Wa,-mno-relax to KBUILD_AFLAGS_MODULE ensures that the assembler is invoked correctly. This may have now been fixed in gcc[2] and this addition should not stop newer gcc and as from working. [1] riscv-non-isa/riscv-elf-psabi-doc#183 [2] gcc-mirror/gcc@3b0a7d6 Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Link: https://lore.kernel.org/r/20220529152200.609809-1-ben.dooks@codethink.co.uk Fixes: ab1ef68 ("RISC-V: Add sections of PLT and GOT for kernel module") Cc: stable@vger.kernel.org Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 89551fd commit c1f6eff

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

arch/riscv/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ ifeq ($(CONFIG_PERF_EVENTS),y)
7373
endif
7474

7575
KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax)
76+
KBUILD_AFLAGS_MODULE += $(call as-option,-Wa$(comma)-mno-relax)
7677

7778
# GCC versions that support the "-mstrict-align" option default to allowing
7879
# unaligned accesses. While unaligned accesses are explicitly allowed in the

0 commit comments

Comments
 (0)