use std::path::PathBuf; use flagset::{flags, FlagSet}; #[derive(Debug, Eq, PartialEq, Copy, Clone)] pub enum ObjSectionKind { Code, Data, Bss, } flags! { pub enum ObjSymbolFlags: u8 { Global, Local, Weak, Common, } } #[derive(Debug, Copy, Clone, Default)] pub struct ObjSymbolFlagSet(pub(crate) FlagSet); #[derive(Debug, Clone)] pub struct ObjSection { pub name: String, pub kind: ObjSectionKind, pub address: u64, pub size: u64, pub data: Vec, pub index: usize, pub symbols: Vec, pub relocations: Vec, } #[derive(Debug, Clone)] pub enum ObjInsArg { Arg(ppc750cl::Argument), Reloc, RelocOffset, } #[derive(Debug, Copy, Clone)] pub struct ObjInsArgDiff { /// Incrementing index for coloring pub idx: usize, } #[derive(Debug, Clone)] pub struct ObjInsBranchFrom { /// Source instruction indices pub ins_idx: Vec, /// Incrementing index for coloring pub branch_idx: usize, } #[derive(Debug, Clone)] pub struct ObjInsBranchTo { /// Target instruction index pub ins_idx: usize, /// Incrementing index for coloring pub branch_idx: usize, } #[derive(Debug, Copy, Clone, Eq, PartialEq, Default)] pub enum ObjInsDiffKind { #[default] None, OpMismatch, ArgMismatch, Replace, Delete, Insert, } #[derive(Debug, Clone)] pub struct ObjIns { pub ins: ppc750cl::Ins, pub mnemonic: String, pub args: Vec, pub reloc: Option, } #[derive(Debug, Clone, Default)] pub struct ObjInsDiff { pub ins: Option, /// Diff kind pub kind: ObjInsDiffKind, /// Branches from instruction pub branch_from: Option, /// Branches to instruction pub branch_to: Option, /// Arg diffs pub arg_diff: Vec>, } #[derive(Debug, Clone)] pub struct ObjSymbol { pub name: String, pub demangled_name: Option, pub address: u64, pub size: u64, pub size_known: bool, pub flags: ObjSymbolFlagSet, // Diff pub diff_symbol: Option, pub instructions: Vec, pub match_percent: f32, } #[derive(Debug, Clone)] pub struct ObjInfo { pub path: PathBuf, pub sections: Vec, pub common: Vec, } #[derive(Debug, Eq, PartialEq, Copy, Clone)] pub enum ObjRelocKind { Absolute, PpcAddr16Hi, PpcAddr16Ha, PpcAddr16Lo, // PpcAddr32, // PpcRel32, // PpcAddr24, PpcRel24, // PpcAddr14, PpcRel14, PpcEmbSda21, } #[derive(Debug, Clone)] pub struct ObjReloc { pub kind: ObjRelocKind, pub address: u64, pub target: ObjSymbol, pub target_section: Option, } // #[derive(Debug, Clone)] // pub struct ObjInsDiff { // pub kind: ObjInsDiffKind, // pub left: Option, // pub right: Option, // }