@@ -29,6 +29,21 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
2929 Ok ( ( ) )
3030 }
3131
32+ /// Extern statics that are initialized with function pointers to the symbols of the same name.
33+ fn weak_symbol_extern_statics (
34+ this : & mut MiriInterpCx < ' mir , ' tcx > ,
35+ names : & [ & str ] ,
36+ ) -> InterpResult < ' tcx > {
37+ for name in names {
38+ assert ! ( this. is_dyn_sym( name) , "{name} is not a dynamic symbol" ) ;
39+ let layout = this. machine . layouts . const_raw_ptr ;
40+ let ptr = this. fn_ptr ( FnVal :: Other ( DynSym :: from_str ( name) ) ) ;
41+ let val = ImmTy :: from_scalar ( Scalar :: from_pointer ( ptr, this) , layout) ;
42+ Self :: alloc_extern_static ( this, name, val) ?;
43+ }
44+ Ok ( ( ) )
45+ }
46+
3247 /// Sets up the "extern statics" for this machine.
3348 pub fn init_extern_statics ( this : & mut MiriInterpCx < ' mir , ' tcx > ) -> InterpResult < ' tcx > {
3449 // "__rust_no_alloc_shim_is_unstable"
@@ -58,12 +73,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
5873 }
5974 "android" => {
6075 Self :: null_ptr_extern_statics ( this, & [ "bsd_signal" ] ) ?;
61- // "signal" -- just needs a non-zero pointer value (function does not even get called),
62- // but we arrange for this to call the `signal` function anyway.
63- let layout = this. machine . layouts . const_raw_ptr ;
64- let ptr = this. fn_ptr ( FnVal :: Other ( DynSym :: from_str ( "signal" ) ) ) ;
65- let val = ImmTy :: from_scalar ( Scalar :: from_pointer ( ptr, this) , layout) ;
66- Self :: alloc_extern_static ( this, "signal" , val) ?;
76+ Self :: weak_symbol_extern_statics ( this, & [ "signal" ] ) ?;
6777 }
6878 "windows" => {
6979 // "_tls_used"
0 commit comments