All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Dooks <ben.dooks@codethink.co.uk>
To: linux-kernel@lists.codethink.co.uk, linux-kernel@vger.kernel.org,
	linux-riscv@lists.infradead.org
Cc: Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Ben Dooks <ben.dooks@codethink.co.uk>
Subject: [PATCH] riscv: add correct as-options for assembly in modules
Date: Mon, 12 Jul 2021 18:48:49 +0100	[thread overview]
Message-ID: <20210712174849.2202287-1-ben.dooks@codethink.co.uk> (raw)

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


WARNING: multiple messages have this Message-ID (diff)
From: Ben Dooks <ben.dooks@codethink.co.uk>
To: linux-kernel@lists.codethink.co.uk, linux-kernel@vger.kernel.org,
	linux-riscv@lists.infradead.org
Cc: Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Ben Dooks <ben.dooks@codethink.co.uk>
Subject: [PATCH] riscv: add correct as-options for assembly in modules
Date: Mon, 12 Jul 2021 18:48:49 +0100	[thread overview]
Message-ID: <20210712174849.2202287-1-ben.dooks@codethink.co.uk> (raw)

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


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

             reply	other threads:[~2021-07-12 18:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-12 17:48 Ben Dooks [this message]
2021-07-12 17:48 ` [PATCH] riscv: add correct as-options for assembly in modules 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
2021-12-08 19:26 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
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210712174849.2202287-1-ben.dooks@codethink.co.uk \
    --to=ben.dooks@codethink.co.uk \
    --cc=aou@eecs.berkeley.edu \
    --cc=linux-kernel@lists.codethink.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.