From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) by mx.groups.io with SMTP id smtpd.web10.63416.1680501227150642862 for ; Sun, 02 Apr 2023 22:53:47 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@9elements.com header.s=google header.b=bg6XQh39; spf=pass (domain: 9elements.com, ip: 209.85.219.178, mailfrom: patrick.rudolph@9elements.com) Received: by mail-yb1-f178.google.com with SMTP id e65so33351127ybh.10 for ; Sun, 02 Apr 2023 22:53:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1680501226; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=cqTpnyQ6MppHxOBGC+noJbcTLb2yLrITq1F17YBlRTI=; b=bg6XQh397hFyn0KstJwN5rdD/xyDy1Wy48EIsYN+Ws7AWL5blN2wiHqU/J31YgQoTa W2vizr6km3fVyljSuKLMmZ31X7aS8QsdBG8WFGEqMA9zIXI/2jlP2l+v+25vquYVZWa6 idFv37OixziVPswPCUvpXpYuUlvRuqRaDJlG5bXxAI86xBDy9z+mcTxhOs31F+GH+yZG Mbvf3wZhdDRBxqkW5l+np2I2jgzMlg1MMC0mYdRdQe/X8vPQ8C2ruAtzpZf4SIBsmUPT 8k9DOPQPIdndIW4Uqw5+RgpXG8zXgN08729VaH15icU21FJBsEQQqbKmPZH57iKT5YIG aD+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680501226; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cqTpnyQ6MppHxOBGC+noJbcTLb2yLrITq1F17YBlRTI=; b=C8yuOawbCZtFSgYYs59K+R69flcKohWClW4fPV//FL732/DDGhrebEquI4MEk4Gjj+ 4nPVixex9XjBcXq1VgIwWRl/OBr8oQx7rBkcPn3cTyDJmTo0cD2WQ5geCUCxe4O8j45o M6Fj87hi/ANVPV2jjP92zLGh2ykkpQR6/nma8m9Y6RTtpHKPp+ZkDuP89Na8yL8MoGo5 fny5FiOacFIEtSoRZaY0TzGpGvxS8V9L7Reku/5rk7XXYPaLHxrZCsvPeZzZG0uaWrjd C9r5Bge7xaKWwRZWcMeOM6sw9zV4T8NVErHQwqCfTg/RPhMQ5NjeHKIitQWm1/3s1S3F gsVw== X-Gm-Message-State: AAQBX9c4baG3ZwpBoIApDAfqoiz5QqRBPE11Be/U3AzLaDZPtIAFDecx p3LdLdc5GLe9G3amBWHg6leEvpWcNeK6Oxc7jsScmOuVD9EyHzDB X-Google-Smtp-Source: AKy350b7ubPewgGZ3xmElC72dxnoShkrFyNqus/y0nlRx7B9Ftw3H2uqJZmX4LFSIp/AQcCpDkH3c5TkHTxQQF6DWH0= X-Received: by 2002:a25:db91:0:b0:b75:8ac3:d5d9 with SMTP id g139-20020a25db91000000b00b758ac3d5d9mr21926829ybf.3.1680501225838; Sun, 02 Apr 2023 22:53:45 -0700 (PDT) MIME-Version: 1.0 References: <024401d9638c$b73deb40$25b9c1c0$@byosoft.com.cn> <7C7DD6B9-D0E7-44B4-A4B3-19D4FAC1FF34@posteo.de> <049801d965c6$916eada0$b44c08e0$@byosoft.com.cn> In-Reply-To: <049801d965c6$916eada0$b44c08e0$@byosoft.com.cn> From: "Patrick Rudolph" Date: Mon, 3 Apr 2023 07:53:34 +0200 Message-ID: Subject: Re: [edk2-devel] [PATCH 2/3] BaseTools/Conf/tools_def: Fix CLANGDWARF_IA32_X64 To: devel@edk2.groups.io, gaoliming@byosoft.com.cn Cc: mhaeuser@posteo.de, guo.dong@intel.com, gua.guo@intel.com, james.lu@intel.com, ray.ni@intel.com, ardb@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, I cannot reproduce the issue on my setup. Please ignore it for now. Regards, Patrick Rudolph On Mon, Apr 3, 2023 at 2:52=E2=80=AFAM gaoliming via groups.io wrote: > > Patrick: > Can you give the reproduce step to generate ELF image that doesn't work= with the option max-page-size? > > > -----=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=8831=E6=97= =A5 18:58 > > =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_d= ef: Fix > > CLANGDWARF_IA32_X64 > > > > Liming, > > > > Platform maintainers can decide whether or not they want to combat *bin= ary > > corruption*? Excuse me, but what the bloody hell? This needs a root cau= se > > analysis for which part of the stack silently borks us and not an =E2= =80=9Coh, 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= : > > > > > > =EF=BB=BFMarvin: > > > Platform developer can decide how to configure this option in their D= SC file > > to resolve their problem. This is one option for the platform developer= . > > > > > > 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/tool= s_def: Fix > > >> CLANGDWARF_IA32_X64 > > >> > > >> 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 > > ridiculous > > >> this can even happen silently, even though it=E2=80=99s unclear whic= h component > > is at > > >> fault. > > >> > > >>> Normal EFI image needs to set its page size for the smaller > > >>> image size. > > >>> > > >>> You can see GCC DLINK option. It also sets page-size as 0x40. > > >>> > > >>> 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-page-size. > > >> > > >>> > > >>> 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 > > >>>> > > >>>> 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 si= ze for > > >> 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? > > >> > > >> Sorry, but the overall description is pretty vague. Which OS / compi= ler > > version > > >> are you using? Do you have any trivial way to detect the corruption?= I > > never > > >> really touched UefiPayloadPkg and have nothing set up to boot it to > > reproduce > > >> the issue. > > >> > > >> Best regards, > > >> Marvin > > >> > > >>>> > > >>>> 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. > > >>>> > > >>>> Test: > > >>>> The ELF generated by > > >>>> 'python UefiPayloadPkg/UniversalPayloadBuild.py -a IA32' boots. > > >>>> > > >>>> 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(-) > > >>>> > > >>>> 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) > > >>>> > > >>>> > > >>>> # LLVM/CLANG doesn't support -n link option. So, it can't share th= e > > same > > >>>> IA32_X64_DLINK_COMMON flag. > > >>>> > > >>>> # LLVM/CLANG doesn't support common page size. So, it can't share = the > > >>>> same GccBase.lds script. > > >>>> > > >>>> -DEFINE CLANGDWARF_IA32_X64_DLINK_COMMON =3D -nostdlib > > >>>> -Wl,-q,--gc-sections -z max-page-size=3D0x40 > > >>>> > > >>>> +DEFINE CLANGDWARF_IA32_X64_DLINK_COMMON =3D -nostdlib > > >>>> -Wl,-q,--gc-sections > > >>>> > > >>>> DEFINE CLANGDWARF_DLINK2_FLAGS_COMMON =3D > > >>>> -Wl,--script=3D$(EDK_TOOLS_PATH)/Scripts/ClangBase.lds > > >>>> > > >>>> 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 > > >>>> > > >>>> 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 > > >>>> > > >>>> -- > > >>>> 2.39.1 > > >>>> > > >>>> > > >>>> > > >>>> -=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 > >