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

[PATCH v2] x86: avoid SORT_BY_INIT_PRIORITY with old GNU ld


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 11 Mar 2022 14:28:40 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oB9UyoUTlYD7+jOARvtGocxIQ/b7yV0YHAi0kIcsud0=; b=kZb+zeekyDAP+0pZOtfPEYcRrszixBEJe+WcyhTxpESxrsxed/P+tR3CBs1y4ni37odAbyG1KuphjAjDPt6nuFbtRmR2fsi0uujk2paSfGlK853+CO6CBX0t7KeaPvId0VFGQvtKo0QupMxlYShfJrsFXFdkOcVuXuP7Pdg4kEiykVBdCAdYa4FM/KmyBqNrVf1sk0PlCCF7FUKMEwvdk8IvkDRTJWPVIY5hqaKBAszItZlpg2ZQ3iv8lTQbpcuu2OyCkhrPeICX1eY25rEb9Lmo6+CMCZ4Y8SAJn01I0+D1oYqZ4DSONVozXoLv4vvrKwZ7JVc3+2N/pqT/dl+CEQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nYJVjNXBBJdwj6kC0B8Yr+BQgQ6HAllLUvQufDBT0YFZcG6q6mMNCst+fFchvjHGQvb76Fit5p9+9+Wd1MyNkmui0AjaPlg4g8UgbhXXvYqkMy2ulCbYqhWE0hyvotHh/e/uRUoAxibTxEzQn40TGZej0Zjx9h/fpIMqjkBdvvGipnezDwD0p3m91kwlTFjL4GkzCSqBA8T7r6TuDtKSOXbMwbtlt374YhVxQGc4nXsWl4NlHKyoe+EL3p4JXsmijncPgOxXFSSkAzuE7d2V5EZp3KqLSouxaBiW3oGWencgrTW47Obyj0Lz/PGH8rKlEizDrPv7w4m208G5pXnOaA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Fri, 11 Mar 2022 13:28:51 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.

Fixes: 4b7fd8153ddf ("x86: fold sections in final binaries")
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v2: Always define HAVE_LD_SORT_BY_INIT_PRIORITY when using LLVM ld.

--- 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 ($(call success,$(LD) --version | head -n 1 | grep -q "GNU ld"),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
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -30,6 +30,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)




 


Rackspace

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