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.web11.7085.1634202509923732973 for ; Thu, 14 Oct 2021 02:08:31 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@posteo.de header.s=2017 header.b=G22cJK77; spf=pass (domain: posteo.de, ip: 185.67.36.66, mailfrom: mhaeuser@posteo.de) Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id A0050240107 for ; Thu, 14 Oct 2021 11:08:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1634202492; bh=jJVVvmhU4aLL7jCvVPuxVz/xz2sezbNKn2GaXvloIH8=; h=Date:Subject:To:Cc:From:From; b=G22cJK77LQ4F10HFMdysaCI67MBGCYUC55Dr7lAC99XdrnTbSG2+TAoyscMOF7B7h gqW/vo3KDQyaoQ6OVFD+REueQk8j+fRb6gCn2goZnVFqS3OPpquvZX8PwsN4ham1TU h6DfdcJ6/iXsbqjI14fyGKuu2+DXPYjKBHBhhYNm7JP5SYBCGPiUX2RMClXMeXpcIp 7fsPi5pCYIXt/eKVB+by8oqcspThEL0Po512PS+fkyPacq0PbY6bLXavUMyKJ8t7Oo eb7NHPyJZ/dYfIRLv3VEJuv3sgddAKXYMIo2NgmbD1JnomiGbMpbbAG/2gVDGQIWvu z/N7Y23hvjncQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4HVNpy6xpRz9rxY; Thu, 14 Oct 2021 11:08:10 +0200 (CEST) Message-ID: <62e21365-66cf-353e-b139-cb8c64aa4fd7@posteo.de> Date: Thu, 14 Oct 2021 09:08:10 +0000 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH v1 1/1] StandaloneMmPkg: To support CLANGPDB build To: "Shi, Steven" , "devel@edk2.groups.io" , "Yang, JiyangX" Cc: Ard Biesheuvel , Sami Mujawar , "Yao, Jiewen" , Supreeth Venkatesh , Vitaly Cheptsov References: <20211014031235.1839-1-jiyangx.yang@intel.com> <20211014031235.1839-2-jiyangx.yang@intel.com> <71754204-38e7-09c5-3d83-ba090d393552@posteo.de> From: =?UTF-8?B?TWFydmluIEjDpHVzZXI=?= In-Reply-To: Content-Language: en-GB Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Hey Steven, As I said, I prefer my patch, but this would work too of course. I talked about the PIE stuff with Ard before, so maybe he has an opinion=20 on this? :) (Small correction for my last e-mail, of course we are not *guaranteed*=20 there are *no* relocations in .text, but they'd all point to GOT (or=20 whatever else the target uses for PIE), and references will probably be=20 relative; for ARM architectures I remember Ard talking about specific=20 kinds of relocations being avoided entirely). Best regards, Marvin On 14.10.21 11:02, Shi, Steven wrote: > > Hi Marvin, > > How about we limit the -fno-pie option only apply on IA32 and X64 like=20 > below? > > diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.inf=20 > b/StandaloneMmPkg/Core/StandaloneMmCore.inf > > [BuildOptions] > > =C2=A0=C2=A0 GCC:*_*_*_CC_FLAGS =3D -fpie > > =C2=A0=C2=A0 GCC:*_*_*_DLINK_FLAGS =3D -Wl,-z,text,-Bsymbolic,-pie > > +=C2=A0 CLANGPDB:*_*_ *IA32*_CC_FLAGS=3D -fno-pie > > +=C2=A0 CLANGPDB:*_*_ *X64*_CC_FLAGS=3D -fno-pie > > diff --git=20 > a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntr= yPoint.inf=20 > b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntr= yPoint.inf > > [BuildOptions] > > =C2=A0=C2=A0 GCC:*_*_*_CC_FLAGS =3D -fpie > > +=C2=A0 CLANGPDB:*_*_ *IA32*_CC_FLAGS=3D -fno-pie > > +=C2=A0 CLANGPDB:*_*_ *X64*_CC_FLAGS=3D -fno-pie > > Thanks > > Steven Shi > > > -----Original Message----- > > > From: devel@edk2.groups.io On Behalf Of Marvin > > > H=C3=A4user > > > Sent: Thursday, October 14, 2021 4:05 PM > > > To: Yang, JiyangX ; devel@edk2.groups.io > > > Cc: Ard Biesheuvel ; Sami Mujawar > > > ; Yao, Jiewen ; Supreeth > > > Venkatesh ; Vitaly Cheptsov > > > ; Shi, Steven > > > Subject: Re: [edk2-devel] [PATCH v1 1/1] StandaloneMmPkg: To support > > > CLANGPDB build > > > > > > Hey Jiyang, > > > > > > NO! Please do not. :) > > > Yes, this fixes build, but the AARCH64 core (I did not check ARM) > > > depends on self-relocation as it is loaded in-place at a location > > > unknown at compile-time. PIE helps ensure there are no relocations in > > > .text among other things. I know CLANGPDB does not support > > > ARM/AARCH64 > > > yet, but if it is added, this may generate binaries with more dangerous > > > relocations, which means the chance of executing an instruction that > > > requires relocation without relocating first (relocation is done in C > > > code now!) is significantly higher. We do not need PIE for IA32 or X64 > > > at all (or more specifically, we only need it for ARM-based > > > architectures as of now), so I prefer my patch which makes that > > > explicit. Though we can theoretically use your solution when limited to > > > non-ARM architectures if you really dislike my patch that much. > > > > > > I'd prefer to hear from the ARM core maintainers before making any move= . > > > > > > Best regards, > > > Marvin > > > > > > On 14.10.21 05:12, Jiyang Yang wrote: > > > > the flag "-fpie" is passed for all builds with a GCC family toolchain= , > > > > including CLANGPDB, but CLANGPDB does not support this flag, it will > > > > report "clang: error: unsupported option '-fpie' for target > > > > 'x86_64-unknown-windows-gnu'". So we add the CLANGPDB option "-fno- > > > pie" > > > > later to overwrite it. > > > > > > > > Cc: Ard Biesheuvel > > > > > Cc: Sami Mujawar > > > > > Cc: Jiewen Yao > > > > > Cc: Supreeth Venkatesh > > > > > Cc: Vitaly Cheptsov > > > > > Cc: Marvin H=C3=A4user > > > > > Cc: Steven Shi > > > > > Signed-off-by: Jiyang Yang > > > > > --- > > > > StandaloneMmPkg/Core/StandaloneMmCore.inf | 2 > > > ++ > > > > > > > StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmC > > > oreEntryPoint.inf | 1 + > > > >=C2=A0=C2=A0 2 files changed, 3 insertions(+) > > > > > > > > diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.inf > > > b/StandaloneMmPkg/Core/StandaloneMmCore.inf > > > > index 56042b7b39f4..3213142523f4 100644 > > > > --- a/StandaloneMmPkg/Core/StandaloneMmCore.inf > > > > +++ b/StandaloneMmPkg/Core/StandaloneMmCore.inf > > > > @@ -79,3 +79,5 @@ > > > >=C2=A0=C2=A0 [BuildOptions] > > > >=C2=A0=C2=A0=C2=A0=C2=A0 GCC:*_*_*_CC_FLAGS =3D -fpie > > > >=C2=A0=C2=A0=C2=A0=C2=A0 GCC:*_*_*_DLINK_FLAGS =3D -Wl,-z,text,-Bsymbo= lic,-pie > > > > +=C2=A0 CLANGPDB:*_*_*_CC_FLAGS =3D -fno-pie > > > > +=C2=A0 CLANGPDB:*_*_*_DLINK_FLAGS =3D > > > > diff --git > > > a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMm > > > CoreEntryPoint.inf > > > b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMm > > > CoreEntryPoint.inf > > > > index 1762586cfa02..ef69e07d2c07 100644 > > > > --- > > > a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMm > > > CoreEntryPoint.inf > > > > +++ > > > b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMm > > > CoreEntryPoint.inf > > > > @@ -56,3 +56,4 @@ > > > > > > > >=C2=A0=C2=A0 [BuildOptions] > > > >=C2=A0=C2=A0=C2=A0=C2=A0 GCC:*_*_*_CC_FLAGS =3D -fpie > > > > +=C2=A0 CLANGPDB:*_*_*_CC_FLAGS =3D -fno-pie > > > > > > > > > > > >=20 > > > >