Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93819C433F5 for ; Wed, 8 Dec 2021 19:54:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239868AbhLHT6G (ORCPT ); Wed, 8 Dec 2021 14:58:06 -0500 Received: from imap3.hz.codethink.co.uk ([176.9.8.87]:38938 "EHLO imap3.hz.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229750AbhLHT6F (ORCPT ); Wed, 8 Dec 2021 14:58:05 -0500 X-Greylist: delayed 1695 seconds by postgrey-1.27 at vger.kernel.org; Wed, 08 Dec 2021 14:58:05 EST Received: from cpc152649-stkp13-2-0-cust121.10-2.cable.virginm.net ([86.15.83.122] helo=rainbowdash) by imap3.hz.codethink.co.uk with esmtpsa (Exim 4.92 #3 (Debian)) id 1mv2Zv-0008VM-5c; Wed, 08 Dec 2021 19:26:11 +0000 Received: from ben by rainbowdash with local (Exim 4.95) (envelope-from ) id 1mv2Zs-002lu4-MW; Wed, 08 Dec 2021 19:26:08 +0000 From: Ben Dooks To: linux-kernel@lists.codethink.co.uk, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Palmer Dabbelt , Albert Ou , Bin Meng , Ben Dooks Subject: [PATCH] riscv: add correct as-options for assembly in modules Date: Wed, 8 Dec 2021 19:26:07 +0000 Message-Id: <20211208192607.660787-1-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- 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