Removes duplicate code in src/obj.rs, crates/obj and crates/jit/object.rs (#1993)
Changes: - Moves object creation code from crates/jit/object.rs to the creates/obj (as ObjectBuilder) - Removes legacy crates/obj/function.rs - Removes write_debugsections
This commit is contained in:
@@ -2,8 +2,10 @@ pub use crate::read_debuginfo::{read_debuginfo, DebugInfoData, WasmFileInfo};
|
||||
pub use crate::transform::transform_dwarf;
|
||||
use gimli::write::{Address, Dwarf, EndianVec, FrameTable, Result, Sections, Writer};
|
||||
use gimli::{RunTimeEndian, SectionId};
|
||||
use wasmtime_environ::entity::{EntityRef, PrimaryMap};
|
||||
use wasmtime_environ::isa::{unwind::UnwindInfo, TargetIsa};
|
||||
use wasmtime_environ::{Compilation, ModuleAddressMap, ModuleVmctxInfo, ValueLabelsRanges};
|
||||
use wasmtime_environ::wasm::DefinedFuncIndex;
|
||||
use wasmtime_environ::{ModuleAddressMap, ModuleVmctxInfo, ValueLabelsRanges};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum DwarfSectionRelocTarget {
|
||||
@@ -130,18 +132,18 @@ impl Writer for WriterRelocate {
|
||||
|
||||
fn create_frame_table<'a>(
|
||||
isa: &dyn TargetIsa,
|
||||
infos: impl Iterator<Item = &'a Option<UnwindInfo>>,
|
||||
infos: &PrimaryMap<DefinedFuncIndex, &Option<UnwindInfo>>,
|
||||
) -> Option<FrameTable> {
|
||||
let mut table = FrameTable::default();
|
||||
|
||||
let cie_id = table.add_cie(isa.create_systemv_cie()?);
|
||||
|
||||
for (i, info) in infos.enumerate() {
|
||||
for (i, info) in infos {
|
||||
if let Some(UnwindInfo::SystemV(info)) = info {
|
||||
table.add_fde(
|
||||
cie_id,
|
||||
info.to_fde(Address::Symbol {
|
||||
symbol: i,
|
||||
symbol: i.index(),
|
||||
addend: 0,
|
||||
}),
|
||||
);
|
||||
@@ -151,16 +153,16 @@ fn create_frame_table<'a>(
|
||||
Some(table)
|
||||
}
|
||||
|
||||
pub fn emit_dwarf(
|
||||
pub fn emit_dwarf<'a>(
|
||||
isa: &dyn TargetIsa,
|
||||
debuginfo_data: &DebugInfoData,
|
||||
at: &ModuleAddressMap,
|
||||
vmctx_info: &ModuleVmctxInfo,
|
||||
ranges: &ValueLabelsRanges,
|
||||
compilation: &Compilation,
|
||||
unwind_info: &PrimaryMap<DefinedFuncIndex, &Option<UnwindInfo>>,
|
||||
) -> anyhow::Result<Vec<DwarfSection>> {
|
||||
let dwarf = transform_dwarf(isa, debuginfo_data, at, vmctx_info, ranges)?;
|
||||
let frame_table = create_frame_table(isa, compilation.into_iter().map(|f| &f.unwind_info));
|
||||
let frame_table = create_frame_table(isa, unwind_info);
|
||||
let sections = emit_dwarf_sections(dwarf, frame_table)?;
|
||||
Ok(sections)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user