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

Mach: Fvmlib is packed and implements Pwrite #105

Closed
m4b opened this issue Sep 30, 2018 · 1 comment
Closed

Mach: Fvmlib is packed and implements Pwrite #105

m4b opened this issue Sep 30, 2018 · 1 comment

Comments

@m4b
Copy link
Owner

m4b commented Sep 30, 2018

warning: borrow of packed field is unsafe and requires unsafe function or block (error E0133)                                                         
   --> /home/m4b/projects/goblin/src/mach/load_command.rs:145:37                                                                                      
    |                                                                                                                                                 
145 | #[derive(Debug, Clone, Copy, Pread, Pwrite, IOread, IOwrite, SizeWith)]                                                                         
    |                                     ^^^^^^                                                                                                      
    |                                                                                                                                                 
    = note: #[warn(safe_packed_borrows)] on by default                                                                                                
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!                 
    = note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043>                                                   
    = note: fields of packed structs might be misaligned: dereferencing a misaligned pointer or even just creating a misaligned reference is undefined behavior

I guess simplest solution is to remove Pwrite impl (luckily it's a deprecated struct, so likely won't ever be needed by any writer); nevertheless, need to figure out what to do here, though it probably belongs in scroll...

@philipc
Copy link
Collaborator

philipc commented Oct 1, 2018

Why does it need to be packed instead of repr(C)? The definition in LLVM is a plain C struct.

@m4b m4b closed this as completed in b3a633f Oct 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants