From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from ma1-aaemail-dr-lapp01.apple.com (ma1-aaemail-dr-lapp01.apple.com [17.171.2.60]) by mx.groups.io with SMTP id smtpd.web12.15746.1655608808115307750 for ; Sat, 18 Jun 2022 20:20:08 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@apple.com header.s=20180706 header.b=bEu65J8u; spf=pass (domain: apple.com, ip: 17.171.2.60, mailfrom: afish@apple.com) Received: from pps.filterd (ma1-aaemail-dr-lapp01.apple.com [127.0.0.1]) by ma1-aaemail-dr-lapp01.apple.com (8.16.0.42/8.16.0.42) with SMTP id 25J3Ehcu041737; Sat, 18 Jun 2022 20:20:01 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apple.com; h=content-type : content-transfer-encoding : from : mime-version : subject : date : message-id : references : cc : in-reply-to : to; s=20180706; bh=5PQa6gZb226yvBEiiGw+hzh3LQaazP4TJG3WoIXvLfM=; b=bEu65J8uQ8z+79T3YP3LObpoliswnXY8dZs1eOXKuMjU2TpR8c9l/2/VfX5XbYUqGyTk f3cPpHL6+3p1pdYFUm1DKPBsua7C60U2Lk8lmJuDoYm6mCiOTecDhzTS8Qrk7ZGOyJO+ P7j5cvJM5VjFI/ENDLHgahfd3h53IHJJLOjhgSTuehX3Kbf2XgHpfkJtjouHHohXV+6T iZQCq5fntx79NgCryGSb/t+kgWG0J/TicOv+5wJk5HzoMCYV9d2vji0rMjvmvjkWOw9e aVwh0x70mWbl8YjxSh6d4YBkfjzBNyQjkMGoYCni7ZgqlzS5eWj2bBj46QkQno+73p3v yw== Received: from ma-mailsvcp-mta-lapp03.corp.apple.com (ma-mailsvcp-mta-lapp03.corp.apple.com [10.226.18.135]) by ma1-aaemail-dr-lapp01.apple.com with ESMTP id 3gsdc2qkuy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Sat, 18 Jun 2022 20:20:01 -0700 Received: from ma-mailsvcp-mmp-lapp04.apple.com (ma-mailsvcp-mmp-lapp04.apple.com [17.32.222.17]) by ma-mailsvcp-mta-lapp03.corp.apple.com (Oracle Communications Messaging Server 8.1.0.18.20220407 64bit (built Apr 7 2022)) with ESMTPS id <0RDP0002YFXCMX10@ma-mailsvcp-mta-lapp03.corp.apple.com>; Sat, 18 Jun 2022 20:20:01 -0700 (PDT) Received: from process_milters-daemon.ma-mailsvcp-mmp-lapp04.apple.com by ma-mailsvcp-mmp-lapp04.apple.com (Oracle Communications Messaging Server 8.1.0.18.20220407 64bit (built Apr 7 2022)) id <0RDP00V00FN91D00@ma-mailsvcp-mmp-lapp04.apple.com>; Sat, 18 Jun 2022 20:20:00 -0700 (PDT) X-Va-A: X-Va-T-CD: cb83049425a79c8a5fb9f1dafa0fda92 X-Va-E-CD: 34d828171d62a66504fe446d19c636f0 X-Va-R-CD: 5cbd49cdda43082027ec393b69d0f453 X-Va-CD: 0 X-Va-ID: 22c5cc14-82c7-45de-8c93-f870331d0130 X-V-A: X-V-T-CD: cb83049425a79c8a5fb9f1dafa0fda92 X-V-E-CD: 34d828171d62a66504fe446d19c636f0 X-V-R-CD: 5cbd49cdda43082027ec393b69d0f453 X-V-CD: 0 X-V-ID: f58b5379-0c9b-42ea-a095-13d5667a821b X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.883 definitions=2022-06-19_02:2022-06-17,2022-06-18 signatures=0 Received: from smtpclient.apple (unknown [17.232.206.145]) by ma-mailsvcp-mmp-lapp04.apple.com (Oracle Communications Messaging Server 8.1.0.18.20220407 64bit (built Apr 7 2022)) with ESMTPSA id <0RDP00X3CFXBXZ00@ma-mailsvcp-mmp-lapp04.apple.com>; Sat, 18 Jun 2022 20:20:00 -0700 (PDT) From: "Andrew Fish" 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: Sat, 18 Jun 2022 20:19:59 -0700 Message-id: References: <0BC4B9BB-0A4A-40EA-B8D8-FB0A04B38806@posteo.de> Cc: =?utf-8?Q?Th=C3=A9o_Jehl?= , edk2-devel-groups-io , Bob Feng , Liming Gao , Yuwei Chen , Vitaly Cheptsov , Rebecca Cran , Pedro Falcato , Isaac W Oram In-reply-to: <0BC4B9BB-0A4A-40EA-B8D8-FB0A04B38806@posteo.de> To: =?utf-8?Q?Marvin_H=C3=A4user?= X-Mailer: iPhone Mail (19F77) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.883 definitions=2022-06-19_02:2022-06-17,2022-06-18 signatures=0 Content-type: text/plain; charset=utf-8 Content-transfer-encoding: quoted-printable Marvin, I=E2=80=99ll look into this. The history here is the original ld64 flags are what was required for prope= r function. I got them directly from the main ld64 maintainer.=20 Big picture ld64 is the macOS and iOS linker, and it does not have official= support for other targets, especially embedded. So the combination of flag= s are what was required for correctness as not all combination of possible = ld64 flags are actually supported. Back in the day we made clang open source contributions to get EFIABI suppo= rted in clang, but we have always used the stock ld64, with help from the a= uthor. > On Jun 18, 2022, at 8:03 PM, Marvin H=C3=A4user wrot= e: >=20 > =EF=BB=BFCC Andrew, Rebecca, mentors >=20 > Hey all, >=20 > The patch itself looks good to me. The description doesn't really capture= the issue, nor why this is an adequate solution. This should also remove t= he mentioned XCODE5-specific code as part of a single series [1] to confirm= 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-only= segments of PIEs to multiple virtual addresses (in different processes), t= his is prohibited right at link-time for obvious reasons. PE/COFF doesn't r= eally have such a feature (I think Windows used to use static addresses and= now uses CoW with traditional relocs?) and UEFI has no concept of page sha= ring anyway. Hence, it is safe to allow such relocs and silence the warning= . All other toolchains should already work this way. >=20 > Andrew, Rebecca, if I remember correctly, you pretty much maintain XCODE5= . I had a conversation with Andrew about related topics before, too. Are yo= u fine with this approach? It seems like it has previously been applied to = 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/cc2db6ebfb6d9d85ba4c7b35fba1fa= 37fffc0bc2/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHan= dlerAsm.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_de= f.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_ENTRY_= POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -all_load -de= ad_strip -seg1addr 0x240 -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map >> - NOOPT_XCODE5_X64_DLINK_FLAGS =3D -arch x86_64 -u _$(IMAGE_ENTRY_= POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -all_load -de= ad_strip -seg1addr 0x240 -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map >> -RELEASE_XCODE5_X64_DLINK_FLAGS =3D -arch x86_64 -u _$(IMAGE_ENTRY_= POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -all_load -de= ad_strip -seg1addr 0x240 -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map >> + DEBUG_XCODE5_X64_DLINK_FLAGS =3D -arch x86_64 -u _$(IMAGE_ENTRY_= POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -all_load -de= ad_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_ENTRY_= POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -all_load -de= ad_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_ENTRY_= POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -all_load -de= ad_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