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

[xen staging] x86: avoid SORT_BY_INIT_PRIORITY with old GNU ld



commit 90ba9a2da23fbdb69c8d822f636447e8a42d1eb8
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Thu May 5 16:26:50 2022 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu May 5 16:26:50 2022 +0200

    x86: avoid SORT_BY_INIT_PRIORITY with old GNU ld
    
    Support for this construct was added in 2.22 only. Avoid the need to
    introduce logic to probe for linker script capabilities by (ab)using the
    probe for a command line option having appeared at about the same time.
    
    Note that this remains x86-specific because Arm is unaffected, by
    requiring GNU ld 2.24 or newer.
    
    Fixes: 4b7fd8153ddf ("x86: fold sections in final binaries")
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 xen/arch/x86/arch.mk   | 10 ++++++++++
 xen/arch/x86/xen.lds.S |  4 ++++
 2 files changed, 14 insertions(+)

diff --git a/xen/arch/x86/arch.mk b/xen/arch/x86/arch.mk
index fce2ef5b67..fb86cbda46 100644
--- a/xen/arch/x86/arch.mk
+++ b/xen/arch/x86/arch.mk
@@ -73,6 +73,16 @@ ifeq ($(CONFIG_UBSAN),y)
 $(call cc-option-add,CFLAGS_UBSAN,CC,-fno-sanitize=alignment)
 endif
 
+ifeq ($(CONFIG_LD_IS_GNU),y)
+# While not much better than going by raw GNU ld version, utilize that the
+# feature we're after has appeared in the same release as the
+# --print-output-format command line option.
+AFLAGS-$(call ld-option,--print-output-format) += 
-DHAVE_LD_SORT_BY_INIT_PRIORITY
+else
+# Assume all versions of LLD support this.
+AFLAGS += -DHAVE_LD_SORT_BY_INIT_PRIORITY
+endif
+
 ifneq ($(CONFIG_PV_SHIM_EXCLUSIVE),y)
 
 efi-check := arch/x86/efi/check
diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index d94915ea7d..8930e14fc4 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -36,6 +36,10 @@ ENTRY(start_pa)
 # define SECTION_ALIGN PAGE_SIZE
 #endif
 
+#ifndef HAVE_LD_SORT_BY_INIT_PRIORITY
+# define SORT_BY_INIT_PRIORITY SORT
+#endif
+
 OUTPUT_FORMAT(FORMAT, FORMAT, FORMAT)
 
 OUTPUT_ARCH(i386:x86-64)
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

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