From dd8a1c6608668b6a8c1be1fc66110adc43dcc4b0 Mon Sep 17 00:00:00 2001 From: Joe Ranweiler Date: Thu, 8 Feb 2018 14:33:00 -0800 Subject: [PATCH] Use external linkage for global input buffer This is to support running saved auto-generated test cases. --- src/include/deepstate/DeepState.h | 12 ++++++++++++ src/lib/DeepState.c | 14 +++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/include/deepstate/DeepState.h b/src/include/deepstate/DeepState.h index d31f440..2e6ef30 100644 --- a/src/include/deepstate/DeepState.h +++ b/src/include/deepstate/DeepState.h @@ -51,6 +51,18 @@ DEEPSTATE_BEGIN_EXTERN_C DECLARE_string(input_test_dir); DECLARE_string(output_test_dir); +enum { + DeepState_InputSize = 8192 +}; + +/* Byte buffer that will contain symbolic data that is used to supply requests + * for symbolic values (e.g. `int`s). */ +extern volatile uint8_t DeepState_Input[DeepState_InputSize]; + +/* Index into the `DeepState_Input` array that tracks how many input bytes have + * been consumed. */ +extern uint32_t DeepState_InputIndex; + /* Return a symbolic value of a given type. */ extern int DeepState_Bool(void); extern size_t DeepState_Size(void); diff --git a/src/lib/DeepState.c b/src/lib/DeepState.c index 89332b6..ac61b90 100644 --- a/src/lib/DeepState.c +++ b/src/lib/DeepState.c @@ -37,17 +37,9 @@ struct DeepState_TestInfo *DeepState_LastTestInfo = NULL; /* Pointer to the test being run in this process by Dr. Fuzz. */ static struct DeepState_TestInfo *DeepState_DrFuzzTest = NULL; -enum { - DeepState_InputSize = 8192 -}; - -/* Byte buffer that will contain symbolic data that is used to supply requests - * for symbolic values (e.g. `int`s). */ -static volatile uint8_t DeepState_Input[DeepState_InputSize]; - -/* Index into the `DeepState_Input` array that tracks how many input bytes have - * been consumed. */ -static uint32_t DeepState_InputIndex = 0; +/* Initialize global input buffer and index. */ +volatile uint8_t DeepState_Input[DeepState_InputSize] = {}; +uint32_t DeepState_InputIndex = 0; /* Jump buffer for returning to `DeepState_Run`. */ jmp_buf DeepState_ReturnToRun = {};