aboutsummaryrefslogtreecommitdiff
path: root/cortex-m-rt/examples
diff options
context:
space:
mode:
authorGravatar bors[bot] <bors[bot]@users.noreply.github.com> 2018-08-12 14:39:00 +0000
committerGravatar bors[bot] <bors[bot]@users.noreply.github.com> 2018-08-12 14:39:00 +0000
commit96b76f974a7de4423f5bb0f529b399b0e310be2a (patch)
tree22068890759b65d96e41a39fab5869a1f77e630c /cortex-m-rt/examples
parent230d42233d35f13de82c1c7cb893352512ed3794 (diff)
parent97b184df173a56287e34841f0115a1e5823d1aa1 (diff)
downloadcortex-m-96b76f974a7de4423f5bb0f529b399b0e310be2a.tar.gz
cortex-m-96b76f974a7de4423f5bb0f529b399b0e310be2a.tar.zst
cortex-m-96b76f974a7de4423f5bb0f529b399b0e310be2a.zip
Merge #87
87: Update linker script to put .data into FLASH r=japaric a=adamgreig This is the updated linker script and test from #86. Sadly it looks like LLD does not use the `ALIGN(4)` in the `.data` section header to align the LMA (unlike gcc), so we still need the `. = ALIGN(4)` at the end of `.rodata` to ensure LMA alignment. I've added a failing example which the ci script ensures fails when `.data` causes overflow. It just checks for non-zero return from cargo rather than specifically grepping for the linker error messages about `.data` overflowing; since we only have the one failing example I could remove the loop and just specifically check it and grep for the relevant error from gcc and lld if people think that would be better. Co-authored-by: Adam Greig <adam@adamgreig.com> Co-authored-by: Jorge Aparicio <jorge@japaric.io>
Diffstat (limited to 'cortex-m-rt/examples')
-rw-r--r--cortex-m-rt/examples/data_overflow.rs30
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 {}
+}