diff options
-rw-r--r-- | Makefile.rules | 7 | ||||
-rw-r--r-- | fuzz/cr50_fuzz.cc (renamed from fuzz/cr50_fuzz.c) | 17 |
2 files changed, 17 insertions, 7 deletions
diff --git a/Makefile.rules b/Makefile.rules index d44db81ba5..d6150a5c47 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -77,6 +77,8 @@ cmd_elf = $(CC) $(objs) $(libsharedobjs_elf-y) $(LDFLAGS) \ cmd_fuzz_exe = $(CXX) $^ $(HOST_TEST_LDFLAGS) $(LDFLAGS_EXTRA) -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_cxx_to_o = $(CXX) -std=c++11 $(CFLAGS) $(CXXFLAGS) -MMD -MP -MF $@.d -c $< \ + -o $(@D)/$(@F) cmd_c_to_build = $(BUILDCC) $(BUILD_CFLAGS) \ $(sort $(foreach c,$($(*F)-objs),util/$(c:%.o=%.c)) $(wildcard $*.c)) \ $(BUILD_LDFLAGS) \ @@ -444,6 +446,11 @@ $(out)/RO/%.o:%.c $(out)/RW/%.o:%.c $(call quiet,c_to_o,CC ) +$(out)/RO/%.o:%.cc + $(call quiet,cxx_to_o,CXX ) +$(out)/RW/%.o:%.cc + $(call quiet,cxx_to_o,CXX ) + $(out)/$(SHOBJLIB)/%.o: override LATE_CFLAGS_DEFINE:=-DSHAREDLIB_IMAGE $(out)/$(SHOBJLIB)/%.o:%.c $(call quiet,c_to_o,CC ) diff --git a/fuzz/cr50_fuzz.c b/fuzz/cr50_fuzz.cc index ccf99172d6..dc4220afb8 100644 --- a/fuzz/cr50_fuzz.c +++ b/fuzz/cr50_fuzz.cc @@ -5,25 +5,28 @@ * Fuzzer for the TPM2 and vendor specific Cr50 commands. */ -#include <stdint.h> -#include <stdlib.h> #include <unistd.h> +#include <cstdint> +#include <cstdlib> + +extern "C" { #include "fuzz_config.h" #include "nvmem.h" #include "nvmem_vars.h" #include "persistence.h" #include "pinweaver.h" +} #define NVMEM_TPM_SIZE ((sizeof((struct nvmem_partition *)0)->buffer) \ - NVMEM_CR50_SIZE) -uint32_t nvmem_user_sizes[NVMEM_NUM_USERS] = { +extern "C" uint32_t nvmem_user_sizes[NVMEM_NUM_USERS] = { NVMEM_TPM_SIZE, NVMEM_CR50_SIZE }; -void rand_bytes(void *buffer, size_t len) +extern "C" void rand_bytes(void *buffer, size_t len) { size_t x = 0; @@ -31,12 +34,12 @@ void rand_bytes(void *buffer, size_t len) ((uint8_t *)buffer)[x] = rand(); } -void get_storage_seed(void *buf, size_t *len) +extern "C" void get_storage_seed(void *buf, size_t *len) { memset(buf, 0x77, *len); } -void run_test(void) +extern "C" void run_test(void) { } @@ -54,7 +57,7 @@ static void assign_pw_field_from_bytes(const uint8_t *data, unsigned int size, /* Prevent this from being stack allocated. */ static uint8_t tpm_io_buffer[PW_MAX_MESSAGE_SIZE]; -int test_fuzz_one_input(const uint8_t *data, unsigned int size) +extern "C" int test_fuzz_one_input(const uint8_t *data, unsigned int size) { struct merkle_tree_t merkle_tree = {}; struct pw_request_t *request = (struct pw_request_t *)tpm_io_buffer; |