mirror of
https://github.com/encounter/objdiff.git
synced 2025-12-11 06:27:55 +00:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user