Write .debug_frame information (#53)
* Write .debug_frame information * mv map_reg
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use faerie::artifact::{Decl, SectionKind};
|
||||
use faerie::*;
|
||||
use gimli::write::{Address, Dwarf, EndianVec, Result, Sections, Writer};
|
||||
use gimli::write::{Address, DebugFrame, Dwarf, EndianVec, FrameTable, Result, Sections, Writer};
|
||||
use gimli::{RunTimeEndian, SectionId};
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -24,6 +24,7 @@ pub fn emit_dwarf(
|
||||
artifact: &mut Artifact,
|
||||
mut dwarf: Dwarf,
|
||||
symbol_resolver: &dyn SymbolResolver,
|
||||
frames: Option<FrameTable>,
|
||||
) -> anyhow::Result<()> {
|
||||
let endian = RunTimeEndian::Little;
|
||||
|
||||
@@ -52,6 +53,30 @@ pub fn emit_dwarf(
|
||||
}
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
if let Some(frames) = frames {
|
||||
let mut debug_frame = DebugFrame::from(WriterRelocate::new(endian, symbol_resolver));
|
||||
frames.write_debug_frame(&mut debug_frame).unwrap();
|
||||
artifact.declare_with(
|
||||
SectionId::DebugFrame.name(),
|
||||
Decl::section(SectionKind::Debug),
|
||||
debug_frame.writer.take(),
|
||||
)?;
|
||||
for reloc in &debug_frame.relocs {
|
||||
artifact.link_with(
|
||||
faerie::Link {
|
||||
from: SectionId::DebugFrame.name(),
|
||||
to: &reloc.name,
|
||||
at: u64::from(reloc.offset),
|
||||
},
|
||||
faerie::Reloc::Debug {
|
||||
size: reloc.size,
|
||||
addend: reloc.addend as i32,
|
||||
},
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user