From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AF306C433FE for ; Thu, 10 Feb 2022 14:54:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/k02Yy3PVQ3urcz5dgJDeWLgnRi/+hsg+ZMLiMaBZrg=; b=G8FDrI2MTE4Iw2 /uxSxSTDZfi3J06Jk0Ndt+AzT9aijYDWh3ctQ2DtgDtjfeMAI2QmwF28YpG5oEy6CbEErrAeWsMmG dbfrm4nJ2L/25o0o2cqzpbG/yo8uwndFtISaNf5zr/RQnm3xbD7EF3Q4OdgWtngLVMICCaSRS8q3m jM2AGhmiT5Lmh5MQUAhHxBhHfpyXsqTXSQdlxWNxBfO/xSVbUJ1+5avP1h0RCHUpDitg/+DB9Iw/S d5vqzIW9zZ4ifcyasUKGSGS2t9ao8z4Qb5JuO7p3/46/dW2UEDcVasVVtxUEtA8HevFZIQFZz22Zh QM80RxiRrWiEw4PB3r0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIAof-0048Ss-JK; Thu, 10 Feb 2022 14:53:01 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIAob-0048Rz-AX for linux-arm-kernel@lists.infradead.org; Thu, 10 Feb 2022 14:52:59 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 54618D6E; Thu, 10 Feb 2022 06:52:55 -0800 (PST) Received: from FVFF77S0Q05N (unknown [10.57.87.61]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 21F3D3F718; Thu, 10 Feb 2022 06:52:52 -0800 (PST) Date: Thu, 10 Feb 2022 14:52:46 +0000 From: Mark Rutland To: linux-kernel@vger.kernel.org, Nick Desaulniers , Nathan Chancellor Cc: acme@redhat.com, ardb@kernel.org, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, dave.hansen@linux.intel.com, jpoimboe@redhat.com, jslaby@suse.cz, linux-arm-kernel@lists.infradead.org, linux@armlinux.org.uk, mingo@redhat.com, peterz@infradead.org, tglx@linutronix.de, will@kernel.org Subject: Re: [PATCH v2 2/7] linkage: add SYM_{ENTRY,START,END}_AT() Message-ID: References: <20220125113200.3829108-1-mark.rutland@arm.com> <20220125113200.3829108-3-mark.rutland@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220125113200.3829108-3-mark.rutland@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220210_065257_482899_AAF0F80D X-CRM114-Status: GOOD ( 23.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org [adding clang folk] Nick, Nathan, I have a couple of questions for you below. On Tue, Jan 25, 2022 at 11:31:55AM +0000, Mark Rutland wrote: > Currently, the SYM_{ENTRY,START,END}() helpers define symbols in terms > of the current position within the section. In subsequent patches we'll > need to define symbols after moving this position. > > This patch splits the core out of SYM_{ENTRY,START,END}() into > SYM_{ENTRY,START,END}_AT() macros which take a location argument, > with SYM_{ENTRY,START,END}() passing the current position. > > There should be no functional change as a result of this patch. Unfortunately, it turns out clang doesn't like this: | [mark@lakrids:~/src/linux]% usellvm 13.0.0 make ARCH=arm LLVM=1 -s omap1_defconfig | [mark@lakrids:~/src/linux]% usellvm 13.0.0 make ARCH=arm LLVM=1 -s -j50 Image | arch/arm/mach-omap1/ams-delta-fiq-handler.S:272:5: error: expected absolute expression | .if (qwerty_fiqin_end - qwerty_fiqin_start) > (0x200 - 0x1c) | ^ | arch/arm/mach-omap1/ams-delta-fiq-handler.S:273:2: error: .err encountered | .err | ^ | make[1]: *** [scripts/Makefile.build:389: arch/arm/mach-omap1/ams-delta-fiq-handler.o] Error 1 | make[1]: *** Waiting for unfinished jobs.... | make: *** [Makefile:1831: arch/arm/mach-omap1] Error 2 | make: *** Waiting for unfinished jobs.... Both GCC and clang are happy to treat labels as constant expressions: | [mark@lakrids:~/asm-test]% cat test-label.S | .text | | start: | nop | end: | | .if (end - start) == 0 | .err | .endif | | [mark@lakrids:~/asm-test]% usekorg 11.1.0 aarch64-linux-gcc -c test-label.S | [mark@lakrids:~/asm-test]% usellvm 13.0.0 clang --target=aarch64-linux -c test-label.S ... but only GCC is happy to treat symbol definitions as constants: | [mark@lakrids:~/asm-test]% cat test-symbol.S | .text | | .set start, .; | nop | .set end, .; | | .if (end - start) == 0 | .err | .endif | | [mark@lakrids:~/asm-test]% usekorg 11.1.0 aarch64-linux-gcc -c test-symbol.S | [mark@lakrids:~/asm-test]% usellvm 13.0.0 clang --target=aarch64-linux -c test-symbol.S | test-symbol.S:7:6: error: expected absolute expression | .if (end - start) == 0 | ^ | test-symbol.S:8:2: error: .err encountered | .err | ^ This is obviously a behavioural difference, but I'm not sure whether it's intentional, or just an artifact of the differing implementation of GNU as and LLVM's integrated assembler. Nich, Nathan, any thoughts on that? Does clang have any mechanism other than labels to define location constants that can be used as absolute expressions? e.g. is there any mechanism to alias a label which results in the alias also being a constant? Thanks, Mark. > Signed-off-by: Mark Rutland > Acked-by: Ard Biesheuvel > Acked-by: Mark Brown > Cc: Borislav Petkov > Cc: Jiri Slaby > Cc: Josh Poimboeuf > Cc: Peter Zijlstra > --- > include/linux/linkage.h | 28 +++++++++++++++++++++++----- > 1 file changed, 23 insertions(+), 5 deletions(-) > > diff --git a/include/linux/linkage.h b/include/linux/linkage.h > index dbf8506decca0..d87c2acda2540 100644 > --- a/include/linux/linkage.h > +++ b/include/linux/linkage.h > @@ -147,25 +147,43 @@ > > /* === generic annotations === */ > > +#ifndef SYM_ENTRY_AT > +#define SYM_ENTRY_AT(name, location, linkage) \ > + linkage(name) ASM_NL \ > + .set name, location ASM_NL > +#endif > + > /* SYM_ENTRY -- use only if you have to for non-paired symbols */ > #ifndef SYM_ENTRY > #define SYM_ENTRY(name, linkage, align...) \ > - linkage(name) ASM_NL \ > align ASM_NL \ > - name: > + SYM_ENTRY_AT(name, ., linkage) > +#endif > + > +/* SYM_START_AT -- use only if you have to */ > +#ifndef SYM_START_AT > +#define SYM_START_AT(name, location, linkage) \ > + SYM_ENTRY_AT(name, location, linkage) > #endif > > /* SYM_START -- use only if you have to */ > #ifndef SYM_START > #define SYM_START(name, linkage, align...) \ > - SYM_ENTRY(name, linkage, align) > + align ASM_NL \ > + SYM_START_AT(name, ., linkage) > +#endif > + > +/* SYM_END_AT -- use only if you have to */ > +#ifndef SYM_END_AT > +#define SYM_END_AT(name, location, sym_type) \ > + .type name sym_type ASM_NL \ > + .size name, location-name ASM_NL > #endif > > /* SYM_END -- use only if you have to */ > #ifndef SYM_END > #define SYM_END(name, sym_type) \ > - .type name sym_type ASM_NL \ > - .size name, .-name > + SYM_END_AT(name, ., sym_type) > #endif > > /* === code annotations === */ > -- > 2.30.2 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel