aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2019-08-13 16:13:11 +0000
committerbloodstalker <thabogre@gmail.com>2019-08-13 16:13:11 +0000
commita46c23d01d20eef63194ce6f8745afb130e9ba20 (patch)
tree30d9fe4b38a88c5b6bdbe96cf84a43b8d4d1f7d0
parentupdate (diff)
downloadfaultreiber-a46c23d01d20eef63194ce6f8745afb130e9ba20.tar.gz
faultreiber-a46c23d01d20eef63194ce6f8745afb130e9ba20.zip
added ltg as submodule to see why --lua switch breaks
-rw-r--r--.gitmodules3
-rwxr-xr-xltg.sh12
m---------luatablegen0
-rwxr-xr-xrun.sh2
-rw-r--r--test/autowasm.c10
-rw-r--r--test/makefile14
6 files changed, 34 insertions, 7 deletions
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..91cc2cc
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "luatablegen"]
+ path = luatablegen
+ url = https://github.com/bloodstalker/luatablegen
diff --git a/ltg.sh b/ltg.sh
new file mode 100755
index 0000000..dc1e37c
--- /dev/null
+++ b/ltg.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/bash
+cd $(dirname $0)
+if [[ -d ./out ]]; then :;else mkdir ./out;fi
+./luatablegen/luatablegen.py --out ./out --luaheader ../test/lua --headeraggr ./out/wasm_tables.h --lualibpath ./out/wasm.lua --docpath ./out/wasm.md --xml ./luatablegen/test/luwasm.xml --tbldefs ./out/ --anon --name wasm --lualibname wasmextra
+clang-format ./out/*.c ./out/*.h -i
+for filename in ./out/*.c; do
+ gcc -c $filename > /dev/null 2>&1
+ if [[ $? != 0 ]]; then
+ echo $filename did not compile.
+ fi
+done
+rm *.o
diff --git a/luatablegen b/luatablegen
new file mode 160000
+Subproject 52724761b65c998ba07fdb8a8d9c77b512c6421
diff --git a/run.sh b/run.sh
index d542844..a500364 100755
--- a/run.sh
+++ b/run.sh
@@ -1,5 +1,5 @@
#!/bin/sh
cd $(dirname $0)
-"./faultreiber.py" --targetname autowasm --outdir ./test/ --structs ./test/struct.json --xml ./resources/wasm2.xml --name wasm --luaalloc --luaheaders ../../../lua/src/lua.h
+"./faultreiber.py" --targetname autowasm --outdir ./test/ --structs ./test/struct.json --xml ./resources/wasm2.xml --name wasm --luaalloc --luaheaders ./lua/
#"./faultreiber.py" --targetname autowasm --outdir ./test/ --structs ./test/struct.json --xml ./resources/wasm2.xml --name wasm --calloc
"clang-format" -i ./test/read.c ./test/structs.c ./test/structs.h ./test/aggregate.c ./test/aggregate.h ./test/read.h
diff --git a/test/autowasm.c b/test/autowasm.c
index 67ecfd1..b7b92b2 100644
--- a/test/autowasm.c
+++ b/test/autowasm.c
@@ -10,6 +10,8 @@
//#include "./read.h"
#include "./aggregate.h"
+#define WASM
+
#pragma weak main
int main (int argc, char** argv) {
@@ -31,7 +33,9 @@ int main (int argc, char** argv) {
}
}
int wasm = open("./read.wasm", O_RDONLY);
- wasm_lib_ret_t* lib_ret = read_aggr_wasm(wasm);
+ lua_State* ls = luaL_newstate();
+ reg_tablegen_tables_wasm(ls);
+ wasm_lib_ret_t* lib_ret = read_aggr_wasm(wasm, ls);
printf("finished reading\n");
#if 1
@@ -174,6 +178,7 @@ int main (int argc, char** argv) {
}
#endif
+#if 0
printf("sizeof magic:%d\n", sizeof(magic_number));
printf("sizeof version:%d\n", sizeof(version));
printf("current void count:%d\n", lib_ret->current_void_count);
@@ -185,6 +190,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]);
+#endif
#if 0
for (int i = lib_ret->current_void_count - 1; i >= 0; --i) {
printf("%d:0x%x ", i, lib_ret->void_train[i]);
@@ -193,7 +199,9 @@ int main (int argc, char** argv) {
}
#endif
//free(lib_ret->void_train);
+#if 0
free(lib_ret->obj);
free(lib_ret);
+#endif
return 0;
}
diff --git a/test/makefile b/test/makefile
index 05d4215..78bbe41 100644
--- a/test/makefile
+++ b/test/makefile
@@ -6,7 +6,8 @@ CC?=clang
CC_FLAGS=-fpic
CC_EXTRA?=
CTAGS_I_PATH?=./
-LD_FLAGS=
+LIB_LUA=./lua/liblua.a
+LD_FLAGS= -lm -ldl -L ./lua
EXTRA_LD_FLAGS?=
ADD_SANITIZERS_CC= -g -fsanitize=address -fno-omit-frame-pointer
ADD_SANITIZERS_LD= -g -fsanitize=address
@@ -67,6 +68,9 @@ depend:.depend
-include ./.depend
+$(LIB_LUA):
+ $(MAKE) -C ./lua linux
+
.c.o:
$(CC) $(CC_FLAGS) -c $< -o $@
@@ -76,13 +80,13 @@ depend:.depend
%.ocov:%.c
$(CC) $(CC_FLAGS) $(COV_CC) -c $< -o $@
-$(TARGET): $(TARGET).o read.o aggregate.o structs.o
+$(TARGET): $(TARGET).o read.o aggregate.o structs.o $(LIB_LUA) ../out/wasm_tables.a
$(CC) $^ $(LD_FLAGS) -o $@
-$(TARGET)-static: $(TARGET).o read.o aggregate.o structs.o
+$(TARGET)-static: $(TARGET).o read.o aggregate.o structs.o $(LIB_LUA)
$(CC) $^ $(LD_FLAGS) -static -o $@
-$(TARGET)-dbg: $(TARGET).odbg read.odbg aggregate.odbg structs.odbg
+$(TARGET)-dbg: $(TARGET).odbg read.odbg aggregate.odbg structs.odbg $(LIB_LUA) ../out/wasm_tables.adbg
$(CC) $^ $(LD_FLAGS) -g -o $@
$(TARGET)-cov: $(TARGET).ocov read.o aggregate.o structs.o
@@ -115,7 +119,7 @@ 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
+$(TARGET).a: $(TARGET).o read.o aggregate.o structs.o $(LIB_LUA)
ar rcs $(TARGET).a $(TARGET).o
valgrind: $(TARGET)