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

[xen staging] EFI: strip xen.efi when putting it on the EFI partition



commit c3cad613dd7ce095098437d9107e791a48db83a9
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Mon Jul 18 17:48:40 2022 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Jul 18 17:48:40 2022 +0200

    EFI: strip xen.efi when putting it on the EFI partition
    
    With debug info retained, xen.efi can be quite large. Unlike for xen.gz
    there's no intermediate step (mkelf32 there) involved which would strip
    debug info kind of as a side effect. While the installing of xen.efi on
    the EFI partition is an optional step (intended to be a courtesy to the
    developer), adjust it also for the purpose of documenting what distros
    would be expected to do during boot loader configuration (which is what
    would normally put xen.efi into the EFI partition).
    
    Model the control over stripping after Linux'es module installation,
    except that the stripped executable is constructed in the build area
    instead of in the destination location. This is to conserve on space
    used there - EFI partitions tend to be only a few hundred Mb in size.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Tested-by: Henry Wang <Henry.Wang@xxxxxxx>
    Tested-by: Wei Chen <Wei.Chen@xxxxxxx> # arm
    Reviewed-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
---
 docs/misc/efi.pandoc | 10 +++++++---
 xen/Makefile         | 22 +++++++++++++++++++++-
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/docs/misc/efi.pandoc b/docs/misc/efi.pandoc
index 71fdc316b6..11c1ac3346 100644
--- a/docs/misc/efi.pandoc
+++ b/docs/misc/efi.pandoc
@@ -20,9 +20,13 @@ 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). The xen.efi binary will also be installed in
-`/usr/lib64/efi/`, unless `EFI_DIR` is set in the environment to override this
-default.
+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.
 
 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
diff --git a/xen/Makefile b/xen/Makefile
index 4d770fef84..3d926e1015 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -464,6 +464,22 @@ 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))
@@ -488,6 +504,9 @@ _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; \
@@ -544,7 +563,8 @@ _clean:
                -o -name ".*.o.tmp" -o -name "*~" -o -name "core" \
                -o -name '*.lex.c' -o -name '*.tab.[ch]' -o -name 
'*.c.cppcheck' \
                -o -name "*.gcno" -o -name ".*.cmd" -o -name "lib.a" \) -exec 
rm -f {} \;
-       rm -f include/asm $(TARGET) $(TARGET).gz $(TARGET).efi 
$(TARGET).efi.map $(TARGET)-syms $(TARGET)-syms.map
+       rm -f include/asm $(TARGET) $(TARGET).gz $(TARGET)-syms 
$(TARGET)-syms.map
+       rm -f $(TARGET).efi $(TARGET).efi.map $(TARGET).efi.stripped
        rm -f asm-offsets.s arch/*/include/asm/asm-offsets.h
        rm -f .banner .allconfig.tmp include/xen/compile.h
        rm -f cppcheck-misra.* xen-cppcheck.xml
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

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