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 EF8F3C433EF for ; Wed, 22 Dec 2021 18:17:36 +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:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=g1YGCTbOiFXgWFkUEMTMEfa2GB7gfoqJvyV719ozIas=; b=Y+caOlciTKMdVW NM17SPuoeYrxt+3Ank68ilUX2nqqhl2B0IGNdEMo367beSOxLCxBlU6YgAiCgrhbnGjvxBz9pjRrX ydNId9Hux4kMAjJVQVKWxiqMun0GCBGsAhGhqgY93QyPjT3WrTfc8S8tJtAudFtutsGH/q/nyHzHu JNGI37cOGDap0F/losSeWPOLyrTaY3tvWusCjLzTu/JjCZ7tR3BZDi/HOPdmHA74JFwrqs+5ZF+9b rUQgy9qX7hC5jIo+fiL5Ch8qULxptIwCAEFjECRGrj0uK/vb4KPRWIM6vehW2b15FUSVdc11iLNhX nmnI9hobvGla4OXesYyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n06A1-00B3a0-KA; Wed, 22 Dec 2021 18:16:21 +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 1n069x-00B3Yj-Pf for linux-arm-kernel@lists.infradead.org; Wed, 22 Dec 2021 18:16:19 +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 3F343106F; Wed, 22 Dec 2021 10:16:17 -0800 (PST) Received: from donnerap.arm.com (donnerap.cambridge.arm.com [10.1.196.172]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8FBE63F5A1; Wed, 22 Dec 2021 10:16:16 -0800 (PST) From: Andre Przywara To: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org, Jaxson Han Subject: [boot-wrapper PATCH v2 1/9] Makefile: Avoid .got section creation Date: Wed, 22 Dec 2021 18:15:59 +0000 Message-Id: <20211222181607.1203191-2-andre.przywara@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211222181607.1203191-1-andre.przywara@arm.com> References: <20211222181607.1203191-1-andre.przywara@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211222_101617_896941_F95DD09D X-CRM114-Status: GOOD ( 12.58 ) 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 At the moment we build the boot-wrapper with the default toolchain settings, which has issues if that is a toolchain targeted to Linux userland, for instance. Since boot-wrapper is rather simple, we get away with this, *mostly*, but there is at least one case where this breaks: Many distributions enable PIE builds by default when building GCC, so by just calling "gcc" we build the .o files for PIE (although we don't link them accordingly, since we use "ld" directly). When we moved the PSCI code from assembly to C, we also introduced global variables, which a PIE enabled GCC will put into a .got section (global offset table), to be able to easily relocate them at runtime (if needed). This section happens to be outside of the memory region we reserve, so can (and will be) overwritten by Linux at some point. Doing PSCI calls afterwards does not end well then. "memtest=1" is one way to trigger this. To avoid the (in our case pointless) creation of the GOT, we specify -fno-pic and -fno-pie, to override any potential toolchain default. This fixes boot-wrapper builds on many distro compilers, for instance as provided by Ubuntu and Arch Linux. Signed-off-by: Andre Przywara --- Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.am b/Makefile.am index d0a68df..3e970a3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -126,6 +126,7 @@ CPPFLAGS += $(INITRD_FLAGS) CFLAGS += -I$(top_srcdir)/include/ -I$(top_srcdir)/$(ARCH_SRC)/include/ CFLAGS += -Wall -fomit-frame-pointer CFLAGS += -ffunction-sections -fdata-sections +CFLAGS += -fno-pic -fno-pie LDFLAGS += --gc-sections OBJ := $(addprefix $(ARCH_SRC),$(ARCH_OBJ)) $(addprefix $(COMMON_SRC),$(COMMON_OBJ)) -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel