On 19/02/2021 08:09, Jan Beulich wrote:
> All of the sudden ld creates base relocations itself, for PE
> executables - as a result we now have two of them for every entity to
> be relocated. While we will likely want to use this down the road, it
> doesn't work quite right yet in corner cases, so rather than suppressing
> our own way of creating the relocations we need to tell ld to avoid
> doing so.
>
> Probe whether --disable-reloc-section (which was introduced by the same
> commit making relocation generation the default) is recognized by ld's PE
> emulation, and use the option if so. (To limit redundancy, move the first
> part of setting EFI_LDFLAGS earlier, and use it already while probing.)
>
> Signed-off-by: Jan Beulich <jbeul...@suse.com>
>
> --- a/xen/arch/x86/Makefile
> +++ b/xen/arch/x86/Makefile
> @@ -123,8 +123,13 @@ ifneq ($(efi-y),)
>  # Check if the compiler supports the MS ABI.
>  export XEN_BUILD_EFI := $(shell $(CC) $(XEN_CFLAGS) -c efi/check.c -o 
> efi/check.o 2>/dev/null && echo y)
>  # Check if the linker supports PE.
> -XEN_BUILD_PE := $(if $(XEN_BUILD_EFI),$(shell $(LD) -mi386pep --subsystem=10 
> -S -o efi/check.efi efi/check.o 2>/dev/null && echo y))
> +EFI_LDFLAGS = $(patsubst -m%,-mi386pep,$(XEN_LDFLAGS)) --subsystem=10 
> --strip-debug
> +XEN_BUILD_PE := $(if $(XEN_BUILD_EFI),$(shell $(LD) $(EFI_LDFLAGS) -o 
> efi/check.efi efi/check.o 2>/dev/null && echo y))
>  CFLAGS-$(XEN_BUILD_EFI) += -DXEN_BUILD_EFI
> +# Check if the linker produces fixups in PE by default (we need to disable 
> it doing so for now).
> +XEN_NO_PE_FIXUPS := $(if $(XEN_BUILD_EFI), \
> +                         $(shell $(LD) $(EFI_LDFLAGS) 
> --disable-reloc-section -o efi/check.efi efi/check.o 2>/dev/null && \
> +                                 echo --disable-reloc-section))

Why does --strip-debug move?

What's wrong with $(call ld-option ...) ?  Actually, lots of this block
of code looks to be opencoding of standard constructs.

~Andrew

Reply via email to