Skip to content

Commit

Permalink
Support DWARF2 for DW_OP_implicit_pointer (#618)
Browse files Browse the repository at this point in the history
  • Loading branch information
crzysdrs committed Apr 7, 2022
1 parent 3607514 commit 5ba0349
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
21 changes: 20 additions & 1 deletion src/read/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,13 @@ where
}
constants::DW_OP_stack_value => Ok(Operation::StackValue),
constants::DW_OP_implicit_pointer | constants::DW_OP_GNU_implicit_pointer => {
let value = bytes.read_offset(encoding.format)?;
let value = if encoding.version == 2 {
bytes
.read_address(encoding.address_size)
.and_then(Offset::from_u64)?
} else {
bytes.read_offset(encoding.format)?
};
let byte_offset = bytes.read_sleb128()?;
Ok(Operation::ImplicitPointer {
value: DebugInfoOffset(value),
Expand Down Expand Up @@ -2738,6 +2744,19 @@ mod tests {
},
encoding8(),
);

check_op_parse(
|s| s.D8(op.0).D64(0x1234_5678).sleb(0x123),
&Operation::ImplicitPointer {
value: DebugInfoOffset(0x1234_5678),
byte_offset: 0x123,
},
Encoding {
format: Format::Dwarf32,
version: 2,
address_size: 8,
},
)
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/write/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,11 @@ impl Operation {
} else {
w.write_u8(constants::DW_OP_GNU_implicit_pointer.0)?;
}
let size = encoding.format.word_size();
let size = if encoding.version == 2 {
encoding.address_size
} else {
encoding.format.word_size()
};
match entry {
Reference::Symbol(symbol) => {
w.write_reference(symbol, size)?;
Expand Down

0 comments on commit 5ba0349

Please sign in to comment.