@@ -228,18 +228,22 @@ impl MemoryExtra {
228228 ) -> InterpResult < ' tcx > {
229229 match this. tcx . sess . target . os . as_str ( ) {
230230 "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 ) ;
237231 // "environ"
238232 Self :: add_extern_static (
239233 this,
240234 "environ" ,
241235 this. machine . env_vars . environ . unwrap ( ) . ptr ,
242236 ) ;
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+ }
243247 }
244248 "windows" => {
245249 // "_tls_used"
0 commit comments