From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by mx.groups.io with SMTP id smtpd.web11.18481.1679859593969687592 for ; Sun, 26 Mar 2023 12:39:54 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@9elements.com header.s=google header.b=WEmLUYzq; spf=pass (domain: 9elements.com, ip: 209.85.208.47, mailfrom: sheng.tan@9elements.com) Received: by mail-ed1-f47.google.com with SMTP id t10so27454359edd.12 for ; Sun, 26 Mar 2023 12:39:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1679859592; x=1682451592; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=LdQOcZJrQhuVqYA0WVglLyVEGm3ufFlPjBZnAcPoC7A=; b=WEmLUYzqfB3gvuWhRdyiCO6K0yMbkwv6Z6HptpCf4r5+LWkEwHY+udBaf9giUVON6G El63DtN3tJm6jycTkISJHN4b5uk2xqPA6GMIAVYVJ8chWcNGufKz6B2jr9jmgRlUO0nd EqCj9XVRoU8bbyL2pVOUklXsiAwJO5mayRa7cuvr5E0QyAGLNvmL1dhaCCthDOaODC8x oY01QhY3cvx+RyC5Nzc1WElnWVzNBINvVw0KZ2fKLQe1BzjRjm7dxh3Q5qX5JzXkKlpK 3D9ANVGUwJDxEgHogwynCMyqX3FKNJ+TVtXT8yeCCWhOEmor9GJaIi7FDeCN8+e1WKCL EIzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679859592; x=1682451592; h=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=LdQOcZJrQhuVqYA0WVglLyVEGm3ufFlPjBZnAcPoC7A=; b=m0b+Hy6vBoUobeKdbaL+hceGaPJJ7pn6i96/mJ/yG0+yKA3qXxlKjYsbWQxaK9WT7k vQvu20fQ3GUdR1rqKNze4SE1QfqYOGfem7ePqu4hz64l/1WRgvMpNjZPC2w2LQfw6PfX jy4xbzbipGahc0jTFjUqvTbZ5r/mCr27ktLU/8TGaid3haIGmw4j2dek+0Ch58Q/6aOg x7HI1aye0TXcBUxvacjwBwASkqqadx9lIt46wX84bLiLwxpjVYULsTSdzdYg8Sz7Mczi mUYK2rfiIH5X8gFJe6/EoDoaQsqAlbqDjZA6fxpt6A3r5Brrx1M+15055xYQPwXL2o0V jvNA== X-Gm-Message-State: AO0yUKUXr9sbPLfBHQhqoe6EpAuavn5zLAbYqXfC3p/We0jt2b5CrdFZ P/c3umqxf1eBH+DSQrFUyE7jr5PWBYcYImHH0tDKEf9BXuFTi8cmR2g= X-Google-Smtp-Source: AK7set89VMnuFfA7GVAuBbHeWUaqHMLg3fOW9C9gFVPVfb+QmIjC55+Xf+gkWrn282SvgLLhz8rlLo8kgfxUO0yvQvw= X-Received: by 2002:a05:6402:540c:b0:4fb:e069:77ac with SMTP id ev12-20020a056402540c00b004fbe06977acmr11452165edb.0.1679859592024; Sun, 26 Mar 2023 12:39:52 -0700 (PDT) MIME-Version: 1.0 References: <20230317140627.1033739-1-patrick.rudolph@9elements.com> <20230317140627.1033739-2-patrick.rudolph@9elements.com> In-Reply-To: <20230317140627.1033739-2-patrick.rudolph@9elements.com> From: "Sheng Lean Tan" Date: Sun, 26 Mar 2023 21:39:16 +0200 Message-ID: Subject: Re: [edk2-devel] [PATCH 2/3] BaseTools/Conf/tools_def: Fix CLANGDWARF_IA32_X64 To: devel@edk2.groups.io, patrick.rudolph@9elements.com, "Feng, Bob C" , "Gao, Liming" Cc: mhaeuser@posteo.de, ardb@kernel.org, yuwei.chen@intel.com Content-Type: multipart/alternative; boundary="00000000000041654a05f7d2cacd" --00000000000041654a05f7d2cacd Content-Type: text/plain; charset="UTF-8" Can someone also help to review this please? Thanks. On Fri, 17 Mar 2023 at 15:06, Patrick Rudolph wrote: > Drop the "-z max-page-size=0x40" option as it causes the ELF > header to overflow into the .text section, causing undefined > behaviour. > > 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=4357 > --- > 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 = ENV(CLANG_BIN) > > # LLVM/CLANG doesn't support -n link option. So, it can't share the 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 = -nostdlib > -Wl,-q,--gc-sections -z max-page-size=0x40 > +DEFINE CLANGDWARF_IA32_X64_DLINK_COMMON = -nostdlib -Wl,-q,--gc-sections > DEFINE CLANGDWARF_DLINK2_FLAGS_COMMON = > -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/ClangBase.lds > DEFINE CLANGDWARF_IA32_X64_ASLDLINK_FLAGS = > DEF(CLANGDWARF_IA32_X64_DLINK_COMMON) -Wl,--defsym=PECOFF_HEADER_SIZE=0 > DEF(CLANGDWARF_DLINK2_FLAGS_COMMON) -Wl,--entry,ReferenceAcpiTable -u > ReferenceAcpiTable > DEFINE CLANGDWARF_IA32_X64_DLINK_FLAGS = > 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 > > > > ------------ > 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/6757431 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub [sheng.tan@9elements.com > ] > ------------ > > > --00000000000041654a05f7d2cacd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Can someone also help to review thi= s please?
Thanks.

On Fri, 1= 7 Mar 2023 at 15:06, Patrick Rudolph <patrick.rudolph@9elements.com> wrote:
Drop the "-z max-page-size= =3D0x40" option as it causes the ELF
header to overflow into the .text section, causing undefined
behaviour.

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 <patrick.rudolph@9elements.com>
Ref: https://bugzilla.tianocore.org/show_bug.c= gi?id=3D4357
---
=C2=A0BaseTools/Conf/tools_def.template | 2 +-
=C2=A01 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.t= emplate
index 9b59bd75c3..0c584ab390 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -2866,7 +2866,7 @@ DEFINE CLANGDWARF_X64_PREFIX=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =3D ENV(CLANG_BIN)

=C2=A0# LLVM/CLANG doesn't support -n link option. So, it can't sha= re the same IA32_X64_DLINK_COMMON flag.
=C2=A0# LLVM/CLANG doesn't support common page size. So, it can't s= hare the same GccBase.lds script.
-DEFINE CLANGDWARF_IA32_X64_DLINK_COMMON=C2=A0 =C2=A0=3D -nostdlib -Wl,-q,-= -gc-sections -z max-page-size=3D0x40
+DEFINE CLANGDWARF_IA32_X64_DLINK_COMMON=C2=A0 =C2=A0=3D -nostdlib -Wl,-q,-= -gc-sections
=C2=A0DEFINE CLANGDWARF_DLINK2_FLAGS_COMMON=C2=A0 =C2=A0 =C2=A0=3D -Wl,--sc= ript=3D$(EDK_TOOLS_PATH)/Scripts/ClangBase.lds
=C2=A0DEFINE 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
=C2=A0DEFINE CLANGDWARF_IA32_X64_DLINK_FLAGS=C2=A0 =C2=A0 =3D DEF(CLANGDWAR= F_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



------------
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#101341): https://edk2.groups.io/g/d= evel/message/101341
Mute This Topic: https://groups.io/mt/97673649/6757431
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [sheng.tan@9elements.c= om]
------------


--00000000000041654a05f7d2cacd--