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

fix:add off_t conversion #106

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alexs-sh
Copy link

Hi,

  1. Thanks for the perfect tool
  2. I ran the bytehound on iMX6 board (ARM CPU). It works fine on a target device, but I faced light issues during the build. All of them are related to mixing 32/64 off_t types.

Here is an example:

error[E0308]: mismatched types
   --> preload/src/api.rs:79:55
    |
79  |     mmap_internal( addr, length, prot, flags, fildes, off, MapKind::Jemalloc )
    |     -------------                                     ^^^ expected `i64`, found `i32`
    |     |
    |     arguments to this function are incorrect
    |
note: function defined here
   --> preload/src/api.rs:895:11
    |
895 | unsafe fn mmap_internal( addr: *mut c_void, length: size_t, prot: c_int, flags: c_int, fildes: c_int, off: libc::off64_t, kind: MapKind )...
    |           ^^^^^^^^^^^^^                                                                               ------------------
help: you can convert an `i32` to an `i64`
    |
79  |     mmap_internal( addr, length, prot, flags, fildes, off.into(), MapKind::Jemalloc )
    |                                                          +++++++

error[E0308]: mismatched types
   --> preload/src/api.rs:881:97
    |
881 |             ptr = syscall::mmap( p0.add( 4096 ), length, prot, flags | libc::MAP_FIXED, fildes, off );
    |                   ------------- arguments to this function are incorrect                        ^^^ expected `i32`, found `i64`
    |
note: function defined here
   --> preload/src/syscall.rs:106:15

I added fixes to make everything buildable/runnable on the target device and prepared PR for discussion. I'm not sure that it's the correct or expected way to deal with problems.

The issue reproduced in 2 enviroments:

  • Ubuntu 23 & rustc 1.66.0-nightly (c0983a9aa 2022-10-12)
  • ArchLinux & rustc 1.68.0 (2c8cc3432 2023-03-06) or rustc 1.66.0-nightly (c0983a9aa 2022-10-12)

Build command:

  • cargo build --target=armv7-unknown-linux-gnueabihf --release

This fix makes bytehound buildable to armv7-unknown-linux-gnueabihf
target and runnable on iMX6 boards.
@alexs-sh alexs-sh marked this pull request as ready for review April 12, 2023 20:00
@hardliner66
Copy link

I recently stumbled upon the same problem, but I think instead of using the bigger type and converting/truncating it, would be to use off_t instead of off64_t, which would make it the correct size for the platform it is compiled for.

e.g.: make_compilable_for_armv7.patch

@alexs-sh
Copy link
Author

@hardliner66 Thanks for the information. I agree. The version with off_t looks better.

@alexs-sh
Copy link
Author

@koute What do you think about that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants