@@ -253,7 +253,23 @@ impl MemoryExtra {
253
253
this. write_scalar ( Scalar :: from_u8 ( 0 ) , & place. into ( ) ) ?;
254
254
Self :: add_extern_static ( this, "_tls_used" , place. ptr ) ;
255
255
}
256
- "android" =>
256
+ "android" => {
257
+ // "environ"
258
+ Self :: add_extern_static (
259
+ this,
260
+ "environ" ,
261
+ this. machine . env_vars . environ . unwrap ( ) . ptr ,
262
+ ) ;
263
+ // A couple zero-initialized pointer-sized extern statics.
264
+ // Most of them are for weak symbols, which we all set to null (indicating that the
265
+ // symbol is not supported, and triggering fallback code which ends up calling a
266
+ // syscall that we do support).
267
+ for name in & [ "__cxa_thread_atexit_impl" , "getrandom" , "statx" ] {
268
+ let layout = this. machine . layouts . usize ;
269
+ let place = this. allocate ( layout, MiriMemoryKind :: ExternStatic . into ( ) ) ?;
270
+ this. write_scalar ( Scalar :: from_machine_usize ( 0 , this) , & place. into ( ) ) ?;
271
+ Self :: add_extern_static ( this, name, place. ptr ) ;
272
+ }
257
273
for symbol_name in & [ "signal" , "bsd_signal" ] {
258
274
let layout = this. machine . layouts . usize ;
259
275
let dlsym = Dlsym :: from_str ( symbol_name. as_bytes ( ) , & this. tcx . sess . target . os ) ?
@@ -268,8 +284,9 @@ impl MemoryExtra {
268
284
let place = this. allocate ( layout, MiriMemoryKind :: ExternStatic . into ( ) ) ?;
269
285
this. write_pointer ( ptr, & place. into ( ) ) ?;
270
286
271
- Self :: add_extern_static ( this, symbol_name, place. ptr . into ( ) ) ;
272
- } ,
287
+ Self :: add_extern_static ( this, symbol_name, place. ptr ) ;
288
+ }
289
+ }
273
290
_ => { } // No "extern statics" supported on this target
274
291
}
275
292
Ok ( ( ) )
0 commit comments