diff options
author | Yicheng Li <yichengli@chromium.org> | 2019-08-21 17:18:06 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-08-23 18:52:49 +0000 |
commit | 5ce0aa26c41ea0d6f0c22deaa2233ca4552797f0 (patch) | |
tree | 881e92111fc417bf2b0d1267155c76311959fbae | |
parent | a06dc0b52c6415eabc3a5d46357894bbe6416a17 (diff) | |
download | chrome-ec-5ce0aa26c41ea0d6f0c22deaa2233ca4552797f0.tar.gz |
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 <yichengli@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1764835
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
-rw-r--r-- | board/hatch_fp/board.h | 2 | ||||
-rw-r--r-- | board/nocturne_fp/board.h | 2 | ||||
-rw-r--r-- | common/build.mk | 22 | ||||
-rw-r--r-- | include/config.h | 7 |
4 files changed, 18 insertions, 15 deletions
diff --git a/board/hatch_fp/board.h b/board/hatch_fp/board.h index d51f57a7fb..5233565c21 100644 --- a/board/hatch_fp/board.h +++ b/board/hatch_fp/board.h @@ -165,7 +165,7 @@ #define CONFIG_RNG -#define CONFIG_ALWAYS_MEMSET +#define CONFIG_LIBCRYPTOC #define CONFIG_CMD_FLASH #define CONFIG_CMD_SPI_XFER diff --git a/board/nocturne_fp/board.h b/board/nocturne_fp/board.h index 4b0a3a5426..4789c70455 100644 --- a/board/nocturne_fp/board.h +++ b/board/nocturne_fp/board.h @@ -150,7 +150,7 @@ #define CONFIG_RNG -#define CONFIG_ALWAYS_MEMSET +#define CONFIG_LIBCRYPTOC #define CONFIG_CMD_FLASH #define CONFIG_CMD_SPI_XFER 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 diff --git a/include/config.h b/include/config.h index c168381834..a31ba2ba81 100644 --- a/include/config.h +++ b/include/config.h @@ -328,11 +328,8 @@ /* Define which ALS sensor is used for dimming the lightbar when dark */ #undef CONFIG_ALS_LIGHTBAR_DIMMING -/* - * Support always_memset() defined in third_party/cryptoc, which will not be - * optimized out by compiler. - */ -#undef CONFIG_ALWAYS_MEMSET +/* Link against third_party/cryptoc. */ +#undef CONFIG_LIBCRYPTOC /* Support AP hang detection host command and state machine */ #undef CONFIG_AP_HANG_DETECT |