From: Marek Marczykowski <marmarek@invisiblethingslab.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Teddy Astie" <teddy.astie@vates.tech>,
"Daniel Smith" <dpsmith@apertussolutions.com>,
"Oleksii Kurochko" <oleksii.kurochko@gmail.com>
Subject: Re: [PATCH for-4.22?] x86/EFI: arrange for non-discardable .reloc in xen.efi
Date: Wed, 24 Jun 2026 13:19:43 +0200 [thread overview]
Message-ID: <aju9T5oCV7FK8agI@mail-itl> (raw)
In-Reply-To: <652b57e0-42f8-47c8-b94d-df862874aba3@suse.com>
[-- Attachment #1: Type: text/plain, Size: 3558 bytes --]
On Tue, Jun 16, 2026 at 06:17:54PM +0200, Jan Beulich wrote:
> Loaders respecting IMAGE_SCN_MEM_DISCARDABLE would not load such sections,
> yet we need to access it ourselves when switching out of "physical mode".
> Leverage behavior new to GNU ld 2.46: Any contribution to .reloc which
> doesn't have the discardable flag set (which cannot even be expressed in
> ELF) will yield the output section also non-discardable.
>
> Since for intermediate binaries we don't care about section attributes,
> link in the new object only on the final linking pass.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
This seems to be enough to indeed make xen.efi .reloc non-discardable
with binutils 2.46.
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> ---
> With a new enough linker, $(dot-target).2r.o could be leveraged instead:
> $(dot-target).2r.S is going to be empty (or if it's not, the .reloc
> section there would already have the wanted property), so instead of
> adding the new relocs-empty.S we could also insert the section directive
> there. Overall that seemed more convoluted to me, though.
>
> --- a/xen/arch/x86/Makefile
> +++ b/xen/arch/x86/Makefile
> @@ -196,7 +196,8 @@ note_file_option ?= $(note_file)
>
> extra-$(XEN_BUILD_PE) += efi.lds
> ifeq ($(XEN_BUILD_PE),y)
> -$(TARGET).efi: $(objtree)/prelink.o $(note_file) $(obj)/efi.lds $(obj)/efi/relocs-dummy.o $(obj)/efi/mkreloc
> +$(TARGET).efi: $(obj)/efi/relocs-dummy.o $(obj)/efi/relocs-empty.o $(obj)/efi/mkreloc
> +$(TARGET).efi: $(objtree)/prelink.o $(note_file) $(obj)/efi.lds
> ifeq ($(CONFIG_DEBUG_INFO),y)
> $(if $(filter --strip-debug,$(EFI_LDFLAGS)),echo,:) "Will strip debug info from $(@F)"
> endif
> @@ -227,7 +228,7 @@ endif
> $(MAKE) $(build)=$(@D) .$(@F).2r.o .$(@F).2s.o
> $(call compare-symbol-tables, $(dot-target).1r.o, $(dot-target).2r.o)
> $(call compare-symbol-tables, $(dot-target).1s.o, $(dot-target).2s.o)
> - $(LD) $(call EFI_LDFLAGS,$(VIRT_BASE)) -T $(obj)/efi.lds $< \
> + $(LD) $(call EFI_LDFLAGS,$(VIRT_BASE)) -T $(obj)/efi.lds $< $(obj)/efi/relocs-empty.o \
> $(dot-target).2r.o $(dot-target).2s.o $(orphan-handling-y) \
> $(note_file_option) -o $@
> $(NM) -pa --format=sysv $@ \
> @@ -247,7 +248,7 @@ $(TARGET).efi: FORCE
> endif
>
> # These should already have been rebuilt when building the prerequisite of "prelink.o"
> -$(obj)/efi/buildid.o $(obj)/efi/relocs-dummy.o: ;
> +$(obj)/efi/buildid.o $(obj)/efi/relocs-dummy.o $(obj)/efi/relocs-empty.o: ;
>
> .PHONY: include
> include: $(objtree)/arch/x86/include/asm/asm-macros.h
> --- a/xen/arch/x86/efi/Makefile
> +++ b/xen/arch/x86/efi/Makefile
> @@ -17,5 +17,5 @@ obj-y := common-stub.o stub.o
> obj-$(XEN_BUILD_EFI) := $(filter-out %.init.o,$(EFIOBJ-y))
> obj-bin-$(XEN_BUILD_EFI) := $(filter %.init.o,$(EFIOBJ-y))
> obj-bin-y += mbi2.init.o
> -extra-$(XEN_BUILD_EFI) += buildid.o relocs-dummy.o
> +extra-$(XEN_BUILD_EFI) += buildid.o relocs-dummy.o relocs-empty.o
> nocov-$(XEN_BUILD_EFI) += stub.o
> --- /dev/null
> +++ b/xen/arch/x86/efi/relocs-empty.S
> @@ -0,0 +1,8 @@
> +/*
> + * Empty .reloc section, simply to indicate to GNU ld that the output .reloc
> + * section in xen.efi should not be marked IMAGE_SCN_MEM_DISCARDABLE. This
> + * requires GNU ld 2.46 or newer to actually be understood in the intended way.
> + */
> +
> + .section .reloc, "a", @progbits
> + .balign 4
--
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2026-06-24 11:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-16 16:17 [PATCH for-4.22?] x86/EFI: arrange for non-discardable .reloc in xen.efi Jan Beulich
2026-06-17 10:29 ` Roger Pau Monné
2026-06-17 10:37 ` Jan Beulich
2026-06-17 10:53 ` Roger Pau Monné
2026-06-17 11:20 ` Andrew Cooper
2026-06-17 11:44 ` Jan Beulich
2026-06-17 10:56 ` Oleksii Kurochko
2026-06-23 7:43 ` Ping: " Jan Beulich
2026-06-23 8:02 ` Yann Sionneau
2026-06-23 8:12 ` Jan Beulich
2026-06-24 11:19 ` Marek Marczykowski [this message]
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=aju9T5oCV7FK8agI@mail-itl \
--to=marmarek@invisiblethingslab.com \
--cc=andrew.cooper3@citrix.com \
--cc=dpsmith@apertussolutions.com \
--cc=jbeulich@suse.com \
--cc=oleksii.kurochko@gmail.com \
--cc=roger.pau@citrix.com \
--cc=teddy.astie@vates.tech \
--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.