2018-03-13 15:58:18 +03:00
|
|
|
extern crate pwasm_utils as utils;
|
2018-02-27 16:52:37 +03:00
|
|
|
extern crate parity_wasm;
|
2018-05-15 19:17:59 +08:00
|
|
|
extern crate pwasm_utils_cli as logger;
|
2018-02-27 16:52:37 +03:00
|
|
|
|
|
|
|
use std::env;
|
2018-03-13 15:58:18 +03:00
|
|
|
use utils::stack_height;
|
2018-02-27 16:52:37 +03:00
|
|
|
|
|
|
|
fn main() {
|
2018-05-15 08:05:00 +08:00
|
|
|
logger::init_log();
|
2018-02-27 16:52:37 +03:00
|
|
|
|
|
|
|
let args = env::args().collect::<Vec<_>>();
|
|
|
|
if args.len() != 3 {
|
|
|
|
println!("Usage: {} input_file.wasm output_file.wasm", args[0]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let input_file = &args[1];
|
|
|
|
let output_file = &args[2];
|
|
|
|
|
|
|
|
// Loading module
|
|
|
|
let module = parity_wasm::deserialize_file(&input_file).expect("Module deserialization to succeed");
|
|
|
|
|
|
|
|
let result = stack_height::inject_limiter(
|
|
|
|
module, 1024
|
|
|
|
).expect("Failed to inject stack height counter");
|
|
|
|
|
|
|
|
parity_wasm::serialize_to_file(&output_file, result).expect("Module serialization to succeed")
|
|
|
|
}
|