diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2021-10-06 15:04:51 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-10-11 19:58:40 +0000 |
commit | 289dfac48450fe2707b0ca381c399ecaabc9b949 (patch) | |
tree | 3415f6dfeb4511bc798c9e4705e7c2f95079b1d6 | |
parent | d1244d6f05b833db439901f7af4d691344f0c214 (diff) | |
download | chrome-ec-289dfac48450fe2707b0ca381c399ecaabc9b949.tar.gz |
cr50: use LTO module for TPM2
In order to reduce code footprint, do not link TPM2 library modules,
instead build TPM2 as a single relocatable object module, a collection
of library sources compiled and linked with LTO enabled.
BUG=b:65253310
TEST=observed code space reduced by 1428 bytes, the bss_libtpm2
section remained practically unchanged:
before:
*** 5548 bytes in flash and 5652 bytes in RAM still ...
000104d0 B __bss_libtpm2_start
000155d7 B __bss_libtpm2_end
after:
*** 6976 bytes in flash and 5652 bytes in RAM still ...
000104d0 B __bss_libtpm2_start
000155d4 B __bss_libtpm2_end
Verified that the new Cr50 image allows a Chrome OS to successfully
boot and restart.
Cq-Depend: chromium:3210050
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Change-Id: I32335df29a332da115d8af56c157d5ad4189e9b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3210510
Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
-rw-r--r-- | board/cr50/build.mk | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/board/cr50/build.mk b/board/cr50/build.mk index f04342d5e8..6080e9c173 100644 --- a/board/cr50/build.mk +++ b/board/cr50/build.mk @@ -186,9 +186,16 @@ board-y += tpm_nvmem_ops.o board-y += wp.o board-$(CONFIG_PINWEAVER)+=pinweaver_tpm_imports.o +TPM2_MODULE := linkedtpm2.cp.o +board-y += $(TPM2_MODULE) + +ifneq ($(H1_RED_BOARD),) +CPPFLAGS += -DH1_RED_BOARD=$(EMPTY) +endif +RW_BD_OUT=$(out)/RW/$(BDIR) + # Build fips code separately ifneq ($(fips-y),) -RW_BD_OUT=$(out)/RW/$(BDIR) FIPS_MODULE=dcrypto/fips_module.o FIPS_LD_SCRIPT=$(BDIR)/dcrypto/fips_module.ld RW_FIPS_OBJS=$(patsubst %.o, $(RW_BD_OUT)/%.o, $(fips-y)) @@ -242,28 +249,17 @@ CFLAGS += -DEMBEDDED_MODE=1 # Use absolute path as the destination to ensure that TPM2 makefile finds the # place for output. -outdir := $(realpath $(out))/tpm2 -cmd_tpm2_base = $(MAKE) obj=$(outdir) EMBEDDED_MODE=1 \ - -C $(EXTLIB) --no-print-directory - -TPM2_OBJS := $(shell $(cmd_tpm2_base) list_copied_objs) - -TPM2_TARGET := $(outdir)/.copied_objs - -# Add dependencies on that library -$(out)/RW/ec.RW.elf $(out)/RW/ec.RW_B.elf: LDFLAGS_EXTRA += $(TPM2_OBJS) -$(out)/RW/ec.RW.elf $(out)/RW/ec.RW_B.elf: $(TPM2_TARGET) - -cmd_tpm2lib = $(cmd_tpm2_base) $(TPM2_TARGET) - -tpm2lib_check_clean = $(cmd_tpm2lib) -q && echo clean +outdir := $(abspath $(RW_BD_OUT)) +cmd_tpm2linked := $(MAKE) obj=$(outdir) EMBEDDED_MODE=1 LTO=1 \ + -C $(EXTLIB) --no-print-directory $(outdir)/$(TPM2_MODULE) -ifneq ($(shell $(tpm2lib_check_clean)),clean) +tpm2_check_clean := $(cmd_tpm2linked) -q && echo clean +ifneq ($(shell $(tpm2_check_clean)),clean) # Force the external build only if it is needed. -.PHONY: $(TPM2_TARGET) +.PHONY: $(RW_BD_OUT)/$(TPM2_MODULE) endif -$(TPM2_TARGET): - $(call quiet,tpm2lib,TPM2 ) +$(RW_BD_OUT)/$(TPM2_MODULE): + $(call quiet,tpm2linked,TPM2 ) endif # BOARD_MK_INCLUDED_ONCE is nonempty |