From 277436ec86b3e52fe070f54f10cca64e3800177f Mon Sep 17 00:00:00 2001 From: Adam Greig Date: Sun, 12 Aug 2018 01:09:21 +0100 Subject: Update linker script to put .data into FLASH Previously .data's LMA was specified by a computated address instead of placing it into FLASH explicitly, which means FLASH overflows caused by .data would not be detected by the linker. Fixes #86. --- cortex-m-rt/examples/data_overflow.rs | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 cortex-m-rt/examples/data_overflow.rs (limited to 'cortex-m-rt/examples/data_overflow.rs') diff --git a/cortex-m-rt/examples/data_overflow.rs b/cortex-m-rt/examples/data_overflow.rs new file mode 100644 index 0000000..f01f91c --- /dev/null +++ b/cortex-m-rt/examples/data_overflow.rs @@ -0,0 +1,42 @@ +//! This is not an example; this is a linker overflow detection test +//! which should fail to link due to .data overflowing FLASH. + +#![deny(warnings)] +#![no_main] +#![no_std] + +#[macro_use(entry, exception)] +extern crate cortex_m_rt as rt; +extern crate panic_abort; + +use core::ptr; + +use rt::ExceptionFrame; + +entry!(main); + +// This large static array uses most of .rodata +static RODATA: [u8; 48*1024] = [1u8; 48*1024]; + +// This large mutable array causes .data to use the rest of FLASH +// without also overflowing RAM. +static mut DATA: [u8; 16*1024] = [1u8; 16*1024]; + +fn main() -> ! { + unsafe { + let _bigdata = ptr::read_volatile(&RODATA as *const u8); + let _bigdata = ptr::read_volatile(&DATA as *const u8); + } + + loop {} +} + +exception!(HardFault, hard_fault); + +fn hard_fault(_ef: &ExceptionFrame) -> ! { + loop {} +} + +exception!(*, default_handler); + +fn default_handler(_irqn: i16) {} -- cgit v1.2.3 From 97b184df173a56287e34841f0115a1e5823d1aa1 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sun, 12 Aug 2018 09:38:16 -0500 Subject: remove exception handler overrides they are not required anymore --- cortex-m-rt/examples/data_overflow.rs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'cortex-m-rt/examples/data_overflow.rs') diff --git a/cortex-m-rt/examples/data_overflow.rs b/cortex-m-rt/examples/data_overflow.rs index f01f91c..396f1c8 100644 --- a/cortex-m-rt/examples/data_overflow.rs +++ b/cortex-m-rt/examples/data_overflow.rs @@ -5,14 +5,12 @@ #![no_main] #![no_std] -#[macro_use(entry, exception)] +#[macro_use(entry)] extern crate cortex_m_rt as rt; extern crate panic_abort; use core::ptr; -use rt::ExceptionFrame; - entry!(main); // This large static array uses most of .rodata @@ -30,13 +28,3 @@ fn main() -> ! { loop {} } - -exception!(HardFault, hard_fault); - -fn hard_fault(_ef: &ExceptionFrame) -> ! { - loop {} -} - -exception!(*, default_handler); - -fn default_handler(_irqn: i16) {} -- cgit v1.2.3