From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>
Subject: [PATCH v2] x86: avoid SORT_BY_INIT_PRIORITY with old GNU ld
Date: Fri, 11 Mar 2022 14:28:40 +0100 [thread overview]
Message-ID: <97bebbfa-b5e8-4c57-162f-2a052de92f02@suse.com> (raw)
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@suse.com>
---
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)
next reply other threads:[~2022-03-11 13:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-11 13:28 Jan Beulich [this message]
2022-03-11 14:34 ` [PATCH v2] x86: avoid SORT_BY_INIT_PRIORITY with old GNU ld Roger Pau Monné
2022-03-11 14:55 ` Jan Beulich
2022-03-11 15:07 ` Roger Pau Monné
2022-03-14 7:38 ` Jan Beulich
2022-03-14 9:05 ` Roger Pau Monné
2022-03-14 9:38 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=97bebbfa-b5e8-4c57-162f-2a052de92f02@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=roger.pau@citrix.com \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.