@@ -228,18 +228,22 @@ impl MemoryExtra {
228
228
) -> InterpResult < ' tcx > {
229
229
match this. tcx . sess . target . os . as_str ( ) {
230
230
"linux" => {
231
- // "__cxa_thread_atexit_impl"
232
- // This should be all-zero, pointer-sized.
233
- let layout = this. machine . layouts . usize ;
234
- let place = this. allocate ( layout, MiriMemoryKind :: ExternStatic . into ( ) ) ?;
235
- this. write_scalar ( Scalar :: from_machine_usize ( 0 , this) , & place. into ( ) ) ?;
236
- Self :: add_extern_static ( this, "__cxa_thread_atexit_impl" , place. ptr ) ;
237
231
// "environ"
238
232
Self :: add_extern_static (
239
233
this,
240
234
"environ" ,
241
235
this. machine . env_vars . environ . unwrap ( ) . ptr ,
242
236
) ;
237
+ // A couple zero-initialized pointer-sized extern statics.
238
+ // Most of them are for weak symbols, which we all set to null (indicating that the
239
+ // symbol is not supported, and triggering fallback code which ends up calling a
240
+ // syscall that we do support).
241
+ for name in & [ "__cxa_thread_atexit_impl" , "getrandom" , "statx" ] {
242
+ let layout = this. machine . layouts . usize ;
243
+ let place = this. allocate ( layout, MiriMemoryKind :: ExternStatic . into ( ) ) ?;
244
+ this. write_scalar ( Scalar :: from_machine_usize ( 0 , this) , & place. into ( ) ) ?;
245
+ Self :: add_extern_static ( this, name, place. ptr ) ;
246
+ }
243
247
}
244
248
"windows" => {
245
249
// "_tls_used"
0 commit comments