From patchwork Sun Jul 11 02:28:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jessica Clarke X-Patchwork-Id: 1503591 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=ucJ4vj4H; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=jrtc27.com header.i=@jrtc27.com header.a=rsa-sha256 header.s=gmail.jrtc27.user header.b=SydL6qdD; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GMrRy1DP5z9sWS for ; Sun, 11 Jul 2021 12:28:44 +1000 (AEST) 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=OS+wSttdsQphaH/b7pTdLb8U4w6nKR4YFTFtwswGOUc=; b=ucJ4vj4HU8kVPK BWLxJCO+n8nvv9ptQqLbRunXtZlGx2mBKMPTqzDu7qq8pvOUJcyqmgGk3J3pj2Ggis0bIMBdxgOtO 5k27HZq29UnXxbfMnqYtv4xP4VC8jCabUBG98YbJS7uGODTVSNitnAwOWtBseCn8SvKyiPhgA/j/v yM1Afw/RGtbaHwq5psNpoEktAAZ9tHIc6EYf2j4Y0wYpNtU9EuWg9cY0R0s1nhHhucw6W0nj41nD2 sgMzP7oK9uds4fmEuvjw1H9LcAI+upENNdRwgVjnH35TeKeh5Lnov9UCC1E8wqIDn2YIP7fNssraO MiXsLr2AdxckGW2i5uow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2PCw-004V3a-LM; Sun, 11 Jul 2021 02:28:38 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2PCs-004V0x-GO for opensbi@lists.infradead.org; Sun, 11 Jul 2021 02:28:36 +0000 Received: by mail-wm1-x334.google.com with SMTP id l6so499023wmq.0 for ; Sat, 10 Jul 2021 19:28:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jrtc27.com; s=gmail.jrtc27.user; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=13vT4VXhxbRJC/cAmoB0N8SOO5e97O1VG6qtQ25AHa4=; b=SydL6qdDDp5CtLPWLY+E+xiYmznkdsmT7/H82B80K/4ah1Jep4F1WBFqs96/WM1EKj U9n9qDq0/Nsnxmw4DTje/Xr3V/rctqBMYBBcIXdXu6sj7Y2rN4jKazZEOwfYUosGPFvY BhnZP3l4/V34wFQAIf2Zc2jpNlBS7KTYkbVlXm1Z418i/Px2dHCfme5JA9QU3FxWXZ/9 9iR9f9xKyApz2Y9tqY2mqyQH9UCdjQY1FDmkBIzz24sYdxzMn5Bgsa9fZY3qQeoFQhRL tDZrXrvbMydrB45mWz5ds9s7hsUNzu9cGmuRrWhMyX1AZz9x5sU8ncXSm/S51DSzgVCt aZTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=13vT4VXhxbRJC/cAmoB0N8SOO5e97O1VG6qtQ25AHa4=; b=OpxSwY8X0hoJ2ISBbulwfQ20wW4V9MDkK4qdl+m6tDSVCQQ5Wx97kcof/8uBIxnJSe 0ZOIeKNkNXOadPLvo9A2f4YkEFRi+mPOXiKZOtT94lovuR4jP/01m7KPa8dcobXErqr2 eN/rxR56odBqLes2OI34f3CRtSkjEubUsEFqXxbrA+QdFz3DS18hqzTnhdrRCnRyGLGy M9tQPeIxjfpTbi5UBSDf4QcDE6IIxpORjQiEHFBMbq2hzjxjr2BVx3uHv0T3Aq8UMgYC AXfgg1yAlTne6OPl2xYOy/5hVKQq9roEr+KM/yv55OpPb58UArEwWwHjeAJpydfaOO0v RqPQ== X-Gm-Message-State: AOAM5319pUcDdlKSPWYCLMlJN9Ag84nNvzVVK5zETxiKZc5wWfmMLP4x CjSmNDZi651QvLASBUsFPmMGXg== X-Google-Smtp-Source: ABdhPJy9OEuALCaLGzv8s747zmIdQWSDjMtGV21QVG8y/6w6P7eqIxZKWoVHjKIFY7bk660P4k1oiA== X-Received: by 2002:a05:600c:4101:: with SMTP id j1mr7093667wmi.84.1625970511578; Sat, 10 Jul 2021 19:28:31 -0700 (PDT) Received: from Jessicas-MacBook-Pro.local (trinity-students-nat.trin.cam.ac.uk. [131.111.193.104]) by smtp.gmail.com with ESMTPSA id v15sm16401470wmj.39.2021.07.10.19.28.30 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 10 Jul 2021 19:28:31 -0700 (PDT) Received: by Jessicas-MacBook-Pro.local (Postfix, from userid 501) id 7338029D73FC; Sun, 11 Jul 2021 03:28:27 +0100 (BST) From: Jessica Clarke To: opensbi@lists.infradead.org Cc: Jessica Clarke Subject: [PATCH v5 4/6] firmware: Only default FW_PIC to y if supported Date: Sun, 11 Jul 2021 03:28:22 +0100 Message-Id: <20210711022824.29915-5-jrtc27@jrtc27.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210711022824.29915-1-jrtc27@jrtc27.com> References: <20210711022824.29915-1-jrtc27@jrtc27.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210710_192834_614089_2645655B X-CRM114-Status: GOOD ( 12.46 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Bare-metal GNU ld does not support PIE, so if using it this will result in a failure to build. Instead, default to FW_PIC=n if not supported. Note that an explicit FW_PIC=y is not overriden, to ensure [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:334 listed in] [list.dnswl.org] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Bare-metal GNU ld does not support PIE, so if using it this will result in a failure to build. Instead, default to FW_PIC=n if not supported. Note that an explicit FW_PIC=y is not overriden, to ensure the build fails rather than silently producing a position-dependent binary. Signed-off-by: Jessica Clarke Reviewed-by: Bin Meng Tested-by: Bin Meng Reviewed-by: Anup Patel --- Makefile | 3 +++ firmware/objects.mk | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6b64205..ba06313 100644 --- a/Makefile +++ b/Makefile @@ -106,6 +106,9 @@ ifndef PLATFORM_RISCV_XLEN endif endif +# Check whether the linker supports creating PIEs +OPENSBI_LD_PIE := $(shell $(CC) -fPIE -nostdlib -Wl,-pie -x c /dev/null -o /dev/null >/dev/null 2>&1 && echo y || echo n) + # Setup list of objects.mk files ifdef PLATFORM platform-object-mks=$(shell if [ -d $(platform_src_dir)/ ]; then find $(platform_src_dir) -iname "objects.mk" | sort -r; fi) diff --git a/firmware/objects.mk b/firmware/objects.mk index 3bc83cd..8da7ca3 100644 --- a/firmware/objects.mk +++ b/firmware/objects.mk @@ -14,7 +14,7 @@ firmware-asflags-y += firmware-ldflags-y += ifndef FW_PIC -FW_PIC := y +FW_PIC := $(OPENSBI_LD_PIE) endif ifeq ($(FW_PIC),y)