From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com [209.85.128.171]) by mx.groups.io with SMTP id smtpd.web10.28818.1678091957959125475 for ; Mon, 06 Mar 2023 00:39:18 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@starlabs-systems.20210112.gappssmtp.com header.s=20210112 header.b=QNcLbGaj; spf=pass (domain: starlabs.systems, ip: 209.85.128.171, mailfrom: sean@starlabs.systems) Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-536bbe5f888so170155457b3.8 for ; Mon, 06 Mar 2023 00:39:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=starlabs-systems.20210112.gappssmtp.com; s=20210112; t=1678091957; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=osrSrnwbEukJV7QLUmK83jah6VjIX47ssGMoo5EXIsk=; b=QNcLbGajcuzH09JTFm+0Nuhulx0o4bDNxQ+WqYRW7ccWwaqn2kVhm5jo82NcRNCS6M e6KVq+BlRodNXsnBYYzJTzaOd6/+NEL5AtGEaJmI2YTQtmvKDFjFqojbakrHuWPyhibe TNMw8AuKuUbEohhHd8SvV9sPOe3NumNiyWt7uahXIHxeUlaUoG4TP8eUWzeSM9mbUBhP yTWff4NDDuSL/b7gZmvRhS1G9FWbk7P/rfv1lCXTqTzY5IN6YFQSG056nPUg4ApZlzZR fu3iajsiVcVtgUB+VvANDiOyRDvhhDKkW9+kj+Pn/vAlKL8kS7AOcyrl9SSqdWQbMHwn shWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678091957; 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=osrSrnwbEukJV7QLUmK83jah6VjIX47ssGMoo5EXIsk=; b=lO4FDqOkhYZ1Lm26wxprWaXXDFF4zAs+KrBzRWneo21ZwS8JG2uimbH2ucPK3WEU4Y mLG2nTX+LDgdjQqks9DjksKK/Sp3ZN0ySHXk4xgaJxHEKXjdgXLPCalDN/Cwxn8DayzN UqPeR/uhEHE+vpisirmEJw+Pr/9sukhT+DFG1ccSLiBKY8zIor9JhlOFv5kHJQ6NUmYu 0zjPwFWDOn8oojWlb0SojIizSLPMjc1XKRYPfUTfIpY9zP1x9WZArZ7Q+G52pE3dd69z LqFlP3Zp7+qnX6qY6LKvAJL5Ip70wUNEK/8lIsJvXgsnk67Fjkwd3CMKN8E0BK1OyrFm nrZQ== X-Gm-Message-State: AO0yUKXowXKfkZDg1JF1QqDID8prt3rTwWFg+Vx23YdTmAsW70GAAdjg rL9aKipgRaSuIkflofnHLTR4c4V4ZlC6eVavSUVv X-Google-Smtp-Source: AK7set+W26TlgIS8JTMRBTEApjrcx0ecEUt7hdKs+Fp6gPeB5tsW3oGiro6GIl+aA7+Bf1H6fhrk5vP7QxNbgW2Htac= X-Received: by 2002:a81:ac21:0:b0:535:cdde:9a63 with SMTP id k33-20020a81ac21000000b00535cdde9a63mr6359723ywh.7.1678091956851; Mon, 06 Mar 2023 00:39:16 -0800 (PST) MIME-Version: 1.0 References: <20230306083757.26274-1-patrick.rudolph@9elements.com> <20230306083757.26274-2-patrick.rudolph@9elements.com> In-Reply-To: <20230306083757.26274-2-patrick.rudolph@9elements.com> From: "Sean Rhodes" Date: Mon, 6 Mar 2023 08:39:05 +0000 Message-ID: Subject: Re: [PATCH 2/3] BaseTools/Conf/tools_def: Fix CLANGDWARF_IA32_X64 To: Patrick Rudolph Cc: devel@edk2.groups.io, guo.dong@intel.com, ray.ni@intel.com, james.lu@intel.com, gua.guo@intel.com Content-Type: multipart/alternative; boundary="000000000000fd291d05f6373a0b" --000000000000fd291d05f6373a0b Content-Type: text/plain; charset="UTF-8" Reviewed-by: Sean Rhodes On Mon, 6 Mar 2023 at 08:38, 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 > > --000000000000fd291d05f6373a0b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Reviewed-by: Sean Rhodes <sean@starlabs.systems>
=

On Mon, 6 Mar 2023 at 08:38, 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

--000000000000fd291d05f6373a0b--