diff options
author | Allen Webb <allenwebb@google.com> | 2018-08-17 14:56:33 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-09-07 18:36:33 -0700 |
commit | 6a9a3a62732ff31e247a9eb61a5f4e7c53154ee5 (patch) | |
tree | 32a71c89e7266301206cc4dd242332bd5b835892 /Makefile.rules | |
parent | 09d4918f464b69390f0c2d12cdd8c6aeafcb2cae (diff) | |
download | chrome-ec-6a9a3a62732ff31e247a9eb61a5f4e7c53154ee5.tar.gz |
fuzz: Hide conflicts with cstdlib and use clang++ for linking.
This creates a build target called libec.a by setting the visibility
of functions that conflict with cstdlib to hidden. It then links
those symbols locally into one large object file that makes up libec.a
Fuzzing targets are linked against libec.a so that they can invoke ec
functionality while depending on outside libraries that need cstdlib.
When linking a particular object against cstdlib, to avoid conflicting
function declarations put the following before any includes from the
ec codebase:
#define __stdlib_compat(...)
The fuzzing targets are now linked using clang++, so that c++ libraries
and objects can be used as part of the fuzzers.
BRANCH=none
BUG=chromium:876582
TEST=make -j buildfuzztests &&
./build/host/host_command_fuzz/host_command_fuzz.exe
Change-Id: Ifdfdc6a51c6ef23b4e192b013ca993bf48a4411b
Signed-off-by: Allen Webb <allenwebb@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1180401
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'Makefile.rules')
-rw-r--r-- | Makefile.rules | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Makefile.rules b/Makefile.rules index 6e4b8ff6a1..8857b24f47 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -52,6 +52,9 @@ endif endif # commands to build all targets +cmd_libec = $(LD) -r $^ -o $@.1.o && \ + $(OBJCOPY) --localize-hidden $@.1.o $@.2.o && \ + $(AR) scr $@ $@.2.o cmd_lds = $(CPP) -P -C -MMD -MF $@.d -MT $@ $(CPPFLAGS) $< -o $@ cmd_lds_b = $(cmd_lds) -DRW_B_LDS # Allow obj_to_bin to be overridden by board or chip specific commands @@ -71,6 +74,7 @@ cmd_bin_to_hex = $(OBJCOPY) -I binary -O ihex \ cmd_smap = $(NM) $< | sort > $@ cmd_elf = $(CC) $(objs) $(libsharedobjs_elf-y) $(LDFLAGS) \ -o $@ -Wl,-T,$< -Wl,-Map,$(patsubst %.elf,%.map,$@) +cmd_fuzz_exe = $(CXX) $^ $(HOST_TEST_LDFLAGS) -o $@ cmd_exe = $(CC) $(ro-objs) $(HOST_TEST_LDFLAGS) -o $@ cmd_c_to_o = $(CC) $(CFLAGS) -MMD -MP -MF $@.d -c $< -o $(@D)/$(@F) cmd_c_to_build = $(BUILDCC) $(BUILD_CFLAGS) \ @@ -341,6 +345,9 @@ $(fuzz-test-targets): host-%: buildfuzztests: TEST_FLAG=TEST_FUZZ=y TEST_ASAN=y buildfuzztests: $(fuzz-test-targets) +$(out)/libec.a: $(ro-objs) + $(call quiet,libec,BUILD ) + $(out)/firmware_image.lds: common/firmware_image.lds.S $(call quiet,lds,LDS ) $(out)/%.lds: core/$(CORE)/ec.lds.S @@ -424,8 +431,13 @@ $(out)/$(SHOBJLIB)/$(SHOBJLIB).elf: $(sharedlib-objs) $(out)/%.smap: $(out)/%.elf $(call quiet,smap,NM ) +ifeq ($(TEST_FUZZ),y) +$(out)/$(PROJECT).exe: $(rw-only-objs) $(out)/libec.a + $(call quiet,fuzz_exe,EXE ) +else $(out)/$(PROJECT).exe: $(ro-objs) $(call quiet,exe,EXE ) +endif $(out)/RO/%.o:%.c $(call quiet,c_to_o,CC ) |