diff options
Diffstat (limited to 'test/binaryen.js/reloc.js')
-rw-r--r-- | test/binaryen.js/reloc.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/binaryen.js/reloc.js b/test/binaryen.js/reloc.js new file mode 100644 index 000000000..68c29228d --- /dev/null +++ b/test/binaryen.js/reloc.js @@ -0,0 +1,26 @@ +function assert(x) { + if (!x) throw 'error!'; +} + +var module = new Binaryen.Module(); + +// memory with offset + +module.addGlobalImport("memory_base", "env", "memory_base", Binaryen.i32, false); +module.setMemory(1, -1, null, [ + { + offset: module.global.get("memory_base", Binaryen.i32), + data: "data data".split('').map(function(x) { return x.charCodeAt(0) }) + } +]); + +// table with offset + +var signature = module.addFunctionType("v", Binaryen.none, []); +var func = module.addFunction("func", signature, [], module.nop()); + +module.addGlobalImport("table_base", "env", "table_base", Binaryen.i32, false); +module.setFunctionTable(1, -1, [ "func", "func" ], module.global.get("table_base", Binaryen.i32)); + +assert(module.validate()); +console.log(module.emitText()); |