Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp4880484ioo; Tue, 31 May 2022 13:56:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsEBDOIjAfYclr8q8za8nGAwi2Kt6Jfa6A5UI3HSvx0LT2myFNmHfh/pIktrO/nItf9NkL X-Received: by 2002:a05:6402:d05:b0:425:b5c8:faeb with SMTP id eb5-20020a0564020d0500b00425b5c8faebmr65639223edb.273.1654030577533; Tue, 31 May 2022 13:56:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654030577; cv=none; d=google.com; s=arc-20160816; b=terWoNPJlwT4OvjVoFaH3lF7hlBhgc1JnZkK7vnln19mA3CSbMxn7kEwsDT0yXQsUm /Xbew+G8DJGHkMigxWMU9ds3UB7xNR3RxOiyR4ponhd0nFUP1qh+sbZCtDg73rcTy8D7 KF8MhDx/eLEQqNDT1nuhRcPt8ccFj3TAbG73zPQUNYCELXXm2WuDpRw/PTM0mzXPkeCe SJbWS5IAKA/6fb+oS3OTAioKZjYh5q79hlSlrezjquQkBf1JkcycqT7Imu3movlFTCC8 WlgK8HjUyjDfOoFjcdbVv2Gg0YkVLrFZs5rh1+hzTVcJUFaZZhdj5sOqbe+gd8/rCh0t oTdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=y/hsXNqhSBSy6P+e3G0CBaS4aay094v0Tpprwr2MTnE=; b=Dd1bNIa5NHgCa36Hx1X7nsLT0t8qkOwCelsmLnxtbhkBo+NT/XgPtWi5/a7He+aZFv SzD6ecv3MbGujxncpFdSkLW156QoAOXpj75yk3tbViUwAIcrwaCyLW5LuDzvQ26O4bua VML0WnNmLGYcnJ/51Az9qDZYwKC9kyhxWkR/3eaHtLfguUAKmYvoqIM2DMbr3dRoBbQH 7lr/W933o2ojd3sr244SHtTYbV4DXkyPQRnjMRNjXHkS3ix0wU7MC9+lDx/NGCLg1S5P yOh4A2RTZ7z5T9aoPjbPJJokfyss8pKjDwfCuCBnkAJC+erNmVAGE2AX7uaodUSTv1zl yAWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id by8-20020a170906a2c800b006f38383ef23si14615477ejb.318.2022.05.31.13.55.52; Tue, 31 May 2022 13:56:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230256AbiE2PpE (ORCPT + 99 others); Sun, 29 May 2022 11:45:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231269AbiE2PpB (ORCPT ); Sun, 29 May 2022 11:45:01 -0400 X-Greylist: delayed 1369 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sun, 29 May 2022 08:45:00 PDT Received: from imap3.hz.codethink.co.uk (imap3.hz.codethink.co.uk [176.9.8.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B298069290 for ; Sun, 29 May 2022 08:45:00 -0700 (PDT) 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 1nvKjx-0004xX-Um; Sun, 29 May 2022 16:22:01 +0100 Received: from ben by rainbowdash with local (Exim 4.95) (envelope-from ) id 1nvKjw-002Ydq-Qz; Sun, 29 May 2022 16:22:00 +0100 From: Ben Dooks To: linux-kernel@lists.codethink.co.uk, linux-riscv@lists.infradead.org Cc: palmer@dabbelt.com, aou@eecs.berkeley.edu, linux-kernel@vger.kernel.org, Ben Dooks , Bin Meng Subject: [PATCH] [PATCH v2] riscv: add as-options for modules with assembly compontents Date: Sun, 29 May 2022 16:22:00 +0100 Message-Id: <20220529152200.609809-1-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 7a8e7da42250138 ("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 Notes: Signed-off-by: Ben Dooks Reviewed-by: Bin Meng --- 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.35.1