From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::443; helo=mail-wr1-x443.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) (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 65D6621199249 for ; Thu, 3 Jan 2019 04:13:20 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id 96so33405190wrb.2 for ; Thu, 03 Jan 2019 04:13:20 -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; bh=bCINsaHfkDOqvhAwH1vmkMRZNE4RwacpVJGMDUMWNKA=; b=FFOvkG32HRzKX1Lc7/EkEB8O5Z3SqylmepQJ6ewtR6SdDr5Pbfsa5H0Vhp1ubxcFOD 7H+m7Sjif+YDkTUSUSr40RlpdHIA4fo37bgScQhCREkuhKFmwc9Lviqft4T4wDTv8DwZ gLf5f168Xi2ndq32yyA4DQPOGUSUvRl6xkPHE= 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; bh=bCINsaHfkDOqvhAwH1vmkMRZNE4RwacpVJGMDUMWNKA=; b=CwItbIeK84eBQ7YyXiBVzd69+tXd7Jk8JakTFiip/GZfXCXLGl6AiUDMgr7j2bVosG CQTfmthVnhyGYXLEYt9DQFt8K3Ljx59hdVqIMv+4HK+KXSRsZp4yZzMF/Z9ro4FUNtDU XNBh6rqAL5etAfvpS0kJcDBN4teLTVblqitJEK0ICRz/r2c7myY+RDO6/co3hgWzpoYh gV4OLY5vkfeHZJA217krpab3QkKl/R+SYJxmaRLxeSIR4tDKJnX0FuVsQF7gxj1EhknJ NnMm5pgv6fJl5uAIm7Du9XNpWqQ1RnORQ7gv0txLAw0/akcHnhCEtejcQXRcgMqr6JbB jqUA== X-Gm-Message-State: AJcUukfi3yi2YzSFYYn+ZuNQRn86k5c7XrGyAyHK5iYWPvCjyuRPkGYk PvEFoMBGAXiqIGwNYJl9gh9cwUTPPh0OkQ== X-Google-Smtp-Source: ALg8bN5P4KYhzuNQvNWjt0YXoVwwkSdUC29xFbJl4U8xgHKPDMQJJvy8mqcodYomoTtUB3gJ1UCe5A== X-Received: by 2002:adf:b783:: with SMTP id s3mr43170755wre.274.1546517598116; Thu, 03 Jan 2019 04:13:18 -0800 (PST) Received: from dogfood.home ([2a01:cb1d:112:6f00:eca9:ed68:e865:3e45]) by smtp.gmail.com with ESMTPSA id y13sm46984928wme.2.2019.01.03.04.13.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Jan 2019 04:13:17 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Cc: Ard Biesheuvel , Bob Feng , Liming Gao , Jagadeesh Ujja Date: Thu, 3 Jan 2019 13:13:15 +0100 Message-Id: <20190103121315.19416-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 Subject: [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: , X-List-Received-Date: Thu, 03 Jan 2019 12:13:20 -0000 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(-) 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 = [] -- 2.17.1