mirror of
https://github.com/pezkuwichain/wasm-instrument.git
synced 2026-06-12 08:51:05 +00:00
handle debug info (#16)
This commit is contained in:
+14
-2
@@ -11,7 +11,7 @@ use alloc::{vec, vec::Vec};
|
||||
use core::{cmp::min, mem, num::NonZeroU32};
|
||||
use parity_wasm::{
|
||||
builder,
|
||||
elements::{self, Instruction, ValueType},
|
||||
elements::{self, IndexMap, Instruction, ValueType},
|
||||
};
|
||||
|
||||
/// An interface that describes instruction costs.
|
||||
@@ -129,7 +129,8 @@ impl Rules for ConstantCostRules {
|
||||
///
|
||||
/// The above transformations are performed for every function body defined in the module. This
|
||||
/// function also rewrites all function indices references by code, table elements, etc., since
|
||||
/// the addition of an imported functions changes the indices of module-defined functions.
|
||||
/// the addition of an imported functions changes the indices of module-defined functions. If the
|
||||
/// the module has a NameSection, added by calling `parse_names`, the indices will also be updated.
|
||||
///
|
||||
/// This routine runs in time linear in the size of the input module.
|
||||
///
|
||||
@@ -212,6 +213,17 @@ pub fn inject<R: Rules>(
|
||||
if *start_idx >= gas_func {
|
||||
*start_idx += 1
|
||||
},
|
||||
elements::Section::Name(s) =>
|
||||
for functions in s.functions_mut() {
|
||||
*functions.names_mut() =
|
||||
IndexMap::from_iter(functions.names().iter().map(|(mut idx, name)| {
|
||||
if idx >= gas_func {
|
||||
idx += 1;
|
||||
}
|
||||
|
||||
(idx, name.clone())
|
||||
}));
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user