From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) by mx.groups.io with SMTP id smtpd.web10.51776.1680260276836089538 for ; Fri, 31 Mar 2023 03:57:57 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@posteo.de header.s=2017 header.b=TfwGNbXj; spf=pass (domain: posteo.de, ip: 185.67.36.65, mailfrom: mhaeuser@posteo.de) Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 1C68F240299 for ; Fri, 31 Mar 2023 12:57:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1680260275; bh=xNXMflkRVyDETyQsSyckVweh7tt6HKIKpYfG7EfrLs4=; h=From:Subject:Date:Cc:To:From; b=TfwGNbXjqjUDQrzDKNd+dkn4bh70ynNqlahlnsf6Ml3++kV3IJmh9VL6yKjhlHRPh oG+RYcAMZLBLRkR69OlfJLvohkwYC245N4Lhsw2mGCtZRABX4fEYtGVu4n3h13xKhY uCsI/TlvgzSkdYVKhB9mH4LsSXc+1HCLpPF++zkIpYlq0DbwqHqxJgU4h5IW0a6SZe hzmGLEN3gom7n3VMo7ID+bpN/rj1gSPCQ4pGiQLj+HtFM7o3VaQk97FIXSaxnE6u31 w5VB72wacWMUeT8F1KzBxCuGpFpss8/6AJ3EB+8Cb5Y839+eNptRar+vtqkcofZqft n1gsXiZFllEFg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Pny1X4Zvbz9rxD; Fri, 31 Mar 2023 12:57:52 +0200 (CEST) From: =?UTF-8?B?TWFydmluIEjDpHVzZXI=?= Mime-Version: 1.0 (1.0) Subject: Re: [edk2-devel] [PATCH 2/3] BaseTools/Conf/tools_def: Fix CLANGDWARF_IA32_X64 Date: Fri, 31 Mar 2023 10:57:52 +0000 Message-Id: <7C7DD6B9-D0E7-44B4-A4B3-19D4FAC1FF34@posteo.de> References: <024401d9638c$b73deb40$25b9c1c0$@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 In-Reply-To: <024401d9638c$b73deb40$25b9c1c0$@byosoft.com.cn> To: gaoliming Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Liming, Platform maintainers can decide whether or not they want to combat *binary = corruption*? Excuse me, but what the bloody hell? This needs a root cause a= nalysis for which part of the stack silently borks us and not an =E2=80=9Co= h, if something fails, well, copy and paste this workaround=E2=80=A6 maybe= =E2=80=9D. If you give me an efficient way to reproduce it, I=E2=80=99ll do= it. Best regards, Marvin > On 31. Mar 2023, at 06:54, gaoliming wrote: >=20 > =EF=BB=BFMarvin: > Platform developer can decide how to configure this option in their DSC f= ile to resolve their problem. This is one option for the platform developer= .=20 >=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 Marvin >> H?user >> =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2023=E5=B9=B43=E6=9C=8828=E6=97=A5= 19:26 >> =E6=94=B6=E4=BB=B6=E4=BA=BA: gaoliming >> =E6=8A=84=E9=80=81: 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 >> =E4=B8=BB=E9=A2=98: Re: [edk2-devel] [PATCH 2/3] BaseTools/Conf/tools_de= f: Fix >> CLANGDWARF_IA32_X64 >>=20 >> Hi all, >>=20 >>>> 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. >>=20 >> A DSC override to fix *binary corruption* of an unknown cause? It is rid= iculous >> this can even happen silently, even though it=E2=80=99s unclear which co= mponent is at >> fault. >>=20 >>> Normal EFI image needs to set its page size for the smaller >>> image size. >>>=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 >>=20 >> Side note, the correct way to do this is setting max-page-size, not >> common-page-size. >>=20 >>>=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 22:06 >>>> =E6=8A=84=E9=80=81: devel@edk2.groups.io; guo.dong@intel.com; gua.guo@= intel.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:= Fix >>>> 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. >>=20 >> That *definitely* is not a fix. Not only does this regress binary size f= or >> platforms 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? >>=20 >> Sorry, but the overall description is pretty vague. Which OS / compiler = version >> 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 repr= oduce >> the issue. >>=20 >> Best regards, >> Marvin >>=20 >>>>=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 sa= me >>>> 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 >>=20 >>=20 >>=20 >>=20 >>=20 >=20 >=20 >=20