Skip to content

Commit

Permalink
read: support section targets in RelocationMap (#675)
Browse files Browse the repository at this point in the history
These are commonly used for DWARF sections in Mach-O.
  • Loading branch information
philipc authored May 1, 2024
1 parent 7dd1fb0 commit 1f3e12c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/read/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,16 @@ impl RelocationMap {
.read_error("Relocation with invalid symbol")?;
entry.addend = symbol.address().wrapping_add(entry.addend);
}
RelocationTarget::Section(section_idx) => {
let section = file
.section_by_index(section_idx)
.read_error("Relocation with invalid section")?;
// DWARF parsers expect references to DWARF sections to be section offsets,
// not addresses. Addresses are useful for everything else.
if section.kind() != SectionKind::Debug {
entry.addend = section.address().wrapping_add(entry.addend);
}
}
_ => {
return Err(Error("Unsupported relocation target"));
}
Expand Down

0 comments on commit 1f3e12c

Please sign in to comment.