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 01C00C433EF for ; Mon, 17 Jan 2022 16:54:38 +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:MIME-Version:References:In-Reply-To: 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=XGHO5t14+fxLtuSZE8cUNGTOC0SDd62QE5t7PdYd/kY=; b=PpDL7Z+PbA0Pa/ 19wmwUSycFeQbq58rceJWX+ZVubBWSVRf4IzurcYhz47DFz6QdTme+Yl1tT1WocHX45GN/2LEguVi b9jDpnsLazUtSgk1y0yn7CpGxVrgy8LiTjKL8BAXKkf4wzVvq3pJTjVEdRlvz5SFahvY2fOF83AZy ThGtF2Ug734eKpA14+Yhqp9DXqvyuQKrRuv88wG93xf8n/YaczdIwMrDSewgwItTEIsNnVlOnQYEj 9vMMm5f5IpU0MIsDAmTOHFSXomVbb1kdYCwJ3CTrBSygpTKsgwAcziYWUIMMgJ0rUbvASd0zXkHzv hEHYPF4B39iWDZSqmqLg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n9VFu-00FdKr-UE; Mon, 17 Jan 2022 16:53:19 +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 1n9VFq-00FdJK-WE for linux-arm-kernel@lists.infradead.org; Mon, 17 Jan 2022 16:53:16 +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 1D20A6D; Mon, 17 Jan 2022 08:53:13 -0800 (PST) Received: from donnerap.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6B4A53F766; Mon, 17 Jan 2022 08:53:12 -0800 (PST) Date: Mon, 17 Jan 2022 16:53:10 +0000 From: Andre Przywara To: Mark Rutland Cc: Jaxson Han , linux-arm-kernel@lists.infradead.org, Robin Murphy Subject: Re: [PATCH v3] Makefile: Tell compiler to generate bare-metal code Message-ID: <20220117165310.769a4799@donnerap.cambridge.arm.com> In-Reply-To: <20220117164720.GA94025@C02TD0UTHF1T.local> References: <20220117153348.2513798-1-andre.przywara@arm.com> <20220117164720.GA94025@C02TD0UTHF1T.local> Organization: ARM X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; aarch64-unknown-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220117_085315_169515_E95EEFB1 X-CRM114-Status: GOOD ( 34.04 ) 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 Mon, 17 Jan 2022 16:47:20 +0000 Mark Rutland wrote: > Hi Andre, > > On Mon, Jan 17, 2022 at 03:33:48PM +0000, Andre Przywara wrote: > > Our GCC invocation does not provide many parameters, which lets the > > toolchain fill in its own default setup. > > In case of a native build or when using a full-featured cross-compiler, > > this probably means Linux userland, which is not what we want for a > > bare-metal application like boot-wrapper. > > > > Tell the compiler to forget about those standard settings, and only use > > what we explicitly ask for. In particular that means to not use toolchain > > provided libraries, since they might pull in more code than we want, and > > might not run well in the boot-wrapper environment. > > Thanks for splitting this out; I'd like to apply this with two minor > fixups (which I'll apply locally if you agree). Yes, I am fine with those changes, please go ahead! > > Disable the stack protector, as this adds code that relies on userland: > > "If a guard check fails, an error message is printed and the program > > exits." (from the gcc manpage). > > I think we should say: > > | Disable the stack protector, as this relies on support code, e.g. > | a __stack_chk_guard variable and __stack_chk_fail function, which the > | boot-wrapper does not implement. > > > Signed-off-by: Andre Przywara > > --- > > Hi, > > > > compared to [PATCH v2 3/9] this drops the more contentious options (for > > now, at least), and focuses on what's really needed. Including > > -fno-stack-protector, as the need for this showed up in the cleanup series > > already. > > > > Cheers, > > Andre > > > > Makefile.am | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/Makefile.am b/Makefile.am > > index f941b07..581840e 100644 > > --- a/Makefile.am > > +++ b/Makefile.am > > @@ -125,6 +125,8 @@ CHOSEN_NODE := chosen { \ > > CPPFLAGS += $(INITRD_FLAGS) > > CFLAGS += -I$(top_srcdir)/include/ -I$(top_srcdir)/$(ARCH_SRC)/include/ > > CFLAGS += -Wall -fomit-frame-pointer > > +CFLAGS += -ffreestanding -nostdlib # this is not for userland > > +CFLAGS += -fno-stack-protector # no terminal to print > > For now, I'd like to drop these comments, since I think the "no terminal > to print" comment is a bit confusing, and the "this is not for userland" > comment is arguably the most obvious. > > Then as a future follow-up we can reoganise this for clarity: > > | # Build code suitable for a bare-metal environment which does not > | # depend on any support libraries > | CFLAGS += ffreestanding -nostdlib > | > | # Disable unnecessary features which require runtime support > | CFLAGS += -fno-stack-protector > | CFLAGS += ... > | > | # Disable unnecessary features which impact code-size > | CFLAGS += -fomit-frame-pointer > | CFLAGS += ... > | > | # Allow the linker to remove unused code and data to shrink the > | # resulting binary > | CFLAGS += -ffunction-sections -fdata-sections > | LDFLAGS += --gc-sections Yes, that looks good to me as a plan. I agree that trying to fit meaningful comment to the rest of the line was not a great idea. Cheers, Andre > > > > CFLAGS += -ffunction-sections -fdata-sections > > CFLAGS += -fno-pic -fno-pie > > LDFLAGS += --gc-sections > > -- > > 2.25.1 > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel