linux-stable/arch/riscv
Ben Dooks e8716ea35e riscv: add as-options for modules with assembly compontents
commit c1f6eff304 upstream.

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 7a8e7da422
("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] https://github.com/riscv/riscv-elf-psabi-doc/issues/183
[2] 3b0a7d624e

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: ab1ef68e54 ("RISC-V: Add sections of PLT and GOT for kernel module")
Cc: stable@vger.kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-29 17:27:55 +02:00
..
boot riscv: dts: microchip: hook up the mpfs' l2cache 2022-07-22 10:21:23 +02:00
configs RISC-V: configs: Configs that had RPMSG_CHAR now get RPMSG_CTRL 2022-04-26 08:19:53 -07:00
errata riscv: errata: alternative: mark vendor_patch_func __initdata 2022-01-09 11:02:46 -08:00
include RISC-V: Split out the XIP fixups into their own file 2022-06-09 10:30:37 +02:00
kernel vmcore: convert copy_oldmem_page() to take an iov_iter 2022-06-29 09:04:36 +02:00
kvm RISC-V: KVM: Fix SRCU deadlock caused by kvm_riscv_check_vcpu_requests() 2022-07-22 10:21:34 +02:00
lib riscv: Fixed misaligned memory access. Fixed pointer comparison. 2022-03-10 10:24:04 -08:00
mm RISC-V: Fix the XIP build 2022-06-09 10:30:38 +02:00
net riscv: bpf: Fix eBPF's exception tables 2022-01-19 10:50:02 -08:00
Kbuild kbuild: use more subdir- for visiting subdirectories while cleaning 2021-10-24 13:49:46 +09:00
Kconfig RISC-V CPU Idle Support 2022-03-30 16:17:54 -07:00
Kconfig.debug
Kconfig.erratas riscv: alternative only works on !XIP_KERNEL 2022-03-10 10:05:19 -08:00
Kconfig.socs RISC-V: cpuidle: fix Kconfig select for RISCV_SBI_CPUIDLE 2022-04-21 15:10:47 -07:00
Makefile riscv: add as-options for modules with assembly compontents 2022-07-29 17:27:55 +02:00