@@ -29,6 +29,21 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
29
29
Ok ( ( ) )
30
30
}
31
31
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
+
32
47
/// Sets up the "extern statics" for this machine.
33
48
pub fn init_extern_statics ( this : & mut MiriInterpCx < ' mir , ' tcx > ) -> InterpResult < ' tcx > {
34
49
// "__rust_no_alloc_shim_is_unstable"
@@ -58,12 +73,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
58
73
}
59
74
"android" => {
60
75
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" ] ) ?;
67
77
}
68
78
"windows" => {
69
79
// "_tls_used"
0 commit comments