From c49f64df0920f89c20eda47f76ff3d3655ad0326 Mon Sep 17 00:00:00 2001 From: Mitch Souders Date: Thu, 25 Apr 2024 16:13:48 -0700 Subject: [PATCH] write: Fix Op::ImplicitPointer::size() to match Op::ImplicitPointer::write() (#712) --- src/write/op.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/write/op.rs b/src/write/op.rs index 0ba03183..dc9b5fb7 100644 --- a/src/write/op.rs +++ b/src/write/op.rs @@ -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 { @@ -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 {