cli diff: Resolve object and project if not specified (#44)

* cli diff: Resolve object and project if not specified

* Make `symbol` positional

* Short circuit ambiguous matches

* Tighten argument matching

* Speed up function lookup
This commit is contained in:
Robin Avery
2024-03-01 00:22:41 -05:00
committed by GitHub
parent 5cfd04fd4f
commit fd27f4d0cd
2 changed files with 67 additions and 14 deletions

View File

@@ -394,6 +394,17 @@ pub fn read(obj_path: &Path) -> Result<ObjInfo> {
Ok(result)
}
pub fn has_function(obj_path: &Path, symbol_name: &str) -> Result<bool> {
let data = {
let file = fs::File::open(obj_path)?;
unsafe { memmap2::Mmap::map(&file) }?
};
Ok(File::parse(&*data)?
.symbol_by_name(symbol_name)
.filter(|o| o.kind() == SymbolKind::Text)
.is_some())
}
fn split_meta(obj_file: &File<'_>) -> Result<Option<SplitMeta>> {
Ok(if let Some(section) = obj_file.section_by_name(SPLITMETA_SECTION) {
if section.size() != 0 {