diff options
| author | Josh Ferrell <josh@vector35.com> | 2024-11-05 17:12:11 -0500 |
|---|---|---|
| committer | Josh Ferrell <josh@vector35.com> | 2024-11-05 17:13:19 -0500 |
| commit | bf8ecfead9fcbe669c5e5c0a531037701c53d52d (patch) | |
| tree | ef49d72dec74647418b3ad5149bdddbc30e76606 | |
| parent | aec66022d5b940bf6f489947f72ac52e0fc7cac4 (diff) | |
Fix .dSYM sibling file load logic and update .dSYM docs
| -rw-r--r-- | docs/guide/types/debuginfo.md | 8 | ||||
| -rw-r--r-- | rust/examples/dwarf/dwarf_import/src/helpers.rs | 13 |
2 files changed, 15 insertions, 6 deletions
diff --git a/docs/guide/types/debuginfo.md b/docs/guide/types/debuginfo.md index 1a23d240..6f6ed085 100644 --- a/docs/guide/types/debuginfo.md +++ b/docs/guide/types/debuginfo.md @@ -14,7 +14,7 @@ DWARF supports information compiled in to ELF binaries, information from externa ## Applying Debug Info -Debug Info is automatically applied by default if applicable. +Debug Info is automatically applied by default if applicable. { width="300" } @@ -44,6 +44,10 @@ Our [DWARF Export plugin](https://github.com/Vector35/binaryninja-api/tree/dev/r #### Special Note for `.dSYM` Files -`.dSYM` packages are often provided as application bundles. Binary Ninja currently does not support extracting the actual `.dSYM` file out of the package for parsing, so you may need to provide a full path for Binary Ninja to correctly parse. +Binary Ninja will automatically load `.dSYM` files given the following: +- The `.dSYM` file is adjacent on the filesystem to the binary being analyzed +- The `.dSYM` file is named `X.dSYM`, where `X` is the name of the binary being analyzed +- `analysis.debugInfo.loadSiblingDebugFiles` is enabled +When a `.dSYM` file is not automatically loaded, you will need to manually import the debug info contained in the `.dSYM`. For example, you could have the file `hello.macho` that you would like to import debug info for. Thankfully, you also have `hello.dSYM`. So you open `hello.macho` with options, find the "External Debug Info File" and provide the `hello.dSYM` file. When the file opens, you notice that no information was imported and the log reads "No available/valid parsers for file." This is because `hello.dSYM` is a bundle. The actual path you needed to provide for the "External Debug Info File" setting would look something like `hello.dSYM/Contents/Resources/DWARF/hello`. diff --git a/rust/examples/dwarf/dwarf_import/src/helpers.rs b/rust/examples/dwarf/dwarf_import/src/helpers.rs index 691c5751..6aba99d4 100644 --- a/rust/examples/dwarf/dwarf_import/src/helpers.rs +++ b/rust/examples/dwarf/dwarf_import/src/helpers.rs @@ -12,7 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::path::PathBuf; +use std::ffi::OsStr; +use std::path::{Path, PathBuf}; use std::{ collections::HashMap, ops::Deref, @@ -553,15 +554,19 @@ pub(crate) fn find_sibling_debug_file(view: &BinaryView) -> Option<String> { return None; } - let filename = view.file().filename().to_string(); + let full_file_path = view.file().filename().to_string(); - let debug_file = PathBuf::from(format!("{}.debug", filename)); - let dsym_folder = PathBuf::from(format!("{}.dSYM/", filename)); + let debug_file = PathBuf::from(format!("{}.debug", full_file_path)); + let dsym_folder = PathBuf::from(format!("{}.dSYM", full_file_path)); if debug_file.exists() && debug_file.is_file() { return Some(debug_file.to_string_lossy().to_string()); } if dsym_folder.exists() && dsym_folder.is_dir() { + let filename = Path::new(&full_file_path) + .file_name() + .unwrap_or(OsStr::new("")); + let dsym_file = dsym_folder .join("Contents/Resources/DWARF/") .join(filename); // TODO: should this just pull any file out? Can there be multiple files? |
