From patchwork Thu Jan 3 18:28:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 154736 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp950245ljp; Thu, 3 Jan 2019 10:28:55 -0800 (PST) X-Google-Smtp-Source: AFSGD/VI4u8VR3I1w8AjoASU6F/srstP6uD7VWXA15o05fkhNeMeBrGM2UL0Zf5t7bWpXuWyRBEE X-Received: by 2002:a62:4e83:: with SMTP id c125mr49707724pfb.101.1546540135403; Thu, 03 Jan 2019 10:28:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546540135; cv=none; d=google.com; s=arc-20160816; b=ppAX2ixIMAuW68Iref88vhdx/1wLK8McU4P178aQ88bwHpISECgiLR6IQcE3w3+Krt yMHnY5dGHsHg4SGsySlZbDBkSiEFIjxheVEjuyZiQ9Q4Pzg7Mb//Zgz9fTckV0TIGQpo 8y52pISHdx7s6EXPG3mwKCsNXkYuhdL1kTMosuyPTcZxJx7dvUftRn9YJ0kWkPr/raXY NJ7jOSGS69GylyUJ0XvuLrQm9sdK9iDqZWbBpukvJKHZ6QXGEhVv4WU3IFDHHG1qjCFx KnIY9jp+cBgRQ4m3ZRihUWxJ7CCbVUbjy1LcX9M9b32qq+5+clI7nrZgxHWjKMz/VdRq 6PYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=O3kg4vThetCB5jhtHtIGZImO4NQ7X1TOpfAAOh5QHGk=; b=dDdqj8eRqds6CiE6W18jEd8rh85ukO5j2EGUjJjI4t4Hsr0GZRROV5nyp7aRjanzSI kwrrcNc3kt069va2U9nOsjEilQGmuQe7Glw2M6cShQSmK8HqFInoEW4bleSVoqyoVN8p yY6v2pixcPKpWoU+A5z1Gz8BuljRrsqR1P7EogMFtu7Y3xoHZwVA0dohQIk94BIeY0V0 ZWULu9p6N5AdTJA9hYC5SUhRZrZ4WUYHCpUFubv/mS+st2v90Zl+fweIUC4oKlDz9htU 4IZEHE6ALws07c/uQMJHOPzO1npVoFZyDpKkO/5poEM1AgJWuLgxd2f6Wgy3wvQA+X/g J+sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jsIAtF98; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id d9si8946414plr.127.2019.01.03.10.28.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Jan 2019 10:28:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jsIAtF98; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id CFAEF211ADA42; Thu, 3 Jan 2019 10:28:52 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::543; helo=mail-ed1-x543.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 30905211ADA34 for ; Thu, 3 Jan 2019 10:28:52 -0800 (PST) Received: by mail-ed1-x543.google.com with SMTP id b3so29889345ede.1 for ; Thu, 03 Jan 2019 10:28:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bCINsaHfkDOqvhAwH1vmkMRZNE4RwacpVJGMDUMWNKA=; b=jsIAtF981mCqhsdHRFV3XenFR0sYVqfEZWGd1ImYQYOz7L0Lwv68HD9WjEvHWGeyVG 1WQAeDZRtUIRGTuOV4k2vx9VxBNRCuciD9psrAbmIcTHHS/87bi+MfGEfy1GUH91Anxv 7sOOxLjeFvAo9hF1bid9YBA55YKWaZfWxWiU8= 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; bh=bCINsaHfkDOqvhAwH1vmkMRZNE4RwacpVJGMDUMWNKA=; b=dcbsZLXsiiDOpZgUudUrU5UEieC3x3cY9p9oomFABnjVxZabfbjm42o290qe2IdJEA bDVzEjj9lQByEBr/xtLt0udn590eneTxuXOs4yBwkZyJ77C7ZmzrdV+l5QcKFsJZC1g5 IgC4c4DdrPs3B03DFSkORLT/EcXsXMPuhn8Wd6rduqggCZ6CHbJVa9kMZtSOChLIR/mq GrvAK8JsM1SPpY4AFnv/qlgJW6L9d+Oy1M6LLtmuj2BW6pKQaE4NvUFR6ZmYA9JqP8IJ IMDPd9I4FP/veWqCENhCp1WiroKIW23UqQ2a/KHg58S69JLS/GOO08s0gWeLSFFu7v39 Qt5A== X-Gm-Message-State: AA+aEWb1irwcqA/q4Jq/uz6k+MiUTb1aXxaXG+o9qjRPX++fiDEjR03W FOyFmGO1234W76Fsj5iNkt07ceRh3Zocuw== X-Received: by 2002:a17:906:78c1:: with SMTP id r1-v6mr35827378ejn.150.1546540129192; Thu, 03 Jan 2019 10:28:49 -0800 (PST) Received: from dogfood.home ([2a01:cb1d:112:6f00:704e:c241:dc88:597d]) by smtp.gmail.com with ESMTPSA id a11sm25707206edc.28.2019.01.03.10.28.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Jan 2019 10:28:48 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 3 Jan 2019 19:28:19 +0100 Message-Id: <20190103182825.32231-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190103182825.32231-1-ard.biesheuvel@linaro.org> References: <20190103182825.32231-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH] BaseTools/GenFds: permit stripped MM_CORE_STANDALONE binaries X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hao Wu , Liming Gao , Michael D Kinney , Laszlo Ersek MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" The standalone MM core is executed in place, and resides in a separate execution context which may be space constrained. Since code and data may be mapped with different attributes for security reasons, the PE/COFF binary could have a section alignment of 4 KB. This means that any relocation data is not only useless, but it will also take up 4 KB of valuable space. So add support for the RELOCS_STRIPPED attribute on FFS files of this type, so that we can get rid of the .reloc section altogether. Combined with the FIXED attribute (which enables an optimization in GenFfs that strips redundant padding) and a TE type binary, this gets rid of all the needless padding around the standalone MM core binary. Cc: Bob Feng Cc: Liming Gao Cc: Jagadeesh Ujja Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- BaseTools/Source/Python/GenFds/EfiSection.py | 2 +- BaseTools/Source/Python/GenFds/FdfParser.py | 2 +- BaseTools/Source/Python/GenFds/FfsInfStatement.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Bob Feng Signed-off-by: Ard Biesheuvel diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Source/Python/GenFds/EfiSection.py index f8573b5c7d1b..0be176ec8ae1 100644 --- a/BaseTools/Source/Python/GenFds/EfiSection.py +++ b/BaseTools/Source/Python/GenFds/EfiSection.py @@ -68,7 +68,7 @@ class EfiSection (EfiSectionClassObject): StringData = FfsInf.__ExtendMacro__(self.StringData) ModuleNameStr = FfsInf.__ExtendMacro__('$(MODULE_NAME)') NoStrip = True - if FfsInf.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM) and SectionType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32): + if FfsInf.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, SUP_MODULE_MM_CORE_STANDALONE) and SectionType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32): if FfsInf.KeepReloc is not None: NoStrip = FfsInf.KeepReloc elif FfsInf.KeepRelocFromRule is not None: diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index e000228d2f6c..de0b166030e7 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -2589,7 +2589,7 @@ class FdfParser: # @staticmethod def _FileCouldHaveRelocFlag (FileType): - if FileType in {SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, 'PEI_DXE_COMBO'}: + if FileType in {SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, SUP_MODULE_MM_CORE_STANDALONE, 'PEI_DXE_COMBO'}: return True else: return False diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py index c1073c96e9aa..d4c61c074963 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -901,7 +901,7 @@ class FfsInfStatement(FfsInfStatementClassObject): # @retval string File name of the generated section file # def __GenComplexFileSection__(self, Rule, FvChildAddr, FvParentAddr, IsMakefile = False): - if self.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM): + if self.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, SUP_MODULE_MM_CORE_STANDALONE): if Rule.KeepReloc is not None: self.KeepRelocFromRule = Rule.KeepReloc SectFiles = []