[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] x86/EFI: restrict use of --dynamicbase



commit 6960bf546e7faf341aae762846e58b73ebeae192
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Tue Jul 1 11:24:47 2025 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Jul 1 11:24:47 2025 +0200

    x86/EFI: restrict use of --dynamicbase
    
    At least GNU ld 2.35 takes this option to (also) mean what newer
    versions have controllable by --enable-reloc-section. From there being
    no relocations in check.efi (as we don't pass the option there) we infer
    that we need to involve mkreloc, we'd end up with two sets of
    relocations, which clearly isn't going to work. Furthermore the
    relocations ld emits in this case also aren't usable: For bsp_idt[] we
    end up with PE_BASE_RELOC_LOW ones, which efi_arch_relocate_image()
    (deliberately) doesn't know how to deal with. (Related to that is also
    why we check the number of relocations produced: The linker simply
    didn't get this right there, yet.)
    
    We also can't add the option to what we use when linking check.efi: That
    ld version then would produce relocations, but 4 of them (instead of the
    expected two). That would make us pass --disable-reloc-section, which
    however only ld 2.36 and newer understand.
    
    For such older binutils versions we therefore need to accept the slight
    inconsistency in DLL characteristics that the earlier commit meant to
    eliminate.
    
    Fixes: f2148773b8ac ("x86/EFI: sanitize DLL characteristics in binary")
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/arch/x86/arch.mk | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/xen/arch/x86/arch.mk b/xen/arch/x86/arch.mk
index 4991545125..594c268cad 100644
--- a/xen/arch/x86/arch.mk
+++ b/xen/arch/x86/arch.mk
@@ -106,7 +106,7 @@ efi-nr-fixups := $(shell LC_ALL=C $(OBJDUMP) -p 
$(efi-check).efi | grep '^[[:bla
 
 ifeq ($(efi-nr-fixups),2)
 MKRELOC := :
-EFI_LDFLAGS += --disable-high-entropy-va
+EFI_LDFLAGS += --disable-high-entropy-va --dynamicbase
 else
 MKRELOC := arch/x86/efi/mkreloc
 # If the linker produced fixups but not precisely two of them, we need to
@@ -117,8 +117,6 @@ EFI_LDFLAGS += --disable-reloc-section
 endif
 endif
 
-EFI_LDFLAGS += --dynamicbase
-
 endif # $(XEN_BUILD_PE)
 
 export XEN_BUILD_EFI XEN_BUILD_PE
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.