From nobody Sun Feb 8 14:53:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+102256+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+102256+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1680254096; cv=none; d=zohomail.com; s=zohoarc; b=CEhAHAm+Z8z8fs0ZWlCWCcCDOxNseWbNlOmpe+yXX40YmUsmmibCg8b+uQo+rWZFmNP1e4nLyLNpiGDsgcKb+kSo9awmauEZYEeoMBSjAe5eG4oaBQZYVMGxcH5euE1V++Cmokx0hrFc5LrY9RZefwkxVcRBT2l4GHknKNz0EDo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1680254096; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=CiXkhoXWZ0FxI2dUC+9UuETB2UOclow+Zd8HthLV7vg=; b=CohCXaV8VJIwLuV2vuWfAPbfb6WN7TcF7AfOQ2oDfTEn/JiYDj8FiWRXXV6m0SS2PryvYlo9h8Y5OpA3RMZGODAGOK2g39/QwblF36hz4kq84hGTXgulzFs4tBEiT66/LClMlWF2KFoU2lT4Vt5vkbQL6DupFoTVoa5Hbg8C5R0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+102256+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1680254096218209.39445726929966; Fri, 31 Mar 2023 02:14:56 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 76cDYY1788612xY4l33Odtbt; Fri, 31 Mar 2023 02:14:55 -0700 X-Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mx.groups.io with SMTP id smtpd.web11.50282.1680254094977224397 for ; Fri, 31 Mar 2023 02:14:55 -0700 X-Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5DDF4B82D7E; Fri, 31 Mar 2023 09:14:52 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D453C433EF; Fri, 31 Mar 2023 09:14:49 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , "Ni, Ray" , Andrew Fish , "Kinney, Michael D" , "Liu, Zhiguang" , Rebecca Cran , Tom Lendacky , =?UTF-8?q?Marvin=20H=C3=A4user?= Subject: [edk2-devel] [RFT PATCH v3 1/5] BaseTools/tools_def CLANGDWARF: Permit text relocations Date: Fri, 31 Mar 2023 11:14:33 +0200 Message-Id: <20230331091437.1593337-2-ardb@kernel.org> In-Reply-To: <20230331091437.1593337-1-ardb@kernel.org> References: <20230331091437.1593337-1-ardb@kernel.org> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,ardb@kernel.org X-Gm-Message-State: hvgI9DRrndNT9nkVaIrZqy87x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1680254095; bh=izTwiJDHCLqxGzS4HGswEBYG5zBXoavTslV//IetLjQ=; h=Cc:Date:From:Reply-To:Subject:To; b=D9sOiZm0crBblKXw5LynJWVY2ND+E82X7pkilFWbkqnhhjYuJmnw6Yz4UF+JRX/r++q trPh+uKte53Q9rXTS5cHxQyl92Yy4Rzg42D2ZaLecyQKUCKh+FPzfdUJgCoqIxsrXVDGz ZmnoUu2R/WtwDQs3Y47SQp9zvpG+Xp4Q1bk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1680254096975100001 Content-Type: text/plain; charset="utf-8" We rely on PIE executables to get the codegen that is suitable for PE/COFF conversion where the resulting executables can be loaded anywhere in the address space. However, ELF linkers may default to disallowing text relocations in PIE executables, as this would require text segments to be updated at runtime, which is bad for security and increases the copy-on-write footprint of ELF executables and shared libraries. However, none of those concerns apply to PE/COFF executables in the context of EFI, which are copied into memory rather than mmap()'ed, and fixed up by the loader before launch. So pass -z notext to the LLD linker to permit runtime relocations in read-only sections. Signed-off-by: Ard Biesheuvel --- BaseTools/Conf/tools_def.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.t= emplate index ae43101853870c6d..5a3af55bfb09d753 100755 --- a/BaseTools/Conf/tools_def.template +++ b/BaseTools/Conf/tools_def.template @@ -2870,7 +2870,7 @@ DEFINE CLANGDWARF_X64_PREFIX =3D ENV(CLANG_BIN) DEFINE CLANGDWARF_IA32_X64_DLINK_COMMON =3D -nostdlib -Wl,-q,--gc-sectio= ns -z max-page-size=3D0x40 DEFINE CLANGDWARF_DLINK2_FLAGS_COMMON =3D -Wl,--script=3D$(EDK_TOOLS_P= ATH)/Scripts/ClangBase.lds DEFINE CLANGDWARF_IA32_X64_ASLDLINK_FLAGS =3D DEF(CLANGDWARF_IA32_X64_DLIN= K_COMMON) -Wl,--defsym=3DPECOFF_HEADER_SIZE=3D0 DEF(CLANGDWARF_DLINK2_FLAGS= _COMMON) -Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable -DEFINE CLANGDWARF_IA32_X64_DLINK_FLAGS =3D DEF(CLANGDWARF_IA32_X64_DLIN= K_COMMON) -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Wl,-Map= ,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive +DEFINE CLANGDWARF_IA32_X64_DLINK_FLAGS =3D DEF(CLANGDWARF_IA32_X64_DLIN= K_COMMON) -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Wl,-Map= ,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive -Wl,-z,notext DEFINE CLANGDWARF_IA32_DLINK2_FLAGS =3D -Wl,--defsym=3DPECOFF_HEADER= _SIZE=3D0x220 DEF(CLANGDWARF_DLINK2_FLAGS_COMMON) DEFINE CLANGDWARF_X64_DLINK2_FLAGS =3D -Wl,--defsym=3DPECOFF_HEADER= _SIZE=3D0x228 DEF(CLANGDWARF_DLINK2_FLAGS_COMMON) =20 --=20 2.39.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 (#102256): https://edk2.groups.io/g/devel/message/102256 Mute This Topic: https://groups.io/mt/97969649/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-