All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] riscv: add correct as-options for assembly in modules
@ 2021-12-08 19:26 ` Ben Dooks
  0 siblings, 0 replies; 20+ messages in thread
From: Ben Dooks @ 2021-12-08 19:26 UTC (permalink / raw)
  To: linux-kernel, linux-kernel, linux-riscv
  Cc: Palmer Dabbelt, Albert Ou, Bin Meng, Ben Dooks

When trying to load modules built for riscv which include assembly
the kernel loader errors with "unexpected relocation type 'R_RISCV_ALIGN'"
due to R_RISCV_ALIGN relocations being generated by the assembler.

In commit 7a8e7da42250138 ("RISC-V: Fixes to module loading") the
CFLAGS have -mno-relax added. This however does not get applied to
KBUILD_AFLAGS_MODULE so when a module builds a .S file, the -mno-relax
is not passed and the above error is seen. Fix it by adding the flags
'-Wa,-mno-relax' to KBUILD_AFLAGS_MODULE.

This may have been fixed in gcc, in:
 https://github.com/gcc-mirror/gcc/commit/3b0a7d624e64eeb81e4d5e8c62c46d86ef521857

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
--
Changes since v1:
- added Bin Meng's review of the original patch
---
 arch/riscv/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 0289a97325d1..cf2ea9a1ac20 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -58,6 +58,7 @@ ifeq ($(CONFIG_PERF_EVENTS),y)
 endif
 
 KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax)
+KBUILD_AFLAGS_MODULE += $(call as-option,-Wa$(comma)-mno-relax)
 
 # GCC versions that support the "-mstrict-align" option default to allowing
 # unaligned accesses.  While unaligned accesses are explicitly allowed in the
-- 
2.33.0


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 20+ messages in thread
* [PATCH] riscv: add correct as-options for assembly in modules
@ 2022-05-29 15:19 ` Ben Dooks
  0 siblings, 0 replies; 20+ messages in thread
From: Ben Dooks @ 2022-05-29 15:19 UTC (permalink / raw)
  To: linux-kernel, linux-riscv; +Cc: palmer, aou, linux-kernel, Ben Dooks, Bin Meng

When trying to load modules built for riscv which include assembly
the kernel loader errors with "unexpected relocation type 'R_RISCV_ALIGN'"
due to R_RISCV_ALIGN relocations being generated by the assembler.

In commit 7a8e7da42250138 ("RISC-V: Fixes to module loading") the
CFLAGS have -mno-relax added. This however does not get applied to
KBUILD_AFLAGS_MODULE so when a module builds a .S file, the -mno-relax
is not passed and the above error is seen. Fix it by adding the flags
'-Wa,-mno-relax' to KBUILD_AFLAGS_MODULE.

This may have been fixed in gcc, in:
 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>
--
Changes since v1:
- added Bin Meng's review of the original patch
---
 arch/riscv/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 0289a97325d1..cf2ea9a1ac20 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -58,6 +58,7 @@ ifeq ($(CONFIG_PERF_EVENTS),y)
 endif
 
 KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax)
+KBUILD_AFLAGS_MODULE += $(call as-option,-Wa$(comma)-mno-relax)
 
 # GCC versions that support the "-mstrict-align" option default to allowing
 # unaligned accesses.  While unaligned accesses are explicitly allowed in the
-- 
2.35.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 20+ messages in thread
* [PATCH] riscv: add correct as-options for assembly in modules
@ 2021-07-12 17:48 ` Ben Dooks
  0 siblings, 0 replies; 20+ messages in thread
From: Ben Dooks @ 2021-07-12 17:48 UTC (permalink / raw)
  To: linux-kernel, linux-kernel, linux-riscv
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Ben Dooks

When trying to load modules built for riscv which include assembly
the kernel loader errors with "unexpected relocation type 'R_RISCV_ALIGN'"
due to R_RISCV_ALIGN relocations being generated by the assembler.

In commit 7a8e7da42250138 ("RISC-V: Fixes to module loading")
the fix for gcc adds -mno-relax to the command line when building
C files. However this was never applied to assembly flags, and gcc
does no pass -mno-relax to gas when presented with a .S file.

The fix (other than making gcc always pass -mno-relax to gas) is
to add -Wa,-mno-relax to gcc to make sure the as is invoked with
the right options.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 arch/riscv/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 1f5c03082976..fca40511a8c6 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -60,6 +60,7 @@ ifeq ($(CONFIG_PERF_EVENTS),y)
 endif
 
 KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax)
+KBUILD_AFLAGS_MODULE += $(call as-option,-Wa$(comma)-mno-relax)
 
 # GCC versions that support the "-mstrict-align" option default to allowing
 # unaligned accesses.  While unaligned accesses are explicitly allowed in the
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2022-05-29 15:45 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-08 19:26 [PATCH] riscv: add correct as-options for assembly in modules Ben Dooks
2021-12-08 19:26 ` Ben Dooks
2022-01-10 15:51 ` Ben Dooks
2022-01-10 15:51   ` Ben Dooks
2022-01-11  7:41 ` Bin Meng
2022-01-11  7:41   ` Bin Meng
  -- strict thread matches above, loose matches on Subject: below --
2022-05-29 15:19 Ben Dooks
2022-05-29 15:19 ` Ben Dooks
2022-05-29 15:23 ` Ben Dooks
2022-05-29 15:23   ` Ben Dooks
2021-07-12 17:48 Ben Dooks
2021-07-12 17:48 ` Ben Dooks
2021-07-16 10:23 ` Ben Dooks
2021-07-16 10:23   ` Ben Dooks
2021-07-16 10:44 ` Bin Meng
2021-07-16 10:44   ` Bin Meng
2021-07-16 15:33   ` Ben Dooks
2021-07-16 15:33     ` Ben Dooks
2021-07-16 22:37     ` Bin Meng
2021-07-16 22:37       ` Bin Meng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.