Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WARP: Update README with macOS library path instructions #6256

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions plugins/warp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,4 @@ Example: `./sigem mylibrary.a` or `./sigem ./all-libs/`

Once its finished you should see a `.sbin` file next to the input file, this can be moved into the corresponding signature folder (see the [user docs](https://docs.binary.ninja/dev/annotation.html?h=install+path#signature-library) for more info)

If you encounter malloc errors or instability try and adjust the number of parallel threads using `RAYON_NUM_THREADS` environment variable (ex. `RAYON_NUM_THREADS=1 ./sigem mylib.a`)

#### macOS

If you are on macOS and the `sigem` binary fails to run due to missing `libbinaryninjacore.1.dylib`, you can set your [`DYLD_LIBRARY_PATH`](x-man-page://1/dyld) to include the `${DEP_BINARYNINJACORE_PATH}/Contents/MacOS/` directory.

```sh
export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}:${DEP_BINARYNINJACORE_PATH}/Contents/MacOS/"
./sigem --help
```
If you encounter malloc errors or instability try and adjust the number of parallel threads using `RAYON_NUM_THREADS` environment variable (ex. `RAYON_NUM_THREADS=1 ./sigem mylib.a`)
41 changes: 40 additions & 1 deletion plugins/warp/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![allow(unused_imports)]
use std::path::PathBuf;
use std::process::Command;
use std::path::Path;

#[cfg(feature = "test")]
fn compile_rust(file: PathBuf) -> bool {
Expand All @@ -18,10 +19,48 @@ fn compile_rust(file: PathBuf) -> bool {
}

fn main() {
if let Some(link_path) = option_env!("BINARYNINJADIR") {

let binja_base_dir: &str = option_env!("DEP_BINARYNINJACORE_BASE_DIR").unwrap_or_else(|| {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our build system needs to set its own paths, so unfortunately we can't do lookups like this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would work fine: 5239ad6

// If the environment variable is not set, try the default locations from
// https://docs.binary.ninja/guide/#binary-path

#[cfg(target_os = "macos")]
{
let default = "/Applications/Binary Ninja.app/";
if Path::new(default).exists() {
return default
}
}

#[cfg(target_os = "windows")]
{
let default = r"C:\Program Files\Vector35\BinaryNinja";
if Path::new(default).exists() {
return default
}
// Nothing at default path, check user path
if let Some(local_app_data) = std::env::var_os("LOCALAPPDATA") {
let user_path = Path::new(&local_app_data).join("Vector35").join("BinaryNinja");
if user_path.exists() {
return user_path.to_str().unwrap()
}
}
}

panic!("DEP_BINARYNINJACORE_BASE_DIR must be set to the base directory of the Binary Ninja installation");
});

if let link_path = binja_base_dir {
println!("cargo::rustc-link-lib=dylib=binaryninjacore");
println!("cargo::rustc-link-search={}", link_path);

#[cfg(target_os = "macos")]
{
// On macOS the binaryninjacore dylib is in the MacOS directory
println!("cargo::rustc-link-search={}/Contents/MacOS", link_path);
println!("cargo::rustc-link-arg=-Wl,-rpath,{0}/Contents/MacOS,-L{0}/Contents/MacOS", link_path);
}

#[cfg(not(target_os = "windows"))]
{
println!("cargo::rustc-link-arg=-Wl,-rpath,{0},-L{0}", link_path);
Expand Down