diff --git a/Cargo.lock b/Cargo.lock index 3363a6a..5e069c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" [[package]] name = "parity-wasm" -version = "0.42.2" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92" +checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" [[package]] name = "proc-macro2" diff --git a/Cargo.toml b/Cargo.toml index 23a5763..35c801d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -parity-wasm = "0.42" +parity-wasm = { version = "0.45", features = ["sign_ext"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/README.md b/README.md new file mode 100644 index 0000000..1b6e081 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +Read import- and exported function symbols from [fugg-fetch](https://git.noest.dev/gijs/fugg-fetch) and applies them to a specified `client.wasm`. diff --git a/src/main.rs b/src/main.rs index 6713980..ab2f8fa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,7 @@ struct FunctionFile { } fn main() { - let directory = Path::new("../fugg-fetch/out/55"); + let directory = Path::new("../fugg-fetch/out/134"); let input = directory.join("client-original.wasm"); let output = directory.join("client.wasm"); @@ -27,8 +27,6 @@ fn main() { file.read_to_string(&mut data).unwrap(); let functions: FunctionFile = serde_json::from_str(&data).expect("JSON was not well-formatted"); - - println!("Functions: {:?}", functions); const MODULE: &str = "env"; @@ -65,6 +63,24 @@ fn main() { } } + { + let code_section = module.code_section_mut().unwrap(); + + println!("Got {} function bodies", code_section.bodies().len()); + + // for entry in function_section.entries_mut() { + // let nice_name = functions.exports.get(entry.field()); + + // if let Some(nice_name) = nice_name { + // println!("Export: Renaming {} to {}", entry.field(), nice_name); + + // *entry.field_mut() = String::from(nice_name); + // } else { + // println!("Export: Unable to find nice name for {}", entry.field()); + // } + // } + } + let output_bytes = parity_wasm::serialize(module).unwrap(); let mut file = OpenOptions::new() .write(true)