1
0
Fork 0

Fix exported symbol detection on macOS

Apparently all exported symbols in Mach-O are prefixed with an
underscore.
This commit is contained in:
Robbert van der Helm 2022-02-26 20:55:33 +01:00
parent e4e0fd2da2
commit a8f66af147

View file

@ -23,6 +23,9 @@ pub fn exported<P: AsRef<Path>>(binary: P, symbol: &str) -> Result<bool> {
goblin::mach::Mach::Binary(obj) => obj,
};
// XXX: Why are all exported symbols on macOS prefixed with an underscore?
let symbol = format!("_{}", symbol);
Ok(obj.exports()?.into_iter().any(|sym| sym.name == symbol))
}
goblin::Object::PE(obj) => Ok(obj.exports.iter().any(|sym| sym.name == Some(symbol))),