CC Andrew, Rebecca, mentors

Hey all,

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 the 
mentioned XCODE5-specific code as part of a single series [1] to confirm the 
issue has been resolved without regressions.

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), 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 and now uses 
CoW with traditional relocs?) and UEFI has no concept of page sharing anyway. 
Hence, it is safe to allow such relocs and silence the warning. All other 
toolchains should already work this way.

Andrew, Rebecca, if I remember correctly, you pretty much maintain XCODE5. 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 to IA32 builds 
already anyway (right from import).

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?).

Best regards,
Marvin

[1] 
https://github.com/tianocore/edk2/tree/cc2db6ebfb6d9d85ba4c7b35fba1fa37fffc0bc2/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandlerAsm.nasm

> On 18. Jun 2022, at 15:21, Théo Jehl <theojeh...@gmail.com> wrote:
> 
> From: Theo Jehl <theojeh...@gmail.com>
> 
> Added -read_only_relocs suppress for XCODE5 X64 toolchain
> This remove the needs for XCODE5 specific source with relocation fixes
> 
> Cc: Bob Feng <bob.c.f...@intel.com>
> Cc: Liming Gao <gaolim...@byosoft.com.cn>
> Cc: Yuwei Chen <yuwei.c...@intel.com>
> Cc: Marvin Häuser <mhaeu...@posteo.de>
> Cc: Vitaly Cheptsov <vit9...@protonmail.com>
> 
> Signed-off-by: Theo Jehl <theojeh...@gmail.com>
> ---
> BaseTools/Conf/tools_def.template | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
> 
> 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   = -arch i386 -c    -Os   
>     -Wall -Werror -inclu
> ##################
> # X64 definitions
> ##################
> -  DEBUG_XCODE5_X64_DLINK_FLAGS      = -arch x86_64 -u _$(IMAGE_ENTRY_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      = -arch x86_64 -u _$(IMAGE_ENTRY_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      = -arch x86_64 -u _$(IMAGE_ENTRY_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      = -arch x86_64 -u _$(IMAGE_ENTRY_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      = -arch x86_64 -u _$(IMAGE_ENTRY_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      = -arch x86_64 -u _$(IMAGE_ENTRY_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
> 
> *_XCODE5_X64_SLINK_FLAGS      = -static -o
>   DEBUG_XCODE5_X64_ASM_FLAGS  = -arch x86_64 -g
> -- 
> 2.32.1 (Apple Git-133)
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#90600): https://edk2.groups.io/g/devel/message/90600
Mute This Topic: https://groups.io/mt/91840126/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to