aboutsummaryrefslogtreecommitdiffstats
path: root/bruiser/autogen/wasm
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2018-09-10 14:01:59 +0000
committerbloodstalker <thabogre@gmail.com>2018-09-10 14:01:59 +0000
commit69360b15987798dfbffbc4c5688d1a8108945ff1 (patch)
tree8b69055cf9ca8b90c1cc47be9f63ac4a82d54d07 /bruiser/autogen/wasm
parentjmp_t_s now uses the new way of registering tables, the 5.3 way. bruiser is s... (diff)
downloadmutator-69360b15987798dfbffbc4c5688d1a8108945ff1.tar.gz
mutator-69360b15987798dfbffbc4c5688d1a8108945ff1.zip
begenning to integrate and test both the codegens. run git pull for faultreiber and tablegen.
Diffstat (limited to 'bruiser/autogen/wasm')
-rwxr-xr-xbruiser/autogen/wasm/ft.sh5
-rw-r--r--bruiser/autogen/wasm/ft/autowasm.c173
-rw-r--r--bruiser/autogen/wasm/ft/makefile143
-rw-r--r--bruiser/autogen/wasm/ft/wasm.xml174
-rwxr-xr-xbruiser/autogen/wasm/ltg.sh11
-rw-r--r--bruiser/autogen/wasm/ltg/makefile51
-rw-r--r--bruiser/autogen/wasm/ltg/wasm.xml174
7 files changed, 731 insertions, 0 deletions
diff --git a/bruiser/autogen/wasm/ft.sh b/bruiser/autogen/wasm/ft.sh
new file mode 100755
index 0000000..e5a1e05
--- /dev/null
+++ b/bruiser/autogen/wasm/ft.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+cd $(dirname $0)
+"../../faultreiber/faultreiber.py" --name wasm --outdir ./ft/ --datetime --xml ./ft/wasm.xml
+#"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
new file mode 100644
index 0000000..30442ba
--- /dev/null
+++ b/bruiser/autogen/wasm/ft/autowasm.c
@@ -0,0 +1,173 @@
+
+#include <fcntl.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "./aggregate.h"
+#include "./read.h"
+#include "./structs.h"
+
+#pragma weak main
+int main(int argc, char **argv) {
+ int wasm = open("./test.wasm", O_RDONLY);
+ read_aggr_wasm(wasm);
+
+ printf("magic_number:%x\n", magic_number_container->magic_number);
+ printf("version:%x\n", version_container->version);
+
+ printf("type section id:%d\n", W_Type_Section_container->id);
+ printf("type section payloadlength:%d\n",
+ W_Type_Section_container->payloadlength);
+ printf("type_section entry count:%d\n", W_Type_Section_container->count);
+ for (int i = 0; i < W_Type_Section_container->count; ++i) {
+ printf("param_count:%d\n",
+ W_Type_Section_container->entries[i]->param_count);
+ for (int j = 0; j < W_Type_Section_container->entries[i]->param_count; ++j)
+ printf("param_types:%d\n",
+ W_Type_Section_container->entries[i]->param_types[j]);
+ printf("return_count:%d\n",
+ W_Type_Section_container->entries[i]->return_count);
+ for (int j = 0; j < W_Type_Section_container->entries[i]->return_count; ++j)
+ printf("param_types:%d\n",
+ W_Type_Section_container->entries[i]->return_types[j]);
+ }
+ printf("import_section_id:%d\n", W_Import_Section_container->id);
+ printf("import_section_payloadlength:%d\n",
+ W_Import_Section_container->payloadlength);
+ printf("import_section_count:%d\n", W_Import_Section_container->count);
+ for (int i = 0; i < W_Import_Section_container->count; ++i) {
+ printf("module_length:%d\n",
+ W_Import_Section_container->entries[i]->module_length);
+ printf("module_str:%s\n",
+ W_Import_Section_container->entries[i]->module_str);
+ printf("field_length:%d\n",
+ W_Import_Section_container->entries[i]->field_len);
+ printf("field_str:%s\n", W_Import_Section_container->entries[i]->field_str);
+ printf("kind:%d\n", W_Import_Section_container->entries[i]->kind);
+ if (W_Import_Section_container->entries[i]->kind == 0)
+ printf("type:%d\n", W_Import_Section_container->entries[i]->kind);
+ printf("\n");
+ }
+ printf("function_section_id:%d\n", W_Function_Section_container->id);
+ printf("function_section_payloadlength:%d\n",
+ W_Function_Section_container->payloadlength);
+ printf("function_section_count:%d\n", W_Function_Section_container->count);
+ for (int i = 0; i < W_Function_Section_container->count; ++i)
+ printf("type:%d\n", W_Function_Section_container->types[i]);
+
+ printf("table_section_id:%d\n", W_Table_Section_container->id);
+ printf("table_section_payloadlength:%d\n",
+ W_Table_Section_container->payloadlength);
+ printf("table_section_count:%d\n", W_Table_Section_container->count);
+ for (int i = 0; i < W_Table_Section_container->count; ++i) {
+ printf("element_type:%d\n",
+ W_Table_Section_container->entries[i]->element_type);
+ printf("rl_flags:%d\n",
+ W_Table_Section_container->entries[i]->resizable_limit->flags);
+ printf("rl_initial:%d\n",
+ W_Table_Section_container->entries[i]->resizable_limit->initial);
+ printf("rl_maximum:%d\n",
+ W_Table_Section_container->entries[i]->resizable_limit->maximum);
+ }
+
+ printf("memory_section_id:%d\n", W_Memory_Section_container->id);
+ printf("memory_section_payload_length:%d\n",
+ W_Memory_Section_container->payloadlength);
+ printf("rl_flags:%d\n",
+ W_Memory_Section_container->entries->resizable_limit->flags);
+ printf("rl_initial:%d\n",
+ W_Memory_Section_container->entries->resizable_limit->initial);
+ printf("rl_maximum:%d\n",
+ W_Memory_Section_container->entries->resizable_limit->maximum);
+
+ if (W_Global_Section_container == NULL)
+ printf("global section doesnt exist.\n");
+
+ printf("export_section_id:%d\n", W_Export_Section_container->id);
+ printf("export_section_payloadlength:%d\n",
+ W_Export_Section_container->payloadlength);
+ printf("entry count:%d\n", W_Export_Section_container->count);
+
+ for (int i = 0; i < W_Export_Section_container->count; ++i) {
+ printf("field_len:%d\n", W_Export_Section_container->entries[i]->field_len);
+ printf("field_str:%s\n", W_Export_Section_container->entries[i]->field_str);
+ printf("kind:%d\n", W_Export_Section_container->entries[i]->kind);
+ printf("index:%d\n", W_Export_Section_container->entries[i]->index);
+ }
+
+ if (W_Start_Section_container == NULL)
+ printf("start section doesnt exist.\n");
+
+ printf("element_seciton_id:%d\n", W_Element_Section_container->id);
+ printf("element_section_payloadlength:%d\n",
+ W_Element_Section_container->payloadlength);
+ printf("entry count:%d\n", W_Element_Section_container->count);
+
+ for (int i = 0; i < W_Element_Section_container->count; ++i) {
+ printf("index:%d\n", W_Element_Section_container->entries[i]->index);
+ for (int j = 0; j < 3; ++j) {
+ printf("code:%d\n",
+ W_Element_Section_container->entries[i]->init->code[j]);
+ }
+ printf("num_length:%d\n",
+ W_Element_Section_container->entries[i]->num_length);
+ for (int j = 0; j < W_Element_Section_container->entries[i]->num_length;
+ ++j) {
+ printf("elems:%d\n", W_Element_Section_container->entries[i]->elems[j]);
+ }
+ }
+
+ printf("code_section_id:%d\n", W_Code_Section_container->id);
+ printf("code_section_payloadlength:%d\n",
+ W_Code_Section_container->payloadlength);
+ printf("count:%d\n", W_Code_Section_container->count);
+
+ for (int i = 0; i < W_Code_Section_container->count; ++i) {
+ printf("body_size:%d\n", W_Code_Section_container->bodies[i]->body_size);
+ printf("local_count:%d\n",
+ W_Code_Section_container->bodies[i]->local_count);
+ if (W_Code_Section_container->bodies[i]->local_count > 0) {
+ for (int j = 0; j < W_Code_Section_container->bodies[i]->local_count;
+ ++j) {
+ for (int k = 0;
+ k < W_Code_Section_container->bodies[i]->locals[j]->count; ++k) {
+ }
+ }
+ }
+ printf("code:\n");
+ for (int j = 0; j < W_Code_Section_container->bodies[i]->body_size; ++j) {
+ printf("%02x ", W_Code_Section_container->bodies[i]->code[j]);
+ }
+ printf("\n");
+ }
+
+ printf("data_section_id:%d\n", W_Data_Section_container->id);
+ printf("data_section_payloadlength:%d\n",
+ W_Data_Section_container->payloadlength);
+ printf("data seg count:%d\n", W_Data_Section_container->count);
+
+ for (int i = 0; i < W_Data_Section_container->count; ++i) {
+ printf("index:%d\n", W_Data_Section_container->entries[i]->index);
+ printf("size:%d\n", W_Data_Section_container->entries[i]->size);
+ printf("code:\n");
+ for (int j = 0; j < W_Data_Section_container->entries[i]->size; ++j) {
+ printf("%c ", W_Data_Section_container->entries[i]->data[j]);
+ }
+ printf("\n");
+ int j = 0;
+ printf("offset:\n");
+ while (1) {
+ printf("%02x ", W_Data_Section_container->entries[i]->offset->code[j]);
+ if (W_Data_Section_container->entries[i]->offset->code[j] == 11) {
+ break;
+ }
+ j++;
+ }
+ printf("\n");
+ }
+
+ release_all();
+ return 0;
+}
diff --git a/bruiser/autogen/wasm/ft/makefile b/bruiser/autogen/wasm/ft/makefile
new file mode 100644
index 0000000..86f0a6b
--- /dev/null
+++ b/bruiser/autogen/wasm/ft/makefile
@@ -0,0 +1,143 @@
+SHELL=bash
+SHELL?=bash
+TARGET=autowasm
+CC=clang
+CC?=clang
+CC_FLAGS=-fpic
+CC_EXTRA?=
+CTAGS_I_PATH?=./
+LD_FLAGS=
+EXTRA_LD_FLAGS?=
+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
+MEM_SANITIZERS_LD= -g -fsanitize=memory
+UB_SANITIZERS_CC= -g -fsanitize=undefined -fno-omit-frame-pointer
+UB_SANITIZERS_LD= -g -fsanitize=undefined
+COV_CC= -fprofile-instr-generate -fcoverage-mapping
+COV_LD= -fprofile-instr-generate
+# BUILD_MODES are=RELEASE(default), DEBUG,ADDSAN,MEMSAN,UBSAN
+BUILD_MODE?=RELEASE
+OBJ_LIST:=$(patsubst %.c, %.o, $(wildcard *.c))
+ASM_LIST:=$(patsubst %.c, %.dis, $(wildcard *.c))
+
+ifeq ($(BUILD_MODE), ADDSAN)
+ifeq ($(CC), gcc)
+$(error This build mode is only useable with clang.)
+endif
+CC_EXTRA+=$(ADD_SANITIZERS_CC)
+EXTRA_LD_FLAGS+=$(ADD_SANITIZERS_LD)
+endif
+
+ifeq ($(BUILD_MODE), MEMSAN)
+ifeq ($(CC), gcc)
+$(error This build mode is only useable with clang.)
+endif
+CC_EXTRA+=$(MEM_SANITIZERS_CC)
+EXTRA_LD_FLAGS+=$(MEM_SANITIZERS_LD)
+endif
+
+ifeq ($(BUILD_MODE), UBSAN)
+ifeq ($(CC), gcc)
+$(error This build mode is only useable with clang.)
+endif
+CC_EXTRA+=$(UB_SANITIZERS_CC)
+EXTRA_LD_FLAGS+=$(UB_SANITIZERS_LD)
+endif
+
+SRCS:=$(wildcard *.c)
+CC_FLAGS+=$(CC_EXTRA)
+LD_FLAGS+=$(EXTRA_LD_FLAGS)
+
+.DEFAULT:all
+
+.PHONY:all clean help ASM SO TAGS
+
+all:$(TARGET)
+
+everything:$(TARGET) A ASM SO $(TARGET)-static $(TARGET)-dbg TAGS $(TARGET)-cov
+
+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
+
+-include ./.depend
+
+.c.o:
+ $(CC) $(CC_FLAGS) -c $< -o $@
+
+%.odbg:%.c
+ $(CC) $(CC_FLAGS) -g -c $< -o $@
+
+%.ocov:%.c
+ $(CC) $(CC_FLAGS) $(COV_CC) -c $< -o $@
+
+$(TARGET): $(TARGET).o read.o aggregate.o structs.o
+ $(CC) $^ $(LD_FLAGS) -o $@
+
+$(TARGET)-static: $(TARGET).o read.o aggregate.o structs.o
+ $(CC) $^ $(LD_FLAGS) -static -o $@
+
+$(TARGET)-dbg: $(TARGET).odbg read.o aggregate.o structs.o
+ $(CC) $^ $(LD_FLAGS) -g -o $@
+
+$(TARGET)-cov: $(TARGET).ocov read.o aggregate.o structs.o
+ $(CC) $^ $(LD_FLAGS) $(COV_LD) -o $@
+
+cov:
+ @llvm-profdata merge -sparse ./default.profraw -o ./default.profdata
+ @llvm-cov show $(TARGET)-cov -instr-profile=default.profdata
+
+covrep:
+ @llvm-profdata merge -sparse ./default.profraw -o ./default.profdata
+ @llvm-cov report $(TARGET)-cov -instr-profile=default.profdata
+
+ASM:$(ASM_LIST)
+
+SO:$(TARGET).so
+
+A:$(TARGET).a
+
+TAGS:tags
+
+tags:$(SRCS)
+ $(shell $(CC) -c -I $(CTAGS_I_PATH) -M $(SRCS)|\
+ sed -e 's/[\\ ]/\n/g'|sed -e '/^$$/d' -e '/\.o:[ \t]*$$/d'|\
+ ctags -L - --c++-kinds=+p --fields=+iaS --extra=+q)
+
+%.dis: %.o
+ objdump -r -d -M intel -S $< > $@
+
+$(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
+
+clean:
+ rm -f *.o *.dis *.odbg *.ocov *~ $(TARGET) $(TARGET).so $(TARGET)-static $(TARGET)-dbg $(TARGET).a $(TARGET)-cov
+
+deepclean:
+ rm -f *.o *.dis *.odbg *.ocov *~ $(TARGET) $(TARGET).so tags $(TARGET)-static $(TARGET)-dbg $(TARGET).a $(TARGET)-cov
+ rm .depend
+
+help:
+ @echo "--all is the default target, runs $(TARGET) target"
+ @echo "--everything will build everything"
+ @echo "--SO will generate the so"
+ @echo "--ASM will generate assembly files"
+ @echo "--TAGS will generate tags file"
+ @echo "--$(TARGET) builds the dynamically-linked executable"
+ @echo "--$(TARGET)-dbg will generate the debug build. BUILD_MODE should be set to DEBUG to work"
+ @echo "--$(TARGET)-static will statically link the executable to the libraries"
+ @echo "--$(TARGET)-cov is the coverage build"
+ @echo "--cov will print the coverage report"
+ @echo "--covrep will print the coverage report"
+ @echo "--A will build the static library"
+ @echo "--TAGS will build the tags file"
+ @echo "--clean"
+ @echo "--deepclean$(newline) will clean almost everything"
diff --git a/bruiser/autogen/wasm/ft/wasm.xml b/bruiser/autogen/wasm/ft/wasm.xml
new file mode 100644
index 0000000..dfae936
--- /dev/null
+++ b/bruiser/autogen/wasm/ft/wasm.xml
@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<FT>
+ <Read>
+ <Magic_Number name="magic_number" type="uint32" count="1"></Magic_Number>
+ <Version name="version" type="uint32" count="1"></Version>
+ <Type_Section name="W_Type_Section" count="1" type="" isaggregate="true" unordered="true" unorderedbegin="true">
+ <ID name="id" type="uint8" encoding="leb128u" issign="true">1</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u"/>
+ <Name name="name" type="string" size="self::NameLength"/>
+ <Count name="count" encoding="leb128u" type="uint32" count="1"/>
+ <Type_Section_Entry count="self::Count" type="self::Type_Section_Entry" name="entries"/>
+ </Type_Section>
+ <Import_Section name="W_Import_Section" count="1" type="" isaggregate="true" unordered="true">
+ <ID name="id" type="uint8" encoding="leb128u" issign="true">2</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u"/>
+ <Name name="name" type="string" size="self::NameLength"/>
+ <Count name="count" encoding="leb128u" type="uint32" count="1"/>
+ <Entries name="entries" type="self::Import_Section_Entry" count="self::Count"/>
+ </Import_Section>
+ <Function_Section name="W_Function_Section" count="1" type="" isaggregate="true" unordered="true">
+ <ID name="id" type="uint8" encoding="leb128u" issign="">3</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u"/>
+ <Name name="name" type="string" size="self::NameLength"/>
+ <Count name="count" encoding="leb128u" type="uint32" count="1"/>
+ <Types name="types" encoding="leb128u" type="uint32" count="self::Count"/>
+ </Function_Section>
+ <Table_Section name="W_Table_Section" count="1" type="" isaggregate="true" unordered="true">
+ <ID name="id" type="uint8" encoding="leb128u" issign="true">4</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u"/>
+ <Name name="name" type="string" size="self::NameLength"/>
+ <Count name="count" encoding="leb128u" type="uint32" count="1"/>
+ <Entries name="entries" type="self::Table_Type" count="self::Count"/>
+ </Table_Section>
+ <Memory_Section name="W_Memory_Section" count="1" type="" isaggregate="true" unordered="true">
+ <ID name="id" type="uint8" encoding="leb128u" issign="true">5</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u"/>
+ <Name name="name" type="string" size="self::NameLength"/>
+ <!--<Count name="count" encoding="leb128u" type="uint32" count="1"/>-->
+ <Entries name="entries" type="self::Memory_Type" count="1"/>
+ </Memory_Section>
+ <Global_Section name="W_Global_Section" count="1" type="" isaggregate="true" unordered="true">
+ <ID name="id" type="uint8" encoding="leb128u" issign="true">6</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u"/>
+ <Name name="name" type="string" size="self::NameLength"/>
+ <Count name="count" encoding="leb128u" type="uint32" count="1"/>
+ <Globals name="globals" type="self::Global_Entry" count="self::Count"/>
+ </Global_Section>
+ <Export_Section name="W_Export_Section" count="1" type="" isaggregate="true" unordered="true">
+ <ID name="id" type="uint8" encoding="leb128u" issign="true">7</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u"/>
+ <Name name="name" type="string" size="self::NameLength"/>
+ <Count name="count" encoding="leb128u" type="uint32" count="1"/>
+ <Entries name="entries" type="self::Export_Entry" count="self::Count"/>
+ </Export_Section>
+ <Start_Section name="W_Start_Section" count="1" isaggregate="true" unordered="true">
+ <ID name="id" type="uint8" encoding="leb128u" issign="true">8</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u"/>
+ <Name name="name" type="string" size="self::NameLength"/>
+ <Index name="index" encoding="leb128u" type="uint32" count="1"/>
+ </Start_Section>
+ <Element_Section name="W_Element_Section" count="1" isaggregate="true" unordered="true">
+ <ID name="id" type="uint8" encoding="leb128u" issign="true">9</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u"/>
+ <Name name="name" type="string" size="self::NameLength"/>
+ <Count name="count" encoding="leb128u" type="uint32" count="1"/>
+ <Entries name="entries" type="self::Element_Segment" count="self::Count"/>
+ </Element_Section>
+ <Code_Section name="W_Code_Section" count="1" isaggregate="true" unordered="true">
+ <ID name="id" type="uint8" encoding="leb128u" issign="true">10</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u"/>
+ <Name name="name" type="string" size="self::NameLength"/>
+ <Count name="count" encoding="leb128u" type="uint32" count="1"/>
+ <Bodies name="bodies" type="self::Function_Body" count="self::Count"/>
+ </Code_Section>
+ <Data_Section name="W_Data_Section" count="1" isaggregate="true" unordered="true">
+ <ID name="id" type="uint8" encoding="leb128u" issign="true">11</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u"/>
+ <Name name="name" type="string" size="self::NameLength"/>
+ <Count name="count" encoding="leb128u" type="uint32" count="1"/>
+ <Entries name="entries" type="self::Data_Segment" count="self::Count"/>
+ </Data_Section>
+ <Custom_Section name="W_Custom_Section" count="*" isaggregate="true" unordered="true" unorderedend="true">
+ <ID name="id" type="uint8" encoding="leb128u" issign="true">0</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u"/>
+ <Name name="name" type="string" size="self::NameLength"/>
+ <Payload name="payload" type="uint8" count="self::PayloadLength"/>
+ </Custom_Section>
+ </Read>
+ <Definition>
+ <Init_Expr name="init_expr_t" isaggregate="true">
+ <Code name="code" type="string" count="1" size="-1" delimiter="11"></Code>
+ </Init_Expr>
+ <Resizable_Limit name="resizable_limit_t" isaggregate="true">
+ <Flags name="flags" encoding="leb128u" type="uint8" count="1"></Flags>
+ <Initial name="initial" encoding="leb128u" type="uint32" count="1"></Initial>
+ <Maximum name="maximum" encoding="leb128u" type="uint32" count="1"></Maximum>
+ </Resizable_Limit>
+ <Global_Type name="global_type_t" isaggregate="true">
+ <Value_Type name="value_type" type="uint32" count="1"></Value_Type>
+ <Mutability name="mutability" encoding="leb128u" type="uint8" count="1"></Mutability>
+ </Global_Type>
+ <Table_Type name="table_type_t" isaggregate="true">
+ <Element_Type name="element_type" encoding="leb128u" type="uint8" count="1"></Element_Type>
+ <Resizable_Limit name="resizable_limit" count="1" type="self::Resizable_Limit"></Resizable_Limit>
+ </Table_Type>
+ <Memory_Type name="memory_type_t" isaggregate="true">
+ <Resizable_Limit count="1" type="self::Resizable_Limit" name="resizable_limit"></Resizable_Limit>
+ </Memory_Type>
+ <Type_Section_Entry name="W_Type_Section_Entry" isaggregate="true">
+ <Form name="form" encoding="leb128u" type="uint8" count="1"/>
+ <Param_Count name="param_count" encoding="leb128u" type="uint32" count="1"/>
+ <Param_Types name="param_types" encoding="leb128u" type="uint8" count="self::Param_Count"/>
+ <Return_Count name="return_count" encoding="leb128u" type="uint8"/>
+ <Return_Types name="return_types" encoding="leb128u" type="uint8" count="self::Return_Count"/>
+ </Type_Section_Entry>
+ <Import_Section_Entry name="W_Import_Section_Entry" isaggregate="true">
+ <Module_Length name="module_length" encoding="leb128u" type="uint32" count="1"/>
+ <Module_Str name="module_str" type="string" count="1" size="self::Module_Length"/>
+ <Field_Len name="field_len" encoding="leb128u" type="uint32" couny="1"/>
+ <Field_Str name="field_str" type="string" count="1" size="self::Field_Len"/>
+ <Kind name="kind" encoding="leb128u" type="uint8" count="1"/>
+ <Type name="type" conditional="true" condition="self::Kind" type="FT::conditional">
+ <condition0 name="type" encoding="leb128u" type="uint32">0</condition0>
+ <condition1 name="type" type="self::Table_Type">1</condition1>
+ <condition2 name="type" type="self::Memory_Type">2</condition2>
+ <condition3 name="type" type="self::Global_Type">3</condition3>
+ </Type>
+ </Import_Section_Entry>
+ <Global_Entry name="W_Global_Entry" isaggregate="true">
+ <Global_Type name="type" type="self::Global_Type" count="1"/>
+ <Init name="init" type="self::Init_Expr" count="1"/>
+ </Global_Entry>
+ <Export_Entry name="W_Export_Entry" isaggregate="true">
+ <Field_Len name="field_len" encoding="leb128u" type="uint32" count="1"/>
+ <Field_Str name="field_str" type="string" count="1" size="self::Field_Len"/>
+ <Kind name="kind" encoding="leb128u" type="uint8" count="1"/>
+ <Index name="index" encoding="leb128u" type="uint32" count="1"/>
+ </Export_Entry>
+ <Element_Segment name="W_Element_Segment" isaggregate="true">
+ <Index name="index" encoding="leb128u" type="uint32" count="1"/>
+ <Init name="init" type="self::Init_Expr" count="1"/>
+ <Num_Length name="num_length" encoding="leb128u" type="uint32" count="1"/>
+ <Elems name="elems" encoding="leb128u" type="uint32" count="self::Num_Length"/>
+ </Element_Segment>
+ <Local_Entry name="W_Local_Entry" isaggregate="true">
+ <Count name="count" encoding="leb128u" type="uint32" count="1"/>
+ <Type name="type" encoding="leb128u" type="uint16" count="self::Count"/>
+ </Local_Entry>
+ <Function_Body name="W_Function_Body" isaggregate="true">
+ <Body_size name="body_size" encoding="leb128u" type="uint32" count="1"/>
+ <Local_Count name="local_count" encoding="leb128u" type="uint32" count="1"/>
+ <Local_Entries name="locals" type="self::Local_Entry" count="self::Local_Count"/>
+ <Code name="code" type="uchar" count="self::Body_size"/>
+ </Function_Body>
+ <Data_Segment name="W_Data_Segment" isaggregate="true">
+ <Index name="index" encoding="leb128u" type="uint32" count="1"/>
+ <Offset name="offset" type="self::Init_Expr" count="1"/>
+ <Size name="size" encoding="leb128u" type="uint32" count="1"/>
+ <Data name="data" type="uchar" count="self::Size"/>
+ </Data_Segment>
+ </Definition>
+</FT>
diff --git a/bruiser/autogen/wasm/ltg.sh b/bruiser/autogen/wasm/ltg.sh
new file mode 100755
index 0000000..94f052b
--- /dev/null
+++ b/bruiser/autogen/wasm/ltg.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/bash
+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/
+clang-format ./ltg/*.c ./ltg/*.h -i
+for filename in ./ltg/*.c; do
+ gcc -c $filename > /dev/null 2>&1
+ if [[ $? != 0 ]]; then
+ echo $filename did not compile.
+ fi
+done
+rm *.o
diff --git a/bruiser/autogen/wasm/ltg/makefile b/bruiser/autogen/wasm/ltg/makefile
new file mode 100644
index 0000000..b59a216
--- /dev/null
+++ b/bruiser/autogen/wasm/ltg/makefile
@@ -0,0 +1,51 @@
+CC=clang
+CC?=clang
+CC_FLAGS=-fpic
+CC_EXTRA?=
+CC_FLAGS+=$(CC_EXTRA)
+SRCS=$(wildcard *.c)
+TBG_OBJLIST=$(patsubst %.c, %.o , $(wildcard *.c))
+TBG_OBJLIST_DBG=$(patsubst %.c, %.odbg , $(wildcard *.c))
+TBG_OBJLIST_COV=$(patsubst %.c, %.ocov , $(wildcard *.c))
+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
+MEM_SANITIZERS_LD= -g -fsanitize=memory
+UB_SANITIZERS_CC= -g -fsanitize=undefined -fno-omit-frame-pointer
+UB_SANITIZERS_LD= -g -fsanitize=undefined
+COV_CC= -fprofile-instr-generate -fcoverage-mapping
+
+.DEFAULT:all
+
+.PHONY:all clean help
+
+all:$(TBG_OBJLIST) $(TBG_OBJLIST_DBG) $(TBG_OBJLIST_COV)
+ @echo $(TBG_OBJLIST)
+ @echo $(TBG_OBJLIST_INC)
+
+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-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
+
+.c.o:
+ $(CC) $(CC_FLAGS) -c $< -o $@
+
+%.odbg:%.c
+ $(CC) $(CC_FLAGS) -g -c $< -o $@
+
+%.ocov:%.c
+ $(CC) $(CC_FLAGS) $(COV_CC) -c $< -o $@
+
+clean:
+ rm -f *.o *~ $(TARGET) *.ocov *.odbg
+ rm .depend
+
+help:
+ @echo "all is the default target"
+ @echo "there is clean."
diff --git a/bruiser/autogen/wasm/ltg/wasm.xml b/bruiser/autogen/wasm/ltg/wasm.xml
new file mode 100644
index 0000000..6d8d0d2
--- /dev/null
+++ b/bruiser/autogen/wasm/ltg/wasm.xml
@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<FT>
+ <Read>
+ <Magic_Number name="magic_number" type="uint32" count="1" luatype="integer"></Magic_Number>
+ <Version name="version" type="uint32" count="1" luatype="integer"></Version>
+ <Type_Section name="W_Type_Section" count="1" type="" isaggregate="true" unordered="true" unorderedbegin="true" luatype="table">
+ <ID name="id" type="uint8" encoding="leb128u" issign="true" luatype="integer">1</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <Name name="name" type="string" size="self::NameLength" luatype="string"/>
+ <Count name="count" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
+ <Type_Section_Entry count="self::Count" type="self::Type_Section_Entry" name="entries" luatype="table"/>
+ </Type_Section>
+ <Import_Section name="W_Import_Section" count="1" type="" isaggregate="true" unordered="true" luatype="table">
+ <ID name="id" type="uint8" encoding="leb128u" issign="true" luatype="integer">2</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <Name name="name" type="string" size="self::NameLength" luatype="string"/>
+ <Count name="count" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
+ <Entries name="entries" type="self::Import_Section_Entry" count="self::Count" luatype="table"/>
+ </Import_Section>
+ <Function_Section name="W_Function_Section" count="1" type="" isaggregate="true" unordered="true" luatype="table">
+ <ID name="id" type="uint8" encoding="leb128u" issign="" luatype="integer">3</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <Name name="name" type="string" size="self::NameLength" luatype="string"/>
+ <Count name="count" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
+ <Types name="types" encoding="leb128u" type="uint32" count="self::Count" luatype="integer"/>
+ </Function_Section>
+ <Table_Section name="W_Table_Section" count="1" type="" isaggregate="true" unordered="true" luatype="table">
+ <ID name="id" type="uint8" encoding="leb128u" issign="true" luatype="integer">4</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <Name name="name" type="string" size="self::NameLength" luatype="string"/>
+ <Count name="count" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
+ <Entries name="entries" type="self::Table_Type" count="self::Count" luatype="table"/>
+ </Table_Section>
+ <Memory_Section name="W_Memory_Section" count="1" type="" isaggregate="true" unordered="true" luatype="table">
+ <ID name="id" type="uint8" encoding="leb128u" issign="true" luatype="integer">5</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <Name name="name" type="string" size="self::NameLength" luatype="string"/>
+ <!--<Count name="count" encoding="leb128u" type="uint32" count="1"/>-->
+ <Entries name="entries" type="self::Memory_Type" count="1" luatype="table"/>
+ </Memory_Section>
+ <Global_Section name="W_Global_Section" count="1" type="" isaggregate="true" unordered="true" luatype="table">
+ <ID name="id" type="uint8" encoding="leb128u" issign="true" luatype="integer">6</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <Name name="name" type="string" size="self::NameLength" luatype="string"/>
+ <Count name="count" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
+ <Globals name="globals" type="self::Global_Entry" count="self::Count" luatype="table"/>
+ </Global_Section>
+ <Export_Section name="W_Export_Section" count="1" type="" isaggregate="true" unordered="true" luatype="table">
+ <ID name="id" type="uint8" encoding="leb128u" issign="true" luatype="integer">7</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <Name name="name" type="string" size="self::NameLength" luatype="string"/>
+ <Count name="count" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
+ <Entries name="entries" type="self::Export_Entry" count="self::Count" luatype="table"/>
+ </Export_Section>
+ <Start_Section name="W_Start_Section" count="1" isaggregate="true" unordered="true" luatype="table">
+ <ID name="id" type="uint8" encoding="leb128u" issign="true" luatype="integer">8</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <Name name="name" type="string" size="self::NameLength" luatype="string"/>
+ <Index name="index" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
+ </Start_Section>
+ <Element_Section name="W_Element_Section" count="1" isaggregate="true" unordered="true" luatype="table">
+ <ID name="id" type="uint8" encoding="leb128u" issign="true" luatype="integer">9</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <Name name="name" type="string" size="self::NameLength" luatype="string"/>
+ <Count name="count" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
+ <Entries name="entries" type="self::Element_Segment" count="self::Count" luatype="table"/>
+ </Element_Section>
+ <Code_Section name="W_Code_Section" count="1" isaggregate="true" unordered="true" luatype="table">
+ <ID name="id" type="uint8" encoding="leb128u" issign="true" luatype="integer">10</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <Name name="name" type="string" size="self::NameLength" luatype="string"/>
+ <Count name="count" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
+ <Bodies name="bodies" type="self::Function_Body" count="self::Count" luatype="table"/>
+ </Code_Section>
+ <Data_Section name="W_Data_Section" count="1" isaggregate="true" unordered="true" luatype="table">
+ <ID name="id" type="uint8" encoding="leb128u" issign="true" luatype="integer">11</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <Name name="name" type="string" size="self::NameLength" luatype="string"/>
+ <Count name="count" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
+ <Entries name="entries" type="self::Data_Segment" count="self::Count" luatype="table"/>
+ </Data_Section>
+ <Custom_Section name="W_Custom_Section" count="*" isaggregate="true" unordered="true" unorderedend="true" luatype="table">
+ <ID name="id" type="uint8" encoding="leb128u" issign="true" luatype="integer">0</ID>
+ <PayloadLength name="payloadlength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <NameLength name="namelength" type="uint32" encoding="leb128u" luatype="integer"/>
+ <Name name="name" type="string" size="self::NameLength" luatype="string"/>
+ <Payload name="payload" type="uint8" count="self::PayloadLength" luatype="integer"/>
+ </Custom_Section>
+ </Read>
+ <Definition>
+ <Init_Expr name="init_expr_t" isaggregate="true" luatype="table">
+ <Code name="code" type="string" count="1" size="-1" delimiter="11" luatype="integer"></Code>
+ </Init_Expr>
+ <Resizable_Limit name="resizable_limit_t" isaggregate="true" luatype="table">
+ <Flags name="flags" encoding="leb128u" type="uint8" count="1" luatype="integer"></Flags>
+ <Initial name="initial" encoding="leb128u" type="uint32" count="1" luatype="integer"></Initial>
+ <Maximum name="maximum" encoding="leb128u" type="uint32" count="1" luatype="integer"></Maximum>
+ </Resizable_Limit>
+ <Global_Type name="global_type_t" isaggregate="true" luatype="table">
+ <Value_Type name="value_type" type="uint32" count="1" luatype="integer"></Value_Type>
+ <Mutability name="mutability" encoding="leb128u" type="uint8" count="1" luatype="integer"></Mutability>
+ </Global_Type>
+ <Table_Type name="table_type_t" isaggregate="true" luatype="table">
+ <Element_Type name="element_type" encoding="leb128u" type="uint8" count="1" luatype="integer"></Element_Type>
+ <Resizable_Limit name="resizable_limit" count="1" type="self::Resizable_Limit" luatype="table"></Resizable_Limit>
+ </Table_Type>
+ <Memory_Type name="memory_type_t" isaggregate="true" luatype="table">
+ <Resizable_Limit count="1" type="self::Resizable_Limit" name="resizable_limit" luatype="table"></Resizable_Limit>
+ </Memory_Type>
+ <Type_Section_Entry name="W_Type_Section_Entry" isaggregate="true" luatype="table">
+ <Form name="form" encoding="leb128u" type="uint8" count="1" luatype="integer"/>
+ <Param_Count name="param_count" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
+ <Param_Types name="param_types" encoding="leb128u" type="uint8" count="self::Param_Count" luatype="integer"/>
+ <Return_Count name="return_count" encoding="leb128u" type="uint8" luatype="integer"/>
+ <Return_Types name="return_types" encoding="leb128u" type="uint8" count="self::Return_Count" luatype="integer"/>
+ </Type_Section_Entry>
+ <Import_Section_Entry name="W_Import_Section_Entry" isaggregate="true" luatype="table">
+ <Module_Length name="module_length" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
+ <Module_Str name="module_str" type="string" count="1" size="self::Module_Length" luatype="string"/>
+ <Field_Len name="field_len" encoding="leb128u" type="uint32" couny="1" luatype="integer"/>
+ <Field_Str name="field_str" type="string" count="1" size="self::Field_Len" luatype="string"/>
+ <Kind name="kind" encoding="leb128u" type="uint8" count="1" luatype="integer"/>
+ <Type name="type" conditional="true" condition="self::Kind" type="FT::conditional" luatype="conditional">
+ <condition0 name="type" encoding="leb128u" type="uint32" luatype="integer">0</condition0>
+ <condition1 name="type" type="self::Table_Type" luatype="table">1</condition1>
+ <condition2 name="type" type="self::Memory_Type" luatype="table">2</condition2>
+ <condition3 name="type" type="self::Global_Type" luatype="table">3</condition3>
+ </Type>
+ </Import_Section_Entry>
+ <Global_Entry name="W_Global_Entry" isaggregate="true" luatype="table">
+ <Global_Type name="type" type="self::Global_Type" count="1" luatype="table"/>
+ <Init name="init" type="self::Init_Expr" count="1" luatype="table"/>
+ </Global_Entry>
+ <Export_Entry name="W_Export_Entry" isaggregate="true" luatype="table">
+ <Field_Len name="field_len" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
+ <Field_Str name="field_str" type="string" count="1" size="self::Field_Len" luatype="string"/>
+ <Kind name="kind" encoding="leb128u" type="uint8" count="1" luatype="integer"/>
+ <Index name="index" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
+ </Export_Entry>
+ <Element_Segment name="W_Element_Segment" isaggregate="true" luatype="table">
+ <Index name="index" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
+ <Init name="init" type="self::Init_Expr" count="1" luatype="table"/>
+ <Num_Length name="num_length" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
+ <Elems name="elems" encoding="leb128u" type="uint32" count="self::Num_Length" luatype="integer"/>
+ </Element_Segment>
+ <Local_Entry name="W_Local_Entry" isaggregate="true" luatype="table">
+ <Count name="count" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
+ <Type name="type" encoding="leb128u" type="uint16" count="self::Count" luatype="integer"/>
+ </Local_Entry>
+ <Function_Body name="W_Function_Body" isaggregate="true" luatype="table">
+ <Body_size name="body_size" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
+ <Local_Count name="local_count" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
+ <Local_Entries name="locals" type="self::Local_Entry" count="self::Local_Count" luatype="table"/>
+ <Code name="code" type="uchar" count="self::Body_size" luatype="integer"/>
+ </Function_Body>
+ <Data_Segment name="W_Data_Segment" isaggregate="true" luatype="table">
+ <Index name="index" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
+ <Offset name="offset" type="self::Init_Expr" count="1" luatype="table"/>
+ <Size name="size" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
+ <Data name="data" type="uchar" count="self::Size" luatype="table"/>
+ </Data_Segment>
+ </Definition>
+</FT>