mirror of
https://github.com/fluencelabs/wasm-utils
synced 2025-05-29 07:31:22 +00:00
fix also bug with externalizer
This commit is contained in:
parent
b2d04ea3a9
commit
de3b30dab5
14
src/ext.rs
14
src/ext.rs
@ -8,7 +8,7 @@ pub fn update_call_index(opcodes: &mut elements::Opcodes, original_imports: usiz
|
|||||||
match opcode {
|
match opcode {
|
||||||
&mut Call(ref mut call_index) => {
|
&mut Call(ref mut call_index) => {
|
||||||
if let Some(pos) = inserts.iter().position(|x| x.1 == *call_index) {
|
if let Some(pos) = inserts.iter().position(|x| x.1 == *call_index) {
|
||||||
*call_index = (original_imports + pos) as u32;
|
*call_index = (original_imports + pos) as u32;
|
||||||
} else if *call_index as usize > original_imports {
|
} else if *call_index as usize > original_imports {
|
||||||
*call_index += inserts.len() as u32;
|
*call_index += inserts.len() as u32;
|
||||||
}
|
}
|
||||||
@ -86,9 +86,17 @@ pub fn externalize(
|
|||||||
if *func_index >= import_funcs_total as u32 { *func_index += replaces.len() as u32; }
|
if *func_index >= import_funcs_total as u32 { *func_index += replaces.len() as u32; }
|
||||||
},
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
&mut elements::Section::Element(ref mut elements_section) => {
|
||||||
|
for ref mut segment in elements_section.entries_mut() {
|
||||||
|
// update all indirect call addresses initial values
|
||||||
|
for func_index in segment.members_mut() {
|
||||||
|
if *func_index >= import_funcs_total as u32 { *func_index += replaces.len() as u32; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
_ => { }
|
_ => { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,11 +256,11 @@ pub struct Set {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Set {
|
impl Set {
|
||||||
fn new(entries: HashMap<InstructionType, u32>) -> Self {
|
pub fn new(entries: HashMap<InstructionType, u32>) -> Self {
|
||||||
Set { entries: entries }
|
Set { entries: entries }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process(&self, opcode: &elements::Opcode) -> u32 {
|
pub fn process(&self, opcode: &elements::Opcode) -> u32 {
|
||||||
self.entries.get(&InstructionType::op(opcode)).map(|x| *x).unwrap_or(1)
|
self.entries.get(&InstructionType::op(opcode)).map(|x| *x).unwrap_or(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user