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

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


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 2 May 2022 09:09:46 +0200
  • 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=n2fo7Dzsa3Ft/jtdOiWLptZXqbyNFQKnC9Q6PYIyfEo=; b=fAveWQ8BdseVVpOJr9BLK2SjSBgFts1C2weBCbYVLOzBg42Hxdg1KMBxz86zlJThK4VHny2Kf24UuPHhaZUr/eXgwzxqXxRx9KrPu9pciYCFGHo9xxGMKF+CwAasAIzAo+kX/us9xesarexb5lTJ2C7fuxg+tD4Y9MbQhfk81H3IwCnVL065L/LVkdcjf/l5tN2zcWD/IXcqSls7cSpzvIcihpFjiqpF5VMBHIEraLi16pKYY14NB29Ql1UBmF9pmgB3wSkK5lYkgms7V6dK5TDjyodri4IuJroVgkzu16VTs1aBpf1YqY2FcqB5lVTAdpSgn9x2Y4+J5Ea7RyjkgQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GmZzk6dxn+vlkfrOnUyyUQXW12uQp+7gOtfpGDUphZUfTiRE/prOrO4VG+w7Wj1wG7jMQUpQXatb4zhVYVi/vcC5qaNdxEZcniERdhtyRzERf+HrVOL/IpJqkOsL1XMmEIA1JWVoQkX5JfphPvW4D6ZZkfxG58QdXx68qEv0x7bxWwNLHeAfgDXIYT90Hj6KeWvTQWFEo1SNavaDN9UBkXP5WiQ8Cs5LaEagDg/IQ/sjGSYwGl6W4aW8DXbsIBGhGdZwJcROoL5VvB+ha/l0GsZg1L4yWWXLPG1cPYRFnd4+3sHOboQOur0Vt+L+lfLgAdyCFymuTmqsPpKyzaHVtg==
  • 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: Mon, 02 May 2022 07:10:06 +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.

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>
---
v3: Rebase over "kconfig: detect LD implementation".
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 ($(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
--- 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)




 


Rackspace

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