@@ -328,13 +328,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
328
328
let symbol_name = this. memory ( ) . get ( symbol. alloc_id ) ?. read_c_str ( tcx, symbol) ?;
329
329
let err = format ! ( "bad c unicode symbol: {:?}" , symbol_name) ;
330
330
let symbol_name = :: std:: str:: from_utf8 ( symbol_name) . unwrap_or ( & err) ;
331
- if let Some ( dlsym) = Dlsym :: from_str ( symbol_name) {
331
+ if let Some ( dlsym) = Dlsym :: from_str ( symbol_name) ? {
332
332
let ptr = this. memory_mut ( ) . create_fn_alloc ( FnVal :: Other ( dlsym) ) ;
333
333
this. write_scalar ( Scalar :: from ( ptr) , dest) ?;
334
334
} else {
335
- return err ! ( Unimplemented ( format!(
336
- "Unsupported dlsym: {}" , symbol_name
337
- ) ) ) ;
335
+ this. write_null ( dest) ?;
338
336
}
339
337
}
340
338
@@ -722,24 +720,31 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
722
720
this. write_null ( dest) ?;
723
721
}
724
722
725
- // Determine stack base address.
726
- "pthread_attr_init" | "pthread_attr_destroy" | "pthread_attr_get_np " |
727
- "pthread_getattr_np" | "pthread_self" | "pthread_get_stacksize_np " => {
723
+ // Stack size/ address stuff .
724
+ "pthread_attr_init" | "pthread_attr_destroy" | "pthread_self " |
725
+ "pthread_attr_setstacksize " => {
728
726
this. write_null ( dest) ?;
729
727
}
730
728
"pthread_attr_getstack" => {
731
- // Second argument is where we are supposed to write the stack size.
732
- let ptr = this. deref_operand ( args[ 1 ] ) ?;
733
- // Just any address.
734
- let stack_addr = Scalar :: from_uint ( STACK_ADDR , args[ 1 ] . layout . size ) ;
735
- this. write_scalar ( stack_addr, ptr. into ( ) ) ?;
729
+ let addr_place = this. deref_operand ( args[ 1 ] ) ?;
730
+ let size_place = this. deref_operand ( args[ 2 ] ) ?;
731
+
732
+ this. write_scalar (
733
+ Scalar :: from_uint ( STACK_ADDR , addr_place. layout . size ) ,
734
+ addr_place. into ( ) ,
735
+ ) ?;
736
+ this. write_scalar (
737
+ Scalar :: from_uint ( STACK_SIZE , size_place. layout . size ) ,
738
+ size_place. into ( ) ,
739
+ ) ?;
740
+
736
741
// Return success (`0`).
737
742
this. write_null ( dest) ?;
738
743
}
739
- "pthread_get_stackaddr_np" => {
740
- // Just any address .
741
- let stack_addr = Scalar :: from_uint ( STACK_ADDR , dest . layout . size ) ;
742
- this . write_scalar ( stack_addr , dest ) ? ;
744
+
745
+ // We don't support threading .
746
+ "pthread_create" => {
747
+ return err ! ( Unimplemented ( format! ( "Miri does not support threading" ) ) ) ;
743
748
}
744
749
745
750
// Stub out calls for condvar, mutex and rwlock, to just return `0`.
@@ -767,6 +772,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
767
772
}
768
773
769
774
// macOS API stubs.
775
+ "pthread_attr_get_np" | "pthread_getattr_np" => {
776
+ this. write_null ( dest) ?;
777
+ }
778
+ "pthread_get_stackaddr_np" => {
779
+ let stack_addr = Scalar :: from_uint ( STACK_ADDR , dest. layout . size ) ;
780
+ this. write_scalar ( stack_addr, dest) ?;
781
+ }
782
+ "pthread_get_stacksize_np" => {
783
+ let stack_size = Scalar :: from_uint ( STACK_SIZE , dest. layout . size ) ;
784
+ this. write_scalar ( stack_size, dest) ?;
785
+ }
770
786
"_tlv_atexit" => {
771
787
// FIXME: register the destructor.
772
788
} ,
0 commit comments