aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bruiser/asmrewriter.c2
-rwxr-xr-xbruiser/autogen/wasm/ft.sh2
-rw-r--r--bruiser/autogen/wasm/ft/autowasm.c42
-rw-r--r--bruiser/autogen/wasm/ft/makefile10
-rwxr-xr-xbruiser/autogen/wasm/ltg.sh2
-rw-r--r--bruiser/autogen/wasm/ltg/makefile12
-rw-r--r--bruiser/bruiser.cpp165
m---------bruiser/faultreiber0
-rw-r--r--bruiser/makefile54
m---------bruiser/tablegen0
10 files changed, 249 insertions, 40 deletions
diff --git a/bruiser/asmrewriter.c b/bruiser/asmrewriter.c
index f5743c1..899c5eb 100644
--- a/bruiser/asmrewriter.c
+++ b/bruiser/asmrewriter.c
@@ -62,7 +62,7 @@ int jmpt_push_args(lua_State* __ls, JMP_S_T* jmpt) {
lua_pushinteger(__ls, jmpt->y);
lua_pushinteger(__ls, jmpt->n);
lua_pushinteger(__ls, jmpt->z);
- return 0;
+ return 12;
}
int new_jmpt_2(lua_State* __ls) {
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 <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
#include <sys/resource.h>
+#include <unistd.h>
-#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
diff --git a/bruiser/bruiser.cpp b/bruiser/bruiser.cpp
index bc4ad65..17cb0db 100644
--- a/bruiser/bruiser.cpp
+++ b/bruiser/bruiser.cpp
@@ -126,11 +126,11 @@ cl::opt<std::string> SHELL_HISTORY_FILE("history", cl::desc("path to bruiser's h
template <typename T>
int pushLuaTableInt(lua_State* __ls, std::vector<T> vec) {
int tableindex = 1;
- lua_newtable(__ls);
if (!lua_checkstack(__ls, 3)) {
PRINT_WITH_COLOR_LB(RED, "cant grow lua stack. current size is too small.");
return -1;
}
+ lua_newtable(__ls);
for (auto& iter : vec) {
lua_pushinteger(__ls, tableindex);
tableindex++;
@@ -142,11 +142,11 @@ int pushLuaTableInt(lua_State* __ls, std::vector<T> vec) {
int pushLuaTableString(lua_State* __ls, std::vector<std::string> vec) {
int tableindex = 1;
- lua_newtable(__ls);
if (!lua_checkstack(__ls, 3)) {
PRINT_WITH_COLOR_LB(RED, "cant grow lua stack. current size is too small.");
return -1;
}
+ lua_newtable(__ls);
for (auto& iter : vec) {
lua_pushinteger(__ls, tableindex);
tableindex++;
@@ -159,11 +159,11 @@ int pushLuaTableString(lua_State* __ls, std::vector<std::string> vec) {
template <typename T>
int pushLuaTableNumber(lua_State* __ls, std::vector<T> vec) {
int tableindex = 1;
- lua_newtable(__ls);
if (!lua_checkstack(__ls, 3)) {
PRINT_WITH_COLOR_LB(RED, "cant grow lua stack. current size is too small.");
return -1;
}
+ lua_newtable(__ls);
for (auto& iter : vec) {
lua_pushinteger(__ls, tableindex);
tableindex++;
@@ -1682,69 +1682,226 @@ class LuaWrapper
if (lua_gettop(__ls) != 1) PRINT_WITH_COLOR_LB(RED, "at least one argument denoting the path is required.");
std::string obj_path = lua_tostring(__ls, 1);
int wasm_file = open(obj_path.c_str(), O_RDONLY);
+ if (wasm_file < 0) {PRINT_WITH_COLOR_LB(RED, "bad file.");return 0;}
+ else {PRINT_WITH_COLOR_LB(GREEN, "good file");}
wasm_lib_ret_t* lib_ret = read_aggr_wasm(wasm_file);
+ std::cout << RED << std::hex << lib_ret->obj->magic_number_container->magic_number << "\n";
+ std::cout << lib_ret->obj->version_container->version << NORMAL << "\n";
+ std::cout << "die die die\n";
close(wasm_file);
+
+ //if (Verbose) {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wall"
+#pragma clang diagnostic ignored "-Wextra"
+ if (Verbose) {
+ printf("magic_number:%x\n", lib_ret->obj->magic_number_container->magic_number);
+ printf("version:%x\n", lib_ret->obj->version_container->version);
+
+ printf("type section id:%d\n", lib_ret->obj->W_Type_Section_container->id);
+ printf("type section payloadlength:%d\n", lib_ret->obj->W_Type_Section_container->payloadlength);
+ printf("type_section entry count:%d\n", lib_ret->obj->W_Type_Section_container->count);
+ for (int i=0; i < lib_ret->obj->W_Type_Section_container->count; ++i) {
+ printf("param_count:%d\n",lib_ret->obj->W_Type_Section_container->entries[i]->param_count);
+ for (int j = 0; j < lib_ret->obj->W_Type_Section_container->entries[i]->param_count; ++j)
+ printf("param_types:%d\n",lib_ret->obj->W_Type_Section_container->entries[i]->param_types[j]);
+ printf("return_count:%d\n", lib_ret->obj->W_Type_Section_container->entries[i]->return_count);
+ for (int j = 0; j < lib_ret->obj->W_Type_Section_container->entries[i]->return_count; ++j)
+ printf("param_types:%d\n",lib_ret->obj->W_Type_Section_container->entries[i]->return_types[j]);
+ }
+ printf("import_section_id:%d\n", lib_ret->obj->W_Import_Section_container->id);
+ printf("import_section_payloadlength:%d\n", lib_ret->obj->W_Import_Section_container->payloadlength);
+ printf("import_section_count:%d\n", lib_ret->obj->W_Import_Section_container->count);
+ for(int i = 0; i < lib_ret->obj->W_Import_Section_container->count; ++i) {
+ printf("module_length:%d\n", lib_ret->obj->W_Import_Section_container->entries[i]->module_length);
+ printf("module_str:%s\n", lib_ret->obj->W_Import_Section_container->entries[i]->module_str);
+ printf("field_length:%d\n", lib_ret->obj->W_Import_Section_container->entries[i]->field_len);
+ printf("field_str:%s\n", lib_ret->obj->W_Import_Section_container->entries[i]->field_str);
+ printf("kind:%d\n", lib_ret->obj->W_Import_Section_container->entries[i]->kind);
+ if (lib_ret->obj->W_Import_Section_container->entries[i]->kind == 0)
+ printf("type:%d\n", lib_ret->obj->W_Import_Section_container->entries[i]->kind);
+ printf("\n");
+ }
+ printf("function_section_id:%d\n", lib_ret->obj->W_Function_Section_container->id);
+ printf("function_section_payloadlength:%d\n", lib_ret->obj->W_Function_Section_container->payloadlength);
+ printf("function_section_count:%d\n", lib_ret->obj->W_Function_Section_container->count);
+ for (int i = 0; i < lib_ret->obj->W_Function_Section_container->count; ++i)
+ printf("type:%d\n", lib_ret->obj->W_Function_Section_container->types[i]);
+
+ printf("table_section_id:%d\n", lib_ret->obj->W_Table_Section_container->id);
+ printf("table_section_payloadlength:%d\n", lib_ret->obj->W_Table_Section_container->payloadlength);
+ printf("table_section_count:%d\n", lib_ret->obj->W_Table_Section_container->count);
+ for (int i = 0; i < lib_ret->obj->W_Table_Section_container->count; ++i) {
+ printf("element_type:%d\n", lib_ret->obj->W_Table_Section_container->entries[i]->element_type);
+ printf("rl_flags:%d\n", lib_ret->obj->W_Table_Section_container->entries[i]->resizable_limit->flags);
+ printf("rl_initial:%d\n", lib_ret->obj->W_Table_Section_container->entries[i]->resizable_limit->initial);
+ printf("rl_maximum:%d\n", lib_ret->obj->W_Table_Section_container->entries[i]->resizable_limit->maximum);
+ }
+
+ printf("memory_section_id:%d\n", lib_ret->obj->W_Memory_Section_container->id);
+ printf("memory_section_payload_length:%d\n", lib_ret->obj->W_Memory_Section_container->payloadlength);
+ printf("rl_flags:%d\n", lib_ret->obj->W_Memory_Section_container->entries->resizable_limit->flags);
+ printf("rl_initial:%d\n", lib_ret->obj->W_Memory_Section_container->entries->resizable_limit->initial);
+ printf("rl_maximum:%d\n", lib_ret->obj->W_Memory_Section_container->entries->resizable_limit->maximum);
+
+ if (lib_ret->obj->W_Global_Section_container == NULL) printf("global section doesnt exist.\n");
+
+ printf("export_section_id:%d\n", lib_ret->obj->W_Export_Section_container->id);
+ printf("export_section_payloadlength:%d\n", lib_ret->obj->W_Export_Section_container->payloadlength);
+ printf("entry count:%d\n", lib_ret->obj->W_Export_Section_container->count);
+
+ for (int i = 0; i < lib_ret->obj->W_Export_Section_container->count; ++i) {
+ printf("field_len:%d\n", lib_ret->obj->W_Export_Section_container->entries[i]->field_len);
+ printf("field_str:%s\n", lib_ret->obj->W_Export_Section_container->entries[i]->field_str);
+ printf("kind:%d\n", lib_ret->obj->W_Export_Section_container->entries[i]->kind);
+ printf("index:%d\n", lib_ret->obj->W_Export_Section_container->entries[i]->index);
+ }
+
+ if (lib_ret->obj->W_Start_Section_container == NULL) printf("start section doesnt exist.\n");
+
+ printf("element_seciton_id:%d\n", lib_ret->obj->W_Element_Section_container->id);
+ printf("element_section_payloadlength:%d\n", lib_ret->obj->W_Element_Section_container->payloadlength);
+ printf("entry count:%d\n", lib_ret->obj->W_Element_Section_container->count);
+
+ for (int i = 0; i < lib_ret->obj->W_Element_Section_container->count; ++i) {
+ printf("index:%d\n", lib_ret->obj->W_Element_Section_container->entries[i]->index);
+ for (int j = 0; j < 3; ++j) {
+ printf("code:%d\n", lib_ret->obj->W_Element_Section_container->entries[i]->init->code[j]);
+ }
+ printf("num_length:%d\n", lib_ret->obj->W_Element_Section_container->entries[i]->num_length);
+ for (int j = 0; j < lib_ret->obj->W_Element_Section_container->entries[i]->num_length; ++j) {
+ printf("elems:%d\n", lib_ret->obj->W_Element_Section_container->entries[i]->elems[j]);
+ }
+ }
+
+ printf("code_section_id:%d\n", lib_ret->obj->W_Code_Section_container->id);
+ printf("code_section_payloadlength:%d\n", lib_ret->obj->W_Code_Section_container->payloadlength);
+ printf("count:%d\n", lib_ret->obj->W_Code_Section_container->count);
+
+ for (int i = 0; i < lib_ret->obj->W_Code_Section_container->count; ++i) {
+ printf("body_size:%d\n", lib_ret->obj->W_Code_Section_container->bodies[i]->body_size);
+ printf("local_count:%d\n", lib_ret->obj->W_Code_Section_container->bodies[i]->local_count);
+ if (lib_ret->obj->W_Code_Section_container->bodies[i]->local_count > 0) {
+ for (int j =0; j < lib_ret->obj->W_Code_Section_container->bodies[i]->local_count; ++j) {
+ for (int k = 0; k < lib_ret->obj->W_Code_Section_container->bodies[i]->locals[j]->count; ++k) {
+ }
+ }
+ }
+ printf("code:\n");
+ for (int j = 0; j < lib_ret->obj->W_Code_Section_container->bodies[i]->body_size; ++j) {
+ printf("%02x ", lib_ret->obj->W_Code_Section_container->bodies[i]->code[j]);
+ }
+ printf("\n");
+ }
+
+ printf("data_section_id:%d\n", lib_ret->obj->W_Data_Section_container->id);
+ printf("data_section_payloadlength:%d\n", lib_ret->obj->W_Data_Section_container->payloadlength);
+ printf("data seg count:%d\n", lib_ret->obj->W_Data_Section_container->count);
+
+ for (int i = 0; i < lib_ret->obj->W_Data_Section_container->count; ++i) {
+ printf("index:%d\n", lib_ret->obj->W_Data_Section_container->entries[i]->index);
+ printf("size:%d\n", lib_ret->obj->W_Data_Section_container->entries[i]->size);
+ printf("code:\n");
+ for (int j = 0; j < lib_ret->obj->W_Data_Section_container->entries[i]->size; ++j) {
+ printf("%c ", lib_ret->obj->W_Data_Section_container->entries[i]->data[j]);
+ }
+ printf("\n");
+ int j = 0;
+ printf("offset:\n");
+ while(1) {
+ printf("%02x ", lib_ret->obj->W_Data_Section_container->entries[i]->offset->code[j]);
+ if (lib_ret->obj->W_Data_Section_container->entries[i]->offset->code[j] == 11) {
+ break;
+ }
+ j++;
+ }
+ printf("\n");
+ }
+ }
+#pragma clang diagnostic pop
+
lua_newtable(__ls);
lua_pushstring(__ls, "magic");
magic_number_push_args(__ls, lib_ret->obj->magic_number_container);
new_magic_number(__ls);
lua_settable(__ls, -3);
+ PRINT_WITH_COLOR_LB(BLUE, "magic");
+
lua_pushstring(__ls, "version");
version_push_args(__ls, lib_ret->obj->version_container);
new_version(__ls);
lua_settable(__ls, -3);
+ PRINT_WITH_COLOR_LB(BLUE, "version");
+
lua_pushstring(__ls, "type_section");
+ std::cout << "1\n";
W_Type_Section_push_args(__ls, lib_ret->obj->W_Type_Section_container);
+ std::cout << "2\n";
new_W_Type_Section(__ls);
+ std::cout << "3\n";
lua_settable(__ls, -3);
+ PRINT_WITH_COLOR_LB(BLUE, "type section");
+ return 1;
+#if 0
lua_pushstring(__ls, "import_section");
W_Import_Section_push_args(__ls, lib_ret->obj->W_Import_Section_container);
new_W_Import_Section(__ls);
lua_settable(__ls, -3);
+ PRINT_WITH_COLOR_LB(BLUE, "import section");
lua_pushstring(__ls, "function_section");
W_Function_Section_push_args(__ls, lib_ret->obj->W_Function_Section_container);
new_W_Function_Section(__ls);
lua_settable(__ls, -3);
+ PRINT_WITH_COLOR_LB(BLUE, "function section");
lua_pushstring(__ls, "table_section");
W_Table_Section_push_args(__ls, lib_ret->obj->W_Table_Section_container);
new_W_Table_Section(__ls);
lua_settable(__ls, -3);
+ PRINT_WITH_COLOR_LB(BLUE, "table section");
lua_pushstring(__ls, "memory_section");
W_Memory_Section_push_args(__ls, lib_ret->obj->W_Memory_Section_container);
new_W_Memory_Section(__ls);
lua_settable(__ls, -3);
+ PRINT_WITH_COLOR_LB(BLUE, "memory section");
lua_pushstring(__ls, "global_section");
W_Global_Section_push_args(__ls, lib_ret->obj->W_Global_Section_container);
new_W_Global_Section(__ls);
lua_settable(__ls, -3);
+ PRINT_WITH_COLOR_LB(BLUE, "global section");
lua_pushstring(__ls, "export_section");
W_Export_Section_push_args(__ls, lib_ret->obj->W_Export_Section_container);
new_W_Export_Section(__ls);
lua_settable(__ls, -3);
+ PRINT_WITH_COLOR_LB(BLUE, "export section");
lua_pushstring(__ls, "start_section");
W_Start_Section_push_args(__ls, lib_ret->obj->W_Start_Section_container);
new_W_Start_Section(__ls);
lua_settable(__ls, -3);
+ PRINT_WITH_COLOR_LB(BLUE, "start section");
lua_pushstring(__ls, "element_section");
W_Element_Section_push_args(__ls, lib_ret->obj->W_Element_Section_container);
new_W_Element_Section(__ls);
lua_settable(__ls, -3);
+ PRINT_WITH_COLOR_LB(BLUE, "element section");
lua_pushstring(__ls, "code_section");
W_Code_Section_push_args(__ls, lib_ret->obj->W_Code_Section_container);
new_W_Code_Section(__ls);
lua_settable(__ls, -3);
+ PRINT_WITH_COLOR_LB(BLUE, "code section");
lua_pushstring(__ls, "data_section");
W_Data_Section_push_args(__ls, lib_ret->obj->W_Data_Section_container);
new_W_Data_Section(__ls);
lua_settable(__ls, -3);
+ PRINT_WITH_COLOR_LB(BLUE, "data section");
return 1;
+#endif
}
int BruiserLuaXObjAllocGlobal(lua_State* __ls) {
int numargs = lua_gettop(__ls);
if (numargs != 2) {PRINT_WITH_COLOR_LB(RED, "expected exactly two args. did not get that.");return 0;}
std::string glob_name = lua_tostring(__ls , 1);
- size_t size = lua_tointeger(__ls, 2);
+ size_t size [[maybe_unused]] = lua_tointeger(__ls, 2);
//xglobals->reserve(size);
return 0;
}
diff --git a/bruiser/faultreiber b/bruiser/faultreiber
-Subproject 66a3830f30ed12281938fae30e5fb77a248333c
+Subproject a5c29b77f877aa33d63439e104952dd57286ccb
diff --git a/bruiser/makefile b/bruiser/makefile
index 1200b44..c6e7cf7 100644
--- a/bruiser/makefile
+++ b/bruiser/makefile
@@ -4,8 +4,12 @@ PY_CONF?=python3-config
LIB_LUA=./lua-5.3.4/src/liblua.a
FT_WASM_SO=./autogen/wasm/ft/autowasm.so
FT_WASM_A=./autogen/wasm/ft/autowasm.a
+FT_WASM_A_DBG=./autogen/wasm/ft/autowasm.adbg
+FT_WASM_A_COV=./autogen/wasm/ft/autowasm.acov
LTG_WASM_SO=./autogen/wasm/ltg/wasm_tables.so
LTG_WASM_A=./autogen/wasm/ltg/wasm_tables.a
+LTG_WASM_A_DBG=./autogen/wasm/ltg/wasm_tables.adbg
+LTG_WASM_A_COV=./autogen/wasm/ltg/wasm_tables.acov
SHELL=bash
SHELL?=bash
CC=clang
@@ -83,7 +87,7 @@ TBG_OBJLIST_COV_INC_WASM=$(patsubst ./autogen/wasm/ltg/%.c, ./autogen/wasm/ltg/%
.DEFAULT:all
-.PHONY:all clean help ASM SO TAGS CODE_GEN
+.PHONY:all clean help ASM SO TAGS CODE_GEN CODE_GEN_DBG CODE_GEN_COV
all:exe
@@ -145,24 +149,51 @@ linenoise.ocov: ./linenoise/linenoise.c
$(LIB_LUA):
$(MAKE) -C lua-5.3.4/src linux
-CODE_GEN: $(FT_WASM_A) $(LTG_WASM_A)
+CODE_GEN: $(FT_WASM_A) $(LTG_WASM_A) $(FT_WASM_SO) $(LTG_WASM_SO)
-$(FT_WASM_SO): ./autogen/wasm/ft/wasm.xml
+CODE_GEN_DBG: $(FT_WASM_A_DBG) $(LTG_WASM_A_DBG)
+
+CODE_GEN_COV: $(FT_WASM_A_COV) $(LTG_WASM_A_COV)
+
+define check_ft_codegen
- $(shell if [[ $$(ls -l ./autogen/wasm/ft/ | wc -l) == 4 ]];then ./autogen/wasm/ft.sh;else :;fi)
+endef
+define check_ltg_codegen
+ - $(shell if [[ $$(ls -l ./autogen/wasm/ltg/ | wc -l) == 3 ]];then ./autogen/wasm/ltg.sh;else :;fi)
+endef
+
+$(FT_WASM_SO): ./autogen/wasm/ft/wasm.xml
+ $(check_ft_codegen)
$(MAKE) -C ./autogen/wasm/ft SO
$(FT_WASM_A): ./autogen/wasm/ft/wasm.xml
- - $(shell if [[ $$(ls -l ./autogen/wasm/ft/ | wc -l) == 4 ]];then ./autogen/wasm/ft.sh;else :;fi)
+ $(check_ft_codegen)
$(MAKE) -C ./autogen/wasm/ft A
+$(FT_WASM_A_DBG): ./autogen/wasm/ft/wasm.xml
+ $(check_ft_codegen)
+ $(MAKE) -C ./autogen/wasm/ft ADBG
+
+$(FT_WASM_A_COV): ./autogen/wasm/ft/wasm.xml
+ $(check_ft_codegen)
+ $(MAKE) -C ./autogen/wasm/ft ACOV
+
$(LTG_WASM_SO): ./autogen/wasm/ltg/wasm.xml
- - $(shell if [[ $$(ls -l ./autogen/wasm/ltg/ | wc -l) == 3 ]];then ./autogen/wasm/ltg.sh;else :;fi)
+ $(check_ltg_codegen)
$(MAKE) -C ./autogen/wasm/ltg SO
$(LTG_WASM_A): ./autogen/wasm/ltg/wasm.xml
- - $(shell if [[ $$(ls -l ./autogen/wasm/ltg/ | wc -l) == 3 ]];then ./autogen/wasm/ltg.sh;else :;fi)
+ $(check_ltg_codegen)
$(MAKE) -C ./autogen/wasm/ltg A
+$(LTG_WASM_A_DBG): ./autogen/wasm/ltg/wasm.xml
+ $(check_ltg_codegen)
+ $(MAKE) -C ./autogen/wasm/ltg ADBG
+
+$(LTG_WASM_A_COV): ./autogen/wasm/ltg/wasm.xml
+ $(check_ltg_codegen)
+ $(MAKE) -C ./autogen/wasm/ltg ACOV
+
%.odbg:%.cpp
$(CXX) $(CXX_FLAGS) -g -c $< -o $@
@@ -170,6 +201,8 @@ $(LTG_WASM_A): ./autogen/wasm/ltg/wasm.xml
$(CXX) $(CXX_FLAGS) $(COV_CXX) -c $< -o $@
exe: CODE_GEN $(TARGET)
+exe-dbg: CODE_GEN_DBG $(TARGET)-dbg
+exe-cov: CODE_GEN_COV $(TARGET)-cov
$(TARGET): $(TARGET).o $(FT_WASM_A) $(LTG_WASM_A) ../m0/mutator_aux.o ../tinyxml2/tinyxml2.o linenoise.o CompletionHints.o mutagen.o ORCmutation.o bruiserffi.o asmrewriter.o bruisercapstone.o ramdump.o ffs.o $(LIB_LUA)
$(CXX) $^ $(LD_FLAGS) -o $@
@@ -178,10 +211,10 @@ $(TARGET): $(TARGET).o $(FT_WASM_A) $(LTG_WASM_A) ../m0/mutator_aux.o ../tinyxml
$(TARGET)-static: $(FT_WASM_A) $(LTG_WASM_A) $(TARGET).o ../m0/mutator_aux.o ../tinyxml2/tinyxml2.o linenoise.o CompletionHints.o mutagen.o ORCmutation.o bruiserffi.o asmrewriter.o bruisercapstone.o ramdump.o ffs.o $(LIB_LUA)
$(CXX) $^ $(LD_FLAGS) -static -o $@
-$(TARGET)-dbg: $(TARGET).odbg ../m0/mutator_aux.odbg ../tinyxml2/tinyxml2.odbg linenoise.odbg CompletionHints.odbg mutagen.o ORCmutation.o bruiserffi.odbg asmrewriter.odbg bruisercapstone.odbg ramdump.odbg ffs.odbg $(LIB_LUA) $(TBG_OBJLIST_DBG_INC)
+$(TARGET)-dbg: $(TARGET).odbg $(FT_WASM_A_DBG) $(LTG_WASM_A_DBG) ../m0/mutator_aux.odbg ../tinyxml2/tinyxml2.odbg linenoise.odbg CompletionHints.odbg mutagen.o ORCmutation.o bruiserffi.odbg asmrewriter.odbg bruisercapstone.odbg ramdump.odbg ffs.odbg $(LIB_LUA)
$(CXX) $^ $(LD_FLAGS) -g -o $@
-$(TARGET)-cov: $(TARGET).ocov ../m0/mutator_aux.ocov ../tinyxml2/tinyxml2.ocov linenoise.ocov CompletionHints.ocov mutagen.o ORCmutation.o bruiserffi.ocov asmrewriter.ocov bruisercapstone.ocov ramdump.ocov ffs.ocov $(LIB_LUA) $(TBG_OBJLIST_COV_INC)
+$(TARGET)-cov: $(TARGET).ocov $(FT_WASM_A_COV) $(LTG_WASM_A_COV) ../m0/mutator_aux.ocov ../tinyxml2/tinyxml2.ocov linenoise.ocov CompletionHints.ocov mutagen.o ORCmutation.o bruiserffi.ocov asmrewriter.ocov bruisercapstone.ocov ramdump.ocov ffs.ocov $(LIB_LUA)
$(CXX) $^ $(LD_FLAGS) $(COV_LD) -o $@
cov:
@@ -209,9 +242,11 @@ tags:$(SRCS)
%.dis: %.o
objdump -r -d -M intel -S $< > $@
+#FIXME
$(TARGET).so: $(TARGET).o ../m0/mutator_aux.o ../tinyxml2/tinyxml2.o linenoise.o CompletionHints.o mutagen.o ORCmutation.o bruiserffi.o asmrewriter.o bruisercapstone.o ramdump.o ffs.o $(LIB_LUA) $(TBG_OBJLIST_INC)
$(CXX) $^ $(LD_FLAGS) -shared -o $@
+#FIXME
$(TARGET).a: $(TARGET).o ../m0/mutator_aux.o ../tinyxml2/tinyxml2.o linenoise.o CompletionHints.o mutagen.o ORCmutation.o bruiserffi.o asmrewriter.o bruisercapstone.o ramdump.o ffs.o $(LIB_LUA) $(TBG_OBJLIST_INC)
ar rcs $(TARGET).a $(TARGET).o
@@ -221,6 +256,9 @@ runcov: $(TARGET)-cov
valgrind: $(TARGET)
- valgrind --leak-check=yes $(TARGET) --lua ./lua-scripts/regtest.lua
+debug: $(TARGET)-dbg
+ gdb --args --lua ./lua-scripts/wasmtest.lua $(TARGET)-dbg
+
clean:
rm -f *.o *.dis *.odbg *.ocov *~ $(TARGET) $(TARGET).so $(TARGET)-static $(TARGET)-dbg $(TARGET).a $(TARGET)-cov
diff --git a/bruiser/tablegen b/bruiser/tablegen
-Subproject 9ca06ce6baaa38010af869096cd498ffbf24de9
+Subproject dc20e9040f652dd327af9aef3a66a4a6f106333