mirror of
https://github.com/pezkuwichain/wasm-instrument.git
synced 2026-06-13 08:11:09 +00:00
finalize tool
This commit is contained in:
+15
-1
@@ -1,5 +1,5 @@
|
||||
use parity_wasm::{elements, builder};
|
||||
use optimizer::import_section;
|
||||
use optimizer::{import_section, export_section};
|
||||
|
||||
type Insertion = (usize, u32, u32, String);
|
||||
|
||||
@@ -49,6 +49,20 @@ pub fn externalize_mem(mut module: elements::Module) -> elements::Module {
|
||||
module
|
||||
}
|
||||
|
||||
pub fn underscore_funcs(mut module: elements::Module) -> elements::Module {
|
||||
for entry in import_section(&mut module).expect("Import section to exist").entries_mut() {
|
||||
if let elements::External::Function(_) = *entry.external() {
|
||||
entry.field_mut().insert(0, '_');
|
||||
}
|
||||
}
|
||||
for entry in export_section(&mut module).expect("Import section to exist").entries_mut() {
|
||||
if let elements::Internal::Function(_) = *entry.internal() {
|
||||
entry.field_mut().insert(0, '_');
|
||||
}
|
||||
}
|
||||
module
|
||||
}
|
||||
|
||||
pub fn externalize(
|
||||
module: elements::Module,
|
||||
replaced_funcs: Vec<&str>,
|
||||
|
||||
Reference in New Issue
Block a user