lurk icon indicating copy to clipboard operation
lurk copied to clipboard

arm64 support?

Open tiann opened this issue 3 years ago • 13 comments

tiann avatar Jul 30 '22 04:07 tiann

I try to build it on arm64 and here is the error:

❯ cargo build --target aarch64-unknown-linux-gnu
   Compiling lurk v0.1.0 (/Users/weishu/dev/github/lurk)
error[E0425]: cannot find function `getregs` in module `ptrace`
   --> src/main.rs:170:23
    |
170 |         match ptrace::getregs(child) {
    |                       ^^^^^^^ not found in `ptrace`

For more information about this error, try `rustc --explain E0425`.
error: could not compile `lurk` due to previous error

nix crate doesn't support ptrace.getregs on arm64 now, the related issue: https://github.com/nix-rust/nix/issues/1419

tiann avatar Aug 05 '22 05:08 tiann

Compiling lurk-cli v0.2.9 (/project)
error[E0432]: unresolved import `linux_personality::personality`
Error:   --> src/main.rs:12:5
   |
12 | use linux_personality::personality;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `personality` in the root

error[E0425]: cannot find function `getregs` in module `ptrace`
Error:    --> src/main.rs:165:23
    |
165 |         match ptrace::getregs(child) {
    |                       ^^^^^^^ not found in `ptrace`

error[E0425]: cannot find value `ADDR_NO_RANDOMIZE` in crate `linux_personality`
Error:    --> src/main.rs:608:36
    |
608 |     personality(linux_personality::ADDR_NO_RANDOMIZE).unwrap();
    |                                    ^^^^^^^^^^^^^^^^^ not found in `linux_personality`
    |
help: consider importing this constant
    |
5   | use libc::ADDR_NO_RANDOMIZE;
    |
help: if you import `ADDR_NO_RANDOMIZE`, refer to it directly
    |
608 -     personality(linux_personality::ADDR_NO_RANDOMIZE).unwrap();
608 +     personality(ADDR_NO_RANDOMIZE).unwrap();
    |

error[E0308]: mismatched types
Error:     --> src/main.rs:657:41
     |
657  |         bytes.write_i64::<LittleEndian>(res).unwrap_or_else(|err| {
     |               ------------------------- ^^^ expected `i64`, found `i32`
     |               |
     |               arguments to this function are incorrect
     |
note: associated function defined here
    --> /cargo/registry/src/github.com-1ecc6[299](https://github.com/2096779623/lurk/actions/runs/3398907517/jobs/5652300328#step:4:301)db9ec823/byteorder-1.4.3/src/io.rs:1394:8
     |
1394 |     fn write_i64<T: ByteOrder>(&mut self, n: i64) -> Result<()> {
     |        ^^^^^^^^^
help: you can convert an `i32` to an `i64`
     |
657  |         bytes.write_i64::<LittleEndian>(res.into()).unwrap_or_else(|err| {
     |                                            +++++++

Some errors have detailed explanations: E0308, E0425, E0432.
For more information about an error, try `rustc --explain E0308`.
error: could not compile `lurk-cli` due to 4 previous errors

2096779623 avatar Nov 05 '22 05:11 2096779623

Thanks for opening this issue. Supporting multiple architectures is something I tried to avoid as long as possible since I need to manually create a syscall-table for every single architecture. Additionally, some libraries might not be supported on every architecture/operating system. Implementing this probably requires rewriting a larger portion of my code to allow for a more generic implementation. I will try to tackle this problem as soon as possible.

JakWai01 avatar Jan 06 '23 12:01 JakWai01

Ah! OK so this is a known issue 👍🏻

As yeah I just tried installing on an M1 macOS...

Darwin D3496LK9V7 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000 arm64

...and was getting this compilation error...

cargo install lurk-cli
    Updating crates.io index
  Downloaded lurk-cli v0.2.9
  Downloaded 1 crate (142.9 KB) in 1.54s
  Installing lurk-cli v0.2.9
  Downloaded once_cell v1.17.1
  Downloaded itoa v1.0.6
  Downloaded ryu v1.0.13
  Downloaded unicode-ident v1.0.8
  Downloaded serde_json v1.0.94
  Downloaded syn v1.0.109
  Downloaded num-complex v0.1.43
  Downloaded users v0.11.0
  Downloaded nix v0.24.3
  Downloaded num v0.1.42
  Downloaded bitflags v0.7.0
  Downloaded rustc-serialize v0.3.24
  Downloaded num-rational v0.1.42
  Downloaded num-bigint v0.1.44
  Downloaded stopwatch v0.0.7
  Downloaded linux-personality v1.0.0
  Downloaded 16 crates (972.7 KB) in 1.11s
   Compiling autocfg v1.1.0
   Compiling libc v0.2.139
   Compiling proc-macro2 v1.0.51
   Compiling version_check v0.9.4
   Compiling quote v1.0.23
   Compiling unicode-ident v1.0.8
   Compiling syn v1.0.109
   Compiling rustc-serialize v0.3.24
   Compiling memchr v2.5.0
   Compiling proc-macro-error-attr v1.0.4
   Compiling num-traits v0.2.15
   Compiling num-integer v0.1.45
   Compiling num-iter v0.1.43
   Compiling proc-macro-error v1.0.4
   Compiling memoffset v0.6.5
   Compiling indexmap v1.9.2
   Compiling cfg-if v1.0.0
   Compiling log v0.4.17
   Compiling serde v1.0.152
   Compiling rand v0.4.6
   Compiling num-bigint v0.1.44
   Compiling num-complex v0.1.43
   Compiling num-rational v0.1.42
   Compiling bitflags v1.3.2
   Compiling os_str_bytes v6.4.1
   Compiling hashbrown v0.12.3
   Compiling serde_json v1.0.94
   Compiling heck v0.4.1
   Compiling anyhow v1.0.69
   Compiling clap_lex v0.2.4
   Compiling num v0.1.42
   Compiling aho-corasick v0.7.20
   Compiling atty v0.2.14
   Compiling once_cell v1.17.1
   Compiling strsim v0.10.0
   Compiling bitflags v0.7.0
   Compiling itoa v1.0.6
   Compiling regex-syntax v0.6.28
   Compiling termcolor v1.2.0
   Compiling clap_derive v3.2.18
   Compiling textwrap v0.16.0
   Compiling ryu v1.0.13
   Compiling linux-personality v1.0.0
   Compiling users v0.11.0
   Compiling nix v0.24.3
   Compiling stopwatch v0.0.7
   Compiling byteorder v1.4.3
   Compiling ansi_term v0.12.1
   Compiling regex v1.7.1
   Compiling clap v3.2.23
   Compiling lurk-cli v0.2.9
error[E0432]: unresolved import `linux_personality::personality`
  --> /Users/integralist/.cargo/registry/src/github.com-1ecc6299db9ec823/lurk-cli-0.2.9/src/main.rs:12:5
   |
12 | use linux_personality::personality;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `personality` in the root

error[E0433]: failed to resolve: use of undeclared type `Options`
   --> /Users/integralist/.cargo/registry/src/github.com-1ecc6299db9ec823/lurk-cli-0.2.9/src/main.rs:154:21
    |
154 |                     Options::PTRACE_O_TRACEFORK
    |                     ^^^^^^^ use of undeclared type `Options`

error[E0433]: failed to resolve: use of undeclared type `Options`
   --> /Users/integralist/.cargo/registry/src/github.com-1ecc6299db9ec823/lurk-cli-0.2.9/src/main.rs:155:27
    |
155 |                         | Options::PTRACE_O_TRACEVFORK
    |                           ^^^^^^^ use of undeclared type `Options`

error[E0433]: failed to resolve: use of undeclared type `Options`
   --> /Users/integralist/.cargo/registry/src/github.com-1ecc6299db9ec823/lurk-cli-0.2.9/src/main.rs:156:27
    |
156 |                         | Options::PTRACE_O_TRACECLONE,
    |                           ^^^^^^^ use of undeclared type `Options`

error[E0425]: cannot find function `setoptions` in module `ptrace`
   --> /Users/integralist/.cargo/registry/src/github.com-1ecc6299db9ec823/lurk-cli-0.2.9/src/main.rs:152:25
    |
152 |                 ptrace::setoptions(
    |                         ^^^^^^^^^^ not found in `ptrace`

error[E0425]: cannot find function `getregs` in module `ptrace`
   --> /Users/integralist/.cargo/registry/src/github.com-1ecc6299db9ec823/lurk-cli-0.2.9/src/main.rs:165:23
    |
165 |         match ptrace::getregs(child) {
    |                       ^^^^^^^ not found in `ptrace`

error[E0425]: cannot find function `syscall` in module `ptrace`
   --> /Users/integralist/.cargo/registry/src/github.com-1ecc6299db9ec823/lurk-cli-0.2.9/src/main.rs:521:23
    |
521 |         match ptrace::syscall(child, None) {
    |                       ^^^^^^^ not found in `ptrace`
    |
help: consider importing this function
    |
5   | use libc::syscall;
    |
help: if you import `syscall`, refer to it directly
    |
521 -         match ptrace::syscall(child, None) {
521 +         match syscall(child, None) {
    |

error[E0425]: cannot find value `ADDR_NO_RANDOMIZE` in crate `linux_personality`
   --> /Users/integralist/.cargo/registry/src/github.com-1ecc6299db9ec823/lurk-cli-0.2.9/src/main.rs:607:36
    |
607 |     personality(linux_personality::ADDR_NO_RANDOMIZE).unwrap();
    |                                    ^^^^^^^^^^^^^^^^^ not found in `linux_personality`

error[E0308]: mismatched types
   --> /Users/integralist/.cargo/registry/src/github.com-1ecc6299db9ec823/lurk-cli-0.2.9/src/main.rs:251:69
    |
251 | ...                   let mut string = read_string(child, reg as *mut c_void);
    |                                        -----------        ^^^^^^^^^^^^^^^^^^ expected `i8`, found enum `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/integralist/.cargo/registry/src/github.com-1ecc6299db9ec823/lurk-cli-0.2.9/src/main.rs:639:4
    |
639 | fn read_string(pid: Pid, address: AddressType) -> String {
    |    ^^^^^^^^^^^           --------------------

error[E0308]: mismatched types
   --> /Users/integralist/.cargo/registry/src/github.com-1ecc6299db9ec823/lurk-cli-0.2.9/src/main.rs:652:33
    |
649 |         let res: c_long;
    |                  ------ expected due to this type
...
652 |             Ok(c_long) => res = c_long,
    |                                 ^^^^^^ expected `i64`, found `i32`

Some errors have detailed explanations: E0308, E0425, E0432, E0433.
For more information about an error, try `rustc --explain E0308`.
error: could not compile `lurk-cli` due to 10 previous errors
error: failed to compile `lurk-cli v0.2.9`, intermediate artifacts can be found at `/var/folders/lj/y1tlk7nd5tgcz5z00fycytjr0000gp/T/cargo-installIBk2Nn`

Integralist avatar Mar 07 '23 09:03 Integralist

This is my m1 build with the 0.3.3 release

   Compiling lurk-cli v0.3.2 (/private/tmp/lurk-20230611-91173-1efmnow/lurk-0.3.3)
error[E0432]: unresolved import `libc::user_regs_struct`
 --> 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`
 --> 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`
 --> src/syscall_info.rs:4:25
  |
4 | use libc::{c_ulonglong, user_regs_struct};
  |                         ^^^^^^^^^^^^^^^^ no `user_regs_struct` in the root

error[E0432]: unresolved imports `linux_personality::personality`, `linux_personality::ADDR_NO_RANDOMIZE`
  --> src/lib.rs:23:25
   |
23 | use linux_personality::{personality, ADDR_NO_RANDOMIZE};
   |                         ^^^^^^^^^^^  ^^^^^^^^^^^^^^^^^ no `ADDR_NO_RANDOMIZE` in the root
   |                         |
   |                         no `personality` in the root
   |
   = help: consider importing one of these items 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::s390x::Sysno::personality
           syscalls::sparc64::Sysno::personality
           syscalls::sparc::Sysno::personality
           syscalls::x86::Sysno::personality
           syscalls::x86_64::Sysno::personality

error[E0432]: unresolved imports `crate::arch::TRACE_CLOCK`, `crate::arch::TRACE_CREDS`, `crate::arch::TRACE_DESC`, `crate::arch::TRACE_FILE`, `crate::arch::TRACE_FSTAT`, `crate::arch::TRACE_FSTATFS`, `crate::arch::TRACE_IPC`, `crate::arch::TRACE_LSTAT`, `crate::arch::TRACE_MEMORY`, `crate::arch::TRACE_NETWORK`, `crate::arch::TRACE_PROCESS`, `crate::arch::TRACE_PURE`, `crate::arch::TRACE_SIGNAL`, `crate::arch::TRACE_STAT`, `crate::arch::TRACE_STATFS`, `crate::arch::TRACE_STATFS_LIKE`, `crate::arch::TRACE_STAT_LIKE`
 --> src/args.rs:2:5
  |
2 |     TRACE_CLOCK, TRACE_CREDS, TRACE_DESC, TRACE_FILE, TRACE_FSTAT, TRACE_FSTATFS, TRACE_IPC,
  |     ^^^^^^^^^^^  ^^^^^^^^^^^  ^^^^^^^^^^  ^^^^^^^^^^  ^^^^^^^^^^^  ^^^^^^^^^^^^^  ^^^^^^^^^ no `TRACE_IPC` in `arch`
  |     |            |            |           |           |            |
  |     |            |            |           |           |            no `TRACE_FSTATFS` in `arch`
  |     |            |            |           |           no `TRACE_FSTAT` in `arch`
  |     |            |            |           no `TRACE_FILE` in `arch`
  |     |            |            no `TRACE_DESC` in `arch`
  |     |            no `TRACE_CREDS` in `arch`
  |     no `TRACE_CLOCK` in `arch`
3 |     TRACE_LSTAT, TRACE_MEMORY, TRACE_NETWORK, TRACE_PROCESS, TRACE_PURE, TRACE_SIGNAL, TRACE_STAT,
  |     ^^^^^^^^^^^  ^^^^^^^^^^^^  ^^^^^^^^^^^^^  ^^^^^^^^^^^^^  ^^^^^^^^^^  ^^^^^^^^^^^^  ^^^^^^^^^^
  |     |            |             |
  |     |            |             no `TRACE_NETWORK` in `arch`
  |     |            no `TRACE_MEMORY` in `arch`
  |     no `TRACE_LSTAT` in `arch`
4 |     TRACE_STATFS, TRACE_STATFS_LIKE, TRACE_STAT_LIKE,
  |     ^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^

error[E0425]: cannot find function `setoptions` in module `ptrace`
  --> src/arch/mod.rs:98:13
   |
98 |     ptrace::setoptions(
   |             ^^^^^^^^^^ not found in `ptrace`

error[E0425]: cannot find value `SYSCALLS` in this scope
   --> src/arch/mod.rs:107:9
    |
107 |         SYSCALLS[syscall.id() as usize]
    |         ^^^^^^^^ not found in this scope

error[E0425]: cannot find function `getregs` in module `ptrace`
   --> src/lib.rs:106:41
    |
106 |             let Ok(registers) = ptrace::getregs(self.pid) else {
    |                                         ^^^^^^^ not found in `ptrace`

error[E0425]: cannot find function `syscall` in module `ptrace`
   --> src/lib.rs:168:24
    |
168 |             if ptrace::syscall(self.pid, None).is_err() {
    |                        ^^^^^^^ not found in `ptrace`
    |
help: consider importing one of these items
    |
18  | use libc::syscall;
    |
18  | use syscalls::mips::Sysno::syscall;
    |
18  | use syscalls::syscall;
    |
help: if you import `syscall`, refer to it directly
    |
168 -             if ptrace::syscall(self.pid, None).is_err() {
168 +             if syscall(self.pid, None).is_err() {
    |

error[E0308]: mismatched types
   --> src/arch/mod.rs:75:51
    |
75  |         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/rui/Library/Caches/Homebrew/cargo_cache/registry/src/github.com-1ecc6299db9ec823/nix-0.26.2/src/sys/ptrace/bsd.rs:181:8
    |
181 | pub fn read(pid: Pid, addr: AddressType) -> Result<c_int> {
    |        ^^^^

error[E0308]: mismatched types
  --> src/arch/mod.rs:76:27
   |
76 |             Ok(c_long) => c_long,
   |                           ^^^^^^ expected `i64`, found `i32`
   |
help: you can convert an `i32` to an `i64`
   |
76 |             Ok(c_long) => c_long.into(),
   |                                 +++++++

error[E0425]: cannot find function `get_arg_value` in this scope
   --> src/arch/mod.rs:112:37
    |
112 |             .map(|(idx, arg)| (arg, get_arg_value(registers, idx)))
    |                                     ^^^^^^^^^^^^^ not found in this scope

Some errors have detailed explanations: E0308, E0425, E0432.

chenrui333 avatar Jun 12 '23 00:06 chenrui333

Thanks for posting your trace! So far, lurk does not support ARM. Supporting it requires updating the syscall tables with the corresponding system calls as well as replacing the libraries that do not exist for your system. It may take some time, but I'll try to tackle this at some point! :smile:

JakWai01 avatar Jun 12 '23 10:06 JakWai01

@JakWai01 also I have having issue compiling it in macos x86 as well, is that expected?

chenrui333 avatar Jun 17 '23 22:06 chenrui333