From 5ce0aa26c41ea0d6f0c22deaa2233ca4552797f0 Mon Sep 17 00:00:00 2001 From: Yicheng Li Date: Wed, 21 Aug 2019 17:18:06 -0700 Subject: common: Add CONFIG_LIBCRYPTOC to enable third_party/cryptoc Boards that have CONFIG_LIBCRYPTOC will be able to use functions in third_party/cryptoc. Functions in third_party/cryptoc that are not called will not be linked because of linker optimization. This can be verified by checking the "smap" file in the build directory for a given target (e.g. build/nocturne_fp/RW/ec.RW.smap), which contains a list of all symbols in the target. Configure CONFIG_LIBCRYPTOC in nocturne_fp and hatch_fp. This config replaces CONFIG_ALWAYS_MEMSET. BRANCH=nocturne BUG=chromium:968809,chromium:989594,b:130238794 TEST=make -j buildall Change-Id: Ia40da9fb429f9d03623bc92e25f6670e5cdbd983 Signed-off-by: Yicheng Li Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1764835 Reviewed-by: Tom Hughes --- common/build.mk | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'common/build.mk') diff --git a/common/build.mk b/common/build.mk index 87534a175b..a5af9a3a5e 100644 --- a/common/build.mk +++ b/common/build.mk @@ -241,20 +241,26 @@ $(out)/rma_key_from_blob.h: board/$(BOARD)/$(BLOB_FILE) util/bin2h.sh endif -ifeq ($(CONFIG_ALWAYS_MEMSET),y) +ifeq ($(CONFIG_LIBCRYPTOC),y) CRYPTOCLIB := $(realpath ../../third_party/cryptoc) +ifneq ($(BOARD),host) CPPFLAGS += -I$(abspath ./builtin) +endif CPPFLAGS += -I$(CRYPTOCLIB)/include - -CRYPTOC_OBJS = $(shell find $(out)/cryptoc -name 'util.o') -$(out)/RW/ec.RW.elf $(out)/RW/ec.RW_B.elf: LDFLAGS_EXTRA += $(CRYPTOC_OBJS) -$(out)/RW/ec.RW.elf $(out)/RW/ec.RW_B.elf: cryptoc_objs +CRYPTOC_LDFLAGS := -L$(out)/cryptoc -lcryptoc # Force the external build each time, so it can look for changed sources. -.PHONY: cryptoc_objs -cryptoc_objs: +.PHONY: $(out)/cryptoc/libcryptoc.a +$(out)/cryptoc/libcryptoc.a: $(MAKE) obj=$(realpath $(out))/cryptoc SUPPORT_UNALIGNED=1 \ - CONFIG_UPTO_SHA512=$(CONFIG_UPTO_SHA512) -C $(CRYPTOCLIB) objs + CONFIG_UPTO_SHA512=$(CONFIG_UPTO_SHA512) -C $(CRYPTOCLIB) + +# Link RW against cryptoc. +$(out)/RW/ec.RW.elf $(out)/RW/ec.RW_B.elf: LDFLAGS_EXTRA += $(CRYPTOC_LDFLAGS) +$(out)/RW/ec.RW.elf $(out)/RW/ec.RW_B.elf: $(out)/cryptoc/libcryptoc.a +# Host test executables (including fuzz tests). +$(out)/$(PROJECT).exe: LDFLAGS_EXTRA += $(CRYPTOC_LDFLAGS) +$(out)/$(PROJECT).exe: $(out)/cryptoc/libcryptoc.a endif include $(_common_dir)fpsensor/build.mk -- cgit v1.2.1