Skip to contentSkip to conversation

xen: Strip xen.efi by default

PATCH Superseded Frediano Ziglio 3 participants 5 messages Nov 10, 2025 – Nov 12, 2025

v5 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 xen: Strip xen.efi by default

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.

---
 docs/misc/efi.pandoc  |  8 +-------
 xen/Kconfig.debug     |  9 ++-------
 xen/Makefile          | 19 -------------------
 xen/arch/x86/Makefile | 16 ++++++++++------
 4 files changed, 13 insertions(+), 39 deletions(-)
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 +0 -19
index ddcee8835c..605a26c181 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))
@@ -535,9 +519,6 @@ _install: $(TARGET)$(CONFIG_XEN_INSTALL_SUFFIX)
 		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 +10 -6
index 407571c510..51d8084693 100644
@@ -228,17 +228,21 @@ endif
 	$(MAKE) $(build)=$(@D) .$(@F).1r.o .$(@F).1s.o
 	$(LD) $(call EFI_LDFLAGS,$(VIRT_BASE)) -T $(obj)/efi.lds $< \
 	      $(dot-target).1r.o $(dot-target).1s.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]
+ifeq ($(CONFIG_DEBUG_INFO)_$(filter --strip-debug,$(EFI_LDFLAGS)),y_)
+	$(OBJCOPY) -O elf64-x86-64 $(TARGET)-syms.efi [email protected]
+	$(STRIP) $(TARGET)-syms.efi -o [email protected]
+else
+	mv -f $(TARGET)-syms.efi -o [email protected]
 endif
-	rm -f $(dot-target).[0-9]* $(@D)/..$(@F).[0-9]*
 ifeq ($(CONFIG_XEN_IBT),y)
-	$(SHELL) $(srctree)/tools/check-endbr.sh $@
+	$(SHELL) $(srctree)/tools/check-endbr.sh [email protected]
 endif
+	mv -f [email protected] $@
+	rm -f $(dot-target).[0-9]* $(@D)/..$(@F).[0-9]*
 else
 $(TARGET).efi: FORCE
 	rm -f $@
Signature · 1 line
2.43.0
#1 lore raw

Sorry, I sent version again by mistake

Frediano

Quoted 142 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.

---
 docs/misc/efi.pandoc  |  8 +-------
 xen/Kconfig.debug     |  9 ++-------
 xen/Makefile          | 19 -------------------
 xen/arch/x86/Makefile | 16 ++++++++++------
 4 files changed, 13 insertions(+), 39 deletions(-)
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 +0 -19
index ddcee8835c..605a26c181 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))
@@ -535,9 +519,6 @@ _install: $(TARGET)$(CONFIG_XEN_INSTALL_SUFFIX)
                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 +10 -7
index 407571c510..51d8084693 100644
@@ -228,17 +228,21 @@ endif
        $(MAKE) $(build)=$(@D) .$(@F).1r.o .$(@F).1s.o
        $(LD) $(call EFI_LDFLAGS,$(VIRT_BASE)) -T $(obj)/efi.lds $< \
              $(dot-target).1r.o $(dot-target).1s.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]
+ifeq ($(CONFIG_DEBUG_INFO)_$(filter --strip-debug,$(EFI_LDFLAGS)),y_)
+       $(OBJCOPY) -O elf64-x86-64 $(TARGET)-syms.efi [email protected]
+       $(STRIP) $(TARGET)-syms.efi -o [email protected]
+else
+       mv -f $(TARGET)-syms.efi -o [email protected]
 endif
-       rm -f $(dot-target).[0-9]* $(@D)/..$(@F).[0-9]*
 ifeq ($(CONFIG_XEN_IBT),y)
-       $(SHELL) $(srctree)/tools/check-endbr.sh $@
+       $(SHELL) $(srctree)/tools/check-endbr.sh [email protected]
 endif
+       mv -f [email protected] $@
+       rm -f $(dot-target).[0-9]* $(@D)/..$(@F).[0-9]*
 else
 $(TARGET).efi: FORCE
        rm -f $@
--

2.43.0

#2 lore raw
In reply to Frediano Ziglio
Quoted 37 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.

---
 docs/misc/efi.pandoc  |  8 +-------
 xen/Kconfig.debug     |  9 ++-------
 xen/Makefile          | 19 -------------------
 xen/arch/x86/Makefile | 16 ++++++++++------
 4 files changed, 13 insertions(+), 39 deletions(-)
docs/misc/efi.pandoc +0 -0
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

docs/misc/efi.pandoc Xen to load the configuration file even if multiboot modules are found. · line 23

Quoted 10 lines
docs/misc/efi.pandoc +1 -7
 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).

This behavioral change likely also calls for a ChangeLog entry, btw.

Jan

#3 lore raw
Quoted 52 lines · Jan Beulich
Quoted 37 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.

---
 docs/misc/efi.pandoc  |  8 +-------
 xen/Kconfig.debug     |  9 ++-------
 xen/Makefile          | 19 -------------------
 xen/arch/x86/Makefile | 16 ++++++++++------
 4 files changed, 13 insertions(+), 39 deletions(-)
docs/misc/efi.pandoc +0 -0
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

docs/misc/efi.pandoc Xen to load the configuration file even if multiboot modules are found. · line 23

Quoted 10 lines
docs/misc/efi.pandoc +1 -7
 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).

This behavioral change likely also calls for a ChangeLog entry, btw.

Quoted 1 line

Jan

Hi,
I'm not familiar with the format/style of this file.

Could it be simply

### Removed
- ...current list ...
- INSTALL_EFI_STRIP environment was removed, xen.efi will be stripped.

?

For simplicity, should we always strip xen.efi and provide also xen-syms.efi only if debug info is enabled?
It would probably be more consistent.

Regards,
Frediano

#4 lore raw
Quoted 55 lines · Frediano Ziglio
Quoted 43 lines · Jan Beulich
Quoted 41 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.

---
 docs/misc/efi.pandoc  |  8 +-------
 xen/Kconfig.debug     |  9 ++-------
 xen/Makefile          | 19 -------------------
 xen/arch/x86/Makefile | 16 ++++++++++------
 4 files changed, 13 insertions(+), 39 deletions(-)
docs/misc/efi.pandoc +0 -2
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
Quoted 8 lines

docs/misc/efi.pandoc Xen to load the configuration file even if multiboot modules are found. · line 23

Quoted 6 lines
docs/misc/efi.pandoc +1 -5
-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).

This behavioral change likely also calls for a ChangeLog entry, btw.

I'm not familiar with the format/style of this file.

Quoted 7 lines

Could it be simply

### Removed
- ...current list ...
- INSTALL_EFI_STRIP environment was removed, xen.efi will be stripped.

?

Not sure if it would better go under Removed or Changed. I'd also be a little more verbose here, to provide context. E.g. "The install-time environment variable INSTALL_EFI_STRIP is no longer supported, xen.efi will is now always being stripped."

Quoted 3 lines

For simplicity, should we always strip xen.efi and provide also xen-syms.efi only if debug info is enabled?
It would probably be more consistent.

That's an option, I suppose.

Jan