File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ //! This is not an example; this is a linker test that ensures
2+ //! that the jump from HardFault to _HardFault doesn't exceed
3+ //! the 2kB limit of the branch instruction.
4+
5+ #![ deny( warnings) ]
6+ #![ no_main]
7+ #![ no_std]
8+
9+ extern crate cortex_m_rt;
10+ extern crate panic_halt;
11+
12+ use core:: arch:: asm;
13+ use cortex_m_rt:: { entry, exception, ExceptionFrame } ;
14+
15+ // This defines both `HardFault` and `_HardFault`. Both should have
16+ // link_section attributes placing them at the end of the .text section,
17+ // close to each other. If one of them is missing that attribute, they
18+ // will end up separated by `foo`, which will make the linker fail.
19+ #[ exception( trampoline = true ) ]
20+ unsafe fn HardFault ( _ef : & ExceptionFrame ) -> ! {
21+ loop { }
22+ }
23+
24+ #[ entry]
25+ fn foo ( ) -> ! {
26+ unsafe {
27+ // 2kB of NOP instructions to make the function artificially larger
28+ asm ! ( ".fill 1024,2,0xbf00" , ) ;
29+ }
30+ loop { }
31+ }
You can’t perform that action at this time.
0 commit comments