orhun / binsider

Analyze ELF binaries like a boss 😼🕵️‍♂️
https://binsider.dev/
Apache License 2.0
2.76k stars 61 forks source link

Failed to run `cargo install binsider` on macos #97

Closed lmapii closed 2 weeks ago

lmapii commented 3 weeks ago

Describe the bug

Compiling/installing binsider using cargo install binsider fails with the following error(s)

To reproduce

Run cargo install binsider the given environment.

Expected behavior

cargo install should work out of the box or additional dependencies should be listed.

Screenshots / Logs

error[E0432]: unresolved import `libc::user_regs_struct`
 --> /Users/martin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lurk-cli-0.3.9/src/arch/mod.rs:3:33
  |
3 | use libc::{c_long, c_ulonglong, user_regs_struct};
  |                                 ^^^^^^^^^^^^^^^^ no `user_regs_struct` in the root

error[E0432]: unresolved import `nix::sys::ptrace::Options`
 --> /Users/martin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lurk-cli-0.3.9/src/arch/mod.rs:5:5
  |
5 | use nix::sys::ptrace::Options;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^ no `Options` in `sys::ptrace`

error[E0432]: unresolved import `libc::user_regs_struct`
 --> /Users/martin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lurk-cli-0.3.9/src/arch/aarch64.rs:2:25
  |
2 | use libc::{c_ulonglong, user_regs_struct};
  |                         ^^^^^^^^^^^^^^^^ no `user_regs_struct` in the root
  |
  = help: consider importing this unresolved item through its public re-export instead:
          crate::arch::user_regs_struct

error[E0432]: unresolved import `libc::user_regs_struct`
 --> /Users/martin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lurk-cli-0.3.9/src/syscall_info.rs:3:25
  |
3 | use libc::{c_ulonglong, user_regs_struct};
  |                         ^^^^^^^^^^^^^^^^ no `user_regs_struct` in the root

error[E0432]: unresolved import `libc::user_regs_struct`
  --> /Users/martin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lurk-cli-0.3.9/src/lib.rs:77:5
   |
77 | use libc::user_regs_struct;
   |     ^^^^^^^^^^^^^^^^^^^^^^ no `user_regs_struct` in the root

error[E0432]: unresolved imports `linux_personality::personality`, `linux_personality::Personality`
  --> /Users/martin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lurk-cli-0.3.9/src/lib.rs:78:25
   |
78 | use linux_personality::{personality, Personality};
   |                         ^^^^^^^^^^^  ^^^^^^^^^^^ no `Personality` in the root
   |                         |
   |                         no `personality` in the root
   |
   = help: consider importing one of these variants instead:
           crate::Sysno::personality
           syscalls::Sysno::personality
           syscalls::arm::Sysno::personality
           syscalls::mips64::Sysno::personality
           syscalls::mips::Sysno::personality
           syscalls::powerpc64::Sysno::personality
           syscalls::powerpc::Sysno::personality
           syscalls::riscv32::Sysno::personality
           syscalls::riscv64::Sysno::personality
           syscalls::s390x::Sysno::personality
           syscalls::sparc64::Sysno::personality
           syscalls::sparc::Sysno::personality
           syscalls::x86::Sysno::personality
           syscalls::x86_64::Sysno::personality

error[E0432]: unresolved import `nix::sys::ptrace::Event`
  --> /Users/martin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lurk-cli-0.3.9/src/lib.rs:79:30
   |
79 | use nix::sys::ptrace::{self, Event};
   |                              ^^^^^ no `Event` in `sys::ptrace`

error[E0425]: cannot find function `setoptions` in module `ptrace`
   --> /Users/martin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lurk-cli-0.3.9/src/arch/mod.rs:102:13
    |
102 |     ptrace::setoptions(
    |             ^^^^^^^^^^ not found in `ptrace`

error[E0425]: cannot find function `setoptions` in module `ptrace`
   --> /Users/martin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lurk-cli-0.3.9/src/arch/mod.rs:109:13
    |
109 |     ptrace::setoptions(
    |             ^^^^^^^^^^ not found in `ptrace`

error[E0425]: cannot find function `getevent` in module `ptrace`
   --> /Users/martin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lurk-cli-0.3.9/src/lib.rs:228:41
    |
228 |                     let event = ptrace::getevent(pid)? as u8;
    |                                         ^^^^^^^^ not found in `ptrace`

error[E0425]: cannot find function `syscall` in module `ptrace`
   --> /Users/martin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lurk-cli-0.3.9/src/lib.rs:429:17
    |
429 |         ptrace::syscall(pid, signal)
    |                 ^^^^^^^ not found in `ptrace`
    |
help: consider importing one of these items
    |
72  + use libc::syscall;
    |
72  + use syscalls::mips::Sysno::syscall;
    |
72  + use syscalls::syscall;
    |
help: if you import `syscall`, refer to it directly
    |
429 -         ptrace::syscall(pid, signal)
429 +         syscall(pid, signal)
    |

error[E0425]: cannot find function `getregs` in module `ptrace`
   --> /Users/martin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lurk-cli-0.3.9/src/lib.rs:435:17
    |
435 |         ptrace::getregs(pid).map_err(|_| anyhow!("Unable to get registers from tracee {}", pid))
    |                 ^^^^^^^ not found in `ptrace`

   Compiling sysinfo v0.32.0
   Compiling unicode-width v0.2.0
error[E0308]: mismatched types
   --> /Users/martin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lurk-cli-0.3.9/src/arch/mod.rs:79:51
    |
79  |         let res: c_long = match ptrace::read(pid, address) {
    |                                 ------------      ^^^^^^^ expected `*mut i8`, found `*mut c_void`
    |                                 |
    |                                 arguments to this function are incorrect
    |
    = note: expected raw pointer `*mut i8`
               found raw pointer `*mut c_void`
note: function defined here
   --> /Users/martin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.29.0/src/sys/ptrace/bsd.rs:173:8
    |
173 | pub fn read(pid: Pid, addr: AddressType) -> Result<c_int> {
    |        ^^^^

error[E0308]: mismatched types
  --> /Users/martin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lurk-cli-0.3.9/src/arch/mod.rs:80:27
   |
80 |             Ok(c_long) => c_long,
   |                           ^^^^^^ expected `i64`, found `i32`
   |
help: you can convert an `i32` to an `i64`
   |
80 |             Ok(c_long) => c_long.into(),
   |                                 +++++++

error[E0599]: no variant or associated item named `PtraceEvent` found for enum `WaitStatus` in the current scope
   --> /Users/martin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lurk-cli-0.3.9/src/lib.rs:213:29
    |
213 |                 WaitStatus::PtraceEvent(pid, _, code) => {
    |                             ^^^^^^^^^^^ variant or associated item not found in `WaitStatus`

error[E0599]: no variant or associated item named `PtraceSyscall` found for enum `WaitStatus` in the current scope
   --> /Users/martin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lurk-cli-0.3.9/src/lib.rs:223:29
    |
223 |                 WaitStatus::PtraceSyscall(pid) => {
    |                             ^^^^^^^^^^^^^ variant or associated item not found in `WaitStatus`

Some errors have detailed explanations: E0308, E0425, E0432, E0599.
For more information about an error, try `rustc --explain E0308`.
error: could not compile `lurk-cli` (lib) due to 16 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `binsider v0.2.1`, intermediate artifacts can be found at `/var/folders/5l/j8785fz13kvfcsf5np_3rg5h0000gn/T/cargo-installqzqKew`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

Software information

Additional context

N/A

orhun commented 3 weeks ago

Can you try cargo install binsider --no-default-features?

lmapii commented 3 weeks ago

Yep that works! What's the dependency that's missing?

orhun commented 2 weeks ago

See #56 #31 #57