File tree 2 files changed +24
-9
lines changed
2 files changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -474,6 +474,19 @@ Miri provides some `extern` functions that programs can import to access
474
474
Miri-specific functionality. They are declared in
475
475
[/tests/utils/miri\_extern.rs](/tests/utils/miri_extern.rs).
476
476
477
+ # # Entry point for no-std binaries
478
+
479
+ Binaries that do not use the standard library are expected to declare a function like this so that
480
+ Miri knows where it is supposed to start execution :
481
+
482
+ ` ` ` rust
483
+ #[cfg(miri)]
484
+ #[no_mangle]
485
+ fn miri_start(argc: isize, argv: *const *const u8) -> isize {
486
+ // Call the actual start function that your project implements, based on your target's conventions.
487
+ }
488
+ ` ` `
489
+
477
490
# # Contributing and getting help
478
491
479
492
If you want to contribute to Miri, great! Please check out our
Original file line number Diff line number Diff line change @@ -358,7 +358,7 @@ fn entry_fn(tcx: TyCtxt<'_>) -> (DefId, EntryFnType) {
358
358
if let Some ( entry_def) = tcx. entry_fn ( ( ) ) {
359
359
return entry_def;
360
360
}
361
- // Look for a symbol in the local crate named `miri_start`, and threat that as the entry point.
361
+ // Look for a symbol in the local crate named `miri_start`, and treat that as the entry point.
362
362
let sym = tcx. exported_symbols ( LOCAL_CRATE ) . iter ( ) . find_map ( |( sym, _) | {
363
363
if sym. symbol_name_for_local_instance ( tcx) . name == "miri_start" { Some ( sym) } else { None }
364
364
} ) ;
@@ -391,14 +391,16 @@ fn entry_fn(tcx: TyCtxt<'_>) -> (DefId, EntryFnType) {
391
391
) ;
392
392
}
393
393
} else {
394
- tcx. dcx ( ) . fatal ( "Miri can only run programs that have a main function.\n \
395
- Alternatively, you can export a `miri_start` function:\n \
396
- \n \
397
- #[cfg(miri)]\n \
398
- #[no_mangle]\n \
399
- fn miri_start(argc: isize, argv: *const *const u8) -> isize {\
400
- \n // Call the actual start function that your project implements, based on your target's conventions.\n \
401
- }") ;
394
+ tcx. dcx ( ) . fatal (
395
+ "Miri can only run programs that have a main function.\n \
396
+ Alternatively, you can export a `miri_start` function:\n \
397
+ \n \
398
+ #[cfg(miri)]\n \
399
+ #[no_mangle]\n \
400
+ fn miri_start(argc: isize, argv: *const *const u8) -> isize {\
401
+ \n // Call the actual start function that your project implements, based on your target's conventions.\n \
402
+ }"
403
+ ) ;
402
404
}
403
405
}
404
406
You can’t perform that action at this time.
0 commit comments