aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bruiser/autogen/wasm/ft/autowasm.c208
-rw-r--r--bruiser/autogen/wasm/ltg/luwasm.xml2
-rw-r--r--bruiser/bruiser.cpp5
m---------bruiser/faultreiber0
-rw-r--r--bruiser/lua-scripts/wasmtest.lua15
m---------bruiser/tablegen0
6 files changed, 157 insertions, 73 deletions
diff --git a/bruiser/autogen/wasm/ft/autowasm.c b/bruiser/autogen/wasm/ft/autowasm.c
index 53986c1..a766d2a 100644
--- a/bruiser/autogen/wasm/ft/autowasm.c
+++ b/bruiser/autogen/wasm/ft/autowasm.c
@@ -30,123 +30,197 @@ int main(int argc, char **argv) {
wasm_lib_ret_t *lib_ret = read_aggr_wasm(wasm);
printf("finished reading\n");
-#if 0
- printf("magic_number:%x\n", lib_ret->obj->magic_number_container->magic_number);
+#if 1
+ printf("magic_number:%x\n",
+ lib_ret->obj->magic_number_container->magic_number);
printf("version:%x\n", lib_ret->obj->version_container->version);
printf("type section id:%d\n", lib_ret->obj->W_Type_Section_container->id);
- printf("type section payloadlength:%d\n", lib_ret->obj->W_Type_Section_container->payloadlength);
- printf("type_section entry count:%d\n", lib_ret->obj->W_Type_Section_container->count);
- for (int i=0; i < lib_ret->obj->W_Type_Section_container->count; ++i) {
- printf("param_count:%d\n",lib_ret->obj->W_Type_Section_container->entries[i]->param_count);
- for (int j = 0; j < lib_ret->obj->W_Type_Section_container->entries[i]->param_count; ++j)
- printf("param_types:%d\n",lib_ret->obj->W_Type_Section_container->entries[i]->param_types[j]);
- printf("return_count:%d\n", lib_ret->obj->W_Type_Section_container->entries[i]->return_count);
- for (int j = 0; j < lib_ret->obj->W_Type_Section_container->entries[i]->return_count; ++j)
- printf("param_types:%d\n",lib_ret->obj->W_Type_Section_container->entries[i]->return_types[j]);
+ printf("type section payloadlength:%d\n",
+ lib_ret->obj->W_Type_Section_container->payloadlength);
+ printf("type_section entry count:%d\n",
+ lib_ret->obj->W_Type_Section_container->count);
+ for (int i = 0; i < lib_ret->obj->W_Type_Section_container->count; ++i) {
+ printf("param_count:%d\n",
+ lib_ret->obj->W_Type_Section_container->entries[i]->param_count);
+ for (int j = 0;
+ j < lib_ret->obj->W_Type_Section_container->entries[i]->param_count;
+ ++j)
+ printf(
+ "param_types:%d\n",
+ lib_ret->obj->W_Type_Section_container->entries[i]->param_types[j]);
+ printf("return_count:%d\n",
+ lib_ret->obj->W_Type_Section_container->entries[i]->return_count);
+ for (int j = 0;
+ j < lib_ret->obj->W_Type_Section_container->entries[i]->return_count;
+ ++j)
+ printf(
+ "param_types:%d\n",
+ lib_ret->obj->W_Type_Section_container->entries[i]->return_types[j]);
}
- printf("import_section_id:%d\n", lib_ret->obj->W_Import_Section_container->id);
- printf("import_section_payloadlength:%d\n", lib_ret->obj->W_Import_Section_container->payloadlength);
- printf("import_section_count:%d\n", lib_ret->obj->W_Import_Section_container->count);
- for(int i = 0; i < lib_ret->obj->W_Import_Section_container->count; ++i) {
- printf("module_length:%d\n", lib_ret->obj->W_Import_Section_container->entries[i]->module_length);
- printf("module_str:%s\n", lib_ret->obj->W_Import_Section_container->entries[i]->module_str);
- printf("field_length:%d\n", lib_ret->obj->W_Import_Section_container->entries[i]->field_len);
- printf("field_str:%s\n", lib_ret->obj->W_Import_Section_container->entries[i]->field_str);
- printf("kind:%d\n", lib_ret->obj->W_Import_Section_container->entries[i]->kind);
+ printf("import_section_id:%d\n",
+ lib_ret->obj->W_Import_Section_container->id);
+ printf("import_section_payloadlength:%d\n",
+ lib_ret->obj->W_Import_Section_container->payloadlength);
+ printf("import_section_count:%d\n",
+ lib_ret->obj->W_Import_Section_container->count);
+ for (int i = 0; i < lib_ret->obj->W_Import_Section_container->count; ++i) {
+ printf("module_length:%d\n",
+ lib_ret->obj->W_Import_Section_container->entries[i]->module_length);
+ printf("module_str:%s\n",
+ lib_ret->obj->W_Import_Section_container->entries[i]->module_str);
+ printf("field_length:%d\n",
+ lib_ret->obj->W_Import_Section_container->entries[i]->field_len);
+ printf("field_str:%s\n",
+ lib_ret->obj->W_Import_Section_container->entries[i]->field_str);
+ printf("kind:%d\n",
+ lib_ret->obj->W_Import_Section_container->entries[i]->kind);
if (lib_ret->obj->W_Import_Section_container->entries[i]->kind == 0)
- printf("type:%d\n", lib_ret->obj->W_Import_Section_container->entries[i]->kind);
+ printf("type:%d\n",
+ lib_ret->obj->W_Import_Section_container->entries[i]->kind);
printf("\n");
}
- printf("function_section_id:%d\n", lib_ret->obj->W_Function_Section_container->id);
- printf("function_section_payloadlength:%d\n", lib_ret->obj->W_Function_Section_container->payloadlength);
- printf("function_section_count:%d\n", lib_ret->obj->W_Function_Section_container->count);
+ printf("function_section_id:%d\n",
+ lib_ret->obj->W_Function_Section_container->id);
+ printf("function_section_payloadlength:%d\n",
+ lib_ret->obj->W_Function_Section_container->payloadlength);
+ printf("function_section_count:%d\n",
+ lib_ret->obj->W_Function_Section_container->count);
for (int i = 0; i < lib_ret->obj->W_Function_Section_container->count; ++i)
printf("type:%d\n", lib_ret->obj->W_Function_Section_container->types[i]);
printf("table_section_id:%d\n", lib_ret->obj->W_Table_Section_container->id);
- printf("table_section_payloadlength:%d\n", lib_ret->obj->W_Table_Section_container->payloadlength);
- printf("table_section_count:%d\n", lib_ret->obj->W_Table_Section_container->count);
+ printf("table_section_payloadlength:%d\n",
+ lib_ret->obj->W_Table_Section_container->payloadlength);
+ printf("table_section_count:%d\n",
+ lib_ret->obj->W_Table_Section_container->count);
for (int i = 0; i < lib_ret->obj->W_Table_Section_container->count; ++i) {
- printf("element_type:%d\n", lib_ret->obj->W_Table_Section_container->entries[i]->element_type);
- printf("rl_flags:%d\n", lib_ret->obj->W_Table_Section_container->entries[i]->resizable_limit->flags);
- printf("rl_initial:%d\n", lib_ret->obj->W_Table_Section_container->entries[i]->resizable_limit->initial);
- printf("rl_maximum:%d\n", lib_ret->obj->W_Table_Section_container->entries[i]->resizable_limit->maximum);
+ printf("element_type:%d\n",
+ lib_ret->obj->W_Table_Section_container->entries[i]->element_type);
+ printf("rl_flags:%d\n", lib_ret->obj->W_Table_Section_container->entries[i]
+ ->resizable_limit->flags);
+ printf("rl_initial:%d\n",
+ lib_ret->obj->W_Table_Section_container->entries[i]
+ ->resizable_limit->initial);
+ printf("rl_maximum:%d\n",
+ lib_ret->obj->W_Table_Section_container->entries[i]
+ ->resizable_limit->maximum);
}
- printf("memory_section_id:%d\n", lib_ret->obj->W_Memory_Section_container->id);
- printf("memory_section_payload_length:%d\n", lib_ret->obj->W_Memory_Section_container->payloadlength);
- printf("rl_flags:%d\n", lib_ret->obj->W_Memory_Section_container->entries->resizable_limit->flags);
- printf("rl_initial:%d\n", lib_ret->obj->W_Memory_Section_container->entries->resizable_limit->initial);
- printf("rl_maximum:%d\n", lib_ret->obj->W_Memory_Section_container->entries->resizable_limit->maximum);
-
- if (lib_ret->obj->W_Global_Section_container == NULL) printf("global section doesnt exist.\n");
-
- printf("export_section_id:%d\n", lib_ret->obj->W_Export_Section_container->id);
- printf("export_section_payloadlength:%d\n", lib_ret->obj->W_Export_Section_container->payloadlength);
+ printf("memory_section_id:%d\n",
+ lib_ret->obj->W_Memory_Section_container->id);
+ printf("memory_section_payload_length:%d\n",
+ lib_ret->obj->W_Memory_Section_container->payloadlength);
+ printf("rl_flags:%d\n", lib_ret->obj->W_Memory_Section_container->entries
+ ->resizable_limit->flags);
+ printf("rl_initial:%d\n", lib_ret->obj->W_Memory_Section_container->entries
+ ->resizable_limit->initial);
+ printf("rl_maximum:%d\n", lib_ret->obj->W_Memory_Section_container->entries
+ ->resizable_limit->maximum);
+
+ if (lib_ret->obj->W_Global_Section_container == NULL)
+ printf("global section doesnt exist.\n");
+
+ printf("export_section_id:%d\n",
+ lib_ret->obj->W_Export_Section_container->id);
+ printf("export_section_payloadlength:%d\n",
+ lib_ret->obj->W_Export_Section_container->payloadlength);
printf("entry count:%d\n", lib_ret->obj->W_Export_Section_container->count);
for (int i = 0; i < lib_ret->obj->W_Export_Section_container->count; ++i) {
- printf("field_len:%d\n", lib_ret->obj->W_Export_Section_container->entries[i]->field_len);
- printf("field_str:%s\n", lib_ret->obj->W_Export_Section_container->entries[i]->field_str);
- printf("kind:%d\n", lib_ret->obj->W_Export_Section_container->entries[i]->kind);
- printf("index:%d\n", lib_ret->obj->W_Export_Section_container->entries[i]->index);
+ printf("field_len:%d\n",
+ lib_ret->obj->W_Export_Section_container->entries[i]->field_len);
+ printf("field_str:%s\n",
+ lib_ret->obj->W_Export_Section_container->entries[i]->field_str);
+ printf("kind:%d\n",
+ lib_ret->obj->W_Export_Section_container->entries[i]->kind);
+ printf("index:%d\n",
+ lib_ret->obj->W_Export_Section_container->entries[i]->index);
}
- if (lib_ret->obj->W_Start_Section_container == NULL) printf("start section doesnt exist.\n");
+ if (lib_ret->obj->W_Start_Section_container == NULL)
+ printf("start section doesnt exist.\n");
- printf("element_seciton_id:%d\n", lib_ret->obj->W_Element_Section_container->id);
- printf("element_section_payloadlength:%d\n", lib_ret->obj->W_Element_Section_container->payloadlength);
+ printf("element_seciton_id:%d\n",
+ lib_ret->obj->W_Element_Section_container->id);
+ printf("element_section_payloadlength:%d\n",
+ lib_ret->obj->W_Element_Section_container->payloadlength);
printf("entry count:%d\n", lib_ret->obj->W_Element_Section_container->count);
for (int i = 0; i < lib_ret->obj->W_Element_Section_container->count; ++i) {
- printf("index:%d\n", lib_ret->obj->W_Element_Section_container->entries[i]->index);
+ printf("index:%d\n",
+ lib_ret->obj->W_Element_Section_container->entries[i]->index);
for (int j = 0; j < 3; ++j) {
- printf("code:%d\n", lib_ret->obj->W_Element_Section_container->entries[i]->init->code[j]);
+ printf(
+ "code:%d\n",
+ lib_ret->obj->W_Element_Section_container->entries[i]->init->code[j]);
}
- printf("num_length:%d\n", lib_ret->obj->W_Element_Section_container->entries[i]->num_length);
- for (int j = 0; j < lib_ret->obj->W_Element_Section_container->entries[i]->num_length; ++j) {
- printf("elems:%d\n", lib_ret->obj->W_Element_Section_container->entries[i]->elems[j]);
+ printf("num_length:%d\n",
+ lib_ret->obj->W_Element_Section_container->entries[i]->num_length);
+ for (int j = 0;
+ j < lib_ret->obj->W_Element_Section_container->entries[i]->num_length;
+ ++j) {
+ printf("elems:%d\n",
+ lib_ret->obj->W_Element_Section_container->entries[i]->elems[j]);
}
}
printf("code_section_id:%d\n", lib_ret->obj->W_Code_Section_container->id);
- printf("code_section_payloadlength:%d\n", lib_ret->obj->W_Code_Section_container->payloadlength);
+ printf("code_section_payloadlength:%d\n",
+ lib_ret->obj->W_Code_Section_container->payloadlength);
printf("count:%d\n", lib_ret->obj->W_Code_Section_container->count);
for (int i = 0; i < lib_ret->obj->W_Code_Section_container->count; ++i) {
- printf("body_size:%d\n", lib_ret->obj->W_Code_Section_container->bodies[i]->body_size);
- printf("local_count:%d\n", lib_ret->obj->W_Code_Section_container->bodies[i]->local_count);
+ printf("body_size:%d\n",
+ lib_ret->obj->W_Code_Section_container->bodies[i]->body_size);
+ printf("local_count:%d\n",
+ lib_ret->obj->W_Code_Section_container->bodies[i]->local_count);
if (lib_ret->obj->W_Code_Section_container->bodies[i]->local_count > 0) {
- for (int j =0; j < lib_ret->obj->W_Code_Section_container->bodies[i]->local_count; ++j) {
- for (int k = 0; k < lib_ret->obj->W_Code_Section_container->bodies[i]->locals[j]->count; ++k) {
+ for (int j = 0;
+ j < lib_ret->obj->W_Code_Section_container->bodies[i]->local_count;
+ ++j) {
+ for (int k = 0; k < lib_ret->obj->W_Code_Section_container->bodies[i]
+ ->locals[j]
+ ->count;
+ ++k) {
}
}
}
printf("code:\n");
- for (int j = 0; j < lib_ret->obj->W_Code_Section_container->bodies[i]->body_size; ++j) {
- printf("%02x ", lib_ret->obj->W_Code_Section_container->bodies[i]->code[j]);
+ for (int j = 0;
+ j < lib_ret->obj->W_Code_Section_container->bodies[i]->body_size;
+ ++j) {
+ printf("%02x ",
+ lib_ret->obj->W_Code_Section_container->bodies[i]->code[j]);
}
printf("\n");
}
printf("data_section_id:%d\n", lib_ret->obj->W_Data_Section_container->id);
- printf("data_section_payloadlength:%d\n", lib_ret->obj->W_Data_Section_container->payloadlength);
+ printf("data_section_payloadlength:%d\n",
+ lib_ret->obj->W_Data_Section_container->payloadlength);
printf("data seg count:%d\n", lib_ret->obj->W_Data_Section_container->count);
for (int i = 0; i < lib_ret->obj->W_Data_Section_container->count; ++i) {
- printf("index:%d\n", lib_ret->obj->W_Data_Section_container->entries[i]->index);
- printf("size:%d\n", lib_ret->obj->W_Data_Section_container->entries[i]->size);
+ printf("index:%d\n",
+ lib_ret->obj->W_Data_Section_container->entries[i]->index);
+ printf("size:%d\n",
+ lib_ret->obj->W_Data_Section_container->entries[i]->size);
printf("code:\n");
- for (int j = 0; j < lib_ret->obj->W_Data_Section_container->entries[i]->size; ++j) {
- printf("%c ", lib_ret->obj->W_Data_Section_container->entries[i]->data[j]);
+ for (int j = 0;
+ j < lib_ret->obj->W_Data_Section_container->entries[i]->size; ++j) {
+ printf("%c ",
+ lib_ret->obj->W_Data_Section_container->entries[i]->data[j]);
}
printf("\n");
int j = 0;
printf("offset:\n");
- while(1) {
- printf("%02x ", lib_ret->obj->W_Data_Section_container->entries[i]->offset->code[j]);
- if (lib_ret->obj->W_Data_Section_container->entries[i]->offset->code[j] == 11) {
+ while (1) {
+ printf(
+ "%02x ",
+ lib_ret->obj->W_Data_Section_container->entries[i]->offset->code[j]);
+ if (lib_ret->obj->W_Data_Section_container->entries[i]->offset->code[j] ==
+ 11) {
break;
}
j++;
diff --git a/bruiser/autogen/wasm/ltg/luwasm.xml b/bruiser/autogen/wasm/ltg/luwasm.xml
index 6db8b7b..8d6efe0 100644
--- a/bruiser/autogen/wasm/ltg/luwasm.xml
+++ b/bruiser/autogen/wasm/ltg/luwasm.xml
@@ -100,7 +100,7 @@
</Read>
<Definition>
<Init_Expr name="init_expr_t" isaggregate="true" luatype="lightuserdata">
- <Code name="code" type="string" count="1" size="-1" delimiter="11" luatype="integer"></Code>
+ <Code name="code" type="string" count="1" size="-1" delimiter="11" luatype="string"></Code>
</Init_Expr>
<Resizable_Limit name="resizable_limit_t" isaggregate="true" luatype="lightuserdata">
<Flags name="flags" encoding="leb128u" type="uint8" count="1" luatype="integer"></Flags>
diff --git a/bruiser/bruiser.cpp b/bruiser/bruiser.cpp
index 726f963..048dc54 100644
--- a/bruiser/bruiser.cpp
+++ b/bruiser/bruiser.cpp
@@ -1546,8 +1546,8 @@ class LuaWrapper {
int j = 0;
printf("offset:\n");
while(1) {
- printf("%02x ", lib_ret->obj->W_Data_Section_container->entries[i]->offset->code[j]);
- if (lib_ret->obj->W_Data_Section_container->entries[i]->offset->code[j] == 11) {
+ printf("%02x ", (unsigned char)lib_ret->obj->W_Data_Section_container->entries[i]->offset->code[j]);
+ if (lib_ret->obj->W_Data_Section_container->entries[i]->offset->code[j] == 11U) {
break;
}
j++;
@@ -2209,6 +2209,7 @@ class RunLoop {
/*cli execution loop*/
while((command = linenoise(">>>")) != NULL) {
+ //FIXME-if the current command is the same as last command skip adding to history
linenoiseHistoryAdd(command);
linenoiseHistorySave(SHELL_HISTORY_FILE.c_str());
le.RunChunk(command);
diff --git a/bruiser/faultreiber b/bruiser/faultreiber
-Subproject a9ba7c19941ae6b47390a8f130a80edc4bad1df
+Subproject aa60b19995fb0100ee16d57265e4096566b2222
diff --git a/bruiser/lua-scripts/wasmtest.lua b/bruiser/lua-scripts/wasmtest.lua
index 15aa395..32c8442 100644
--- a/bruiser/lua-scripts/wasmtest.lua
+++ b/bruiser/lua-scripts/wasmtest.lua
@@ -197,9 +197,18 @@ function demo4()
for k,v in pairs(a["data_section"]:entries()) do
io.write(v:index().."\t")
io.write(tostring(v:offset()).."\t")
- io.write(v:size().."\n")
- --FIXME
- --io.write(v:data().."\n")
+ print(colors("%{red}"..tostring(#v:offset():code())))
+ for i = 1, #v:offset():code() do
+ local c = v:offset():code():sub(i,i)
+ print(colors("%{red}"..string.byte(c)))
+ end
+ --io.write(colors("%{yellow}"..v:offset():code()))
+ io.write("size:"..v:size().."\n")
+ io.write(tostring(v:data()).."\n")
+ for i, j in pairs(v:data()) do
+ io.write(colors("%{blue}"..string.char(j)))
+ end
+ io.write("\n")
end
end
else
diff --git a/bruiser/tablegen b/bruiser/tablegen
-Subproject 66e1d73de5160333a8552f4e28027e8dcd69cb3
+Subproject c0eda3bcb258278bba83b6d3d26d5d7f4b65ef4