wip - fix #636, check memory before calculating offset

This commit is contained in:
data-pup
2019-11-26 12:43:31 -05:00
parent 46766ed925
commit bbea2855be

View File

@@ -163,26 +163,30 @@ impl Compiler {
let body_len = compilation.get(i).body.len(); let body_len = compilation.get(i).body.len();
funcs.push((ptr, body_len)); funcs.push((ptr, body_len));
} }
let module_vmctx_info = { let ofs = VMOffsets::new(target_config.pointer_bytes(), &module);
let ofs = VMOffsets::new(target_config.pointer_bytes(), &module); if ofs.num_defined_memories > 0 {
let memory_offset = let module_vmctx_info = {
ofs.vmctx_vmmemory_definition_base(DefinedMemoryIndex::new(0)) as i64; let memory_offset =
ModuleVmctxInfo { ofs.vmctx_vmmemory_definition_base(DefinedMemoryIndex::new(0)) as i64;
memory_offset, ModuleVmctxInfo {
stack_slots, memory_offset,
} stack_slots,
}; }
let bytes = emit_debugsections_image( };
triple, let bytes = emit_debugsections_image(
&target_config, triple,
&debug_data, &target_config,
&module_vmctx_info, &debug_data,
&address_transform, &module_vmctx_info,
&value_ranges, &address_transform,
&funcs, &value_ranges,
) &funcs,
.map_err(|e| SetupError::DebugInfo(e))?; )
Some(bytes) .map_err(|e| SetupError::DebugInfo(e))?;
Some(bytes)
} else {
None
}
} else { } else {
None None
}; };