diff options
author | 2018-08-15 20:35:40 +0100 | |
---|---|---|
committer | 2018-08-15 20:35:40 +0100 | |
commit | 0b991c1d463bb6aff351d5ba3d4f1c4e017dfa71 (patch) | |
tree | 96a411b41bb3c931bdfe2bf81fa78c4d2cfac195 /cortex-m-rt/examples/data_overflow.rs | |
parent | 3b25e71a78c6ac8514f3d59dc6e124a57439dcb6 (diff) | |
parent | 1089ef3423e60c6c9b186f77868ea1b16e153e01 (diff) | |
download | cortex-m-0b991c1d463bb6aff351d5ba3d4f1c4e017dfa71.tar.gz cortex-m-0b991c1d463bb6aff351d5ba3d4f1c4e017dfa71.tar.zst cortex-m-0b991c1d463bb6aff351d5ba3d4f1c4e017dfa71.zip |
Merge branch 'master' into release
Diffstat (limited to 'cortex-m-rt/examples/data_overflow.rs')
-rw-r--r-- | cortex-m-rt/examples/data_overflow.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/cortex-m-rt/examples/data_overflow.rs b/cortex-m-rt/examples/data_overflow.rs new file mode 100644 index 0000000..396f1c8 --- /dev/null +++ b/cortex-m-rt/examples/data_overflow.rs @@ -0,0 +1,30 @@ +//! 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)] +extern crate cortex_m_rt as rt; +extern crate panic_abort; + +use core::ptr; + +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 {} +} |