Skip to contentSkip to conversation

xen: Strip xen.efi by default

PATCH Superseded Frediano Ziglio 5 participants 13 messages Dec 5, 2025 – Dec 8, 2025

v9 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v9 cover xen: Strip xen.efi by default

From: Frediano Ziglio <[email protected]>

The main purpose of this series is to strip xen.efi file.

First patch disable the build of the file on systems having broken toolstack. Second patch strip the wanted file.

Frediano Ziglio (2):
Do not attempt to workaround older binutils
xen: Strip xen.efi by default

 .gitignore            |  1 +
 CHANGELOG.md          |  3 +++
 docs/misc/efi.pandoc  |  8 +-------
 xen/Kconfig.debug     |  9 ++-------
 xen/Makefile          | 25 +++----------------------
 xen/arch/x86/Makefile | 12 +++++++++---
 xen/arch/x86/arch.mk  |  7 -------
 7 files changed, 19 insertions(+), 46 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v9 1/2 Do not attempt to workaround older binutils

From: Frediano Ziglio <[email protected]>

Older binutils versions do not handle correctly PE files. It looks like they could work if they don't produce debug information but they mess the PE file in other way like putting invalid flags in sections.
Also different tools will complain about the format (like objdump and strip).

---
 xen/arch/x86/arch.mk | 7 -------
 1 file changed, 7 deletions(-)
xen/arch/x86/arch.mk +0 -7
index 16368a498b..10eb8e4292 100644
@@ -88,13 +88,6 @@ EFI_LDFLAGS := $(patsubst -m%,-mi386pep,$(LDFLAGS)) --subsystem=10 --enable-long
 LD_PE_check_cmd = $(call ld-option,$(EFI_LDFLAGS) --image-base=0x100000000 -o $(efi-check).efi $(efi-check).o)
 XEN_BUILD_PE := $(LD_PE_check_cmd)
 
-# If the above failed, it may be merely because of the linker not dealing well
-# with debug info. Try again with stripping it.
-ifeq ($(CONFIG_DEBUG_INFO)-$(XEN_BUILD_PE),y-n)
-EFI_LDFLAGS += --strip-debug
-XEN_BUILD_PE := $(LD_PE_check_cmd)
-endif
-
 ifeq ($(XEN_BUILD_PE),y)
 
 # Check if the linker produces fixups in PE by default
Signature · 1 line
2.43.0
Acked-by on v9 1/2
#2 lore raw

Re: [PATCH v9 1/2] Do not attempt to workaround older binutils

Quoted 22 lines · Frediano Ziglio

From: Frediano Ziglio <[email protected]>

Older binutils versions do not handle correctly PE files. It looks like they could work if they don't produce debug information but they mess the PE file in other way like putting invalid flags in sections.
Also different tools will complain about the format (like objdump and strip).

---
 xen/arch/x86/arch.mk | 7 -------
 1 file changed, 7 deletions(-)
xen/arch/x86/arch.mk +0 -0
index 16368a498b..10eb8e4292 100644
@@ -88,13 +88,6 @@ EFI_LDFLAGS := $(patsubst -m%,-mi386pep,$(LDFLAGS)) --subsystem=10 --enable-long
 LD_PE_check_cmd = $(call ld-option,$(EFI_LDFLAGS) --image-base=0x100000000 -o $(efi-check).efi $(efi-check).o)
 XEN_BUILD_PE := $(LD_PE_check_cmd)
 

xen/arch/x86/arch.mk EFI_LDFLAGS := $(patsubst -m%,-mi386pep,$(LDFLAGS)) --subsystem=10 --enable-long · line 93

Quoted 10 lines
xen/arch/x86/arch.mk +0 -7
-# If the above failed, it may be merely because of the linker not dealing well
-# with debug info. Try again with stripping it.
-ifeq ($(CONFIG_DEBUG_INFO)-$(XEN_BUILD_PE),y-n)
-EFI_LDFLAGS += --strip-debug
-XEN_BUILD_PE := $(LD_PE_check_cmd)
-endif
-
 ifeq ($(XEN_BUILD_PE),y)
 
 # Check if the linker produces fixups in PE by default

Given the practical breakage, it's clear that noone's using xen.efi generated from toolchains these old.

So, while it's not completely ideal to be "dropping" xen.efi on such systems, it firmly seems like the right thing to do overall.

EFI support is still available on such systems via xen.gz + MB2.

#3 lore raw

Re: [PATCH v9 1/2] Do not attempt to workaround older binutils

Quoted 32 lines · Andrew Cooper
Quoted 31 lines · Frediano Ziglio

From: Frediano Ziglio <[email protected]>

Older binutils versions do not handle correctly PE files. It looks like they could work if they don't produce debug information but they mess the PE file in other way like putting invalid flags in sections.
Also different tools will complain about the format (like objdump and strip).

---
 xen/arch/x86/arch.mk | 7 -------
 1 file changed, 7 deletions(-)
xen/arch/x86/arch.mk +0 -7
index 16368a498b..10eb8e4292 100644
@@ -88,13 +88,6 @@ EFI_LDFLAGS := $(patsubst -m%,-mi386pep,$(LDFLAGS)) --subsystem=10 --enable-long
 LD_PE_check_cmd = $(call ld-option,$(EFI_LDFLAGS) --image-base=0x100000000 -o $(efi-check).efi $(efi-check).o)
 XEN_BUILD_PE := $(LD_PE_check_cmd)
 
-# If the above failed, it may be merely because of the linker not dealing well
-# with debug info. Try again with stripping it.
-ifeq ($(CONFIG_DEBUG_INFO)-$(XEN_BUILD_PE),y-n)
-EFI_LDFLAGS += --strip-debug
-XEN_BUILD_PE := $(LD_PE_check_cmd)
-endif
-
 ifeq ($(XEN_BUILD_PE),y)
 
Quoted 4 lines

xen/arch/x86/arch.mk EFI_LDFLAGS := $(patsubst -m%,-mi386pep,$(LDFLAGS)) --subsystem=10 --enable-long · line 93

Quoted 1 line
xen/arch/x86/arch.mk +0 -0
 # Check if the linker produces fixups in PE by default

Given the practical breakage, it's clear that noone's using xen.efi generated from toolchains these old.

Where are you taking this conclusion from? The description saying "putting invalid flags in sections" is pretty vague, and doesn't clarify whether the result is actually unusable. I've been using xen.efi from various pretty old tool chains without any issue. I may not have done so recently, but if there was breakage there this would be a regression on our part then.

Jan

Quoted 9 lines

So, while it's not completely ideal to be "dropping" xen.efi on such systems, it firmly seems like the right thing to do overall.

EFI support is still available on such systems via xen.gz + MB2.

#4 lore raw

Re: [PATCH v9 1/2] Do not attempt to workaround older binutils

In reply to Frediano Ziglio
Quoted 8 lines · Frediano Ziglio

From: Frediano Ziglio <[email protected]>

Older binutils versions do not handle correctly PE files. It looks like they could work if they don't produce debug information but they mess the PE file in other way like putting invalid flags in sections.
Also different tools will complain about the format (like objdump and strip).

As already alluded to in the reply to Andrew - the above doesn't make clear whether these binaries were in fact broken badly enough to be unusable. As indicated there, my experience was that they were nevertheless usable. In which case I don't think we should take such a measure.

Jan

#5 lore raw

Re: [PATCH v9 1/2] Do not attempt to workaround older binutils

Quoted 11 lines · Jan Beulich
Quoted 8 lines · Frediano Ziglio

From: Frediano Ziglio <[email protected]>

Older binutils versions do not handle correctly PE files. It looks like they could work if they don't produce debug information but they mess the PE file in other way like putting invalid flags in sections.
Also different tools will complain about the format (like objdump and strip).

Quoted 6 lines

As already alluded to in the reply to Andrew - the above doesn't make clear whether these binaries were in fact broken badly enough to be unusable. As indicated there, my experience was that they were nevertheless usable. In which case I don't think we should take such a measure.

Jan

Hi,
adding some more comments.

Frediano

#6 lore raw

PATCH v9 2/2 xen: Strip xen.efi by default

In reply to Frediano Ziglio

From: Frediano Ziglio <[email protected]>

For xen.gz file we strip all symbols and have an additional xen-syms.efi file version with all symbols.
Make xen.efi more coherent stripping all symbols too. xen-syms.efi can be used for debugging.

---
Changes since v1:
- avoid leaving target if some command fails.

Changes since v2:
- do not convert type but retain PE format;
- use xen-syms.efi for new file name, more consistent with ELF.

Changes since v3:
- update documentation;
- do not remove xen.efi.elf;
- check endbr instruction before generating final target.

Changes since v4:
- simplify condition check;
- avoid reuse of [email protected] file.

Changes since v5:
- avoid creation of temporary file.

Changes since v6:
- install xen-syms.efi;
- always strip xen.efi;
- restore EFI_LDFLAGS check during rule execution;
- update CHANGELOG.md;
- added xen-syms.efi to .gitignore.

Changes since v7:
- move and improve CHANGELOG.md changes.

Changes since v8:
- rebase on master;
- clean xen-syms.efi file.

---
 .gitignore            |  1 +
 CHANGELOG.md          |  3 +++
 docs/misc/efi.pandoc  |  8 +-------
 xen/Kconfig.debug     |  9 ++-------
 xen/Makefile          | 25 +++----------------------
 xen/arch/x86/Makefile | 12 +++++++++---
 6 files changed, 19 insertions(+), 39 deletions(-)
.gitignore +1 -0
index 57d54f676f..f282192b3e 100644
@@ -223,6 +223,7 @@ tools/flask/policy/xenpolicy-*
 xen/xen
 xen/suppression-list.txt
 xen/xen-syms
+xen/xen-syms.efi
 xen/xen-syms.map
 xen/xen.*
 
CHANGELOG.md +3 -0
index 3aaf598623..f26ec5b538 100644
@@ -38,6 +38,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
      BAR for HVM guests, to improve performance of guests using it to map the
      grant table or foreign memory.
    - Allow configuring the number of altp2m tables per domain via vm.cfg.
+   - The install-time environment variable INSTALL_EFI_STRIP no longer exists.
+     xen.efi is always stripped, while the symbols remain available in
+     xen-syms.efi.
 
 ### Added
  - Introduce new PDX compression algorithm to cope with Intel Sierra Forest and
docs/misc/efi.pandoc +1 -7
index 11c1ac3346..c66b18a66b 100644
@@ -20,13 +20,7 @@ Xen to load the configuration file even if multiboot modules are found.
 Once built, `make install-xen` will place the resulting binary directly into
 the EFI boot partition, provided `EFI_VENDOR` is set in the environment (and
 `EFI_MOUNTPOINT` is overridden as needed, should the default of `/boot/efi` not
-match your system). When built with debug info, the binary can be quite large.
-Setting `INSTALL_EFI_STRIP=1` in the environment will cause it to be stripped
-of debug info in the process of installing. `INSTALL_EFI_STRIP` can also be set
-to any combination of options suitable to pass to `strip`, in case the default
-ones don't do. The xen.efi binary will also be installed in `/usr/lib64/efi/`,
-unless `EFI_DIR` is set in the environment to override this default. This
-binary will not be stripped in the process.
+match your system).
 
 The binary itself will require a configuration file (names with the `.efi`
 extension of the binary's name replaced by `.cfg`, and - until an existing
xen/Kconfig.debug +2 -7
index d900d926c5..1a8e0c6ec3 100644
@@ -147,12 +147,7 @@ config DEBUG_INFO
 	  Say Y here if you want to build Xen with debug information. This
 	  information is needed e.g. for doing crash dump analysis of the
 	  hypervisor via the "crash" tool.
-	  Saying Y will increase the size of the xen-syms and xen.efi
-	  binaries. In case the space on the EFI boot partition is rather
-	  limited, you may want to install a stripped variant of xen.efi in
-	  the EFI boot partition (look for "INSTALL_EFI_STRIP" in
-	  docs/misc/efi.pandoc for more information - when not using
-	  "make install-xen" for installing xen.efi, stripping needs to be
-	  done outside the Xen build environment).
+	  Saying Y will increase the size of the xen-syms, xen-syms.efi and
+	  xen.efi.elf binaries.
 
 endmenu
xen/Makefile +3 -22
index fc9244420e..5ed029fed1 100644
@@ -493,22 +493,6 @@ endif
 .PHONY: _build
 _build: $(TARGET)$(CONFIG_XEN_INSTALL_SUFFIX)
 
-# Strip
-#
-# INSTALL_EFI_STRIP, if defined, will cause xen.efi to be stripped before it
-# is installed. If INSTALL_EFI_STRIP is '1', then the default option(s) below
-# will be used. Otherwise, INSTALL_EFI_STRIP value will be used as the
-# option(s) to the strip command.
-ifdef INSTALL_EFI_STRIP
-
-ifeq ($(INSTALL_EFI_STRIP),1)
-efi-strip-opt := --strip-debug --keep-file-symbols
-else
-efi-strip-opt := $(INSTALL_EFI_STRIP)
-endif
-
-endif
-
 .PHONY: _install
 _install: D=$(DESTDIR)
 _install: T=$(notdir $(TARGET))
@@ -526,18 +510,15 @@ _install: $(TARGET)$(CONFIG_XEN_INSTALL_SUFFIX)
 	if [ -r $(TARGET).efi -a -n '$(EFI_DIR)' ]; then \
 		[ -d $(D)$(EFI_DIR) ] || $(INSTALL_DIR) $(D)$(EFI_DIR); \
 		$(INSTALL_DATA) $(TARGET).efi $(D)$(EFI_DIR)/$(T)-$(XEN_FULLVERSION).efi; \
-		for x in map elf; do \
-			if [ -e $(TARGET).efi.$$x ]; then \
-				$(INSTALL_DATA) $(TARGET).efi.$$x $(D)$(DEBUG_DIR)/$(T)-$(XEN_FULLVERSION).efi.$$x; \
+		for x in .efi.map .efi.elf -syms.efi; do \
+			if [ -e $(TARGET)$$x ]; then \
+				$(INSTALL_DATA) $(TARGET)$$x $(D)$(DEBUG_DIR)/$(T)-$(XEN_FULLVERSION)$$x; \
 			fi; \
 		done; \
 		ln -sf $(T)-$(XEN_FULLVERSION).efi $(D)$(EFI_DIR)/$(T)-$(XEN_VERSION).$(XEN_SUBVERSION).efi; \
 		ln -sf $(T)-$(XEN_FULLVERSION).efi $(D)$(EFI_DIR)/$(T)-$(XEN_VERSION).efi; \
 		ln -sf $(T)-$(XEN_FULLVERSION).efi $(D)$(EFI_DIR)/$(T).efi; \
 		if [ -n '$(EFI_MOUNTPOINT)' -a -n '$(EFI_VENDOR)' ]; then \
-			$(if $(efi-strip-opt), \
-			     $(STRIP) $(efi-strip-opt) -p -o $(TARGET).efi.stripped $(TARGET).efi && \
-			     $(INSTALL_DATA) $(TARGET).efi.stripped $(D)$(EFI_MOUNTPOINT)/efi/$(EFI_VENDOR)/$(T)-$(XEN_FULLVERSION).efi ||) \
 			$(INSTALL_DATA) $(TARGET).efi $(D)$(EFI_MOUNTPOINT)/efi/$(EFI_VENDOR)/$(T)-$(XEN_FULLVERSION).efi; \
 		elif [ "$(D)" = "$(patsubst $(shell cd $(XEN_ROOT) && pwd)/%,%,$(D))" ]; then \
 			echo 'EFI installation only partially done (EFI_VENDOR not set)' >&2; \
xen/arch/x86/Makefile +9 -3
index 300cc67407..ee787068f8 100644
@@ -232,12 +232,17 @@ endif
 	$(MAKE) $(build)=$(@D) .$(@F).2r.o .$(@F).2s.o
 	$(LD) $(call EFI_LDFLAGS,$(VIRT_BASE)) -T $(obj)/efi.lds $< \
 	      $(dot-target).2r.o $(dot-target).2s.o $(orphan-handling-y) \
-	      $(note_file_option) -o $@
-	$(NM) -pa --format=sysv $@ \
+	      $(note_file_option) -o $(TARGET)-syms.efi
+	$(NM) -pa --format=sysv $(TARGET)-syms.efi \
 		| $(objtree)/tools/symbols --all-symbols --xensyms --sysv --sort \
 		> [email protected]
 ifeq ($(CONFIG_DEBUG_INFO),y)
-	$(if $(filter --strip-debug,$(EFI_LDFLAGS)),:$(space))$(OBJCOPY) -O elf64-x86-64 $@ [email protected]
+	$(if $(filter --strip-debug,$(EFI_LDFLAGS)),:$(space))$(OBJCOPY) \
+		-O elf64-x86-64 $(TARGET)-syms.efi [email protected]
+endif
+	$(STRIP) $(TARGET)-syms.efi -o $@
+ifneq ($(CONFIG_DEBUG_INFO),y)
+	rm -f $(TARGET)-syms.efi
 endif
 	rm -f $(dot-target).[0-9]* $(@D)/..$(@F).[0-9]*
 ifeq ($(CONFIG_XEN_IBT),y)
@@ -281,6 +286,7 @@ $(obj)/xen.lds $(obj)/efi.lds: $(src)/xen.lds.S FORCE
 clean-files := \
     include/asm/asm-macros.* \
     $(objtree)/.xen-syms.[0-9]* \
+    $(objtree)/xen-syms.efi \
     $(objtree)/.xen.elf32 \
     $(objtree)/.xen.efi.[0-9]* \
     efi/*.efi
Signature · 1 line
2.43.0
#8 lore raw
In reply to Frediano Ziglio
Quoted 35 lines · Frediano Ziglio

From: Frediano Ziglio <[email protected]>

For xen.gz file we strip all symbols and have an additional xen-syms.efi file version with all symbols.
Make xen.efi more coherent stripping all symbols too. xen-syms.efi can be used for debugging.

---
Changes since v1:
- avoid leaving target if some command fails.

Changes since v2:
- do not convert type but retain PE format;
- use xen-syms.efi for new file name, more consistent with ELF.

Changes since v3:
- update documentation;
- do not remove xen.efi.elf;
- check endbr instruction before generating final target.

Changes since v4:
- simplify condition check;
- avoid reuse of [email protected] file.

Changes since v5:
- avoid creation of temporary file.

Changes since v6:
- install xen-syms.efi;
- always strip xen.efi;
- restore EFI_LDFLAGS check during rule execution;
- update CHANGELOG.md;
- added xen-syms.efi to .gitignore.

Quoted 6 lines

Changes since v7:
- move and improve CHANGELOG.md changes.

Changes since v8:
- rebase on master;
- clean xen-syms.efi file.

I.e. not addressing my prior, more fundamental comments.

Jan

#9 lore raw
Quoted 40 lines · Jan Beulich
Quoted 38 lines · Frediano Ziglio

From: Frediano Ziglio <[email protected]>

For xen.gz file we strip all symbols and have an additional xen-syms.efi file version with all symbols.
Make xen.efi more coherent stripping all symbols too. xen-syms.efi can be used for debugging.

---
Changes since v1:
- avoid leaving target if some command fails.

Changes since v2:
- do not convert type but retain PE format;
- use xen-syms.efi for new file name, more consistent with ELF.

Changes since v3:
- update documentation;
- do not remove xen.efi.elf;
- check endbr instruction before generating final target.

Changes since v4:
- simplify condition check;
- avoid reuse of [email protected] file.

Changes since v5:
- avoid creation of temporary file.

Changes since v6:
- install xen-syms.efi;
- always strip xen.efi;
- restore EFI_LDFLAGS check during rule execution;
- update CHANGELOG.md;
- added xen-syms.efi to .gitignore.

Changes since v7:
- move and improve CHANGELOG.md changes.

Quoted 7 lines
Quoted 3 lines

Changes since v8:
- rebase on master;
- clean xen-syms.efi file.

I.e. not addressing my prior, more fundamental comments.

Jan

Hi,
In version 8 you commented that code should not double linking, and
the current version does not double link.
In version 7 you commented that changelog is in the wrong section, which was addressed.
In version 5 you commented the changelog entry was missing, which was addressed.

What are you referring to?

Regards,
Frediano

#10 lore raw
Quoted 41 lines · Frediano Ziglio
Quoted 40 lines · Jan Beulich
Quoted 38 lines · Frediano Ziglio

From: Frediano Ziglio <[email protected]>

For xen.gz file we strip all symbols and have an additional xen-syms.efi file version with all symbols.
Make xen.efi more coherent stripping all symbols too. xen-syms.efi can be used for debugging.

---
Changes since v1:
- avoid leaving target if some command fails.

Changes since v2:
- do not convert type but retain PE format;
- use xen-syms.efi for new file name, more consistent with ELF.

Changes since v3:
- update documentation;
- do not remove xen.efi.elf;
- check endbr instruction before generating final target.

Changes since v4:
- simplify condition check;
- avoid reuse of [email protected] file.

Changes since v5:
- avoid creation of temporary file.

Changes since v6:
- install xen-syms.efi;
- always strip xen.efi;
- restore EFI_LDFLAGS check during rule execution;
- update CHANGELOG.md;
- added xen-syms.efi to .gitignore.

Changes since v7:
- move and improve CHANGELOG.md changes.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Changes since v8:
- rebase on master;
- clean xen-syms.efi file.

I.e. not addressing my prior, more fundamental comments.

In version 8 you commented that code should not double linking, and
the current version does not double link.

That was the reply directly to you. There was also a reply to Marek's comments, as to extending the probing of the toolchain that we do to figure out how well the PE/COFF linking actually works.

Jan

#11 lore raw
Quoted 49 lines · Jan Beulich
Quoted 47 lines · Frediano Ziglio
Quoted 45 lines · Jan Beulich
Quoted 35 lines · Frediano Ziglio

From: Frediano Ziglio <[email protected]>

For xen.gz file we strip all symbols and have an additional xen-syms.efi file version with all symbols.
Make xen.efi more coherent stripping all symbols too. xen-syms.efi can be used for debugging.

---
Changes since v1:
- avoid leaving target if some command fails.

Changes since v2:
- do not convert type but retain PE format;
- use xen-syms.efi for new file name, more consistent with ELF.

Changes since v3:
- update documentation;
- do not remove xen.efi.elf;
- check endbr instruction before generating final target.

Changes since v4:
- simplify condition check;
- avoid reuse of [email protected] file.

Changes since v5:
- avoid creation of temporary file.

Changes since v6:
- install xen-syms.efi;
- always strip xen.efi;
- restore EFI_LDFLAGS check during rule execution;
- update CHANGELOG.md;
- added xen-syms.efi to .gitignore.

Quoted 6 lines

Changes since v7:
- move and improve CHANGELOG.md changes.

Changes since v8:
- rebase on master;
- clean xen-syms.efi file.

I.e. not addressing my prior, more fundamental comments.

Quoted 8 lines
Quoted 2 lines

In version 8 you commented that code should not double linking, and
the current version does not double link.

That was the reply directly to you. There was also a reply to Marek's comments, as to extending the probing of the toolchain that we do to figure out how well the PE/COFF linking actually works.

Jan

Surely it would be good to have, but it looks out of scope here, we already agreed that the current build produces artifacts with issues and we already agree that this change should be integrated to solve such issues.

On checking linking one simple thing would be to check that objdump has no complaints (like a line like "objdump -x xen.efi > /dev/null" in the Makefile).
I have a patch that does not tweak and checks on the xen.efi file and there was a similar code posted a while ago but that's surely out of scope.

Frediano

Acked-by on v9 2/2
#12 lore raw
In reply to Frediano Ziglio

CHANGELOG.md The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) · line 43

Quoted 11 lines · Frediano Ziglio
CHANGELOG.md +3 -0
index 3aaf598623..f26ec5b538 100644
@@ -38,6 +38,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
       BAR for HVM guests, to improve performance of guests using it to map the
       grant table or foreign memory.
     - Allow configuring the number of altp2m tables per domain via vm.cfg.
+   - The install-time environment variable INSTALL_EFI_STRIP no longer exists.
+     xen.efi is always stripped, while the symbols remain available in
+     xen-syms.efi.

It seems like it should be moved to the 4.22 section. After doing that:

Thanks.

~ Oleksii