android_kernel_motorola_sm6225/arch
Ben Dooks d2da5392d2 riscv: add as-options for modules with assembly compontents
commit c1f6eff304e4dfa4558b6a8c6b2d26a91db6c998 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:10:30 +02:00
..
alpha alpha: define get_cycles macro for arch-override 2022-06-25 11:49:09 +02:00
arc ARC: entry: fix syscall_trace_exit argument 2022-04-27 13:39:45 +02:00
arm ARM: dts: stm32: use the correct clock source for CEC on stm32mp151 2022-07-21 21:09:32 +02:00
arm64 arm64: ftrace: fix branch range checks 2022-06-25 11:49:16 +02:00
c6x
h8300
hexagon hexagon: export raw I/O routines for modules 2021-11-26 11:36:23 +01:00
ia64 ia64: define get_cycles macro for arch-override 2022-06-25 11:49:09 +02:00
m68k m68k: use fallback for random_get_entropy() instead of zero 2022-06-25 11:49:10 +02:00
microblaze
mips MIPS: Remove repetitive increase irq_err_count 2022-07-02 16:27:33 +02:00
nds32 nds32: fix access_ok() checks in get/put_user 2022-03-28 08:41:44 +02:00
nios2 nios2: use fallback for random_get_entropy() instead of zero 2022-06-25 11:49:10 +02:00
openrisc openrisc: start CPU timer early in boot 2022-06-14 16:59:17 +02:00
parisc parisc: define get_cycles macro for arch-override 2022-06-25 11:49:09 +02:00
powerpc powerpc/powernv: delay rng platform device creation until later in boot 2022-07-12 16:29:01 +02:00
riscv riscv: add as-options for modules with assembly compontents 2022-07-29 17:10:30 +02:00
s390 s390/archrandom: simplify back to earlier design and initialize earlier 2022-07-07 17:35:09 +02:00
sh mips,s390,sh,sparc: gup: Work around the "COW can break either way" issue 2022-01-27 09:04:34 +01:00
sparc sparc: use fallback for random_get_entropy() instead of zero 2022-06-25 11:49:10 +02:00
um um: use fallback for random_get_entropy() instead of zero 2022-06-25 11:49:10 +02:00
unicore32
x86 x86: Clear .brk area at early boot 2022-07-21 21:09:31 +02:00
xtensa xtensa: Fix refcount leak bug in time.c 2022-07-02 16:27:36 +02:00
.gitignore
Kconfig x86: Make ARCH_USE_MEMREMAP_PROT a generic Kconfig symbol 2021-12-22 09:19:01 +01:00