From d800d1e2cbe86540a500d1d1cbea5e4a7a207e53 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 27 Nov 2021 17:15:14 -0500 Subject: [PATCH] rustup; stub support for some extern statics used for weak symbols --- rust-version | 2 +- src/machine.rs | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/rust-version b/rust-version index e7e504a38a7..0844897398b 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -5bc98076f37dd8c1476de4bbe0515c55a65332b7 +686e313a9aa14107c8631ffe48fa09110a7692db diff --git a/src/machine.rs b/src/machine.rs index 201854e76fa..b1998ccccaa 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -228,18 +228,22 @@ impl MemoryExtra { ) -> InterpResult<'tcx> { match this.tcx.sess.target.os.as_str() { "linux" => { - // "__cxa_thread_atexit_impl" - // This should be all-zero, pointer-sized. - let layout = this.machine.layouts.usize; - let place = this.allocate(layout, MiriMemoryKind::ExternStatic.into())?; - this.write_scalar(Scalar::from_machine_usize(0, this), &place.into())?; - Self::add_extern_static(this, "__cxa_thread_atexit_impl", place.ptr); // "environ" Self::add_extern_static( this, "environ", this.machine.env_vars.environ.unwrap().ptr, ); + // A couple zero-initialized pointer-sized extern statics. + // Most of them are for weak symbols, which we all set to null (indicating that the + // symbol is not supported, and triggering fallback code which ends up calling a + // syscall that we do support). + for name in &["__cxa_thread_atexit_impl", "getrandom", "statx"] { + let layout = this.machine.layouts.usize; + let place = this.allocate(layout, MiriMemoryKind::ExternStatic.into())?; + this.write_scalar(Scalar::from_machine_usize(0, this), &place.into())?; + Self::add_extern_static(this, name, place.ptr); + } } "windows" => { // "_tls_used"