Skip to content

Commit 238f3d2

Browse files
bjorn3RalfJung
andcommitted
Add a couple of comments
Co-Authored-By: Ralf Jung <post@ralfj.de>
1 parent 331bf8b commit 238f3d2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/tools/miri/src/shims/foreign_items.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
5151

5252
// Some shims forward to other MIR bodies.
5353
match link_name.as_str() {
54+
// This allocator function has forwarding shims synthesized during normal codegen
55+
// (see `allocator_shim_contents`); this is where we emulate that behavior.
5456
// FIXME should use global_fn_name, but mangle_internal_symbol requires a static str.
5557
name if name == this.mangle_internal_symbol("__rust_alloc_error_handler") => {
5658
// Forward to the right symbol that implements this function.
@@ -60,14 +62,16 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
6062
"`__rust_alloc_error_handler` cannot be called when no alloc error handler is set"
6163
);
6264
};
63-
if handler_kind == AllocatorKind::Global {
65+
if handler_kind == AllocatorKind::Default {
6466
let name =
6567
Symbol::intern(this.mangle_internal_symbol("__rdl_alloc_error_handler"));
6668
let handler = this
6769
.lookup_exported_symbol(name)?
6870
.expect("missing alloc error handler symbol");
6971
return interp_ok(Some(handler));
7072
}
73+
// Fall through to the `lookup_exported_symbol` below which should find
74+
// a `__rust_alloc_error_handler`.
7175
}
7276
_ => {}
7377
}

0 commit comments

Comments
 (0)