aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--README.md2
-rwxr-xr-xbruiser/autogen/wasm/ft.sh3
-rw-r--r--bruiser/autogen/wasm/ft/autowasm.c8
-rw-r--r--bruiser/autogen/wasm/ft/makefile34
-rw-r--r--bruiser/autogen/wasm/ltg/makefile2
-rw-r--r--bruiser/bruiser.cpp51
m---------bruiser/faultreiber0
-rw-r--r--bruiser/lua-scripts/wasmtest.lua142
m---------bruiser/tablegen0
-rw-r--r--m0/mutator-lvl0.cpp68
-rw-r--r--m0/mutator_aux.cpp2
-rw-r--r--obfuscator/compile_commands.json7
12 files changed, 249 insertions, 70 deletions
diff --git a/README.md b/README.md
index 1639a17..7623e80 100644
--- a/README.md
+++ b/README.md
@@ -175,7 +175,7 @@ Currently there is only the master branch which is the dev branch. All the as-of
### Building
#### Requirements
-* `LLVM/Clang` 5.0, 6.0 or 8.0(we will skip 7.0). For 8.0, the latest tested trunk version is 340121.<br/>
+* `LLVM/Clang` 5.0, 6.0 or 8.0(we will skip 7.0). For 8.0, the latest tested trunk version is 355787.<br/>
* `libffi`<br/>
* `libcapstone`<br/>
* `libkeystone`<br/>
diff --git a/bruiser/autogen/wasm/ft.sh b/bruiser/autogen/wasm/ft.sh
index a7f5ac6..71a4c20 100755
--- a/bruiser/autogen/wasm/ft.sh
+++ b/bruiser/autogen/wasm/ft.sh
@@ -1,5 +1,6 @@
#!/bin/sh
cd $(dirname $0)
"../../faultreiber/faultreiber.py" --name wasm --outdir ./ft/ --datetime --xml ./wasm.xml --calloc --voidtraininitsize 60 --voidtrainfactor 1.9
-#"clang-format" -i ./test/read.c ./test/structs.c ./test/structs.h ./test/aggregate.c ./test/aggregate.h ./test/read.h
+#"../../faultreiber/faultreiber.py" --name wasm --outdir ./ft/ --datetime --xml ./wasm.xml --luaalloc --voidtraininitsize 60 --voidtrainfactor 1.9 --luaheaders ../../../lua-5.3.4/src
+"clang-format" -i ./ft/read.c ./ft/structs.c ./ft/structs.h ./ft/aggregate.c ./ft/aggregate.h ./ft/read.h
#"less" ./test/structs.h
diff --git a/bruiser/autogen/wasm/ft/autowasm.c b/bruiser/autogen/wasm/ft/autowasm.c
index 42bf474..617bd42 100644
--- a/bruiser/autogen/wasm/ft/autowasm.c
+++ b/bruiser/autogen/wasm/ft/autowasm.c
@@ -9,12 +9,14 @@
#include "./aggregate.h"
#include "./read.h"
#include "./structs.h"
+#include "../../../lua-5.3.4/src/lua.h"
#pragma weak main
int main(int argc, char **argv) {
const rlim_t kStackSize = 160 * 1024 * 1024; // min stack size = 16 MB
struct rlimit rl;
int result;
+ lua_State* LS = luaL_newstate();
result = getrlimit(RLIMIT_STACK, &rl);
if (result == 0) {
@@ -27,10 +29,10 @@ int main(int argc, char **argv) {
}
}
int wasm = open("./test.wasm", O_RDONLY);
- wasm_lib_ret_t *lib_ret = read_aggr_wasm(wasm);
+#if 0
+ wasm_lib_ret_t *lib_ret = read_aggr_wasm(wasm, LS);
printf("finished reading\n");
-#if 0
printf("magic_number:%x\n",
lib_ret->obj->magic_number_container->magic_number);
printf("version:%x\n", lib_ret->obj->version_container->version);
@@ -240,6 +242,7 @@ int main(int argc, char **argv) {
// free(lib_ret->void_train[2]);
// free(lib_ret->void_train[1]);
// free(lib_ret->void_train[0]);
+#if 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;
@@ -248,5 +251,6 @@ int main(int argc, char **argv) {
free(lib_ret->void_train);
free(lib_ret->obj);
free(lib_ret);
+#endif
return 0;
}
diff --git a/bruiser/autogen/wasm/ft/makefile b/bruiser/autogen/wasm/ft/makefile
index b02dcfc..08e0ffe 100644
--- a/bruiser/autogen/wasm/ft/makefile
+++ b/bruiser/autogen/wasm/ft/makefile
@@ -1,13 +1,14 @@
+TARGET=autowasm
SHELL=bash
SHELL?=bash
-TARGET=autowasm
CC=clang
CC?=clang
-CC_FLAGS=-fpic
+CC_FLAGS= -fPIC
CC_EXTRA?=
CTAGS_I_PATH?=./
LD_FLAGS=
-EXTRA_LD_FLAGS?=
+LIB_LUA=../../../lua-5.3.4/src/liblua.a
+EXTRA_LD_FLAGS?=-lm -ldl
ADD_SANITIZERS_CC= -g -fsanitize=address -fno-omit-frame-pointer
ADD_SANITIZERS_LD= -g -fsanitize=address
MEM_SANITIZERS_CC= -g -fsanitize=memory -fno-omit-frame-pointer
@@ -62,8 +63,8 @@ depend:.depend
.depend:$(SRCS)
rm -rf .depend
$(CC) -MM $(CC_FLAGS) $^ > ./.depend
- echo $(patsubst %.o:, %.odbg:, $(shell $(CC) -MM $(CC_FLAGS) $^)) | sed -r 's/[a-z0-9\-\_]+\.odbg/\n&/g' >> ./.depend
- echo $(patsubst %.o:, %.ocov:, $(shell $(CC) -MM $(CC_FLAGS) $^)) | sed -r 's/[a-z0-9\-\_]+\.ocov/\n&/g' >> ./.depend
+ echo $(patsubst %.o:, %.odbg:, $(shell $(CC) -MM $(CC_FLAGS) $^)) | sed -r 's/[A-Za-z0-9\-\_]+\.odbg/\n&/g' >> ./.depend
+ echo $(patsubst %.o:, %.ocov:, $(shell $(CC) -MM $(CC_FLAGS) $^)) | sed -r 's/[A-Za-z0-9\-\_]+\.ocov/\n&/g' >> ./.depend
-include ./.depend
@@ -76,16 +77,19 @@ depend:.depend
%.ocov:%.c
$(CC) $(CC_FLAGS) $(COV_CC) -c $< -o $@
-$(TARGET): $(TARGET).o read.o aggregate.o structs.o
- $(CC) $^ $(LD_FLAGS) -o $@
+$(LIB_LUA):
+ $(MAKE) -C ../../../lua-5.3.4/src linux
+
+$(TARGET): $(TARGET).o $(LIB_LUA) read.o aggregate.o structs.o
+ $(CC) $(LD_FLAGS) $^ -o $@
-$(TARGET)-static: $(TARGET).o read.o aggregate.o structs.o
+$(TARGET)-static: $(TARGET).o $(LIB_LUA) read.o aggregate.o structs.o
$(CC) $^ $(LD_FLAGS) -static -o $@
-$(TARGET)-dbg: $(TARGET).odbg read.odbg aggregate.odbg structs.odbg
+$(TARGET)-dbg: $(TARGET).odbg $(LIB_LUA) read.odbg aggregate.odbg structs.odbg
$(CC) $^ $(LD_FLAGS) -g -o $@
-$(TARGET)-cov: $(TARGET).ocov read.ocov aggregate.ocov structs.ocov
+$(TARGET)-cov: $(TARGET).ocov $(LIB_LUA) read.ocov aggregate.ocov structs.ocov
$(CC) $^ $(LD_FLAGS) $(COV_LD) -o $@
cov:
@@ -117,13 +121,13 @@ tags:$(SRCS)
$(TARGET).so: $(TARGET).o read.o aggregate.o structs.o
$(CC) $^ $(LD_FLAGS) -shared -o $@
-$(TARGET).a: $(TARGET).o read.o aggregate.o structs.o
- ar rcs $(TARGET).a $(TARGET).o read.o aggregate.o structs.o
+$(TARGET).a: $(LIB_LUA) read.o aggregate.o structs.o
+ ar rcs $(TARGET).a 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).adbg: $(LIB_LUA) read.odbg aggregate.odbg structs.odbg
+ ar rcs $(TARGET).adbg read.odbg aggregate.odbg structs.odbg
-$(TARGET).acov: $(TARGET).ocov read.ocov aggregate.ocov structs.ocov
+$(TARGET).acov: $(LIB_LUA) read.ocov aggregate.ocov structs.ocov
ar rcs $(TARGET).acov $(TARGET).ocov read.ocov aggregate.ocov structs.ocov
valgrind: $(TARGET)
diff --git a/bruiser/autogen/wasm/ltg/makefile b/bruiser/autogen/wasm/ltg/makefile
index e21fdaf..41d6c5a 100644
--- a/bruiser/autogen/wasm/ltg/makefile
+++ b/bruiser/autogen/wasm/ltg/makefile
@@ -56,7 +56,7 @@ LD_FLAGS+=$(EXTRA_LD_FLAGS)
.PHONY:all clean help ASM SO TAGS
-all: A ADBG
+all:A ADBG
everything:$(TARGET) A ASM SO $(TARGET)-static $(TARGET)-dbg TAGS $(TARGET)-cov
diff --git a/bruiser/bruiser.cpp b/bruiser/bruiser.cpp
index 6e73a44..7081b2b 100644
--- a/bruiser/bruiser.cpp
+++ b/bruiser/bruiser.cpp
@@ -1424,6 +1424,7 @@ class LuaWrapper {
}
PRINT_WITH_COLOR_LB(RED, "before");
wasm_lib_ret_t* lib_ret = read_aggr_wasm(wasm_file);
+ //wasm_lib_ret_t* lib_ret = read_aggr_wasm(wasm_file, __ls);
PRINT_WITH_COLOR_LB(RED, "after");
close(wasm_file);
@@ -1535,6 +1536,7 @@ class LuaWrapper {
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("number:%d\n", i+1);
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");
@@ -1564,7 +1566,7 @@ class LuaWrapper {
new_magic_number(__ls);
lua_settable(__ls, -3);
}
- //PRINT_WITH_COLOR_LB(BLUE, "magic");
+ PRINT_WITH_COLOR_LB(BLUE, "magic");
if (lib_ret->obj->w32_version_container != NULL) {
lua_pushstring(__ls, "version");
@@ -1572,7 +1574,7 @@ class LuaWrapper {
new_w32_version(__ls);
lua_settable(__ls, -3);
}
- //PRINT_WITH_COLOR_LB(BLUE, "version");
+ PRINT_WITH_COLOR_LB(BLUE, "version");
if (lib_ret->obj->W_Type_Section_container != NULL) {
lua_pushstring(__ls, "type_section");
@@ -1580,7 +1582,7 @@ class LuaWrapper {
new_W_Type_Section(__ls);
lua_settable(__ls, -3);
}
- //PRINT_WITH_COLOR_LB(BLUE, "type section");
+ PRINT_WITH_COLOR_LB(BLUE, "type section");
if (lib_ret->obj->W_Import_Section_container != NULL) {
lua_pushstring(__ls, "import_section");
@@ -1588,7 +1590,7 @@ class LuaWrapper {
new_W_Import_Section(__ls);
lua_settable(__ls, -3);
}
- //PRINT_WITH_COLOR_LB(BLUE, "import section");
+ PRINT_WITH_COLOR_LB(BLUE, "import section");
if (lib_ret->obj->W_Function_Section_container != NULL) {
lua_pushstring(__ls, "function_section");
@@ -1596,7 +1598,7 @@ class LuaWrapper {
new_W_Function_Section(__ls);
lua_settable(__ls, -3);
}
- //PRINT_WITH_COLOR_LB(BLUE, "function section");
+ PRINT_WITH_COLOR_LB(BLUE, "function section");
if (lib_ret->obj->W_Table_Section_container != NULL) {
lua_pushstring(__ls, "table_section");
@@ -1604,7 +1606,7 @@ class LuaWrapper {
new_W_Table_Section(__ls);
lua_settable(__ls, -3);
}
- //PRINT_WITH_COLOR_LB(BLUE, "table section");
+ PRINT_WITH_COLOR_LB(BLUE, "table section");
if (lib_ret->obj->W_Memory_Section_container != NULL) {
lua_pushstring(__ls, "memory_section");
@@ -1612,7 +1614,7 @@ class LuaWrapper {
new_W_Memory_Section(__ls);
lua_settable(__ls, -3);
}
- //PRINT_WITH_COLOR_LB(BLUE, "memory section");
+ PRINT_WITH_COLOR_LB(BLUE, "memory section");
if (lib_ret->obj->W_Global_Section_container != NULL) {
lua_pushstring(__ls, "global_section");
@@ -1620,7 +1622,7 @@ class LuaWrapper {
new_W_Global_Section(__ls);
lua_settable(__ls, -3);
}
- //PRINT_WITH_COLOR_LB(BLUE, "global section");
+ PRINT_WITH_COLOR_LB(BLUE, "global section");
if (lib_ret->obj->W_Export_Section_container != NULL) {
lua_pushstring(__ls, "export_section");
@@ -1628,7 +1630,7 @@ class LuaWrapper {
new_W_Export_Section(__ls);
lua_settable(__ls, -3);
}
- //PRINT_WITH_COLOR_LB(BLUE, "export section");
+ PRINT_WITH_COLOR_LB(BLUE, "export section");
if (lib_ret->obj->W_Start_Section_container != NULL) {
lua_pushstring(__ls, "start_section");
@@ -1636,7 +1638,7 @@ class LuaWrapper {
new_W_Start_Section(__ls);
lua_settable(__ls, -3);
}
- //PRINT_WITH_COLOR_LB(BLUE, "start section");
+ PRINT_WITH_COLOR_LB(BLUE, "start section");
if (lib_ret->obj->W_Element_Section_container != NULL) {
lua_pushstring(__ls, "element_section");
@@ -1644,15 +1646,38 @@ class LuaWrapper {
new_W_Element_Section(__ls);
lua_settable(__ls, -3);
}
- //PRINT_WITH_COLOR_LB(BLUE, "element section");
+ PRINT_WITH_COLOR_LB(BLUE, "element section");
if (lib_ret->obj->W_Code_Section_container != NULL) {
lua_pushstring(__ls, "code_section");
W_Code_Section_push_args(__ls, lib_ret->obj->W_Code_Section_container);
new_W_Code_Section(__ls);
+ lua_pushlightuserdata(__ls, lib_ret->obj->W_Code_Section_container);
+ lua_pushvalue(__ls, -2);
+ lua_settable(__ls, LUA_REGISTRYINDEX);
+#if 1
+ for (int ii = 0; ii < lib_ret->obj->W_Code_Section_container->count; ++ii) {
+ W_Function_Body_push_args(__ls, lib_ret->obj->W_Code_Section_container->bodies[ii]);
+ new_W_Function_Body(__ls);
+ lua_pushlightuserdata(__ls, lib_ret->obj->W_Code_Section_container->bodies[ii]);
+ lua_pushvalue(__ls, -2);
+ lua_settable(__ls, LUA_REGISTRYINDEX);
+ lua_pop(__ls, 1);
+ }
+#endif
lua_settable(__ls, -3);
+#if 0
+ for (int i = 0; i < lib_ret->obj->W_Code_Section_container->count; ++i) {
+ W_Function_Body_push_args(__ls, lib_ret->obj->W_Code_Section_container->bodies[i]);
+ new_W_Function_Body(__ls);
+ for (int j = 0; j < lib_ret->obj->W_Code_Section_container->bodies[i]->local_count; ++j) {
+ W_Local_Entry_push_args(__ls, lib_ret->obj->W_Code_Section_container->bodies[i]->locals[j]);
+ new_W_Local_Entry(__ls);
+ }
+ }
+#endif
}
- //PRINT_WITH_COLOR_LB(BLUE, "code section");
+ PRINT_WITH_COLOR_LB(BLUE, "code section");
if (lib_ret->obj->W_Data_Section_container != NULL) {
lua_pushstring(__ls, "data_section");
@@ -1660,7 +1685,7 @@ class LuaWrapper {
new_W_Data_Section(__ls);
lua_settable(__ls, -3);
}
- //PRINT_WITH_COLOR_LB(BLUE, "data section");
+ PRINT_WITH_COLOR_LB(BLUE, "data section");
if (lib_ret->obj->W_Custom_Section_container != NULL) {
}
return 1;
diff --git a/bruiser/faultreiber b/bruiser/faultreiber
-Subproject da65d18f0ebf28cb8a829a946d51d7111f6b493
+Subproject 29635ce7e1f3fa2e8aeb1c6b3938ab10786cad0
diff --git a/bruiser/lua-scripts/wasmtest.lua b/bruiser/lua-scripts/wasmtest.lua
index b863081..c568b31 100644
--- a/bruiser/lua-scripts/wasmtest.lua
+++ b/bruiser/lua-scripts/wasmtest.lua
@@ -30,7 +30,6 @@ function libwasm.dump_import_section(a)
io.write("count:"..tostring(a["import_section"]:count()).."\n")
io.write("entries"..tostring(a["import_section"]:entries()).."\n")
for k, v in pairs(a["import_section"]:entries()) do
- --print(k, v, type(v))
io.write("module length:"..v:module_length().."\t")
io.write("module str:"..v:module_str().."\t")
io.write("field len:"..v:field_len().."\t")
@@ -370,6 +369,98 @@ function libwasm.demo_setters(wasm_path)
end
--FIXME-entries
+ local entry1 = W_Import_Section_Entry()
+ local entry2 = W_Import_Section_Entry()
+ local entry3 = W_Import_Section_Entry()
+ local entry4 = W_Import_Section_Entry()
+ local kind0 = 12345
+ local rsz = resizable_limit_t(111,222,333)
+ local rsz1 = resizable_limit_t(11,22,33)
+ local kind1 = table_type_t(10, rsz)
+ kind1:set_resizable_limit(rsz)
+ local kind2 = memory_type_t(rsz1)
+ kind2:set_resizable_limit(rsz1)
+ local kind3 = global_type_t(13,13)
+
+ entry1:set_module_length(3)
+ entry1:set_module_str("env")
+ entry1:set_field_len(2)
+ entry1:set_field_str("ab")
+ entry1:set_kind(0)
+ entry1:set_type(kind0)
+
+ entry2:set_module_length(3)
+ entry2:set_module_str("env")
+ entry2:set_field_len(3)
+ entry2:set_field_str("abc")
+ entry2:set_kind(1)
+ entry2:set_type(kind1)
+
+ entry3:set_module_length(3)
+ entry3:set_module_str("env")
+ entry3:set_field_len(4)
+ entry3:set_field_str("abcd")
+ entry3:set_kind(2)
+ entry3:set_type(kind2)
+
+ entry4:set_module_length(3)
+ entry4:set_module_str("env")
+ entry4:set_field_len(5)
+ entry4:set_field_str("abcde")
+ entry4:set_kind(3)
+ entry4:set_type(kind3)
+
+ local entries = {}
+ entries[1] = entry1
+ entries[2] = entry2
+ entries[3] = entry3
+ entries[4] = entry4
+
+ a["import_section"]:set_count(4)
+ pre = a["import_section"]:entries()
+ a["import_section"]:set_entries(entries)
+ post = a["import_section"]:entries()
+
+ print(colors("%{red}".."start of import seciton entry contests for settter."))
+ for k,v in pairs(a["import_section"]:entries()) do
+ print(k, v)
+ print("module_length: "..v:module_length())
+ print("module_str: "..v:module_str())
+ print("field_len: "..v:field_len())
+ print("field_str: "..v:field_str())
+ print("kind: "..v:kind())
+ --print(v:type())
+ --print(colors("%{green}"..type(v:type()).."\n"))
+ --[[
+ if v:kind() == 0 then
+ v:set_type(54321)
+ print(v:type())
+ end
+ ]]--
+ if v:kind() == 1 then
+ --io.write(colors("%{blue}"..v:type():element_type().."\n"))
+ io.write(colors("%{blue}"..v:type():resizable_limit():flags().."\n"))
+ io.write(colors("%{blue}"..v:type():resizable_limit():initial().."\n"))
+ io.write(colors("%{blue}"..v:type():resizable_limit():maximum().."\n"))
+ end
+ if v:kind() == 2 then
+ io.write(colors("%{blue}"..v:type():resizable_limit():initial().."\n"))
+ io.write(colors("%{blue}"..v:type():resizable_limit():maximum().."\n"))
+ io.write(colors("%{blue}"..v:type():resizable_limit():flags().."\n"))
+ end
+ if v:kind() == 3 then
+ io.write(colors("%{blue}"..v:type():value_type().."\n"))
+ io.write(colors("%{blue}"..v:type():mutability().."\n"))
+ end
+ end
+
+ if pre == post then
+ io.write(colors("%{red}".."import_section:entries:failure\n"))
+ else
+ io.write(colors("%{green}".."import_section:entries:pass\n"))
+ end
+
+ print(colors("%{red}".."end of import seciton entry contests for settter."))
end
end
@@ -911,10 +1002,53 @@ function libwasm.demo_setters(wasm_path)
end
+--FIXME-fixed?
+function libwasm.demo_setter_aux()
+ require("wasmextra")
+ local rsz = resizable_limit_t(111,222,333)
+ local zz = resizable_limit_t(11,22,33)
+ local kind1 = table_type_t(10, rsz)
+ local kind2 = memory_type_t(rsz)
+ local kind3 = global_type_t(1,1)
+ print(rsz:flags())
+ print(rsz:initial())
+ print(rsz:maximum())
+ rsz:set_flags(100)
+ rsz:set_initial(200)
+ rsz:set_maximum(300)
+ print(rsz:flags())
+ print(rsz:initial())
+ print(rsz:maximum())
+
+ print(kind1:element_type())
+ print(kind1:resizable_limit())
+ kind1:set_element_type(17)
+ kind1:set_resizable_limit(zz)
+ print(kind1:element_type())
+ print(kind1:resizable_limit())
+ io.write(colors("%{blue}"..kind1:resizable_limit():initial().."\n"))
+ io.write(colors("%{blue}"..kind1:resizable_limit():maximum().."\n"))
+ io.write(colors("%{blue}"..kind1:resizable_limit():flags().."\n"))
+
+ print(kind2:resizable_limit())
+ kind2:set_resizable_limit(zz)
+ print(kind2:resizable_limit())
+ print("max after set:"..kind2:resizable_limit():maximum())
+
+ print(kind3:value_type())
+ print(kind3:mutability())
+ kind3:set_value_type(0)
+ kind3:set_mutability(0)
+ print(kind3:value_type())
+ print(kind3:mutability())
+end
+
+--libwasm.demo_setters("/home/bloodstalker/devi/hell2/bruiser/autogen/wasm/test/read.wasm")
--libwasm.dev("/home/bloodstalker/devi/hell2/bruiser/autogen/wasm/ft/test.wasm")
---libwasm.demo_getters("/home/bloodstalker/extra/faultreiber/test/read.wasm")
---libwasm.demo_getters("/home/bloodstalker/devi/hell2/bruiser/autogen/wasm/test/read.wasm")
-libwasm.demo_setters("/home/bloodstalker/devi/hell2/bruiser/autogen/wasm/ft/test.wasm")
+libwasm.demo_getters("/home/bloodstalker/devi/hell2/bruiser/autogen/wasm/test/read.wasm")
+--libwasm.demo_setters("/home/bloodstalker/devi/hell2/bruiser/autogen/wasm/ft/test.wasm")
--libwasm.dump_all("/home/bloodstalker/devi/hell2/bruiser/autogen/wasm/ft/test.wasm")
+--libwasm.dump_all("/home/bloodstalker/devi/hell2/bruiser/autogen/wasm/test/read.wasm")
+--libwasm.demo_setter_aux()
return libwasm
diff --git a/bruiser/tablegen b/bruiser/tablegen
-Subproject 47c85761f66dadd4e492a641fbd66893649ea83
+Subproject 4e1ea95b5e599c765fa8f3c634730ff9c9bd6ec
diff --git a/m0/mutator-lvl0.cpp b/m0/mutator-lvl0.cpp
index f6663dd..cdd625f 100644
--- a/m0/mutator-lvl0.cpp
+++ b/m0/mutator-lvl0.cpp
@@ -324,6 +324,7 @@ private:
};
/**********************************************************************************************************************/
/**************************************************ASTMatcher Callbacks************************************************/
+#if 0
class [[deprecated("replaced by a more efficient class"), maybe_unused]] MCForCmpless : public MatchFinder::MatchCallback {
public:
MCForCmpless (Rewriter &Rewrite) : Rewrite (Rewrite) {}
@@ -342,7 +343,9 @@ public:
private:
Rewriter &Rewrite;
};
+#endif
/**********************************************************************************************************************/
+#if 0
class [[deprecated("replaced by a more efficient class"), maybe_unused]] MCWhileCmpless : public MatchFinder::MatchCallback {
public:
MCWhileCmpless (Rewriter &Rewrite) : Rewrite (Rewrite) {}
@@ -361,6 +364,7 @@ public:
private:
Rewriter &Rewrite;
};
+#endif
/**********************************************************************************************************************/
class MCElseCmpless : public MatchFinder::MatchCallback {
public:
@@ -4483,40 +4487,31 @@ public:
}
#endif
- if (TypeIsUSignedInt)
- {
+ if (TypeIsUSignedInt) {
int64_t UnoFinal = 0;
int64_t DousFinal = 0;
bool MatchedUno = false;
bool MatchedDous = false;
/*@DEVI-compilers that actually treat post and pre inc or dec need more. this doesnt support that.*/
- if (MR.Nodes.getNodeAs<clang::UnaryOperator>("mcexpr1211uno") != nullptr)
- {
+ if (MR.Nodes.getNodeAs<clang::UnaryOperator>("mcexpr1211uno") != nullptr) {
MatchedUno = true;
-
const UnaryOperator* UO = MR.Nodes.getNodeAs<clang::UnaryOperator>("mcexpr1211uno");
-
clang::UnaryOperator::Opcode UnoOpKind = UO->getOpcode();
-
const Expr* UnoSubEXP = UO->getSubExpr();
-
+#if __clang_major__ >= 9
+ clang::Expr::EvalResult UnoResult;
+#elif __clang_major__ < 9
llvm::APSInt UnoResult;
-
UnoFinal = UnoResult.getExtValue();
+#endif
- if (UnoSubEXP->EvaluateAsInt(UnoResult, *ASTC))
- {
- if (UnoOpKind == UO_PostInc || UnoOpKind == UO_PreInc)
- {
+ if (UnoSubEXP->EvaluateAsInt(UnoResult, *ASTC)) {
+ if (UnoOpKind == UO_PostInc || UnoOpKind == UO_PreInc) {
UnoFinal++;
- }
- else if (UnoOpKind == UO_PostDec || UnoOpKind == UO_PreDec)
- {
+ } else if (UnoOpKind == UO_PostDec || UnoOpKind == UO_PreDec) {
UnoFinal--;
- }
- else
- {
+ } else {
/*intentionally left blank. we cant get anything else. were only matching for these two unaryoperators.*/
}
}
@@ -4533,16 +4528,25 @@ public:
const Expr* DousLHS = BO->getLHS();
const Expr* DousRHS = BO->getRHS();
+#if __clang_major__ >= 9
+ clang::Expr::EvalResult DousLHSAPS;
+ clang::Expr::EvalResult DousRHSAPS;
+#elif __clang_major__ < 9
llvm::APSInt DousLHSAPS;
llvm::APSInt DousRHSAPS;
+#endif
if (DousLHS->EvaluateAsInt(DousLHSAPS, *ASTC) && DousRHS->EvaluateAsInt(DousRHSAPS, *ASTC))
{
+#if __clang_major__ >= 9
+ int64_t DousLHSInt64 = DousLHSAPS.Val.getInt().getExtValue();
+ int64_t DousRHSInt64 = DousRHSAPS.Val.getInt().getExtValue();
+#elif __clang_major__ < 9
int64_t DousLHSInt64 = DousLHSAPS.getExtValue();
int64_t DousRHSInt64 = DousRHSAPS.getExtValue();
+#endif
- switch (DousOpKind)
- {
+ switch (DousOpKind) {
case BO_Add:
DousFinal = DousRHSInt64 + DousLHSInt64;
break;
@@ -4562,16 +4566,18 @@ public:
}
}
+#if __clang_major__ >= 9
+ clang::Expr::EvalResult OverflowCondidate;
+ EXP->EvaluateAsInt(OverflowCondidate, *ASTC);
+ int64_t IntExprValue = OverflowCondidate.Val.getInt().getExtValue();
+#elif __clang_major__ < 9
llvm::APSInt OverflowCondidate;
-
EXP->EvaluateAsInt(OverflowCondidate, *ASTC);
-
int64_t IntExprValue = OverflowCondidate.getExtValue();
+#endif
- if ((MatchedDous && (DousFinal != IntExprValue)) || (MatchedUno && (UnoFinal != IntExprValue)))
- {
+ if ((MatchedDous && (DousFinal != IntExprValue)) || (MatchedUno && (UnoFinal != IntExprValue))) {
std::cout << "12.11" << ":" << "Constant Unsinged Expr evaluation resuslts in an overflow:" << SL.printToString(*MR.SourceManager) << ":" << IntExprValue << " " << DousFinal << " " << ":" << targetExpr << "\n";
-
XMLDocOut.XMLAddNode(MR.Context, SL, "12.11", "Constant Unsinged Expr evaluation resuslts in an overflow:");
JSONDocOUT.JSONAddElement(MR.Context, SL, "12.11", "Constant Unsinged Expr evaluation resuslts in an overflow:");
}
@@ -7052,7 +7058,7 @@ private:
/**********************************************************************************************************************/
class MyASTConsumer : public ASTConsumer {
public:
- MyASTConsumer(Rewriter &R) : HandlerForCmpless(R), HandlerWhileCmpless(R), HandlerElseCmpless(R), HandlerIfCmpless(R), \
+ MyASTConsumer(Rewriter &R) : HandlerElseCmpless(R), HandlerIfCmpless(R), \
HandlerForIfElse(R), HandlerForSwitchBrkLess(R), HandlerForSwitchDftLEss(R), HandlerForMCSwitch151(R), HandlerForMCSwitch155(R), \
HandlerForMCFunction161(R), HandlerForFunction162(R), HandlerForFunction164(R), HandlerForFunction166(R), HandlerForFunction168(R), \
HandlerForFunction169(R), HandlerForPA171(R), HandlerForSU184(R), HandlerForType6465(R), HandlerForDCDF81(R), HandlerForDCDF82(R), \
@@ -7071,8 +7077,8 @@ public:
/*@DEVI-disables all matchers*/
#if defined(_MUT0_EN_MATCHERS)
- Matcher.addMatcher(forStmt(unless(hasDescendant(compoundStmt()))).bind("mcfor"), &HandlerForCmpless);
- Matcher.addMatcher(whileStmt(unless(hasDescendant(compoundStmt()))).bind("mcwhile"), &HandlerWhileCmpless);
+ //Matcher.addMatcher(forStmt(unless(hasDescendant(compoundStmt()))).bind("mcfor"), &HandlerForCmpless);
+ //Matcher.addMatcher(whileStmt(unless(hasDescendant(compoundStmt()))).bind("mcwhile"), &HandlerWhileCmpless);
Matcher.addMatcher(ifStmt(allOf(hasElse(unless(ifStmt())), hasElse(unless(compoundStmt())))).bind("mcelse"), &HandlerElseCmpless);
Matcher.addMatcher(ifStmt(unless(hasDescendant(compoundStmt()))).bind("mcif"), &HandlerIfCmpless);
Matcher.addMatcher(ifStmt(allOf(hasElse(ifStmt()), unless(hasAncestor(ifStmt())), unless(hasDescendant(ifStmt(hasElse(unless(ifStmt()))))))).bind("mcifelse"), &HandlerForIfElse);
@@ -7481,8 +7487,8 @@ public:
}
private:
- MCForCmpless HandlerForCmpless;
- MCWhileCmpless HandlerWhileCmpless;
+ //MCForCmpless HandlerForCmpless;
+ //MCWhileCmpless HandlerWhileCmpless;
MCElseCmpless HandlerElseCmpless;
MCIfCmpless HandlerIfCmpless;
IfElseMissingFixer HandlerForIfElse;
diff --git a/m0/mutator_aux.cpp b/m0/mutator_aux.cpp
index b563bbe..9d2d4dc 100644
--- a/m0/mutator_aux.cpp
+++ b/m0/mutator_aux.cpp
@@ -45,7 +45,7 @@ SourceLocation SourceLocationHasMacro [[deprecated("doesnt work")]] (SourceLocat
/*get the expansion range which is startloc and endloc*/
#if __clang_major__ <= 6
std::pair <SourceLocation, SourceLocation> expansionRange = Rewrite.getSourceMgr().getImmediateExpansionRange(SL);
-#elif __clang_major__ == 8
+#elif __clang_major__ >= 8
CharSourceRange expansionRange = Rewrite.getSourceMgr().getImmediateExpansionRange(SL);
#endif
if (Kind == "start") {
diff --git a/obfuscator/compile_commands.json b/obfuscator/compile_commands.json
index 6fa5c24..d4fa21d 100644
--- a/obfuscator/compile_commands.json
+++ b/obfuscator/compile_commands.json
@@ -1,7 +1,12 @@
[
{
- "command": "c++ -c -v -I/home/bloodstalker/extra/llvm-6/llvm/include -I/home/bloodstalker/extra/llvm-6/build/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -ffunction-sections -fdata-sections -O2 -fno-exceptions -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/bloodstalker/extra/llvm-6/llvm/tools/clang/include -I/home/bloodstalker/extra/llvm-6/build/tools/clang/include -std=c++1z -stdlib=libstdc++ -UNDEBUG -fexceptions -o obfuscator.o obfuscator.cpp",
+ "command": "c++ -c -fpic -I/home/bloodstalker/extra/llvm-clang-4/llvm/include -I/home/bloodstalker/extra/llvm-clang-4/build/include -std=c++11 -fno-exceptions -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/bloodstalker/extra/llvm-clang-4/llvm/tools/clang/include -I/home/bloodstalker/extra/llvm-clang-4/build/tools/clang/include -stdlib=libstdc++ -std=c++17 -fexceptions -o obfuscator.o obfuscator.cpp",
"directory": "/home/bloodstalker/devi/hell2/obfuscator",
"file": "/home/bloodstalker/devi/hell2/obfuscator/obfuscator.cpp"
+ },
+ {
+ "command": "c++ -c -fpic -I/home/bloodstalker/extra/llvm-clang-4/llvm/include -I/home/bloodstalker/extra/llvm-clang-4/build/include -std=c++11 -fno-exceptions -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/bloodstalker/extra/llvm-clang-4/llvm/tools/clang/include -I/home/bloodstalker/extra/llvm-clang-4/build/tools/clang/include -stdlib=libstdc++ -std=c++17 -fexceptions -o ../m0/mutator_aux.o ../m0/mutator_aux.cpp",
+ "directory": "/home/bloodstalker/devi/hell2/obfuscator",
+ "file": "/home/bloodstalker/devi/hell2/m0/mutator_aux.cpp"
}
] \ No newline at end of file