about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-02-14 00:12:25 +0100
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-05-11 14:35:09 +0000
commitffd8cb87bf342488b56fe8e0238b0e556e813601 (patch)
tree34d5754dfebac178e40d625834c04dfccf0908a7
parent568deb7ece889ed2871fa023100cb69c5c086967 (diff)
downloadrust-ffd8cb87bf342488b56fe8e0238b0e556e813601.tar.gz
rust-ffd8cb87bf342488b56fe8e0238b0e556e813601.zip
Fix review comments
Co-authored-by: Ralf Jung <post@ralfj.de>
-rw-r--r--src/tools/miri/src/shims/foreign_items.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/tools/miri/src/shims/foreign_items.rs b/src/tools/miri/src/shims/foreign_items.rs
index 167370ef4a8..57fce448b60 100644
--- a/src/tools/miri/src/shims/foreign_items.rs
+++ b/src/tools/miri/src/shims/foreign_items.rs
@@ -359,10 +359,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
         match allocator_kind {
             AllocatorKind::Global => {
                 // When `#[global_allocator]` is used, `__rust_*` is defined by the macro expansion
-                // of this attribute rather than generated by the allocator shim. As such we have
-                // to call the definition produced by `#[global_allocator]` instead of the shim like
-                // in the case of `#[global_allocator]` not existing. Somewhat unintuitively doing
-                // so is done by returning `NotSupported`.
+                // of this attribute. As such we have to call an exported Rust function,
+                // and not execute any Miri shim. Somewhat unintuitively doing so is done
+                // by returning `NotSupported`, which triggers the `lookup_exported_symbol`
+                // fallback case in `emulate_foreign_item`.
                 return Ok(EmulateByNameResult::NotSupported);
             }
             AllocatorKind::Default => {
@@ -559,9 +559,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
             // Rust allocation
             "__rust_alloc" | "miri_alloc" => {
                 let default = |this: &mut MiriInterpCx<'mir, 'tcx>| {
-                    // Only call `check_shim` when `#[global_allocator]` isn't used. The macro
-                    // expansion of `#[global_allocator]` defines this symbol and `check_shim`
-                    // checks that there exists no definition of a shim.
+                    // Only call `check_shim` when `#[global_allocator]` isn't used. When that
+                    // macro is used, we act like no shim exists, so that the exported function can run.
                     let [size, align] = this.check_shim(abi, Abi::Rust, link_name, args)?;
                     let size = this.read_target_usize(size)?;
                     let align = this.read_target_usize(align)?;