diff --git a/objdiff-core/src/obj/comment.rs b/objdiff-core/src/obj/comment.rs new file mode 100644 index 00000000..e9e7b980 --- /dev/null +++ b/objdiff-core/src/obj/comment.rs @@ -0,0 +1,62 @@ +use anyhow::{Result, anyhow}; + +use crate::util::{read_u8, read_u16, read_u32}; + +pub const COMMENT_SECTION: &str = ".comment"; + +const MAGIC: &[u8] = "CodeWarrior".as_bytes(); +const HEADER_SIZE: u8 = 0x2C; + +// Partial implementation, does not include all fields +pub struct MWComment { + pub version: u8, +} + +impl MWComment { + pub fn from_reader(_obj_file: &object::File, reader: &mut &[u8]) -> Result { + let mut out = MWComment { version: 0 }; + let magic: [u8; MAGIC.len()] = reader[..MAGIC.len()].try_into()?; + *reader = &reader[MAGIC.len()..]; + if magic != MAGIC { + return Err(anyhow!("Invalid .comment section magic: {magic:?}")); + } + out.version = read_u8(reader)?; + if !matches!(out.version, 8 | 10 | 11 | 13 | 14 | 15) { + return Err(anyhow!("Unknown .comment section version: {}", out.version)); + } + *reader = &reader[8..]; + let header_size = read_u8(reader)?; + if header_size != HEADER_SIZE { + return Err(anyhow!("Expected header size {HEADER_SIZE:#X}, got {header_size:#X}")); + } + *reader = &reader[0x17..]; + Ok(out) + } +} + +#[derive(Debug, Copy, Clone)] +pub struct CommentSym { + pub align: u32, + pub vis_flags: u8, + pub active_flags: u8, +} + +impl CommentSym { + pub fn from_reader(obj_file: &object::File, reader: &mut &[u8]) -> Result { + let mut out = CommentSym { align: 0, vis_flags: 0, active_flags: 0 }; + out.align = read_u32(obj_file, reader)?; + out.vis_flags = read_u8(reader)?; + if !matches!(out.vis_flags, 0 | 0xD | 0xE) { + log::warn!("Unknown vis_flags: {:#X}", out.vis_flags); + } + out.active_flags = read_u8(reader)?; + if !matches!(out.active_flags, 0 | 0x8 | 0x10 | 0x20) { + log::warn!("Unknown active_flags: {:#X}", out.active_flags); + } + let padding = read_u16(obj_file, reader)?; + if padding != 0 { + return Err(anyhow!("Unexpected value after active_flags: {padding:#X}")); + } + Ok(out) + } +} diff --git a/objdiff-core/src/obj/mod.rs b/objdiff-core/src/obj/mod.rs index 479186e1..29e57b4e 100644 --- a/objdiff-core/src/obj/mod.rs +++ b/objdiff-core/src/obj/mod.rs @@ -1,3 +1,4 @@ +pub mod comment; #[cfg(feature = "dwarf")] mod dwarf2; mod mdebug; diff --git a/objdiff-core/src/obj/read.rs b/objdiff-core/src/obj/read.rs index 6000159d..3377709c 100644 --- a/objdiff-core/src/obj/read.rs +++ b/objdiff-core/src/obj/read.rs @@ -6,7 +6,10 @@ use alloc::{ vec, vec::Vec, }; -use core::{cmp::Ordering, num::NonZeroU64}; +use core::{ + cmp::Ordering, + num::{NonZeroU32, NonZeroU64}, +}; use anyhow::{Context, Result, anyhow, bail, ensure}; use object::{Architecture, Object as _, ObjectSection as _, ObjectSymbol as _}; @@ -17,6 +20,7 @@ use crate::{ obj::{ FlowAnalysisResult, Object, Relocation, RelocationFlags, Section, SectionData, SectionFlag, SectionKind, Symbol, SymbolFlag, SymbolFlagSet, SymbolKind, + comment::{COMMENT_SECTION, CommentSym, MWComment}, split_meta::{SPLITMETA_SECTION, SplitMeta}, }, util::{align_data_slice_to, align_u64_to, read_u16, read_u32}, @@ -103,6 +107,7 @@ fn map_symbol( symbol: &object::Symbol, section_indices: &[usize], split_meta: Option<&SplitMeta>, + comment_syms: Option<&Vec>, config: &DiffObjConfig, ) -> Result { let mut name = symbol.name().context("Failed to process symbol name")?.to_string(); @@ -156,6 +161,9 @@ fn map_symbol( }; let address = arch.symbol_address(symbol.address(), kind); let demangled_name = config.demangler.demangle(&name); + // Find the alignment for the symbol if available + let comment_sym = comment_syms.map(|vec| vec[symbol.index().0 - 1]); + let align = comment_sym.and_then(|c| NonZeroU32::new(c.align)); // Find the virtual address for the symbol if available let virtual_address = split_meta .and_then(|m| m.virtual_addresses.as_ref()) @@ -175,7 +183,7 @@ fn map_symbol( kind, section, flags, - align: None, // TODO parse .comment + align, virtual_address, }) } @@ -185,6 +193,7 @@ fn map_symbols( obj_file: &object::File, section_indices: &[usize], split_meta: Option<&SplitMeta>, + comment_syms: Option<&Vec>, config: &DiffObjConfig, ) -> Result<(Vec, Vec)> { // symbols() is not guaranteed to be sorted by address. @@ -219,7 +228,15 @@ fn map_symbols( let mut symbols = Vec::::with_capacity(obj_symbols.len() + obj_file.sections().count()); let mut symbol_indices = vec![usize::MAX; max_index + 1]; for obj_symbol in obj_symbols { - let symbol = map_symbol(arch, obj_file, &obj_symbol, section_indices, split_meta, config)?; + let symbol = map_symbol( + arch, + obj_file, + &obj_symbol, + section_indices, + split_meta, + comment_syms, + config, + )?; symbol_indices[obj_symbol.index().0] = symbols.len(); symbols.push(symbol); } @@ -1071,10 +1088,17 @@ pub fn parse(data: &[u8], config: &DiffObjConfig, diff_side: DiffSide) -> Result let obj_file = object::File::parse(data)?; let mut arch = new_arch(&obj_file, diff_side)?; let split_meta = parse_split_meta(&obj_file)?; + let comment_syms = parse_mw_comment_syms(&obj_file)?; let (mut sections, section_indices) = map_sections(arch.as_ref(), &obj_file, split_meta.as_ref())?; - let (mut symbols, symbol_indices) = - map_symbols(arch.as_ref(), &obj_file, §ion_indices, split_meta.as_ref(), config)?; + let (mut symbols, symbol_indices) = map_symbols( + arch.as_ref(), + &obj_file, + §ion_indices, + split_meta.as_ref(), + comment_syms.as_ref(), + config, + )?; map_relocations(arch.as_ref(), &obj_file, &mut sections, §ion_indices, &symbol_indices)?; // Infer symbol sizes for 0-size symbols (must be done after map_relocations is called) infer_symbol_sizes(arch.as_ref(), &mut symbols, §ions)?; @@ -1124,6 +1148,27 @@ fn parse_split_meta(obj_file: &object::File) -> Result> { }) } +fn parse_mw_comment_syms(obj_file: &object::File) -> Result>> { + Ok(if let Some(section) = obj_file.section_by_name(COMMENT_SECTION) { + let data = section.uncompressed_data()?; + let mut reader: &[u8] = data.as_ref(); + if let Ok(_header) = MWComment::from_reader(obj_file, &mut reader) { + CommentSym::from_reader(obj_file, &mut reader)?; // Null symbol + let mut comment_syms = Vec::with_capacity(obj_file.symbols().count()); + for _symbol in obj_file.symbols() { + let comment_sym = CommentSym::from_reader(obj_file, &mut reader)?; + comment_syms.push(comment_sym); + } + Some(comment_syms) + } else { + // .comment section exists but the header failed to parse, likely an unsupported compiler version (e.g. mwccarm) + None + } + } else { + None + }) +} + #[cfg(test)] mod test { use super::*; diff --git a/objdiff-core/src/util.rs b/objdiff-core/src/util.rs index 10053f5e..a6783c98 100644 --- a/objdiff-core/src/util.rs +++ b/objdiff-core/src/util.rs @@ -40,6 +40,13 @@ pub fn read_u16(obj_file: &object::File, reader: &mut &[u8]) -> Result { Ok(obj_file.endianness().read_u16(value)) } +pub fn read_u8(reader: &mut &[u8]) -> Result { + ensure!(!reader.is_empty(), "Not enough bytes to read u8"); + let value = reader[0]; + *reader = &reader[1..]; + Ok(value) +} + pub fn align_size_to_4(size: usize) -> usize { (size + 3) & !3 } #[cfg(feature = "std")] diff --git a/objdiff-core/tests/snapshots/arch_ppc__read_extab.snap b/objdiff-core/tests/snapshots/arch_ppc__read_extab.snap index 4a2911ac..82c3d202 100644 --- a/objdiff-core/tests/snapshots/arch_ppc__read_extab.snap +++ b/objdiff-core/tests/snapshots/arch_ppc__read_extab.snap @@ -137,7 +137,9 @@ Object { 0, ), flags: FlagSet(Local), - align: None, + align: Some( + 4, + ), virtual_address: None, }, Symbol { @@ -151,7 +153,9 @@ Object { 0, ), flags: FlagSet(Global | HasExtra), - align: None, + align: Some( + 4, + ), virtual_address: None, }, Symbol { @@ -165,7 +169,9 @@ Object { 0, ), flags: FlagSet(Global | HasExtra), - align: None, + align: Some( + 4, + ), virtual_address: None, }, Symbol { @@ -181,7 +187,9 @@ Object { 0, ), flags: FlagSet(Global | Weak | HasExtra), - align: None, + align: Some( + 4, + ), virtual_address: None, }, Symbol { @@ -195,7 +203,9 @@ Object { 1, ), flags: FlagSet(Local), - align: None, + align: Some( + 4, + ), virtual_address: None, }, Symbol { @@ -209,7 +219,9 @@ Object { 1, ), flags: FlagSet(Local | CompilerGenerated), - align: None, + align: Some( + 4, + ), virtual_address: None, }, Symbol { @@ -223,7 +235,9 @@ Object { 1, ), flags: FlagSet(Local | CompilerGenerated), - align: None, + align: Some( + 4, + ), virtual_address: None, }, Symbol { @@ -237,7 +251,9 @@ Object { 1, ), flags: FlagSet(Local | CompilerGenerated), - align: None, + align: Some( + 4, + ), virtual_address: None, }, Symbol { @@ -251,7 +267,9 @@ Object { 2, ), flags: FlagSet(Local), - align: None, + align: Some( + 4, + ), virtual_address: None, }, Symbol { @@ -265,7 +283,9 @@ Object { 2, ), flags: FlagSet(Local | CompilerGenerated), - align: None, + align: Some( + 4, + ), virtual_address: None, }, Symbol { @@ -279,7 +299,9 @@ Object { 2, ), flags: FlagSet(Local | CompilerGenerated), - align: None, + align: Some( + 4, + ), virtual_address: None, }, Symbol { @@ -293,7 +315,9 @@ Object { 2, ), flags: FlagSet(Local | CompilerGenerated), - align: None, + align: Some( + 4, + ), virtual_address: None, }, Symbol { diff --git a/objdiff-core/tests/snapshots/arch_ppc__read_ppc-3.snap b/objdiff-core/tests/snapshots/arch_ppc__read_ppc-3.snap index 99e5f38b..0dc6188a 100644 --- a/objdiff-core/tests/snapshots/arch_ppc__read_ppc-3.snap +++ b/objdiff-core/tests/snapshots/arch_ppc__read_ppc-3.snap @@ -11,7 +11,7 @@ expression: output [(Address(24), Dim, 5), (Spacing(4), Normal, 0), (Opcode("addi", 263), Normal, 10), (Argument(Opaque("r4")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("r4")), Normal, 0), (Basic(", "), Normal, 0), (Symbol(Symbol { name: "__upper_map", demangled_name: None, normalized_name: None, address: 0, size: 0, kind: Unknown, section: None, flags: FlagSet(Global), align: None, virtual_address: Some(0) }), Bright, 0), (Basic("@l"), Normal, 0), (Eol, Normal, 0)] [(Address(28), Dim, 5), (Spacing(4), Normal, 0), (Opcode("lbzx", 323), Normal, 10), (Argument(Opaque("r0")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("r4")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("r0")), Normal, 0), (Basic(" <"), Normal, 0), (Symbol(Symbol { name: "__upper_map", demangled_name: None, normalized_name: None, address: 0, size: 0, kind: Unknown, section: None, flags: FlagSet(Global), align: None, virtual_address: Some(0) }), Bright, 0), (Basic(">"), Normal, 0), (Eol, Normal, 0)] [(Address(32), Dim, 5), (BranchArrow(4), Rotating(1), 0), (Opcode("extrwi", 283), Normal, 10), (Argument(Opaque("r5")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("r3")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("8")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("8")), Normal, 0), (Eol, Normal, 0)] -[(Address(36), Dim, 5), (Spacing(4), Normal, 0), (Opcode("stb", 445), Normal, 10), (Argument(Opaque("r0")), Normal, 0), (Basic(", "), Normal, 0), (Symbol(Symbol { name: "text$52", demangled_name: None, normalized_name: Some("text$0000"), address: 8, size: 5, kind: Object, section: Some(2), flags: FlagSet(Local), align: None, virtual_address: Some(2153420056) }), Bright, 0), (Basic("@sda21"), Normal, 0), (Eol, Normal, 0)] +[(Address(36), Dim, 5), (Spacing(4), Normal, 0), (Opcode("stb", 445), Normal, 10), (Argument(Opaque("r0")), Normal, 0), (Basic(", "), Normal, 0), (Symbol(Symbol { name: "text$52", demangled_name: None, normalized_name: Some("text$0000"), address: 8, size: 5, kind: Object, section: Some(2), flags: FlagSet(Local), align: Some(4), virtual_address: Some(2153420056) }), Bright, 0), (Basic("@sda21"), Normal, 0), (Eol, Normal, 0)] [(Address(40), Dim, 5), (Spacing(4), Normal, 0), (Opcode("cmpwi", 260), Normal, 10), (Argument(Opaque("r5")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Signed(-1)), Normal, 0), (Eol, Normal, 0)] [(Address(44), Dim, 5), (Spacing(4), Normal, 0), (Opcode("bne", 265), Normal, 10), (BranchDest(56), Normal, 0), (BranchArrow(14), Rotating(2), 0), (Eol, Normal, 0)] [(Address(48), Dim, 5), (Spacing(4), Normal, 0), (Opcode("li", 263), Normal, 10), (Argument(Opaque("r0")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Signed(-1)), Normal, 0), (Eol, Normal, 0)] @@ -20,7 +20,7 @@ expression: output [(Address(60), Dim, 5), (Spacing(4), Normal, 0), (Opcode("addi", 263), Normal, 10), (Argument(Opaque("r4")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("r4")), Normal, 0), (Basic(", "), Normal, 0), (Symbol(Symbol { name: "__upper_map", demangled_name: None, normalized_name: None, address: 0, size: 0, kind: Unknown, section: None, flags: FlagSet(Global), align: None, virtual_address: Some(0) }), Bright, 0), (Basic("@l"), Normal, 0), (Eol, Normal, 0)] [(Address(64), Dim, 5), (Spacing(4), Normal, 0), (Opcode("lbzx", 323), Normal, 10), (Argument(Opaque("r0")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("r4")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("r5")), Normal, 0), (Basic(" <"), Normal, 0), (Symbol(Symbol { name: "__upper_map", demangled_name: None, normalized_name: None, address: 0, size: 0, kind: Unknown, section: None, flags: FlagSet(Global), align: None, virtual_address: Some(0) }), Bright, 0), (Basic(">"), Normal, 0), (Eol, Normal, 0)] [(Address(68), Dim, 5), (BranchArrow(13), Rotating(3), 0), (Opcode("extrwi", 283), Normal, 10), (Argument(Opaque("r5")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("r3")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("8")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("16")), Normal, 0), (Eol, Normal, 0)] -[(Address(72), Dim, 5), (Spacing(4), Normal, 0), (Opcode("li", 263), Normal, 10), (Argument(Opaque("r4")), Normal, 0), (Basic(", "), Normal, 0), (Symbol(Symbol { name: "text$52", demangled_name: None, normalized_name: Some("text$0000"), address: 8, size: 5, kind: Object, section: Some(2), flags: FlagSet(Local), align: None, virtual_address: Some(2153420056) }), Bright, 0), (Basic("@sda21"), Normal, 0), (Eol, Normal, 0)] +[(Address(72), Dim, 5), (Spacing(4), Normal, 0), (Opcode("li", 263), Normal, 10), (Argument(Opaque("r4")), Normal, 0), (Basic(", "), Normal, 0), (Symbol(Symbol { name: "text$52", demangled_name: None, normalized_name: Some("text$0000"), address: 8, size: 5, kind: Object, section: Some(2), flags: FlagSet(Local), align: Some(4), virtual_address: Some(2153420056) }), Bright, 0), (Basic("@sda21"), Normal, 0), (Eol, Normal, 0)] [(Address(76), Dim, 5), (Spacing(4), Normal, 0), (Opcode("cmpwi", 260), Normal, 10), (Argument(Opaque("r5")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Signed(-1)), Normal, 0), (Eol, Normal, 0)] [(Address(80), Dim, 5), (Spacing(4), Normal, 0), (Opcode("stb", 445), Normal, 10), (Argument(Opaque("r0")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Signed(1)), Normal, 0), (Basic("("), Normal, 0), (Argument(Opaque("r4")), Normal, 0), (Basic(")"), Normal, 0), (Eol, Normal, 0)] [(Address(84), Dim, 5), (Spacing(4), Normal, 0), (Opcode("bne", 265), Normal, 10), (BranchDest(96), Normal, 0), (BranchArrow(24), Rotating(4), 0), (Eol, Normal, 0)] @@ -30,7 +30,7 @@ expression: output [(Address(100), Dim, 5), (Spacing(4), Normal, 0), (Opcode("addi", 263), Normal, 10), (Argument(Opaque("r4")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("r4")), Normal, 0), (Basic(", "), Normal, 0), (Symbol(Symbol { name: "__upper_map", demangled_name: None, normalized_name: None, address: 0, size: 0, kind: Unknown, section: None, flags: FlagSet(Global), align: None, virtual_address: Some(0) }), Bright, 0), (Basic("@l"), Normal, 0), (Eol, Normal, 0)] [(Address(104), Dim, 5), (Spacing(4), Normal, 0), (Opcode("lbzx", 323), Normal, 10), (Argument(Opaque("r0")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("r4")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("r5")), Normal, 0), (Basic(" <"), Normal, 0), (Symbol(Symbol { name: "__upper_map", demangled_name: None, normalized_name: None, address: 0, size: 0, kind: Unknown, section: None, flags: FlagSet(Global), align: None, virtual_address: Some(0) }), Bright, 0), (Basic(">"), Normal, 0), (Eol, Normal, 0)] [(Address(108), Dim, 5), (BranchArrow(23), Rotating(5), 0), (Opcode("clrlwi", 283), Normal, 10), (Argument(Opaque("r4")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("r3")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("24")), Normal, 0), (Eol, Normal, 0)] -[(Address(112), Dim, 5), (Spacing(4), Normal, 0), (Opcode("li", 263), Normal, 10), (Argument(Opaque("r3")), Normal, 0), (Basic(", "), Normal, 0), (Symbol(Symbol { name: "text$52", demangled_name: None, normalized_name: Some("text$0000"), address: 8, size: 5, kind: Object, section: Some(2), flags: FlagSet(Local), align: None, virtual_address: Some(2153420056) }), Bright, 0), (Basic("@sda21"), Normal, 0), (Eol, Normal, 0)] +[(Address(112), Dim, 5), (Spacing(4), Normal, 0), (Opcode("li", 263), Normal, 10), (Argument(Opaque("r3")), Normal, 0), (Basic(", "), Normal, 0), (Symbol(Symbol { name: "text$52", demangled_name: None, normalized_name: Some("text$0000"), address: 8, size: 5, kind: Object, section: Some(2), flags: FlagSet(Local), align: Some(4), virtual_address: Some(2153420056) }), Bright, 0), (Basic("@sda21"), Normal, 0), (Eol, Normal, 0)] [(Address(116), Dim, 5), (Spacing(4), Normal, 0), (Opcode("cmpwi", 260), Normal, 10), (Argument(Opaque("r4")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Signed(-1)), Normal, 0), (Eol, Normal, 0)] [(Address(120), Dim, 5), (Spacing(4), Normal, 0), (Opcode("stb", 445), Normal, 10), (Argument(Opaque("r0")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Signed(2)), Normal, 0), (Basic("("), Normal, 0), (Argument(Opaque("r3")), Normal, 0), (Basic(")"), Normal, 0), (Eol, Normal, 0)] [(Address(124), Dim, 5), (Spacing(4), Normal, 0), (Opcode("bne", 265), Normal, 10), (BranchDest(136), Normal, 0), (BranchArrow(34), Rotating(6), 0), (Eol, Normal, 0)] @@ -39,14 +39,14 @@ expression: output [(Address(136), Dim, 5), (BranchArrow(31), Rotating(6), 0), (Opcode("lis", 264), Normal, 10), (Argument(Opaque("r3")), Normal, 0), (Basic(", "), Normal, 0), (Symbol(Symbol { name: "__upper_map", demangled_name: None, normalized_name: None, address: 0, size: 0, kind: Unknown, section: None, flags: FlagSet(Global), align: None, virtual_address: Some(0) }), Bright, 0), (Basic("@ha"), Normal, 0), (Eol, Normal, 0)] [(Address(140), Dim, 5), (Spacing(4), Normal, 0), (Opcode("addi", 263), Normal, 10), (Argument(Opaque("r3")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("r3")), Normal, 0), (Basic(", "), Normal, 0), (Symbol(Symbol { name: "__upper_map", demangled_name: None, normalized_name: None, address: 0, size: 0, kind: Unknown, section: None, flags: FlagSet(Global), align: None, virtual_address: Some(0) }), Bright, 0), (Basic("@l"), Normal, 0), (Eol, Normal, 0)] [(Address(144), Dim, 5), (Spacing(4), Normal, 0), (Opcode("lbzx", 323), Normal, 10), (Argument(Opaque("r3")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("r3")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("r4")), Normal, 0), (Basic(" <"), Normal, 0), (Symbol(Symbol { name: "__upper_map", demangled_name: None, normalized_name: None, address: 0, size: 0, kind: Unknown, section: None, flags: FlagSet(Global), align: None, virtual_address: Some(0) }), Bright, 0), (Basic(">"), Normal, 0), (Eol, Normal, 0)] -[(Address(148), Dim, 5), (BranchArrow(33), Rotating(7), 0), (Opcode("li", 263), Normal, 10), (Argument(Opaque("r5")), Normal, 0), (Basic(", "), Normal, 0), (Symbol(Symbol { name: "text$52", demangled_name: None, normalized_name: Some("text$0000"), address: 8, size: 5, kind: Object, section: Some(2), flags: FlagSet(Local), align: None, virtual_address: Some(2153420056) }), Bright, 0), (Basic("@sda21"), Normal, 0), (Eol, Normal, 0)] +[(Address(148), Dim, 5), (BranchArrow(33), Rotating(7), 0), (Opcode("li", 263), Normal, 10), (Argument(Opaque("r5")), Normal, 0), (Basic(", "), Normal, 0), (Symbol(Symbol { name: "text$52", demangled_name: None, normalized_name: Some("text$0000"), address: 8, size: 5, kind: Object, section: Some(2), flags: FlagSet(Local), align: Some(4), virtual_address: Some(2153420056) }), Bright, 0), (Basic("@sda21"), Normal, 0), (Eol, Normal, 0)] [(Address(152), Dim, 5), (Spacing(4), Normal, 0), (Opcode("li", 263), Normal, 10), (Argument(Opaque("r0")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Signed(0)), Normal, 0), (Eol, Normal, 0)] [(Address(156), Dim, 5), (Spacing(4), Normal, 0), (Opcode("stb", 445), Normal, 10), (Argument(Opaque("r3")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Signed(3)), Normal, 0), (Basic("("), Normal, 0), (Argument(Opaque("r5")), Normal, 0), (Basic(")"), Normal, 0), (Eol, Normal, 0)] [(Address(160), Dim, 5), (Spacing(4), Normal, 0), (Opcode("lis", 264), Normal, 10), (Argument(Opaque("r3")), Normal, 0), (Basic(", "), Normal, 0), (Symbol(Symbol { name: "__ctype_map", demangled_name: None, normalized_name: None, address: 0, size: 0, kind: Unknown, section: None, flags: FlagSet(Global), align: None, virtual_address: Some(0) }), Bright, 0), (Basic("@ha"), Normal, 0), (Eol, Normal, 0)] [(Address(164), Dim, 5), (Spacing(4), Normal, 0), (Opcode("addi", 263), Normal, 10), (Argument(Opaque("r4")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("r3")), Normal, 0), (Basic(", "), Normal, 0), (Symbol(Symbol { name: "__ctype_map", demangled_name: None, normalized_name: None, address: 0, size: 0, kind: Unknown, section: None, flags: FlagSet(Global), align: None, virtual_address: Some(0) }), Bright, 0), (Basic("@l"), Normal, 0), (Eol, Normal, 0)] [(Address(168), Dim, 5), (Spacing(4), Normal, 0), (Opcode("stb", 445), Normal, 10), (Argument(Opaque("r0")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Signed(4)), Normal, 0), (Basic("("), Normal, 0), (Argument(Opaque("r5")), Normal, 0), (Basic(")"), Normal, 0), (Eol, Normal, 0)] [(Address(172), Dim, 5), (Spacing(4), Normal, 0), (Opcode("li", 263), Normal, 10), (Argument(Opaque("r0")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Signed(45)), Normal, 0), (Eol, Normal, 0)] -[(Address(176), Dim, 5), (Spacing(4), Normal, 0), (Opcode("lbz", 441), Normal, 10), (Argument(Opaque("r3")), Normal, 0), (Basic(", "), Normal, 0), (Symbol(Symbol { name: "text$52", demangled_name: None, normalized_name: Some("text$0000"), address: 8, size: 5, kind: Object, section: Some(2), flags: FlagSet(Local), align: None, virtual_address: Some(2153420056) }), Bright, 0), (Basic("@sda21"), Normal, 0), (Eol, Normal, 0)] +[(Address(176), Dim, 5), (Spacing(4), Normal, 0), (Opcode("lbz", 441), Normal, 10), (Argument(Opaque("r3")), Normal, 0), (Basic(", "), Normal, 0), (Symbol(Symbol { name: "text$52", demangled_name: None, normalized_name: Some("text$0000"), address: 8, size: 5, kind: Object, section: Some(2), flags: FlagSet(Local), align: Some(4), virtual_address: Some(2153420056) }), Bright, 0), (Basic("@sda21"), Normal, 0), (Eol, Normal, 0)] [(Address(180), Dim, 5), (Spacing(4), Normal, 0), (Opcode("lbzx", 323), Normal, 10), (Argument(Opaque("r3")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("r4")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("r3")), Normal, 0), (Basic(" <"), Normal, 0), (Symbol(Symbol { name: "__ctype_map", demangled_name: None, normalized_name: None, address: 0, size: 0, kind: Unknown, section: None, flags: FlagSet(Global), align: None, virtual_address: Some(0) }), Bright, 0), (Basic(">"), Normal, 0), (Eol, Normal, 0)] [(Address(184), Dim, 5), (Spacing(4), Normal, 0), (Opcode("andi.", 289), Normal, 10), (Argument(Opaque("r3")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("r3")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Unsigned(220)), Normal, 0), (Eol, Normal, 0)] [(Address(188), Dim, 5), (Spacing(4), Normal, 0), (Opcode("bne", 265), Normal, 10), (BranchDest(196), Normal, 0), (BranchArrow(49), Rotating(8), 0), (Eol, Normal, 0)] @@ -66,5 +66,5 @@ expression: output [(Address(244), Dim, 5), (Spacing(4), Normal, 0), (Opcode("andi.", 289), Normal, 10), (Argument(Opaque("r3")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("r3")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Unsigned(220)), Normal, 0), (Eol, Normal, 0)] [(Address(248), Dim, 5), (Spacing(4), Normal, 0), (Opcode("bne", 265), Normal, 10), (BranchDest(256), Normal, 0), (BranchArrow(64), Rotating(11), 0), (Eol, Normal, 0)] [(Address(252), Dim, 5), (Spacing(4), Normal, 0), (Opcode("stb", 445), Normal, 10), (Argument(Opaque("r0")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Signed(0)), Normal, 0), (Basic("("), Normal, 0), (Argument(Opaque("r5")), Normal, 0), (Basic(")"), Normal, 0), (Eol, Normal, 0)] -[(Address(256), Dim, 5), (BranchArrow(62), Rotating(11), 0), (Opcode("li", 263), Normal, 10), (Argument(Opaque("r3")), Normal, 0), (Basic(", "), Normal, 0), (Symbol(Symbol { name: "text$52", demangled_name: None, normalized_name: Some("text$0000"), address: 8, size: 5, kind: Object, section: Some(2), flags: FlagSet(Local), align: None, virtual_address: Some(2153420056) }), Bright, 0), (Basic("@sda21"), Normal, 0), (Eol, Normal, 0)] +[(Address(256), Dim, 5), (BranchArrow(62), Rotating(11), 0), (Opcode("li", 263), Normal, 10), (Argument(Opaque("r3")), Normal, 0), (Basic(", "), Normal, 0), (Symbol(Symbol { name: "text$52", demangled_name: None, normalized_name: Some("text$0000"), address: 8, size: 5, kind: Object, section: Some(2), flags: FlagSet(Local), align: Some(4), virtual_address: Some(2153420056) }), Bright, 0), (Basic("@sda21"), Normal, 0), (Eol, Normal, 0)] [(Address(260), Dim, 5), (Spacing(4), Normal, 0), (Opcode("blr", 269), Normal, 10), (Eol, Normal, 0)] diff --git a/objdiff-core/tests/snapshots/arch_ppc__read_ppc.snap b/objdiff-core/tests/snapshots/arch_ppc__read_ppc.snap index e876b544..8f1714ea 100644 --- a/objdiff-core/tests/snapshots/arch_ppc__read_ppc.snap +++ b/objdiff-core/tests/snapshots/arch_ppc__read_ppc.snap @@ -22,7 +22,9 @@ Object { 0, ), flags: FlagSet(Local), - align: None, + align: Some( + 4, + ), virtual_address: Some( 2150895620, ), @@ -40,7 +42,9 @@ Object { 0, ), flags: FlagSet(Global), - align: None, + align: Some( + 4, + ), virtual_address: Some( 2150895620, ), @@ -56,7 +60,9 @@ Object { 0, ), flags: FlagSet(Local), - align: None, + align: Some( + 4, + ), virtual_address: Some( 2150895884, ), @@ -72,7 +78,9 @@ Object { 1, ), flags: FlagSet(Local), - align: None, + align: Some( + 4, + ), virtual_address: Some( 2151461704, ), @@ -88,7 +96,9 @@ Object { 2, ), flags: FlagSet(Local), - align: None, + align: Some( + 8, + ), virtual_address: Some( 2153420048, ), @@ -104,7 +114,9 @@ Object { 2, ), flags: FlagSet(Global), - align: None, + align: Some( + 4, + ), virtual_address: Some( 2153420048, ), @@ -122,7 +134,9 @@ Object { 2, ), flags: FlagSet(Local), - align: None, + align: Some( + 4, + ), virtual_address: Some( 2153420056, ),