@@ -47,21 +47,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
4747 this. read_scalar ( len) ?,
4848 ) ?;
4949 }
50- "getrandom" => {
51- let [ ptr, len, flags] =
52- this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
53- let ptr = this. read_pointer ( ptr) ?;
54- let len = this. read_target_usize ( len) ?;
55- let _flags = this. read_scalar ( flags) ?. to_i32 ( ) ?;
56- // flags on freebsd does not really matter
57- // in practice, GRND_RANDOM does not particularly draw from /dev/random
58- // since it is the same as to /dev/urandom.
59- // GRND_INSECURE is only an alias of GRND_NONBLOCK, which
60- // does not affect the RNG.
61- // https://man.freebsd.org/cgi/man.cgi?query=getrandom&sektion=2&n=1
62- this. gen_random ( ptr, len) ?;
63- this. write_scalar ( Scalar :: from_target_usize ( len, this) , dest) ?;
64- }
6550
6651 // File related shims
6752 // For those, we both intercept `func` and `call@FBSD_1.0` symbols cases
@@ -90,7 +75,22 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
9075 this. write_scalar ( result, dest) ?;
9176 }
9277
93- // errno
78+ // Miscellaneous
79+ "getrandom" => {
80+ let [ ptr, len, flags] =
81+ this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
82+ let ptr = this. read_pointer ( ptr) ?;
83+ let len = this. read_target_usize ( len) ?;
84+ let _flags = this. read_scalar ( flags) ?. to_i32 ( ) ?;
85+ // flags on freebsd does not really matter
86+ // in practice, GRND_RANDOM does not particularly draw from /dev/random
87+ // since it is the same as to /dev/urandom.
88+ // GRND_INSECURE is only an alias of GRND_NONBLOCK, which
89+ // does not affect the RNG.
90+ // https://man.freebsd.org/cgi/man.cgi?query=getrandom&sektion=2&n=1
91+ this. gen_random ( ptr, len) ?;
92+ this. write_scalar ( Scalar :: from_target_usize ( len, this) , dest) ?;
93+ }
9494 "__error" => {
9595 let [ ] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
9696 let errno_place = this. last_error_place ( ) ?;
0 commit comments