From 72d44ed611459d1716d4e47ed7b881586bec7abc Mon Sep 17 00:00:00 2001 From: bloodstalker Date: Wed, 19 Sep 2018 02:11:57 +0430 Subject: still WIP --- bruiser/autogen/wasm/ft.sh | 2 +- bruiser/autogen/wasm/ft/autowasm.c | 42 +++++++++++++++++--------------------- bruiser/autogen/wasm/ft/makefile | 10 ++++++++- bruiser/autogen/wasm/ltg.sh | 2 +- bruiser/autogen/wasm/ltg/makefile | 12 ++++++++++- 5 files changed, 41 insertions(+), 27 deletions(-) (limited to 'bruiser/autogen') diff --git a/bruiser/autogen/wasm/ft.sh b/bruiser/autogen/wasm/ft.sh index e5a1e05..ce72011 100755 --- a/bruiser/autogen/wasm/ft.sh +++ b/bruiser/autogen/wasm/ft.sh @@ -1,5 +1,5 @@ #!/bin/sh cd $(dirname $0) -"../../faultreiber/faultreiber.py" --name wasm --outdir ./ft/ --datetime --xml ./ft/wasm.xml +"../../faultreiber/faultreiber.py" --name wasm --outdir ./ft/ --datetime --xml ./ft/wasm.xml --calloc #"clang-format" -i ./test/read.c ./test/structs.c ./test/structs.h ./test/aggregate.c ./test/aggregate.h ./test/read.h #"less" ./test/structs.h diff --git a/bruiser/autogen/wasm/ft/autowasm.c b/bruiser/autogen/wasm/ft/autowasm.c index cbc6e5a..53986c1 100644 --- a/bruiser/autogen/wasm/ft/autowasm.c +++ b/bruiser/autogen/wasm/ft/autowasm.c @@ -3,35 +3,31 @@ #include #include #include -#include #include +#include -#include "./structs.h" -#include "./read.h" #include "./aggregate.h" - +#include "./read.h" +#include "./structs.h" #pragma weak main -int main (int argc, char** argv) { - const rlim_t kStackSize = 160 * 1024 * 1024; // min stack size = 16 MB +int main(int argc, char **argv) { + const rlim_t kStackSize = 160 * 1024 * 1024; // min stack size = 16 MB struct rlimit rl; int result; result = getrlimit(RLIMIT_STACK, &rl); - if (result == 0) - { - if (rl.rlim_cur < kStackSize) - { - rl.rlim_cur = kStackSize; - result = setrlimit(RLIMIT_STACK, &rl); - if (result != 0) - { - fprintf(stderr, "setrlimit returned result = %d\n", result); - } + if (result == 0) { + if (rl.rlim_cur < kStackSize) { + rl.rlim_cur = kStackSize; + result = setrlimit(RLIMIT_STACK, &rl); + if (result != 0) { + fprintf(stderr, "setrlimit returned result = %d\n", result); } + } } int wasm = open("./test.wasm", O_RDONLY); - wasm_lib_ret_t* lib_ret = read_aggr_wasm(wasm); + wasm_lib_ret_t *lib_ret = read_aggr_wasm(wasm); printf("finished reading\n"); #if 0 @@ -165,14 +161,14 @@ int main (int argc, char** argv) { printf("void_train first:0x%x\n", lib_ret->void_train[0]); printf("void_train first:0x%x\n", lib_ret->void_train[1]); printf("void_train self address:0x%x\n", lib_ret->void_train); - //free(lib_ret->void_train[0]); - //release_all(lib_ret->void_train, lib_ret->current_void_count); - //free(lib_ret->void_train[2]); - //free(lib_ret->void_train[1]); - //free(lib_ret->void_train[0]); + // free(lib_ret->void_train[0]); + // release_all(lib_ret->void_train, lib_ret->current_void_count); + // free(lib_ret->void_train[2]); + // free(lib_ret->void_train[1]); + // free(lib_ret->void_train[0]); for (int i = lib_ret->current_void_count - 1; i >= 0; --i) { printf("%d:0x%x ", i, lib_ret->void_train[i]); - //if (i == 1) continue; + // if (i == 1) continue; free(lib_ret->void_train[i]); } free(lib_ret->void_train); diff --git a/bruiser/autogen/wasm/ft/makefile b/bruiser/autogen/wasm/ft/makefile index be67649..d67c45b 100644 --- a/bruiser/autogen/wasm/ft/makefile +++ b/bruiser/autogen/wasm/ft/makefile @@ -101,6 +101,8 @@ ASM:$(ASM_LIST) SO:$(TARGET).so A:$(TARGET).a +ADBG:$(TARGET).adbg +ACOV:$(TARGET).acov TAGS:tags @@ -118,6 +120,12 @@ $(TARGET).so: $(TARGET).o read.o aggregate.o structs.o $(TARGET).a: $(TARGET).o read.o aggregate.o structs.o ar rcs $(TARGET).a $(TARGET).o read.o aggregate.o structs.o +$(TARGET).adbg: $(TARGET).odbg read.odbg aggregate.odbg structs.odbg + ar rcs $(TARGET).adbg $(TARGET).odbg read.odbg aggregate.odbg structs.odbg + +$(TARGET).acov: $(TARGET).ocov read.ocov aggregate.ocov structs.ocov + ar rcs $(TARGET).acov $(TARGET).ocov read.ocov aggregate.ocov structs.ocov + valgrind: $(TARGET) valgrind --leak-check=yes $(TARGET) @@ -125,7 +133,7 @@ test: $(TARGET) $(TARGET) clean: - rm -f *.o *.dis *.odbg *.ocov *~ $(TARGET) $(TARGET).so $(TARGET)-static $(TARGET)-dbg $(TARGET).a $(TARGET)-cov + rm -f *.o *.dis *.odbg *.ocov *~ $(TARGET) $(TARGET).so $(TARGET)-static $(TARGET)-dbg $(TARGET).a $(TARGET)-cov $(TARGET).adbg $(TARGET).acov deepclean: rm -f *.o *.dis *.odbg *.ocov *~ $(TARGET) $(TARGET).so tags $(TARGET)-static $(TARGET)-dbg $(TARGET).a $(TARGET)-cov diff --git a/bruiser/autogen/wasm/ltg.sh b/bruiser/autogen/wasm/ltg.sh index 769a11f..69e0a73 100755 --- a/bruiser/autogen/wasm/ltg.sh +++ b/bruiser/autogen/wasm/ltg.sh @@ -1,6 +1,6 @@ #!/bin/sh cd $(dirname $0) -"../../tablegen/luatablegen.py" --out ./ltg/ --luaheader ../../../lua-5.3.4/src --headeraggr ./ltg/wasm_tables.h --lualibpath ./ltg/wasm.lua --docpath ./ltg/wasm.md --xml ./ltg/wasm.xml --tbldefs ./ltg/ --name wasm +"../../tablegen/luatablegen.py" --out ./ltg/ --luaheader ../../../lua-5.3.4/src --headeraggr ./ltg/wasm_tables.h --lualibpath ./ltg/wasm.lua --docpath ./ltg/wasm.md --xml ./ltg/wasm.xml --tbldefs ./ltg/ --name wasm --anon clang-format ./ltg/*.c ./ltg/*.h -i for filename in ./ltg/*.c; do gcc -c $filename > /dev/null 2>&1 diff --git a/bruiser/autogen/wasm/ltg/makefile b/bruiser/autogen/wasm/ltg/makefile index 3a98ee0..58152ab 100644 --- a/bruiser/autogen/wasm/ltg/makefile +++ b/bruiser/autogen/wasm/ltg/makefile @@ -20,6 +20,8 @@ COV_LD= -fprofile-instr-generate # BUILD_MODES are=RELEASE(default), DEBUG,ADDSAN,MEMSAN,UBSAN BUILD_MODE?=RELEASE OBJ_LIST:=$(patsubst %.c, %.o, $(wildcard *.c)) +OBJ_LIST_DBG:=$(patsubst %.c, %.odbg, $(wildcard *.c)) +OBJ_LIST_COV:=$(patsubst %.c, %.ocov, $(wildcard *.c)) ASM_LIST:=$(patsubst %.c, %.dis, $(wildcard *.c)) ifeq ($(BUILD_MODE), ADDSAN) @@ -105,6 +107,8 @@ ASM:$(ASM_LIST) SO:$(TARGET).so A:$(TARGET).a +ADBG:$(TARGET).adbg +ACOV:$(TARGET).acov TAGS:tags @@ -122,6 +126,12 @@ $(TARGET).so: $(TARGET).o $(LIB_LUA) $(OBJ_LIST) $(TARGET).a: $(TARGET).o $(LIB_LUA) $(OBJ_LIST) ar rcs $(TARGET).a $(OBJ_LIST) +$(TARGET).adbg: $(TARGET).odbg $(LIB_LUA) $(OBJ_LIST_DBG) + ar rcs $(TARGET).adbg $(OBJ_LIST_DBG) + +$(TARGET).acov: $(TARGET).ocov $(LIB_LUA) $(OBJ_LIST_COV) + ar rcs $(TARGET).acov $(OBJ_LIST_DBG) + runcov: $(TARGET)-cov $(TARGET)-cov @@ -129,7 +139,7 @@ valgrind: $(TARGET) - valgrind --leak-check=yes $(TARGET) clean: - rm -f *.o *.dis *.odbg *.ocov *~ $(TARGET) $(TARGET).so $(TARGET)-static $(TARGET)-dbg $(TARGET).a $(TARGET)-cov + rm -f *.o *.dis *.odbg *.ocov *~ $(TARGET) $(TARGET).so $(TARGET)-static $(TARGET)-dbg $(TARGET).a $(TARGET)-cov $(TARGET).adbg $(TARGET).acov deepclean: clean if [[ -d tags ]];then rm tags;fi -- cgit v1.2.3