Skip to content

Commit e62924e

Browse files
committed
Auto merge of #1926 - RalfJung:rustup, r=RalfJung
rustup; stub support for some extern statics used for weak symbols
2 parents 0949cd3 + d800d1e commit e62924e

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5bc98076f37dd8c1476de4bbe0515c55a65332b7
1+
686e313a9aa14107c8631ffe48fa09110a7692db

src/machine.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)