1- use crate :: machine:: Mapping ;
1+ use crate :: machine:: { Mapping , PAGE_SIZE } ;
22use crate :: shims:: unix:: fs:: EvalContextExt as _;
33use crate :: * ;
44use rustc_target:: abi:: { Align , Size } ;
55
6- const PAGE_SIZE : u64 = 4096 ;
7-
86impl < ' mir , ' tcx : ' mir > EvalContextExt < ' mir , ' tcx > for crate :: MiriEvalContext < ' mir , ' tcx > { }
97pub trait EvalContextExt < ' mir , ' tcx : ' mir > : crate :: MiriEvalContextExt < ' mir , ' tcx > {
108 fn mmap (
@@ -25,12 +23,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
2523 let fd = this. read_scalar ( fd) ?. to_i32 ( ) ?;
2624 let offset = this. read_scalar ( offset) ?. to_machine_usize ( this) ?;
2725
28- let print_args = || {
29- eprintln ! (
30- "mmap(addr: {addr}, length: {length}, prot: {prot:x}, flags: {flags:0x}, fd: {fd}, offset: {offset})"
31- ) ;
32- } ;
33-
3426 let prot_read = this. eval_libc_i32 ( "PROT_READ" ) ?;
3527 let prot_write = this. eval_libc_i32 ( "PROT_WRITE" ) ?;
3628 let map_private = this. eval_libc_i32 ( "MAP_PRIVATE" ) ?;
@@ -46,22 +38,18 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
4638 }
4739
4840 if prot & this. eval_libc_i32 ( "PROT_EXEC" ) ? > 0 {
49- print_args ( ) ;
5041 throw_unsup_format ! ( "Miri does not support mapping executable pages" ) ;
5142 }
5243
5344 if offset != 0 {
54- print_args ( ) ;
5545 throw_unsup_format ! ( "Miri does not support non-zero offsets to mmap (yet)" ) ;
5646 }
5747
5848 if !this. ptr_is_null ( addr) ? {
59- print_args ( ) ;
6049 throw_unsup_format ! ( "Miri does not support non-null pointers to mmap" ) ;
6150 }
6251
6352 if length == 0 {
64- print_args ( ) ;
6553 this. set_last_error ( Scalar :: from_i32 ( this. eval_libc_i32 ( "EINVAL" ) ?) ) ?;
6654 return Ok ( Pointer :: null ( ) ) ;
6755 }
0 commit comments