]> git.baikalelectronics.ru Git - kernel.git/commit
riscv: add as-options for modules with assembly compontents
authorBen Dooks <ben.dooks@codethink.co.uk>
Sun, 29 May 2022 15:22:00 +0000 (16:22 +0100)
committerPalmer Dabbelt <palmer@rivosinc.com>
Thu, 21 Jul 2022 19:09:29 +0000 (12:09 -0700)
commit91ec088866d1148747842786a7abd96cf1d7798e
tree1074a9eaaf0191593a8a8f7a5e31703a8b614b94
parentc97e15a7b5a1a952912e9c2e3be9f83467266cf7
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 22c906a874399f5
("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] https://github.com/gcc-mirror/gcc/commit/3b0a7d624e64eeb81e4d5e8c62c46d86ef521857

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: 76333b1a4288 ("RISC-V: Add sections of PLT and GOT for kernel module")
Cc: stable@vger.kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/Makefile