Skip to content

Commit

Permalink
write: Fix Op::ImplicitPointer::size() to match Op::ImplicitPointer::…
Browse files Browse the repository at this point in the history
…write() (#712)
  • Loading branch information
crzysdrs authored Apr 25, 2024
1 parent 1701668 commit c49f64d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/write/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,12 @@ impl Operation {
}
Operation::ImplicitValue(ref data) => uleb128_size(data.len() as u64) + data.len(),
Operation::ImplicitPointer { byte_offset, .. } => {
encoding.format.word_size() as usize + sleb128_size(byte_offset)
let size = if encoding.version == 2 {
encoding.address_size
} else {
encoding.format.word_size()
};
size as usize + sleb128_size(byte_offset)
}
Operation::Piece { size_in_bytes } => uleb128_size(size_in_bytes),
Operation::BitPiece {
Expand Down Expand Up @@ -1072,7 +1077,7 @@ mod tests {
#[test]
#[allow(clippy::type_complexity)]
fn test_operation() {
for version in [3, 4, 5] {
for version in [2, 3, 4, 5] {
for address_size in [4, 8] {
for format in [Format::Dwarf32, Format::Dwarf64] {
let encoding = Encoding {
Expand Down

0 comments on commit c49f64d

Please sign in to comment.