/// A relocation to be applied to a section. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pubstruct Relocation { /// The offset within the section where the relocation should be applied. pub offset: usize, /// The size of the value to be relocated. pub size: u8, /// The target of the relocation. pub target: RelocationTarget, /// The addend to be applied to the relocated value. pub addend: i64, /// The pointer encoding for relocations in unwind information. pub eh_pe: Option<constants::DwEhPe>,
}
/// The target of a relocation. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pubenum RelocationTarget { /// The relocation target is a symbol. /// /// The meaning of this value is decided by the writer, but /// will typically be an index into a symbol table.
Symbol(usize), /// The relocation target is a section.
Section(SectionId),
}
/// A `Writer` which also records relocations. pubtrait RelocateWriter { /// The type of the writer being used to write the section data. type Writer: Writer;
/// Get the writer being used to write the section data. fn writer(&self) -> &Self::Writer;
/// Get the writer being used to write the section data. fn writer_mut(&mutself) -> &mutSelf::Writer;
/// Record a relocation. fn relocate(&mutself, relocation: Relocation);
}
impl<T: RelocateWriter> Writer for T { type Endian = <<T as RelocateWriter>::Writer as Writer>::Endian;
// No relocation for plain data.
section.write_udata(0x12345678, 4).unwrap();
expected_data.extend_from_slice(&0x12345678u32.to_le_bytes());
// No relocation for a constant address.
section
.write_address(Address::Constant(0x87654321), 4)
.unwrap();
expected_data.extend_from_slice(&0x87654321u32.to_le_bytes());
// Relocation for a symbol address. let offset = section.len();
section
.write_address(
Address::Symbol {
symbol: 1,
addend: 0x12345678,
}, 4,
)
.unwrap();
expected_data.extend_from_slice(&[0; 4]);
expected_relocations.push(Relocation {
offset,
size: 4,
target: RelocationTarget::Symbol(1),
addend: 0x12345678,
eh_pe: None,
});
// Relocation for a section offset. let offset = section.len();
section
.write_offset(0x12345678, SectionId::DebugAbbrev, 4)
.unwrap();
expected_data.extend_from_slice(&[0; 4]);
expected_relocations.push(Relocation {
offset,
size: 4,
target: RelocationTarget::Section(SectionId::DebugAbbrev),
addend: 0x12345678,
eh_pe: None,
});
// Relocation for a section offset at a specific offset. let offset = section.len();
section.write_udata(0x12345678, 4).unwrap();
section
.write_offset_at(offset, 0x12345678, SectionId::DebugStr, 4)
.unwrap();
expected_data.extend_from_slice(&[0; 4]);
expected_relocations.push(Relocation {
offset,
size: 4,
target: RelocationTarget::Section(SectionId::DebugStr),
addend: 0x12345678,
eh_pe: None,
});
// No relocation for a constant in unwind information.
section
.write_eh_pointer(Address::Constant(0x87654321), constants::DW_EH_PE_absptr, 8)
.unwrap();
expected_data.extend_from_slice(&0x87654321u64.to_le_bytes());
// No relocation for a relative constant in unwind information. let offset = section.len();
section
.write_eh_pointer(
Address::Constant(offset as u64 - 8),
constants::DW_EH_PE_pcrel | constants::DW_EH_PE_sdata4, 8,
)
.unwrap();
expected_data.extend_from_slice(&(-8i32).to_le_bytes());
// Relocation for a symbol in unwind information. let offset = section.len();
section
.write_eh_pointer(
Address::Symbol {
symbol: 2,
addend: 0x12345678,
},
constants::DW_EH_PE_pcrel | constants::DW_EH_PE_sdata4, 8,
)
.unwrap();
expected_data.extend_from_slice(&[0; 4]);
expected_relocations.push(Relocation {
offset,
size: 4,
target: RelocationTarget::Symbol(2),
addend: 0x12345678,
eh_pe: Some(constants::DW_EH_PE_pcrel | constants::DW_EH_PE_sdata4),
});
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.11Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-06-19)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.