File tree 4 files changed +76
-7
lines changed
4 files changed +76
-7
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ main() {
11
11
main
12
12
state
13
13
)
14
+ local fail_examples=(
15
+ data_overflow
16
+ )
14
17
if [ $TRAVIS_RUST_VERSION = nightly ]; then
15
18
# linking with GNU LD
16
19
for ex in " ${examples[@]} " ; do
@@ -22,6 +25,15 @@ main() {
22
25
-C link-arg=-nostartfiles \
23
26
-C link-arg=-Wl,-Tlink.x
24
27
done
28
+ for ex in " ${fail_examples[@]} " ; do
29
+ ! cargo rustc --target $TARGET --example $ex -- \
30
+ -C link-arg=-nostartfiles \
31
+ -C link-arg=-Wl,-Tlink.x
32
+
33
+ ! cargo rustc --target $TARGET --example $ex --release -- \
34
+ -C link-arg=-nostartfiles \
35
+ -C link-arg=-Wl,-Tlink.x
36
+ done
25
37
26
38
cargo rustc --target $TARGET --example device --features device -- \
27
39
-C link-arg=-nostartfiles \
@@ -43,6 +55,17 @@ main() {
43
55
-Z linker-flavor=ld.lld \
44
56
-C link-arg=-Tlink.x
45
57
done
58
+ for ex in " ${fail_examples[@]} " ; do
59
+ ! cargo rustc --target $TARGET --example $ex -- \
60
+ -C linker=rust-lld \
61
+ -Z linker-flavor=ld.lld \
62
+ -C link-arg=-Tlink.x
63
+
64
+ ! cargo rustc --target $TARGET --example $ex --release -- \
65
+ -C linker=rust-lld \
66
+ -Z linker-flavor=ld.lld \
67
+ -C link-arg=-Tlink.x
68
+ done
46
69
47
70
cargo rustc --target $TARGET --example device --features device -- \
48
71
-C linker=rust-lld \
Original file line number Diff line number Diff line change
1
+ //! This is not an example; this is a linker overflow detection test
2
+ //! which should fail to link due to .data overflowing FLASH.
3
+
4
+ #![ deny( warnings) ]
5
+ #![ no_main]
6
+ #![ no_std]
7
+
8
+ #[ macro_use( entry, exception) ]
9
+ extern crate cortex_m_rt as rt;
10
+ extern crate panic_abort;
11
+
12
+ use core:: ptr;
13
+
14
+ use rt:: ExceptionFrame ;
15
+
16
+ entry ! ( main) ;
17
+
18
+ // This large static array uses most of .rodata
19
+ static RODATA : [ u8 ; 48 * 1024 ] = [ 1u8 ; 48 * 1024 ] ;
20
+
21
+ // This large mutable array causes .data to use the rest of FLASH
22
+ // without also overflowing RAM.
23
+ static mut DATA : [ u8 ; 16 * 1024 ] = [ 1u8 ; 16 * 1024 ] ;
24
+
25
+ fn main ( ) -> ! {
26
+ unsafe {
27
+ let _bigdata = ptr:: read_volatile ( & RODATA as * const u8 ) ;
28
+ let _bigdata = ptr:: read_volatile ( & DATA as * const u8 ) ;
29
+ }
30
+
31
+ loop { }
32
+ }
33
+
34
+ exception ! ( HardFault , hard_fault) ;
35
+
36
+ fn hard_fault ( _ef : & ExceptionFrame ) -> ! {
37
+ loop { }
38
+ }
39
+
40
+ exception ! ( * , default_handler) ;
41
+
42
+ fn default_handler ( _irqn : i16 ) { }
Original file line number Diff line number Diff line change @@ -84,24 +84,24 @@ SECTIONS
84
84
} > FLASH
85
85
86
86
/* ### .rodata */
87
- .rodata :
87
+ .rodata : ALIGN(4)
88
88
{
89
89
*(.rodata .rodata.*);
90
90
91
- /* 4-byte align the end (VMA) of this section */
92
- /* WHY? To my knowledge there's no way to indicate the alignment of *LMA* so we align *this*
93
- section with the goal of using its end address as the LMA of .data */
91
+ /* 4-byte align the end (VMA) of this section.
92
+ This is required by LLD to ensure the LMA of the following .data
93
+ section will have the correct alignment. */
94
94
. = ALIGN(4);
95
95
} > FLASH
96
96
97
97
/* ## Sections in RAM */
98
98
/* ### .data */
99
- .data : AT(ADDR(.rodata) + SIZEOF(.rodata)) /* LMA */
99
+ .data : ALIGN(4)
100
100
{
101
101
*(.data .data.*);
102
102
103
103
. = ALIGN(4); /* 4-byte align the end (VMA) of this section */
104
- } > RAM
104
+ } > RAM AT > FLASH
105
105
106
106
/* VMA of .data */
107
107
__sdata = ADDR(.data);
@@ -111,7 +111,7 @@ SECTIONS
111
111
__sidata = LOADADDR(.data);
112
112
113
113
/* ### .bss */
114
- .bss :
114
+ .bss : ALIGN(4)
115
115
{
116
116
*(.bss .bss.*);
117
117
Original file line number Diff line number Diff line change 1
1
/* Device specific memory layout */
2
2
3
+ /* This file is used to build the cortex-m-rt examples,
4
+ but not other applications using cortex-m-rt. */
5
+
3
6
MEMORY
4
7
{
5
8
/* FLASH and RAM are mandatory memory regions */
9
+ /* Update examples/data_overflow.rs if you change these sizes. */
6
10
FLASH : ORIGIN = 0x08000000 , LENGTH = 64 K
7
11
RAM : ORIGIN = 0x20000000 , LENGTH = 20 K
8
12
You can’t perform that action at this time.
0 commit comments