diff options
Diffstat (limited to '')
-rw-r--r-- | test/autowasm.c | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/test/autowasm.c b/test/autowasm.c index 87478c1..cbc6e5a 100644 --- a/test/autowasm.c +++ b/test/autowasm.c @@ -4,6 +4,7 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <sys/resource.h> #include "./structs.h" #include "./read.h" @@ -12,14 +13,31 @@ #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; + + result = getrlimit(RLIMIT_STACK, &rl); + if (result == 0) + { + if (rl.rlim_cur < kStackSize) + { + rl.rlim_cur = kStackSize; + result = setrlimit(RLIMIT_STACK, &rl); + if (result != 0) + { + fprintf(stderr, "setrlimit returned result = %d\n", result); + } + } + } int wasm = open("./test.wasm", O_RDONLY); 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); printf("version:%x\n", lib_ret->obj->version_container->version); - printf("fuck\n"); 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); @@ -139,7 +157,26 @@ int main (int argc, char** argv) { } printf("\n"); } - - release_all(lib_ret->void_train, lib_ret->current_void_count); +#endif + + 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); + printf("void_train first:0x%x\n", lib_ret->void_train[0]); + printf("void_train first:0x%x\n", lib_ret->void_train[1]); + printf("void_train self address:0x%x\n", lib_ret->void_train); + //free(lib_ret->void_train[0]); + //release_all(lib_ret->void_train, lib_ret->current_void_count); + //free(lib_ret->void_train[2]); + //free(lib_ret->void_train[1]); + //free(lib_ret->void_train[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; + free(lib_ret->void_train[i]); + } + free(lib_ret->void_train); + free(lib_ret->obj); + free(lib_ret); return 0; } |