diff options
author | Allen Webb <allenwebb@google.com> | 2018-08-20 10:50:49 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-09-07 18:36:35 -0700 |
commit | a8e3f2388c0a950ec431e6fffc916b42ea6c816d (patch) | |
tree | 0f8554e770469a1515321aca1bdaab4cef59b198 /fuzz | |
parent | 269ff3569799531fa2b7f7a5def012ea254ceb57 (diff) | |
download | chrome-ec-a8e3f2388c0a950ec431e6fffc916b42ea6c816d.tar.gz |
makefule.rules: Add cxx_to_o rule for building c++ files.
This adds a rule for building c++ object files to make it possible
to use libprotobuf-mutator in fuzzing targets.
BRANCH=none
BUG=chromium:876582
TEST=make -j buildfuzztargets &&
./build/host/cr50_fuzz/cr50_fuzz.exe
Change-Id: I1355c313e47a1a83a599eb0f0b9142fefdf6de8b
Signed-off-by: Allen Webb <allenwebb@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1183535
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'fuzz')
-rw-r--r-- | fuzz/cr50_fuzz.cc (renamed from fuzz/cr50_fuzz.c) | 17 |
1 files changed, 10 insertions, 7 deletions
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; |