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.web12.10496.1655919833501571131 for ; Wed, 22 Jun 2022 10:43:54 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@posteo.de header.s=2017 header.b=jAfDIwhX; spf=pass (domain: posteo.de, ip: 185.67.36.66, mailfrom: mhaeuser@posteo.de) Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id C3E32240109 for ; Wed, 22 Jun 2022 19:43:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1655919831; bh=7DQon7DL7Yi7pD1hMJvLAAAmyU93tiZQjJvR9Z3WJ4g=; h=From:Subject:Date:Cc:To:From; b=jAfDIwhXKDtX1gza0HychxUNSIK+WSQlUrIJRiFvdAK+Uzkibml4srWGVtV/6sG0x /bZdabBR0p4bFlgX39tBrNksn5/OTeYIzGKjRPR/1nhUVYyD/VB243wwmPjfdHjXSh Lz60BkwGfp/rCcXrU8ltp+kWp/2OwLTm6C2L834i3bM06GjSe460U4EU6oVFt9xlAh 80DNzCbq6u/seik3ncfw51U3X/85CyLj2bLzgoeEn0C+dB3us+KXYs3/imMrR8NSOg cgIll+6myCOJjKB6Umui0IWGn8mhL4Hjj4Og2w+Wlfn31uXUE2Ge9IVYOiMAZFIXbD Ryoi1GD//6RMA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4LSrN30Xqsz6tmc; Wed, 22 Jun 2022 19:43:46 +0200 (CEST) From: =?utf-8?Q?Marvin_H=C3=A4user?= Mime-Version: 1.0 (1.0) Subject: Re: [edk2-devel] [PATCH v1 1/1] BaseTools: Suppress read only relocs errors on XCODE5 X64 toolchain Date: Wed, 22 Jun 2022 17:43:46 +0000 Message-Id: References: <5C4BDE52-3FA5-4683-ABF2-FEEB447A6DCE@apple.com> Cc: devel@edk2.groups.io, =?utf-8?Q?Th=C3=A9o_Jehl?= , Bob Feng , Liming Gao , Yuwei Chen , Vitaly Cheptsov , Rebecca Cran , Pedro Falcato , Isaac W Oram In-Reply-To: <5C4BDE52-3FA5-4683-ABF2-FEEB447A6DCE@apple.com> To: Andrew Fish Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hey Andrew, thanks for verifying! If my last mail was not clear, this is already done f= or IA32 builds, by the way. I suspect more trouble appeared there due to th= e lack of IP-relative addressing. Theo wanted to prepare a V2 with an enhanced commit message and a 2nd patch= to remove the related hacks, I believe. Best regards, Marvin > On 22. Jun 2022, at 19:22, Andrew Fish wrote: >=20 > =EF=BB=BFI reached out to the Xcode ld64 maintainer to make sure it is sa= fe to use -read_only_relocs suppress this way.=20 >=20 > Thanks, >=20 > Andrew Fish >=20 >> On Jun 18, 2022, at 8:19 PM, Andrew Fish via groups.io wrote: >>=20 >> Marvin, >>=20 >> I=E2=80=99ll look into this. >>=20 >> The history here is the original ld64 flags are what was required for pr= oper function. I got them >> directly from the main ld64 maintainer.=20 >>=20 >> Big picture ld64 is the macOS and iOS linker, and it does not have offic= ial support for other targets, especially embedded. So the combination of f= lags are what was required for correctness as not all combination of possib= le ld64 flags are actually supported. >>=20 >> Back in the day we made clang open source contributions to get EFIABI su= pported in clang, but we have always used the stock ld64, with help from th= e author. >>>> On Jun 18, 2022, at 8:03 PM, Marvin H=C3=A4user w= rote: >>>=20 >>> =EF=BB=BFCC Andrew, Rebecca, mentors >>>=20 >>> Hey all, >>>=20 >>> The patch itself looks good to me. The description doesn't really captu= re the issue, nor why this is an adequate solution. This should also remove= the mentioned XCODE5-specific code as part of a single series [1] to confi= rm the issue has been resolved without regressions. >>>=20 >>> TL;dr for the rest: Apple ld64 complains because there are relocations = to read-only segments in a PIE executable. As Mach-O allows mapping read-on= ly segments of PIEs to multiple virtual addresses (in different processes),= this is prohibited right at link-time for obvious reasons. PE/COFF doesn't= really have such a feature (I think Windows used to use static addresses a= nd now uses CoW with traditional relocs?) and UEFI has no concept of page s= haring anyway. Hence, it is safe to allow such relocs and silence the warni= ng. All other toolchains should already work this way. >>>=20 >>> Andrew, Rebecca, if I remember correctly, you pretty much maintain XCOD= E5. I had a conversation with Andrew about related topics before, too. Are = you fine with this approach? It seems like it has previously been applied t= o IA32 builds already anyway (right from import). >>>=20 >>> Maybe PIE could be dropped as a whole somehow in the future? For UEFI, = it basically only adds overhead (or are there blockers to this?). >>>=20 >>> Best regards, >>> Marvin >>>=20 >>> [1] https://github.com/tianocore/edk2/tree/cc2db6ebfb6d9d85ba4c7b35fba1= fa37fffc0bc2/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionH= andlerAsm.nasm >>>=20 >>>> On 18. Jun 2022, at 15:21, Th=C3=A9o Jehl wrote= : >>>>=20 >>>> From: Theo Jehl >>>>=20 >>>> Added -read_only_relocs suppress for XCODE5 X64 toolchain >>>> This remove the needs for XCODE5 specific source with relocation fixes >>>>=20 >>>> Cc: Bob Feng >>>> Cc: Liming Gao >>>> Cc: Yuwei Chen >>>> Cc: Marvin H=C3=A4user >>>> Cc: Vitaly Cheptsov >>>>=20 >>>> Signed-off-by: Theo Jehl >>>> --- >>>> BaseTools/Conf/tools_def.template | 6 +++--- >>>> 1 file changed, 3 insertions(+), 3 deletions(-) >>>>=20 >>>> diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_= def.template >>>> index 5ed19810b727..be35094cecc3 100755 >>>> --- a/BaseTools/Conf/tools_def.template >>>> +++ b/BaseTools/Conf/tools_def.template >>>> @@ -2977,9 +2977,9 @@ RELEASE_XCODE5_IA32_CC_FLAGS =3D -arch i386 -c= -Os -Wall -Werror -inclu >>>> ################## >>>> # X64 definitions >>>> ################## >>>> - DEBUG_XCODE5_X64_DLINK_FLAGS =3D -arch x86_64 -u _$(IMAGE_ENTR= Y_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -all_load -= dead_strip -seg1addr 0x240 -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map >>>> - NOOPT_XCODE5_X64_DLINK_FLAGS =3D -arch x86_64 -u _$(IMAGE_ENTR= Y_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -all_load -= dead_strip -seg1addr 0x240 -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map >>>> -RELEASE_XCODE5_X64_DLINK_FLAGS =3D -arch x86_64 -u _$(IMAGE_ENTR= Y_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -all_load -= dead_strip -seg1addr 0x240 -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map >>>> + DEBUG_XCODE5_X64_DLINK_FLAGS =3D -arch x86_64 -u _$(IMAGE_ENTR= Y_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -all_load -= dead_strip -seg1addr 0x240 -read_only_relocs suppress -map $(DEST_DIR_DEBUG= )/$(BASE_NAME).map >>>> + NOOPT_XCODE5_X64_DLINK_FLAGS =3D -arch x86_64 -u _$(IMAGE_ENTR= Y_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -all_load -= dead_strip -seg1addr 0x240 -read_only_relocs suppress -map $(DEST_DIR_DEBUG= )/$(BASE_NAME).map >>>> +RELEASE_XCODE5_X64_DLINK_FLAGS =3D -arch x86_64 -u _$(IMAGE_ENTR= Y_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -all_load -= dead_strip -seg1addr 0x240 -read_only_relocs suppress -map $(DEST_DIR_DEBUG= )/$(BASE_NAME).map >>>>=20 >>>> *_XCODE5_X64_SLINK_FLAGS =3D -static -o >>>> DEBUG_XCODE5_X64_ASM_FLAGS =3D -arch x86_64 -g >>>> --=20 >>>> 2.32.1 (Apple Git-133) >>>>=20 >>>=20 >>=20 >>=20 >>=20 >>=20 >>=20 >=20