From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) by mx.groups.io with SMTP id smtpd.web10.63682.1680002740225373768 for ; Tue, 28 Mar 2023 04:25:41 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@posteo.de header.s=2017 header.b=Oadybbb8; spf=pass (domain: posteo.de, ip: 185.67.36.66, mailfrom: mhaeuser@posteo.de) Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 064D22403DC for ; Tue, 28 Mar 2023 13:25:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1680002738; bh=Ugcj4FZ/zVrcfRcGpA9YLB46da5LCncI2ANuqgFPVDM=; h=Subject:From:Cc:Date:To:From; b=Oadybbb8LbVn+MO3t+0K1g9mmQCHUaB7/cbEswV8z4GZexkpkhTzdxEPZHhi3Kh06 m+RCa64+HeG7EPoNtXRe7BrBLJeIuovGVbHak8tW0pe0/1CrrK8WPojwId3qaVnt8y 59+qHRbwtMCUfqI0/3jNmD2QWeVJbtHtrqaNaHO0pXYmMmsgDo0DoenuJyp9B72IQv zCp6mp427VHmIzJISXO5UHsj9hK66Vx2I+Rt/BslqvlVJGnvgOftizWG2V14nU2yUZ Qk7fUANQUeXq7eVLL55LIjNMpPB8U7vUqehctz7vbMOf3I3DCuyrYEszCsMSI+2B3G cQ3EmztQNklLg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Pm6mv59Npz9rxf; Tue, 28 Mar 2023 13:25:35 +0200 (CEST) Mime-Version: 1.0 (1.0) Subject: Re: [edk2-devel] [PATCH 2/3] BaseTools/Conf/tools_def: Fix CLANGDWARF_IA32_X64 From: =?UTF-8?B?TWFydmluIEjDpHVzZXI=?= In-Reply-To: <023601d96137$7e714bb0$7b53e310$@byosoft.com.cn> Cc: devel@edk2.groups.io, patrick.rudolph@9elements.com, guo.dong@intel.com, gua.guo@intel.com, james.lu@intel.com, ray.ni@intel.com, ardb@kernel.org Date: Tue, 28 Mar 2023 11:25:34 +0000 Message-Id: <23BF58B2-BF1C-442D-A988-B0A8A1174CEA@posteo.de> References: <023601d96137$7e714bb0$7b53e310$@byosoft.com.cn> To: gaoliming Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi all, > On 28. Mar 2023, at 07:38, gaoliming wrote: > =EF=BB=BFPatrick: > I prefer to override this option in DSC instead of the change in > tools_def.txt. A DSC override to fix *binary corruption* of an unknown cause? It is ridicul= ous this can even happen silently, even though it=E2=80=99s unclear which co= mponent is at fault. > Normal EFI image needs to set its page size for the smaller > image size.=20 >=20 > You can see GCC DLINK option. It also sets page-size as 0x40. >=20 > DEFINE GCC49_IA32_X64_DLINK_COMMON =3D -nostdlib -Wl,-n,-q,--gc-sections= -z > common-page-size=3D0x40 Side note, the correct way to do this is setting max-page-size, not common-p= age-size. >=20 > Thanks > Liming >> -----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB=B6----- >> =E5=8F=91=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io =E4= =BB=A3=E8=A1=A8 Patrick >> Rudolph >> =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2023=E5=B9=B43=E6=9C=8817=E6=97=A5 2= 2:06 >> =E6=8A=84=E9=80=81: devel@edk2.groups.io; guo.dong@intel.com; gua.guo@int= el.com; >> james.lu@intel.com; ray.ni@intel.com; mhaeuser@posteo.de; >> ardb@kernel.org >> =E4=B8=BB=E9=A2=98: [edk2-devel] [PATCH 2/3] BaseTools/Conf/tools_def: Fi= x >> CLANGDWARF_IA32_X64 >>=20 >> Drop the "-z max-page-size=3D0x40" option as it causes the ELF >> header to overflow into the .text section, causing undefined >> behaviour. That *definitely* is not a fix. Not only does this regress binary size for p= latforms that have tight SPI space constraints, it also only masks the issue= . In the (frankly near-impossible) case the ELF header dramatically grows in= size, who knows whether it can overflow again? Sorry, but the overall description is pretty vague. Which OS / compiler vers= ion are you using? Do you have any trivial way to detect the corruption? I n= ever really touched UefiPayloadPkg and have nothing set up to boot it to rep= roduce the issue. Best regards, Marvin >>=20 >> With high optimization level it corrupts essential code and >> the binary would crash. It might work with low optimization >> level though. As the default is to use Oz and LTO, it always >> crashes. >>=20 >> Test: >> The ELF generated by >> 'python UefiPayloadPkg/UniversalPayloadBuild.py -a IA32' boots. >>=20 >> Signed-off-by: Patrick Rudolph >> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4357 >> --- >> BaseTools/Conf/tools_def.template | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >>=20 >> diff --git a/BaseTools/Conf/tools_def.template >> b/BaseTools/Conf/tools_def.template >> index 9b59bd75c3..0c584ab390 100755 >> --- a/BaseTools/Conf/tools_def.template >> +++ b/BaseTools/Conf/tools_def.template >> @@ -2866,7 +2866,7 @@ DEFINE CLANGDWARF_X64_PREFIX =3D >> ENV(CLANG_BIN) >>=20 >>=20 >> # LLVM/CLANG doesn't support -n link option. So, it can't share the same >> IA32_X64_DLINK_COMMON flag. >>=20 >> # LLVM/CLANG doesn't support common page size. So, it can't share the >> same GccBase.lds script. >>=20 >> -DEFINE CLANGDWARF_IA32_X64_DLINK_COMMON =3D -nostdlib >> -Wl,-q,--gc-sections -z max-page-size=3D0x40 >>=20 >> +DEFINE CLANGDWARF_IA32_X64_DLINK_COMMON =3D -nostdlib >> -Wl,-q,--gc-sections >>=20 >> DEFINE CLANGDWARF_DLINK2_FLAGS_COMMON =3D >> -Wl,--script=3D$(EDK_TOOLS_PATH)/Scripts/ClangBase.lds >>=20 >> DEFINE CLANGDWARF_IA32_X64_ASLDLINK_FLAGS =3D >> DEF(CLANGDWARF_IA32_X64_DLINK_COMMON) >> -Wl,--defsym=3DPECOFF_HEADER_SIZE=3D0 >> DEF(CLANGDWARF_DLINK2_FLAGS_COMMON) >> -Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable >>=20 >> DEFINE CLANGDWARF_IA32_X64_DLINK_FLAGS =3D >> DEF(CLANGDWARF_IA32_X64_DLINK_COMMON) >> -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) >> -Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive >>=20 >> -- >> 2.39.1 >>=20 >>=20 >>=20 >> -=3D-=3D-=3D-=3D-=3D-=3D >> Groups.io Links: You receive all messages sent to this group. >> View/Reply Online (#101341): >> https://edk2.groups.io/g/devel/message/101341 >> Mute This Topic: https://groups.io/mt/97673649/4905953 >> Group Owner: devel+owner@edk2.groups.io >> Unsubscribe: https://edk2.groups.io/g/devel/unsub >> [gaoliming@byosoft.com.cn] >> -=3D-=3D-=3D-=3D-=3D-=3D