parent
a0f8765251
commit
94f11cc3a8
src
@ -68,8 +68,17 @@ impl WriteDebugInfo for ObjectProduct {
|
||||
.into_bytes();
|
||||
|
||||
let segment = self.object.segment_name(StandardSegment::Debug).to_vec();
|
||||
let section_id = self.object.add_section(segment, name, SectionKind::Debug);
|
||||
self.object.section_mut(section_id).set_data(data, 1);
|
||||
// FIXME use SHT_X86_64_UNWIND for .eh_frame
|
||||
let section_id = self.object.add_section(segment, name.clone(), if id == SectionId::EhFrame {
|
||||
SectionKind::ReadOnlyData
|
||||
} else {
|
||||
SectionKind::Debug
|
||||
});
|
||||
self.object.section_mut(section_id).set_data(data, if id == SectionId::EhFrame {
|
||||
8
|
||||
} else {
|
||||
1
|
||||
});
|
||||
let symbol_id = self.object.section_symbol(section_id);
|
||||
(section_id, symbol_id)
|
||||
}
|
||||
@ -95,7 +104,7 @@ impl WriteDebugInfo for ObjectProduct {
|
||||
Relocation {
|
||||
offset: u64::from(reloc.offset),
|
||||
symbol,
|
||||
kind: RelocationKind::Absolute,
|
||||
kind: reloc.kind,
|
||||
encoding: RelocationEncoding::Generic,
|
||||
size: reloc.size * 8,
|
||||
addend: i64::try_from(symbol_offset).unwrap() + reloc.addend,
|
||||
|
@ -46,6 +46,7 @@ pub(crate) struct DebugReloc {
|
||||
pub(crate) size: u8,
|
||||
pub(crate) name: DebugRelocName,
|
||||
pub(crate) addend: i64,
|
||||
pub(crate) kind: object::RelocationKind,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -122,14 +123,13 @@ impl Writer for WriterRelocate {
|
||||
size,
|
||||
name: DebugRelocName::Symbol(symbol),
|
||||
addend: addend as i64,
|
||||
kind: object::RelocationKind::Absolute,
|
||||
});
|
||||
self.write_udata(0, size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: implement write_eh_pointer
|
||||
|
||||
fn write_offset(&mut self, val: usize, section: SectionId, size: u8) -> Result<()> {
|
||||
let offset = self.len() as u32;
|
||||
self.relocs.push(DebugReloc {
|
||||
@ -137,6 +137,7 @@ impl Writer for WriterRelocate {
|
||||
size,
|
||||
name: DebugRelocName::Section(section),
|
||||
addend: val as i64,
|
||||
kind: object::RelocationKind::Absolute,
|
||||
});
|
||||
self.write_udata(0, size)
|
||||
}
|
||||
@ -153,7 +154,55 @@ impl Writer for WriterRelocate {
|
||||
size,
|
||||
name: DebugRelocName::Section(section),
|
||||
addend: val as i64,
|
||||
kind: object::RelocationKind::Absolute,
|
||||
});
|
||||
self.write_udata_at(offset, 0, size)
|
||||
}
|
||||
|
||||
fn write_eh_pointer(
|
||||
&mut self,
|
||||
address: Address,
|
||||
eh_pe: gimli::DwEhPe,
|
||||
size: u8,
|
||||
) -> Result<()> {
|
||||
match address {
|
||||
// Address::Constant arm copied from gimli
|
||||
Address::Constant(val) => {
|
||||
// Indirect doesn't matter here.
|
||||
let val = match eh_pe.application() {
|
||||
gimli::DW_EH_PE_absptr => val,
|
||||
gimli::DW_EH_PE_pcrel => {
|
||||
// TODO: better handling of sign
|
||||
let offset = self.len() as u64;
|
||||
offset.wrapping_sub(val)
|
||||
}
|
||||
_ => {
|
||||
return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe));
|
||||
}
|
||||
};
|
||||
self.write_eh_pointer_data(val, eh_pe.format(), size)
|
||||
}
|
||||
Address::Symbol { symbol, addend } => {
|
||||
match eh_pe.application() {
|
||||
gimli::DW_EH_PE_pcrel => {
|
||||
let size = match eh_pe.format() {
|
||||
gimli::DW_EH_PE_sdata4 => 4,
|
||||
_ => return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe)),
|
||||
};
|
||||
self.relocs.push(DebugReloc {
|
||||
offset: self.len() as u32,
|
||||
size,
|
||||
name: DebugRelocName::Symbol(symbol),
|
||||
addend,
|
||||
kind: object::RelocationKind::Relative,
|
||||
});
|
||||
self.write_udata(0, size)
|
||||
}
|
||||
_ => {
|
||||
return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,10 @@ impl<'tcx> UnwindContext<'tcx> {
|
||||
pub(crate) fn new(tcx: TyCtxt<'tcx>, isa: &dyn TargetIsa) -> Self {
|
||||
let mut frame_table = FrameTable::default();
|
||||
|
||||
let cie_id = if let Some(cie) = isa.create_systemv_cie() {
|
||||
let cie_id = if let Some(mut cie) = isa.create_systemv_cie() {
|
||||
if isa.flags().is_pic() {
|
||||
cie.fde_address_encoding = gimli::DwEhPe(gimli::DW_EH_PE_pcrel.0 | gimli::DW_EH_PE_sdata4.0);
|
||||
}
|
||||
Some(frame_table.add_cie(cie))
|
||||
} else {
|
||||
None
|
||||
|
Loading…
x
Reference in New Issue
Block a user