aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2018-06-09 23:33:16 +0000
committerbloodstalker <thabogre@gmail.com>2018-06-09 23:33:16 +0000
commite81de6189127845b5cec3e29b0effae5a7a7e7c6 (patch)
tree4d6de042319de82464a3df80c0a2d00c8fb6aaeb
parentmissed the json file for the test (diff)
downloadmutator-e81de6189127845b5cec3e29b0effae5a7a7e7c6.tar.gz
mutator-e81de6189127845b5cec3e29b0effae5a7a7e7c6.zip
the codegen is working now. the generated codes will not be part of the repo for the time being. they will be generated during the build process.
Diffstat (limited to '')
-rw-r--r--bruiser/bruiser.cpp6
-rw-r--r--bruiser/defaults.lua3
-rw-r--r--bruiser/lua-scripts/asmtest.lua4
-rw-r--r--bruiser/luatablegen/makefile34
-rw-r--r--bruiser/makefile11
-rw-r--r--bruiser/wasm.h13
-rwxr-xr-xbruiser/wasm/dwasm.py38
-rwxr-xr-xextra-tools/luatablegen.py121
-rwxr-xr-xextra-tools/tablegen-test/run.sh10
-rw-r--r--extra-tools/wasmtablegen.json56
-rw-r--r--makefile1
-rw-r--r--mutator_aux.cpp114
12 files changed, 261 insertions, 150 deletions
diff --git a/bruiser/bruiser.cpp b/bruiser/bruiser.cpp
index 7b3864d..b38327e 100644
--- a/bruiser/bruiser.cpp
+++ b/bruiser/bruiser.cpp
@@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*
#include "asmrewriter.h"
#include "ramdump.h"
#include "ffs.h"
+#include "./luatablegen/wasm_tables.h"
/*standard headers*/
#include <exception>
#include <fstream>
@@ -254,6 +255,10 @@ class LuaEngine
lua_pop(LS, 1);
}
+ void registerAutogenTables(void) {
+ reg_tablegen_tables(LS);
+ }
+
void RunLuaDefaults(void) {
char buf[500];
std::string bruiser_path;
@@ -2305,6 +2310,7 @@ int main(int argc, const char **argv) {
LE.LoadEverylib();
LE.RunLuaDefaults();
LE.registerJMPTable();
+ LE.registerAutogenTables();
void* lua_e_p = lua_getextraspace_wrapper(LE.GetLuaState(), 0);
void* lua_e_p2 = lua_getextraspace_wrapper(LE.GetLuaState(), 1);
RunLoop runloop(LE.GetLuaState(), LE);
diff --git a/bruiser/defaults.lua b/bruiser/defaults.lua
index d0e91d4..8f1692b 100644
--- a/bruiser/defaults.lua
+++ b/bruiser/defaults.lua
@@ -1,5 +1,8 @@
-- bruiser default script.
-- This is run everytime bruiser is called.
+-- By default bruiser will look for a file named defaults.lua in the same
+-- directory as its executable. you can change the file using the --luadefault
+-- option.
-- adds luarocks' path and cpath to bruiser
function default_luarocks_modules()
diff --git a/bruiser/lua-scripts/asmtest.lua b/bruiser/lua-scripts/asmtest.lua
index ac5730e..d7c0583 100644
--- a/bruiser/lua-scripts/asmtest.lua
+++ b/bruiser/lua-scripts/asmtest.lua
@@ -1,6 +1,6 @@
-xobj = require("lua-scripts.xobj")
-asmrw = require("lua-scripts.asmrw")
+xobj = require("xobj")
+asmrw = require("asmrw")
function test()
local elf_exe = "../bfd/test/test"
diff --git a/bruiser/luatablegen/makefile b/bruiser/luatablegen/makefile
new file mode 100644
index 0000000..937902b
--- /dev/null
+++ b/bruiser/luatablegen/makefile
@@ -0,0 +1,34 @@
+CC=clang
+CC?=clang
+CC_FLAGS=
+CC_EXTRA?=
+CC_FLAGS+=$(CC_EXTRA)
+SRCS=$(wildcard *.c)
+TBG_OBJLIST=$(patsubst %.c, %.o , $(wildcard *.c))
+
+.DEFAULT:all
+
+.PHONY:all clean help
+
+all:$(TBG_OBJLIST)
+ @echo $(TBG_OBJLIST)
+ @echo $(TBG_OBJLIST_INC)
+
+depend:.depend
+
+.depend:$(SRCS)
+ rm -rf .depend
+ $(CC) -MM $(CC_FLAGS) $^ > ./.depend
+
+-include ./.depend
+
+.c.o:
+ $(CC) $(CC_FLAGS) -c $< -o $@
+
+clean:
+ rm -f *.o *~ $(TARGET)
+ rm .depend
+
+help:
+ @echo "all is the default target"
+ @echo "there is clean."
diff --git a/bruiser/makefile b/bruiser/makefile
index d6682c9..3f38539 100644
--- a/bruiser/makefile
+++ b/bruiser/makefile
@@ -17,10 +17,11 @@ C_SRCS=$(wildcard *.c)
#for some reason without ld the build fails on ubuntu trusty on travis
#EXTRA_LD_FLAGS+=-lpthread -ldl -lutil -lm -Xlinker -lpython3
EXTRA_LD_FLAGS+=$(shell $(PY_CONF) --ldflags) -lffi -lcapstone -lkeystone -L./lua-5.3.4/src -llua
+TBG_OBJLIST_INC=$(patsubst ./luatablegen/%.c, ./luatablegen/%.o, $(wildcard ./luatablegen/*.c))
######################################RULES####################################
.DEFAULT: all
-.PHONY: all clean help
+.PHONY: all clean help tablegen
all: $(BRUISER)
@@ -45,6 +46,10 @@ dependc:.dependc
linenoise.o:
$(CC) $(CC_FLAGS) linenoise/linenoise.c -c -o linenoise.o
+tablegen:
+ ../extra-tools/tablegen-test/run.sh
+ $(MAKE) -C luatablegen
+
$(LIB_LUA):
$(MAKE) -C lua-5.3.4/src linux a
@echo "building with vanilla"
@@ -53,13 +58,14 @@ $(LIB_LUA_JIT):
$(MAKE) -C LuaJIT
@echo "building with jit"
-$(BRUISER): $(BRUISER).o ../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)
+$(BRUISER): $(BRUISER).o ../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) -o $@
clean:
rm -f *.o *~ $(BRUISER)
rm .depend
rm .dependc
+ $(MAKE) -C luatablegen clean
deepclean:
rm -f *.o *~ $(BRUISER)
@@ -67,6 +73,7 @@ deepclean:
rm .dependc
$(MAKE) -C lua-5.3.4 clean
$(MAKE) -C LuaJIT clean
+ $(MAKE) -C luatablegen clean
help:
@echo 'there is help.'
diff --git a/bruiser/wasm.h b/bruiser/wasm.h
index ec68553..5c21c99 100644
--- a/bruiser/wasm.h
+++ b/bruiser/wasm.h
@@ -97,7 +97,7 @@ typedef int32_t varuint32;
}W_Import_Section_Entry;
typedef struct {
- int count;
+ varuint32 count;
W_Import_Section_Entry** entries;
}W_Import_Section;
@@ -119,7 +119,7 @@ typedef int32_t varuint32;
typedef struct {
global_type_t* type;
- init_expr_t init;
+ init_expr_t* init;
}W_Global_Entry;
typedef struct {
@@ -131,7 +131,7 @@ typedef int32_t varuint32;
varuint32 field_len;
char* field_str;
enum external_kind_t kind;
- int varuint32;
+ varuint32 index;
}W_Export_Entry;
typedef struct {
@@ -145,7 +145,7 @@ typedef int32_t varuint32;
typedef struct {
varuint32 index;
- init_expr_t offset;
+ init_expr_t* offset;
varuint32 num_length;
varuint32* elems;
}W_Elem_Segment;
@@ -175,14 +175,14 @@ typedef int32_t varuint32;
typedef struct {
varuint32 index;
- init_expr_t offset;
+ init_expr_t* offset;
varuint32 size;
char* data;
}W_Data_Segment;
typedef struct {
varuint32 count;
- struct W_Data_Segment** entries;
+ W_Data_Segment** entries;
}W_Data_Section;
#if 0
@@ -192,6 +192,7 @@ typedef int32_t varuint32;
#endif
typedef struct Wasm_Module {
+ W_Type_Section* type_section;
W_Import_Section* import_section;
W_Function_Section* function_section;
W_Table_Section* table_section;
diff --git a/bruiser/wasm/dwasm.py b/bruiser/wasm/dwasm.py
index 93217b4..28f3c4d 100755
--- a/bruiser/wasm/dwasm.py
+++ b/bruiser/wasm/dwasm.py
@@ -5,45 +5,9 @@ import code
import readline
import signal
import sys
-from parse import premain
+from parse import Argparser, premain, SigHandler_SIGINT
from utils import ParseFlags
-def SigHandler_SIGINT(signum, frame):
- print()
- sys.exit(0)
-
-class Argparser(object):
- def __init__(self):
- parser = argparse.ArgumentParser()
- parser.add_argument("--wast", type=str, help="path to the wasm text file")
- parser.add_argument("--wasm", type=str, nargs='+', help="path to the wasm object file")
- parser.add_argument("--asb", type=str, help="path to the wast file to assemble")
- parser.add_argument("--dis", type=str, help="path to the wasm file to disassemble")
- parser.add_argument("-o", type=str, help="the path to the output file")
- parser.add_argument("--dbg", action='store_true', help="print debug info", default=False)
- parser.add_argument("--unval", action='store_true', help="skips validation tests", default=False)
- parser.add_argument("--memdump", type=int, help="dumps the linear memory")
- parser.add_argument("--idxspc", action='store_true', help="print index space data", default=False)
- parser.add_argument("--run", action='store_true', help="runs the start function", default=False)
- parser.add_argument("--metric", action='store_true', help="print metrics", default=False)
- parser.add_argument("--gas", action='store_true', help="print gas usage", default=False)
- parser.add_argument("--entry", type=str, help="name of the function that will act as the entry point into execution")
- parser.add_argument("--link", type=str, nargs="+", help="link the following wasm modules")
- parser.add_argument("--sectiondump", type=str, help="dumps the section provided")
- parser.add_argument("--hexdump", type=int, help="dumps all sections")
- parser.add_argument("--dbgsection", type=str, help="dumps the parsed section provided", default="")
- parser.add_argument("--interactive", action='store_true', help="open in cli mode", default=False)
- parser.add_argument("--rawdump", type=int, nargs=2, help="dumps all sections")
- self.args = parser.parse_args()
- if self.args.wasm is not None and self.args.wast is not None:
- raise Exception("the --wast option and the --wasm option cannot\
- be set at the same time. you need to choose one.")
-
- def getParseFlags(self):
- return(ParseFlags(self.args.wast, self.args.wasm, self.args.asb, self.args.dis,
- self.args.o, self.args.dbg, self.args.unval, self.args.memdump,
- self.args.idxspc, self.args.run, self.args.metric, self.args.gas, self.args.entry))
-
def main():
signal.signal(signal.SIGINT, SigHandler_SIGINT)
argparser = Argparser()
diff --git a/extra-tools/luatablegen.py b/extra-tools/luatablegen.py
index a4569ca..7443c39 100755
--- a/extra-tools/luatablegen.py
+++ b/extra-tools/luatablegen.py
@@ -62,10 +62,20 @@ TABLE_REGISTER = ['int XXX_register(lua_State* __ls) {\n',
SOURCE_FILE_NAME='XXX_luatablegen.c'
HEADER_FILE_NAME='XXX_luatablegen.h'
+LUA_LIB = ["local wasm = {}\n\n", "return wasm\n"]
+LUA_SETMETA_NEW = ["setmetatable(XXX, {__call =\n", "\tfunction(selfAAA)\n",
+ "\t\tlocal t = self.new(AAA)\n", "\t\treturn t\n\tend\n\t}\n)\n"]
+
def SigHandler_SIGINT(signum, frame):
print()
sys.exit(0)
+def get_filename(filename):
+ if filename[-1] == "/":
+ c_source = filename + c_filename
+ else:
+ c_source = "/" + c_filename
+
class Argparser(object):
def __init__(self):
parser = argparse.ArgumentParser()
@@ -75,14 +85,21 @@ class Argparser(object):
parser.add_argument("--post", type=str, help="path to source code file to add before header guard/extern c end")
parser.add_argument("--luaheader", type=str, help="path to lua header files")
parser.add_argument("--dbg", action="store_true", help="debug", default=False)
+ parser.add_argument("--singlefile", action="store_true", help="should all the generated code be added to a single file", default=False)
+ parser.add_argument("--makemacro", action="store_true", help="generate a makefile containing all objects in a macro to be included by abother makefile", default=False)
+ parser.add_argument("--outfile", type=str, help="name of the output file if signlefile is set, ignored otherwise")
+ parser.add_argument("--headeraggr", type=str, help="header aggregate file name")
+ parser.add_argument("--lualibpath", type=str, help="where the lua module file will be placed")
self.args = parser.parse_args()
class TbgParser(object):
- def __init__(self, tbg, out, argparser):
- self.tbg_file = json.load(open(tbg))
+ def __init__(self, argparser):
+ self.tbg_file = json.load(open(argparser.args.tbg))
self.argparser = argparser
- def begin(self, c_source, h_filename, struct_name):
+ def begin(self, c_source, struct_name, h_filename, is_source):
+ c_source.write("\n")
+ c_source.write("// automatically generated by luatablegen\n")
for header in HEADER_LIST:
if self.argparser.args.luaheader:
c_source.write(header.replace("HHH", self.argparser.args.luaheader+"/"))
@@ -90,14 +107,14 @@ class TbgParser(object):
c_source.write(header.replace("HHH", ""))
c_source.write(HEADER_GUARD[0].replace("XXX", struct_name))
c_source.write(EXTERN_C[0])
- #c_source.write('#include "./'+h_filename+'"\n')
+ if is_source: c_source.write("#include " + '"./' +h_filename+ '"\n')
c_source.write("\n")
if self.argparser.args.pre:
pre_file = open(self.argparser.args.pre)
for line in pre_file:
c_source.write(line)
+ pre_file.close()
c_source.write("\n")
- pre_file.close()
def struct(self, c_source, field_names, field_types, struct_name):
c_source.write("typedef struct {\n")
@@ -148,7 +165,7 @@ class TbgParser(object):
if lua_type == "integer": dummy = "\t"+field_type +" "+field_name+" = "+"luaL_optinteger(__ls,"+repr(rev_counter)+",0);\n"
elif lua_type == "lightuserdata": dummy = "\t"+field_type +" "+field_name+" = "+"lua_touserdata(__ls,"+repr(rev_counter)+");\n"
elif lua_type == "number": pass
- elif lua_type == "string":dummy = "\t"+field_type +" "+field_name+" = "+"lua_tostring(__ls,"+repr(rev_counter)+",0);\n"
+ elif lua_type == "string":dummy = "\t"+field_type +" "+field_name+" = "+"lua_tostring(__ls,"+repr(rev_counter)+");\n"
elif lua_type == "boolean": pass
else:
print("bad lua_type entry in the json file")
@@ -230,26 +247,61 @@ class TbgParser(object):
post_file = open(self.argparser.args.post)
for line in post_file:
c_source.write(line)
+ post_file.clsoe()
c_source.write("\n")
c_source.write(EXTERN_C[1])
c_source.write(HEADER_GUARD[1])
c_source.write("\n")
+ def luagen(self):
+ l_source = open(self.argparser.args.lualibpath, "w")
+ l_source.write("-- automatically generated by luatablegen\n")
+ l_source.write(LUA_LIB[0])
+ for k, v in self.tbg_file.items():
+ struct_name = k
+ field_names = v['field_name']
+ field_types = v['field_type']
+ lua_types = v['lua_type']
+ methods = v['methods']
+ l_source.write(LUA_SETMETA_NEW[0].replace("XXX", struct_name))
+ arg_list_str = str()
+ for i in range(0, len(field_names)):
+ arg_list_str += ", arg" + repr(i)
+ l_source.write(LUA_SETMETA_NEW[1].replace("AAA", arg_list_str))
+ l_source.write(LUA_SETMETA_NEW[2].replace("AAA", arg_list_str[2:]))
+ l_source.write(LUA_SETMETA_NEW[3])
+ arg_list_str = str()
+ l_source.write("\n")
+
+ l_source.write(LUA_LIB[1])
+
def run(self):
+ header_aggr_list = []
+ table_reg_list = []
+ if self.argparser.args.singlefile:
+ c_source = open(self.argparser.args.outfile, "w")
for k, v in self.tbg_file.items():
struct_name = k
field_names = v['field_name']
field_types = v['field_type']
lua_types = v['lua_type']
methods = v['methods']
- c_filename = struct_name + "_tablegen.h"
- h_filename = struct_name + "_tablegen.h"
- if self.argparser.args.out[-1] == "/":
- c_source = open(self.argparser.args.out + c_filename, "w")
- else:
- c_source = open(self.argparser.args.out + "/" + c_filename, "w")
- self.begin(c_source, h_filename, struct_name)
- self.struct(c_source, field_names, field_types, struct_name)
+ if not self.argparser.args.singlefile:
+ c_filename = struct_name + "_tablegen.c"
+ h_filename = struct_name + "_tablegen.h"
+ if self.argparser.args.out[-1] == "/":
+ c_source = open(self.argparser.args.out + c_filename, "w")
+ header_aggr_list.append("./" + h_filename)
+ h_source = open(self.argparser.args.out + h_filename, "w")
+ else:
+ c_source = open(self.argparser.args.out + "/" + c_filename, "w")
+ header_aggr_list.append("./" + h_filename)
+ h_source = open(self.argparser.args.out + "/" + h_filename, "w")
+ # source file
+ # TODO - the c source file is getting a header guard and cpp
+ # inclusion macros
+ self.begin(c_source, struct_name, h_filename, True)
+ #self.struct(c_source, field_names, field_types, struct_name)
self.convert(c_source, struct_name)
self.check(c_source, struct_name)
self.push_self(c_source, struct_name)
@@ -261,13 +313,50 @@ class TbgParser(object):
self.register_table_meta(c_source, struct_name)
self.register_table(c_source, struct_name)
self.end(c_source)
- c_source.close()
+ if not self.argparser.args.singlefile: c_source.close()
+ # header file
+ self.begin(h_source, struct_name, h_filename, False)
+ h_source.write(CONVERT[0].replace("XXX", struct_name).replace(" {\n", ";\n"))
+ h_source.write(CHECK[0].replace("XXX", struct_name).replace(" {\n", ";\n"))
+ h_source.write(PUSH_SELF[0].replace("XXX", struct_name).replace(" {\n", ";\n"))
+ h_source.write(PUSH_ARGS[0].replace("XXX", struct_name).replace(" {\n", ";\n"))
+ h_source.write(NEW[0].replace("XXX", struct_name).replace(" {\n", ";\n"))
+ for field_name, lua_type in zip(field_names, lua_types):
+ h_source.write(GETTER_GEN[0].replace("XXX", struct_name).replace("YYY", field_name).replace(" {\n", ";\n"))
+ for field_name, lua_type in zip(field_names, lua_types):
+ h_source.write(SETTER_GEN[0].replace("XXX", struct_name).replace("YYY", field_name).replace(" {\n", ";\n"))
+ table_reg_list.append(struct_name + "_register(__ls);\n")
+ h_source.write(TABLE_REGISTER[0].replace("XXX", struct_name).replace(" {\n", ";\n"))
+ self.end(h_source)
+ if self.argparser.args.headeraggr:
+ aggr_header = open(self.argparser.args.headeraggr, "w")
+ aggr_header.write(HEADER_GUARD[0].replace("XXX", "WASM_TABLES_AGGR"))
+ aggr_header.write(EXTERN_C[0])
+ aggr_header.write("\n")
+ for item in header_aggr_list:
+ aggr_header.write("#include " + '"' + item + '"\n')
+ aggr_header.write("\n")
+ aggr_header.write("void reg_tablegen_tables(lua_State* __ls) {\n")
+ for func_sig in table_reg_list:
+ aggr_header.write("\t" + func_sig)
+ aggr_header.write("\t" + "lua_pop(__ls, 1);\n")
+ aggr_header.write("}\n")
+ aggr_header.write(EXTERN_C[1])
+ aggr_header.write(HEADER_GUARD[1])
+ aggr_header.write("\n")
+ if self.argparser.args.makemacro:
+ if self.argparser.args.out[-1] == "/":
+ m_source = open(self.argparser.args.out + "tablegen.mk", "w")
+ else:
+ m_source = open(self.argparser.args.out + "/" + "tablegen.mk", "w")
+ # generate lua module
+ self.luagen()
# write code here
def premain(argparser):
signal.signal(signal.SIGINT, SigHandler_SIGINT)
#here
- parser = TbgParser(argparser.args.tbg, argparser.args.out, argparser)
+ parser = TbgParser(argparser)
parser.run()
def main():
diff --git a/extra-tools/tablegen-test/run.sh b/extra-tools/tablegen-test/run.sh
index f9eda4d..c70e23b 100755
--- a/extra-tools/tablegen-test/run.sh
+++ b/extra-tools/tablegen-test/run.sh
@@ -1,4 +1,10 @@
#!/usr/bin/bash
cd $(dirname $0)
-../luatablegen.py --tbg ../wasmtablegen.json --out ./ --luaheader ../../bruiser/lua-5.3.4/src --pre ./pre.txt --post ./post.txt
-less ./jmp_s_t_tablegen.h
+../luatablegen.py --tbg ../wasmtablegen.json --out ../../bruiser/luatablegen --luaheader ../../bruiser/lua-5.3.4/src --pre ./wasmheader.txt --headeraggr ../../bruiser/luatablegen/wasm_tables.h --lualibpath ../../bruiser/lua-scripts/wasm.lua
+#../luatablegen.py --tbg ../wasmtablegen.json --out ../../bruiser/luatablegen --luaheader ../../bruiser/lua-5.3.4/src --pre ./wasmheader.txt --singlefile --outfile ../../bruiser/luatablegen/wasmtablegen.h
+for filename in ../../bruiser/luatablegen/*.c; do
+ gcc -c $filename > /dev/null 2>&1
+ if [[ $? != 0 ]]; then
+ echo $filename did not compile.
+ fi
+done
diff --git a/extra-tools/wasmtablegen.json b/extra-tools/wasmtablegen.json
index 8647c57..38fe5a7 100644
--- a/extra-tools/wasmtablegen.json
+++ b/extra-tools/wasmtablegen.json
@@ -1,5 +1,51 @@
-{"jmp_s_t": {"field_name": ["type", "location", "size", "next", "next_y", "next_n", "address", "address_y", "address_n", "y", "n", "z"],
- "field_type": ["JMP_T", "uint64_t", "uint8_t", "struct jmp_s_t*", "struct jmp_s_t*", "struct jmp_s_t*", "uint64_t", "uint64_t", "uint64_t", "bool", "bool", "bool"],
- "methods": ["convert", "check", "push_self","push_args", "new", "gc", "tostring" ],
- "lua_type": ["integer", "integer", "integer", "lightuserdata", "lightuserdata", "lightuserdata", "integer", "integer", "integer", "integer", "integer", "integer"]
-}}
+{ "init_expr_t":
+ {"field_name": ["size", "code"], "field_type": ["varuint32", "char*"], "lua_type": ["integer", "string"], "methods": ["convert", "check", "push_self", "push_args", "new"]},
+ "resizable_limit_t":
+ {"field_name":["flags", "initial", "maximum"], "field_type": ["varuint1", "varuint32", "varuint32"], "lua_type": ["integer", "integer", "integer"], "methods":["convert", "check", "push_self", "push_args", "new"]},
+ "global_type_t":
+ {"field_name": ["value_type", "mutability"], "field_type": ["enum value_type_t", "varuint1"], "lua_type":["integer", "integer"], "methods":["convert", "check", "push_self", "push_args", "new"]},
+ "table_type_t":
+ {"field_name": ["element_type", "resizable_limit"],"field_type": ["varint7", "resizable_limit_t*"], "lua_type":["integer", "lightuserdata"], "methods":["convert", "check", "push_self", "push_args", "new"]},
+ "memory_type_t":
+ {"field_name":["resizable_limit"], "field_type":["resizable_limit_t*"], "lua_type":["lightuserdata"], "methods":["convert", "check", "push_self", "push_args", "new"]},
+ "W_Type_Section_Entry":
+ {"field_name": ["form", "param_count", "param_types", "return_count", "return_types"], "field_type":["varint7", "varuint32", "varint7*", "varuint1", "varint7*"], "lua_type":["integer", "integer", "lightuserdata", "integer", "lightuserdata"], "methods":["convert", "check", "push_self", "push_args","new"]},
+ "W_Type_Section":
+ {"field_name":["count", "entries"], "field_type": ["varuint32", "W_Type_Section_Entry**"], "lua_type":["integer", "lightuserdata"], "methods":["convert", "check", "push_self", "push_args", "new"]},
+ "W_Import_Section_Entry":
+ {"field_name":["module_length", "module_str", "field_len", "field_str", "kind", "type"], "field_type":["varuint32", "char*", "varuint32", "char*", "enum external_kind_t", "void*"], "lua_type": ["integer", "string", "integer", "string", "integer", "lightuserdata"], "methods": ["convert", "check", "push_self", "push_args", "new"]},
+ "W_Import_Section":
+ {"field_name":["count", "entries"], "field_type":["varuint32","W_Import_Section**"], "lua_type":["integer", "lightuserdata"], "methods":["convert", "check", "push_self", "push_args", "new"]},
+ "W_Function_Section":
+ {"field_name":["count", "types"], "field_type":["varuint32", "varuint32*"], "lua_type":["integer", "lightuserdata"], "methods":["convert", "check", "push_self", "push_args", "new"]},
+ "W_Table_Section":
+ {"field_name":["count", "entries"], "field_type":["varuint32", "table_type_t**"], "lua_type":["integer", "lightuserdata"], "methods":["convert", "check", "push_self", "push_args", "new"]},
+ "W_Memory_Section":
+ {"field_name":["count", "entries"], "field_type":["varuint32", "memory_type_t**"], "lua_type":["integer", "lightuserdata"], "methods":["convert", "check", "push_self", "push_args", "new"]},
+ "W_Global_Entry":
+ {"field_name":["type", "init"], "field_type":["global_type_t*", "init_expr_t*"], "lua_type":["lightuserdata", "lightuserdata"], "methods":["convert", "check", "push_self", "push_args", "new"]},
+ "W_Global_Section":
+ {"field_name":["count", "globals"], "field_type":["varuint32", "W_Global_Entry**"], "lua_type":["integer", "lightuserdata"], "methods":["convert", "check", "push_self", "push_args", "new"]},
+ "W_Export_Entry":
+ {"field_name":["field_len", "field_str", "kind", "index"], "field_type":["varuint32", "char*", "enum external_kind_t", "varuint32"], "lua_type":["integer", "string", "integer", "integer"], "methods":["convert", "check", "push_self", "push_args", "new"]},
+ "W_Export_Section":
+ {"field_name":["count", "entries"], "field_type": ["varuint32", "W_Export_Entry**"], "lua_type":["integer", "lightuserdata"], "methods":["convert", "check", "push_self", "push_args", "new"]},
+ "W_Start_Section":
+ {"field_name":["index"], "field_type":["varuint32"], "lua_type":["integer"], "methods":["convert", "check", "push_self", "push_args", "new"]},
+ "W_Elem_Segment":
+ {"field_name":["index", "offset", "num_length", "elems"], "field_type":["varuint32", "init_expr_t*", "varuint32", "varuint32*"], "lua_type":["integer", "lightuserdata", "integer", "integer"], "methods": ["convert", "check", "push_self", "push_args", "new"]},
+ "W_Element_Section":
+ {"field_name":["count", "entries"], "field_type":["varuint32", "W_Elem_Segment**"], "lua_type":["integer", "lightuserdata"], "methods":["convert", "check", "push_self", "push_args", "new"]},
+ "W_Local_Entry":
+ {"field_name":["count", "type"], "field_type":["varuint32", "enum value_type_t"], "lua_type":["integer", "integer"], "methods":["convert", "check", "push_self", "push_args", "new"]},
+ "W_Function_Body":
+ {"field_name":["body_size", "local_count", "locals", "code"], "field_type":["varuint32", "varuint32", "W_Local_Entry**", "char*"], "lua_type":["integer", "integer", "lightuserdata", "string"], "methods": ["convert", "check", "push_self", "push_args", "new"]},
+ "W_Code_Section":
+ {"field_name":["count", "bodies"], "field_type":["varuint32", "W_Function_Body**"], "lua_type":["integer", "lightuserdata"], "methods":["convert", "check", "push_self", "push_args", "new"]},
+ "W_Data_Segment":
+ {"field_name":["index", "offset", "size", "data"], "field_type":["varuint32", "init_expr_t*", "varuint32", "char*"], "lua_type":["integer", "lightuserdata", "integer", "string"], "methods":["convert", "check", "push_self", "push_args", "new"]},
+ "W_Data_Section":
+ {"field_name": ["count", "entries"], "field_type":["varuint32", "W_Data_Segment**"], "lua_type":["integer", "lightuserdata"], "methods":["convert", "check", "push_self", "push_args", "new"]},
+ "Wasm_Module":
+ {"field_name":["type_section", "import_section", "function_section", "table_section", "memory_section", "global_section", "export_section", "start_section", "element_section", "code_section", "data_section", "W_Custom_Sections", "name"], "field_type":["W_Type_Section*", "W_Import_Section*", "W_Function_Section*", "W_Table_Section*", "W_Memory_Section*", "W_Global_Section*", "W_Export_Section*", "W_Start_Section*", "W_Element_Section*", "W_Code_Section*", "W_Data_Section*", "void**", "char*"], "lua_type":["lightuserdata", "lightuserdata", "lightuserdata", "lightuserdata", "lightuserdata", "lightuserdata", "lightuserdata", "lightuserdata", "lightuserdata", "lightuserdata", "lightuserdata", "lightuserdata","string"], "methods":["convert", "check", "push_self", "push_args", "new"]}
+}
diff --git a/makefile b/makefile
index 6449da3..6f511b4 100644
--- a/makefile
+++ b/makefile
@@ -48,6 +48,7 @@ $(SFCPP01):
$(MAKE) -C safercpp CXX=$(CXX) LLVM_CONF=$(LLVM_CONF) BUILD_MODE=$(BUILD_MODE)
$(BRUISER):
+ $(MAKE) -C bruiser tablegen bruiser CXX=$(CXX) LLVM_CONF=$(LLVM_CONF) BUILD_MODE=$(BUILD_MODE)
$(MAKE) -C bruiser CXX=$(CXX) LLVM_CONF=$(LLVM_CONF) BUILD_MODE=$(BUILD_MODE)
$(OBSC):
diff --git a/mutator_aux.cpp b/mutator_aux.cpp
index 665124b..a382764 100644
--- a/mutator_aux.cpp
+++ b/mutator_aux.cpp
@@ -36,50 +36,36 @@ using namespace clang;
namespace Devi {
/*a simple function that checks the sourcelocations for a macro expansion. returns the sourcelocation without
macro expansion address.*/
-SourceLocation SourceLocationHasMacro [[deprecated("doesnt work")]] (SourceLocation SL, Rewriter &Rewrite, std::string Kind)
-{
+#if 1
+SourceLocation SourceLocationHasMacro [[deprecated("doesnt work")]] (SourceLocation SL, Rewriter &Rewrite, std::string Kind) {
/*does the sourcelocation include a macro expansion?*/
- if ( SL.isMacroID() )
- {
+ if ( SL.isMacroID()) {
/*get the expansion range which is startloc and endloc*/
std::pair <SourceLocation, SourceLocation> expansionRange = Rewrite.getSourceMgr().getImmediateExpansionRange(SL);
-
- if (Kind == "start")
- {
+ if (Kind == "start") {
return (expansionRange.first);
- }
- else if (Kind == "end")
- {
+ } else if (Kind == "end") {
return (expansionRange.second);
- }
- else
- {
+ } else {
std::cout << "the third argument of Devi::SourceLocationHasMacro is invalid." << std::endl;
}
-
- }
- else
- {
+ } else {
return (SL);
}
-
return (SL);
}
+#endif
SourceLocation SourceLocationHasMacro(SourceLocation __sl, Rewriter &__rewrite)
{
- if (__sl.isMacroID())
- {
+ if (__sl.isMacroID()) {
return __rewrite.getSourceMgr().getSpellingLoc(__sl);
- }
- else
- {
+ } else {
return __sl;
}
}
-SourceLocation getSLSpellingLoc(SourceLocation __sl, Rewriter &__rewrite)
-{
+SourceLocation getSLSpellingLoc(SourceLocation __sl, Rewriter &__rewrite) {
if (__sl.isMacroID()) {return __rewrite.getSourceMgr().getSpellingLoc(__sl);}
else {return __sl;}
}
@@ -87,106 +73,74 @@ SourceLocation getSLSpellingLoc(SourceLocation __sl, Rewriter &__rewrite)
/*********************************************************************************************************************/
/*********************************************************************************************************************/
/*the first argument is the option SysHeader from the mutator-lvl0 cl.*/
-bool IsTheMatchInSysHeader(bool SysHeaderFlag, const ast_matchers::MatchFinder::MatchResult &MR, SourceLocation SL)
-{
+bool IsTheMatchInSysHeader(bool SysHeaderFlag, const ast_matchers::MatchFinder::MatchResult &MR, SourceLocation SL) {
ASTContext *const ASTC = MR.Context;
const SourceManager &SM = ASTC->getSourceManager();
- if (SM.isInSystemHeader(SL) && !SysHeaderFlag)
- {
+ if (SM.isInSystemHeader(SL) && !SysHeaderFlag) {
return true;
- }
- else
- {
+ } else {
return false;
}
}
-bool IsTheMatchInSysHeader(bool SysHeaderFlag, const SourceManager &SM, SourceLocation SL)
-{
- if (SM.isInSystemHeader(SL) && !SysHeaderFlag)
- {
+bool IsTheMatchInSysHeader(bool SysHeaderFlag, const SourceManager &SM, SourceLocation SL) {
+ if (SM.isInSystemHeader(SL) && !SysHeaderFlag) {
return true;
- }
- else
- {
+ } else {
return false;
}
}
-bool IsTheMatchInSysHeader(bool SysHeaderFlag, bool SysHeader, SourceLocation SL)
-{
- if (SysHeader && !SysHeaderFlag)
- {
+bool IsTheMatchInSysHeader(bool SysHeaderFlag, bool SysHeader, SourceLocation SL) {
+ if (SysHeader && !SysHeaderFlag) {
return true;
- }
- else
- {
+ } else {
return false;
}
}
bool IsTheMatchInSysHeader(bool SysHeaderFlag, bool SysHeader)
{
- if (SysHeader && !SysHeaderFlag)
- {
+ if (SysHeader && !SysHeaderFlag) {
return true;
- }
- else
- {
+ } else {
return false;
}
}
/*********************************************************************************************************************/
/*********************************************************************************************************************/
/*********************************************************************************************************************/
-bool IsTheMatchInMainFile(bool MainFileFlag, const ast_matchers::MatchFinder::MatchResult &MR, SourceLocation SL)
-{
+bool IsTheMatchInMainFile(bool MainFileFlag, const ast_matchers::MatchFinder::MatchResult &MR, SourceLocation SL) {
ASTContext *const ASTC = MR.Context;
const SourceManager &SM = ASTC->getSourceManager();
-
- if (SM.isInMainFile(SL) || (!SM.isInMainFile(SL) && !MainFileFlag))
- {
+ if (SM.isInMainFile(SL) || (!SM.isInMainFile(SL) && !MainFileFlag)) {
return true;
- }
- else
- {
+ } else {
return false;
}
}
-bool IsTheMatchInMainFile(bool MainFileFlag, const SourceManager &SM, SourceLocation SL)
-{
- if (SM.isInMainFile(SL) || (!SM.isInMainFile(SL) && !MainFileFlag))
- {
+bool IsTheMatchInMainFile(bool MainFileFlag, const SourceManager &SM, SourceLocation SL) {
+ if (SM.isInMainFile(SL) || (!SM.isInMainFile(SL) && !MainFileFlag)) {
return true;
- }
- else
- {
+ } else {
return false;
}
}
-bool IsTheMatchInMainFile(bool MainFileFlag, bool MainFile, SourceLocation SL)
-{
- if (MainFile || (!MainFile && !MainFileFlag))
- {
+bool IsTheMatchInMainFile(bool MainFileFlag, bool MainFile, SourceLocation SL) {
+ if (MainFile || (!MainFile && !MainFileFlag)) {
return true;
- }
- else
- {
+ } else {
return false;
}
}
-bool IsTheMatchInMainFile(bool MainFileFlag, bool MainFile)
-{
- if (MainFile || (!MainFile && !MainFileFlag))
- {
+bool IsTheMatchInMainFile(bool MainFileFlag, bool MainFile) {
+ if (MainFile || (!MainFile && !MainFileFlag)) {
return true;
- }
- else
- {
+ } else {
return false;
}
}