diff options
author | 2018-08-07 14:43:28 -0500 | |
---|---|---|
committer | 2018-08-07 15:22:39 -0500 | |
commit | f2c5e2e4058b0a57a1d874878bde67f612b2d9dd (patch) | |
tree | ba2164706a20c1fac83a9118753cd81302724402 /cortex-m-rt/examples/alignment.rs | |
parent | 6e5e5ea4597ec6634f5d730b3218f8b71156da40 (diff) | |
download | cortex-m-f2c5e2e4058b0a57a1d874878bde67f612b2d9dd.tar.gz cortex-m-f2c5e2e4058b0a57a1d874878bde67f612b2d9dd.tar.zst cortex-m-f2c5e2e4058b0a57a1d874878bde67f612b2d9dd.zip |
refactor the linker script
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.
Diffstat (limited to 'cortex-m-rt/examples/alignment.rs')
-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) {} |