aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cortex-m-rt/Cargo.toml4
-rw-r--r--cortex-m-rt/src/lang_items.rs22
-rw-r--r--cortex-m-rt/src/lib.rs6
3 files changed, 10 insertions, 22 deletions
diff --git a/cortex-m-rt/Cargo.toml b/cortex-m-rt/Cargo.toml
index 2c70fa8..fc1c181 100644
--- a/cortex-m-rt/Cargo.toml
+++ b/cortex-m-rt/Cargo.toml
@@ -7,7 +7,7 @@ keywords = ["arm", "cortex-m", "runtime", "startup"]
license = "MIT OR Apache-2.0"
name = "cortex-m-rt"
repository = "https://github.com/japaric/cortex-m-rt"
-version = "0.2.4"
+version = "0.3.0"
[dependencies]
r0 = "0.2.1"
@@ -22,3 +22,5 @@ default = ["exceptions", "linker-script"]
exceptions = ["cortex-m"]
# generic linker script
linker-script = []
+# provides a panic_fmt implementation that calls the abort instruction (`udf 0xfe`)
+abort-on-panic = [] \ No newline at end of file
diff --git a/cortex-m-rt/src/lang_items.rs b/cortex-m-rt/src/lang_items.rs
index b154b5f..236b2bd 100644
--- a/cortex-m-rt/src/lang_items.rs
+++ b/cortex-m-rt/src/lang_items.rs
@@ -1,28 +1,14 @@
/// Default panic handler
+#[cfg(feature = "abort-on-panic")]
#[lang = "panic_fmt"]
-#[linkage = "weak"]
unsafe extern "C" fn panic_fmt(
- _args: ::core::fmt::Arguments,
- _file: &'static str,
- _line: u32,
+ _: ::core::fmt::Arguments,
+ _: &'static str,
+ _: u32,
) -> ! {
::core::intrinsics::abort()
}
-#[macro_export]
-macro_rules! panic_fmt {
- ($f:expr) => {
- #[export_name = "rust_begin_unwind"]
- pub unsafe extern "C" fn _panic_fmt(
- args: ::core::fmt::Arguments,
- file: &'static str,
- line: u32,
- ) -> ! {
- $f(args, file, line)
- }
- }
-}
-
/// Lang item required to make the normal `main` work in applications
// This is how the `start` lang item works:
// When `rustc` compiles a binary crate, it creates a `main` function that looks
diff --git a/cortex-m-rt/src/lib.rs b/cortex-m-rt/src/lib.rs
index 1908c50..4e10b59 100644
--- a/cortex-m-rt/src/lib.rs
+++ b/cortex-m-rt/src/lib.rs
@@ -145,11 +145,11 @@
//! 8000404: b084 sub sp, #16
//! ```
+#![cfg_attr(feature = "abort-on-panic", feature(core_intrinsics))]
#![deny(missing_docs)]
#![deny(warnings)]
#![feature(asm)]
#![feature(compiler_builtins_lib)]
-#![feature(core_intrinsics)]
#![feature(lang_items)]
#![feature(linkage)]
#![feature(used)]
@@ -186,8 +186,8 @@ extern "C" {
/// This is the entry point of all programs
#[link_section = ".reset_handler"]
unsafe extern "C" fn reset_handler() -> ! {
- ::r0::zero_bss(&mut _sbss, &mut _ebss);
- ::r0::init_data(&mut _sdata, &mut _edata, &_sidata);
+ r0::zero_bss(&mut _sbss, &mut _ebss);
+ r0::init_data(&mut _sdata, &mut _edata, &_sidata);
// Neither `argc` or `argv` make sense in bare metal context so we just
// stub them