From f2c5e2e4058b0a57a1d874878bde67f612b2d9dd Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Tue, 7 Aug 2018 14:43:28 -0500 Subject: 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. --- cortex-m-rt/examples/alignment.rs | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 cortex-m-rt/examples/alignment.rs (limited to 'cortex-m-rt/examples') 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) {} -- cgit v1.2.3