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 E2D67C433F5 for ; Fri, 14 Jan 2022 16:32:19 +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=lIWE1mfwmXOMX5gOzCuP4SnRMz4thsy4Ef80f9KpjEY=; b=BmLUbjDAEVFWHh IAFN5Cgr9paYsxKlf+ymqLisZT3j6Dr58ZdIHF20PvZqgeImu7LpTHHAFxqqwXmX45sNL4CqmCH8D Gj1yfAJkrtdj0asZJKo0re+J/qcodISo7pX+4+lEvV3Ndf+j0yjfcdMWHVZVSTSycPaW732fZ++l4 aEhOBMUH/11HDZBxh9f/GFNsN0anp+3v5hJxr6Z1Cr4TKf026NXBAvu4yI+N2KrYO1KuMpt3IY90D UutDx1uregGoKE7HKK38DIpwODnLH/qNICfBFQxry+rNE1rxix5+wVtHzf/GebQyL3tBb1IvHVaVt 86Q4rFXEErRQ65w4q73g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n8PTj-009lIT-Mo; Fri, 14 Jan 2022 16:31:03 +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 1n8PTY-009lGb-9z for linux-arm-kernel@lists.infradead.org; Fri, 14 Jan 2022 16:30:53 +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 945236D; Fri, 14 Jan 2022 08:30:51 -0800 (PST) Received: from FVFF77S0Q05N (unknown [10.57.2.91]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 690C53F766; Fri, 14 Jan 2022 08:30:50 -0800 (PST) Date: Fri, 14 Jan 2022 16:30:47 +0000 From: Mark Rutland To: Robin Murphy Cc: Andre Przywara , linux-arm-kernel@lists.infradead.org, Jaxson.Han@arm.com, vladimir.murzin@arm.com, Wei.Chen@arm.com Subject: Re: [bootwrapper PATCH v2 11/13] Announce locations of memory objects Message-ID: References: <20220114105653.3003399-1-mark.rutland@arm.com> <20220114105653.3003399-12-mark.rutland@arm.com> <20220114153053.658a5ffa@donnerap.cambridge.arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220114_083052_452962_F6F91F0C X-CRM114-Status: GOOD ( 16.02 ) 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 On Fri, Jan 14, 2022 at 04:04:19PM +0000, Robin Murphy wrote: > On 2022-01-14 15:30, Andre Przywara wrote: > > On Fri, 14 Jan 2022 10:56:51 +0000 > > Mark Rutland wrote: > > > +void print_ulong_hex(unsigned long val) > > > +{ > > > + const char hex_chars[16] = "0123456789abcdef"; > > > > This breaks the build for me (I guess because of the const?): > > ------------------- > > ld --gc-sections arch/aarch64/boot.o arch/aarch64/stack.o arch/aarch64/utils.o arch/aarch64/init.o arch/aarch64/psci.o common/boot.o common/bakery_lock.o common/platform.o common/lib.o common/init.o common/psci.o common/gic-v3.o -o linux-system.axf --script=model.lds > > ld: common/platform.o: in function `print_ulong_hex': > > /src/boot-wrapper-aarch64.git/common/platform.c:58: undefined reference to `__stack_chk_guard' > > ld: /src/boot-wrapper-aarch64.git/common/platform.c:58: undefined reference to `__stack_chk_guard' > > ld: /src/boot-wrapper-aarch64.git/common/platform.c:66: undefined reference to `__stack_chk_fail' > > /src/boot-wrapper-aarch64.git/common/platform.c:66:(.text.print_ulong_hex+0xa0): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__stack_chk_fail' > > make: *** [Makefile:684: linux-system.axf] Error 1 > > ------------------ > > I got curious and tried a quick test compiling this function in isolation, > and indeed for some reason GCC (9.3.0 at -O2) seems to end up allocating 80 > bytes of stack, which is apparently large enough to trigger insertion of a > stack check, and laboriously copying the string from static data into it. > FWIW either making hex_chars static const, or simply '#define hex_chars > "01234567abcdef"', not only avoids a stack check but also leads to notably > nicer code. For the stack check, I think Andre's patch to add -fno-stack-protector is the correct fix, so I'd like to take that as a prerequisite. To avoid using the stack unnecessarily and to make the code nicer, I'll also take your suggestion with the fixup below. Thanks, Mark. ---->8---- -#define HEX_CHARS_PER_LONG (2 * sizeof(long)) +#define HEX_CHARS_PER_LONG (2 * sizeof(long)) +#define HEX_CHARS "0123456789abcdef" void print_ulong_hex(unsigned long val) { - const char hex_chars[16] = "0123456789abcdef"; int i; for (i = HEX_CHARS_PER_LONG - 1; i >= 0; i--) { int v = (val >> (4 * i)) & 0xf; - print_char(hex_chars[v]); + print_char(HEX_CHARS[v]); } } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel