diff options
author | 2018-08-07 21:55:53 +0000 | |
---|---|---|
committer | 2018-08-07 21:55:53 +0000 | |
commit | 7865725aacf3c9718902361b9d9919b7bebce7be (patch) | |
tree | 07bf6f7ffd16961fe89feae3c4509e2599149727 /cortex-m-rt/examples | |
parent | 6e5e5ea4597ec6634f5d730b3218f8b71156da40 (diff) | |
parent | dd9f1e45ed17c06d2d21cd4cf2fced11edf72407 (diff) | |
download | cortex-m-7865725aacf3c9718902361b9d9919b7bebce7be.tar.gz cortex-m-7865725aacf3c9718902361b9d9919b7bebce7be.tar.zst cortex-m-7865725aacf3c9718902361b9d9919b7bebce7be.zip |
Merge #84
84: refactor the linker script r=therealprof a=japaric
to make it more compatible with LLD. This commit contains no functional changes.
fixes #70
Overview of changes:
- Alignment checks are enabled now that rust-lld (LLD 7.0) supports the modulo
operator.
- Removed some private symbols (e.g. __foo) in favor of ADDR and SIZEOF.
- Turned .got into a NOLOAD section now that rust-lld supports it.
- Replaced `ABSOLUTE(.)` with `.` as an old LLD overlap bug seems to be gone and
ABSOLUTE seems to cause problems, like #70, on bigger programs.
- Made the linker assertion messages more uniform.
- Extended test suite to check that linking works with both rust-lld and GNU
LD.
r? therealprof (chosen at random)
Co-authored-by: Jorge Aparicio <jorge@japaric.io>
Diffstat (limited to 'cortex-m-rt/examples')
-rw-r--r-- | cortex-m-rt/examples/alignment.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/cortex-m-rt/examples/alignment.rs b/cortex-m-rt/examples/alignment.rs new file mode 100644 index 0000000..ef1beaa --- /dev/null +++ b/cortex-m-rt/examples/alignment.rs @@ -0,0 +1,45 @@ +//! This is not an example; this is a link-pass test + +#![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); + +static mut BSS1: u16 = 0; +static mut BSS2: u8 = 0; +static mut DATA1: u8 = 1; +static mut DATA2: u16 = 1; +static RODATA1: &[u8; 3] = b"012"; +static RODATA2: &[u8; 2] = b"34"; + +fn main() -> ! { + unsafe { + let _bss1 = ptr::read_volatile(&BSS1); + let _bss2 = ptr::read_volatile(&BSS2); + let _data1 = ptr::read_volatile(&DATA1); + let _data2 = ptr::read_volatile(&DATA2); + let _rodata1 = ptr::read_volatile(&RODATA1); + let _rodata2 = ptr::read_volatile(&RODATA2); + } + + loop {} +} + +exception!(HardFault, hard_fault); + +fn hard_fault(_ef: &ExceptionFrame) -> ! { + loop {} +} + +exception!(*, default_handler); + +fn default_handler(_irqn: i16) {} |