From nobody Mon Feb 9 16:18:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+61042+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61042+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1591777078; cv=none; d=zohomail.com; s=zohoarc; b=TGHDxZmDVbgOygM5vHVT8b4UzbGwKjAXFh4Rpid6fbG3zZREiLYFYJoBqbNyBzkGPqXJrFDcyQUiYmeIzYPj6FYtRU/7IqdegwlA3ua9nYlBh3eufRxLG0KM3Lksl/011zYa8qU+Gcb1fnj+1Dk2ucFsMw6qvn3mo+cE/Pgn+9c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591777078; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=3tVbVHdPfBzy0inUlnXfRq3MWzFA3/YBRdI4fYpRVug=; b=QSxmqF/mDBzjLvnzo9jY0NRxhw1mHBCoGB3Bp4Neyiud9p5Zq9yscdN2qLzMX52VdUWGAxczokLGGqexZHop3clwpMocf0CkE1Odm4AXwQYOWDORPAj7wm4XtlFwl1zQYPsl96iGketQXS62FzPnV6nCHI37W19Ua7Lq3QQK/dU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61042+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1591777078082475.7297014790994; Wed, 10 Jun 2020 01:17:58 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id p6eJYY1788612xnShqRFDecy; Wed, 10 Jun 2020 01:17:57 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.6158.1591777077029646352 for ; Wed, 10 Jun 2020 01:17:57 -0700 X-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 B10EC1F1; Wed, 10 Jun 2020 01:17:56 -0700 (PDT) X-Received: from localhost.localdomain (unknown [10.37.8.184]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1D8AC3F6CF; Wed, 10 Jun 2020 01:17:54 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Michael D Kinney , Liming Gao , Jiewen Yao , Sami Mujawar , Ilias Apalodimas Subject: [edk2-devel] [PATCH 4/5] StandaloneMmPkg: generate position independent code for StMM core Date: Wed, 10 Jun 2020 10:17:39 +0200 Message-Id: <20200610081740.54581-5-ard.biesheuvel@arm.com> In-Reply-To: <20200610081740.54581-1-ard.biesheuvel@arm.com> References: <20200610081740.54581-1-ard.biesheuvel@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ard.biesheuvel@arm.com X-Gm-Message-State: PZqdFqxNF6Ab537wMcMdDCXbx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1591777077; bh=hl32pT37hDbcPkAiaQ31nDHGh7uM5MY/YH0CBs2GnuE=; h=Cc:Date:From:Reply-To:Subject:To; b=r6q58wy8xRGJs67Rq8GukIPVc24CHNOkLgkVRjBTiFqoefvRgg0TWNc5nSkjqA0EaYh dGgMf9taIHfUha7FMyWyfqv7yElH1ZtIYtkDUPXbKZ2Z3eY5Qi2nv2TfJzoq8Y8CMjPS5 9Evu82ZwHSyKCnklfVYcelnEE6CN65SKQqM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" The standalone MM core runs in a restricted environment that is set up by a higher privilege level, and which may not allow memory regions to be writable and executable at the same time. This means that making the StMM core self-relocatable requires that all the targets of the relocation fixups are outside of the executable region of the image, given that we cannot remap the executable code writable from the executable code itself without losing those execute permissions. So instead, use the existing toolchain support to ensure that position independent code is used where possible, and that all the remaining relocated quantities are emitted into the data section. (Note that staticallly initialized const pointers will be emitted into the .data.rel.ro section, which gets pulled into the .data section by our linker script) To ensure that we don't pick up any absolute references in executable code inadvertently (e.g., in assembler code), add the '-z text' linker option which will force the build to fail in this case. Signed-off-by: Ard Biesheuvel Acked-by: Jiewen Yao --- StandaloneMmPkg/Core/StandaloneMmCore.inf = | 4 ++++ StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPo= int.inf | 3 +++ 2 files changed, 7 insertions(+) diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.inf b/StandaloneMmPkg/Co= re/StandaloneMmCore.inf index d17ff9965bdc..87bf6e9440a7 100644 --- a/StandaloneMmPkg/Core/StandaloneMmCore.inf +++ b/StandaloneMmPkg/Core/StandaloneMmCore.inf @@ -75,3 +75,7 @@ [Guids] gEfiEventLegacyBootGuid gEfiEventExitBootServicesGuid gEfiEventReadyToBootGuid + +[BuildOptions] + GCC:*_*_*_CC_FLAGS =3D -fpie + GCC:*_*_*_DLINK_FLAGS =3D -Wl,-z,text,-Bsymbolic,-pie diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneM= mCoreEntryPoint.inf b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/St= andaloneMmCoreEntryPoint.inf index 891c292e92f8..7d6ee4e08ecb 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEn= tryPoint.inf +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEn= tryPoint.inf @@ -48,3 +48,6 @@ [Guids] gEfiMmPeiMmramMemoryReserveGuid gEfiStandaloneMmNonSecureBufferGuid gEfiArmTfCpuDriverEpDescriptorGuid + +[BuildOptions] + GCC:*_*_*_CC_FLAGS =3D -fpie --=20 2.26.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#61042): https://edk2.groups.io/g/devel/message/61042 Mute This Topic: https://groups.io/mt/74792291/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-