~taiite/protodump

3f54b0693834758391297041d55278f8d55aa480 — Hubert Hirtz 27 days ago 19283ba
Show object file architecture

<https://docs.rs/object/latest/object/enum.Architecture.html>
1 files changed, 11 insertions(+), 0 deletions(-)

M src/main.rs
M src/main.rs => src/main.rs +11 -0
@@ 58,6 58,7 @@ struct SymbolFilter {
struct ObjectInfo<'a> {
    container_type: ContainerType,
    is_little_endian: bool,
    architecture: object::Architecture,
    symbol_whitelist: HashMap<&'a str, u64>,
}



@@ 65,6 66,7 @@ impl PartialEq for ObjectInfo<'_> {
    fn eq(&self, other: &ObjectInfo<'_>) -> bool {
        self.container_type == other.container_type
            && self.is_little_endian == other.is_little_endian
            && self.architecture == other.architecture
    }
}



@@ 97,6 99,13 @@ fn show_object_info_diff(prev: &ObjectInfo<'_>, next: &ObjectInfo<'_>) {
            )),
        );
    }
    if prev.architecture != next.architecture {
        eprintln!(
            "Architecture: {} {}",
            Paint::red(format_args!("-{:?}", prev.architecture)),
            Paint::green(format_args!("+{:?}", next.architecture)),
        );
    }
    // TODO show symbol whitelist diff?
}



@@ 336,6 345,7 @@ fn read_object_info<'a>(obj: &object::File<'a>, filter: SymbolFilter) -> Result<
    Ok(ObjectInfo {
        container_type,
        is_little_endian: obj.is_little_endian(),
        architecture: obj.architecture(),
        symbol_whitelist,
    })
}


@@ 529,6 539,7 @@ fn main() -> Result<()> {
        } else {
            eprintln!("Endianness: big");
        }
        eprintln!("Architecture: {:?}", object_info.architecture);
        let skipped = object_info.symbol_whitelist.len() - sources.subprograms.len();
        if skipped != 0 {
            eprintln!("Symbols with missing debug info: {}", skipped);