Skip to content
This repository was archived by the owner on Jan 24, 2022. It is now read-only.

refactor the linker script #84

Merged
merged 3 commits into from
Aug 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 1 addition & 32 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ matrix:

- env: TARGET=thumbv6m-none-eabi
rust: stable
addons:
apt:
packages:
- gcc-arm-none-eabi
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)

- env: TARGET=thumbv6m-none-eabi CC=clang
Expand All @@ -19,10 +15,6 @@ matrix:

- env: TARGET=thumbv7m-none-eabi
rust: stable
addons:
apt:
packages:
- gcc-arm-none-eabi
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)

- env: TARGET=thumbv7m-none-eabi CC=clang
Expand All @@ -31,10 +23,6 @@ matrix:

- env: TARGET=thumbv7em-none-eabi
rust: stable
addons:
apt:
packages:
- gcc-arm-none-eabi
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)

- env: TARGET=thumbv7em-none-eabi CC=clang
Expand All @@ -43,10 +31,6 @@ matrix:

- env: TARGET=thumbv7em-none-eabihf
rust: stable
addons:
apt:
packages:
- gcc-arm-none-eabi
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)

- env: TARGET=thumbv7em-none-eabihf CC=clang
Expand All @@ -55,40 +39,25 @@ matrix:

- env: TARGET=thumbv6m-none-eabi
rust: nightly
addons:
apt:
packages:
- gcc-arm-none-eabi
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)

- env: TARGET=thumbv7m-none-eabi
rust: nightly
addons:
apt:
packages:
- gcc-arm-none-eabi
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)

- env: TARGET=thumbv7em-none-eabi
rust: nightly
addons:
apt:
packages:
- gcc-arm-none-eabi
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)

- env: TARGET=thumbv7em-none-eabihf
rust: nightly
addons:
apt:
packages:
- gcc-arm-none-eabi
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)

before_install: set -e

install:
- bash ci/install.sh
- export PATH="$PATH:$PWD/gcc/bin"

script:
- bash ci/script.sh
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ r0 = "0.2.1"

[dev-dependencies]
panic-semihosting = "0.3.0"
panic-abort = "0.2.0"

[features]
device = []
8 changes: 4 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ INCLUDE device.x"#
writeln!(
f,
r#"
ASSERT(__einterrupts - __eexceptions <= 0x{:x}, "
There can't be more than {} interrupt handlers. This may be a bug in
your device crate, or you may have registered more than 240 interrupt
ASSERT(SIZEOF(.vector_table) <= 0x{:x}, "
There can't be more than {1} interrupt handlers. This may be a bug in
your device crate, or you may have registered more than {1} interrupt
handlers.");
"#,
max_int_handlers * 4,
max_int_handlers * 4 + 0x40,
max_int_handlers
).unwrap();

Expand Down
6 changes: 6 additions & 0 deletions ci/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ set -euxo pipefail
main() {
if [ $TARGET != x86_64-unknown-linux-gnu ]; then
rustup target add $TARGET

if [ ${CC:-gcc} = gcc ]; then
mkdir gcc

curl -L https://developer.arm.com/-/media/Files/downloads/gnu-rm/7-2018q2/gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2?revision=bc2c96c0-14b5-4bb4-9f18-bceb4050fee7?product=GNU%20Arm%20Embedded%20Toolchain,64-bit,,Linux,7-2018-q2-update | tar --strip-components=1 -C gcc -xj
fi
fi
}

Expand Down
25 changes: 25 additions & 0 deletions ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ main() {
cargo check --target $TARGET --features device

local examples=(
alignment
minimal
main
state
)
if [ $TRAVIS_RUST_VERSION = nightly ]; then
# linking with GNU LD
for ex in "${examples[@]}"; do
cargo rustc --target $TARGET --example $ex -- \
-C link-arg=-nostartfiles \
Expand All @@ -28,6 +30,29 @@ main() {
cargo rustc --target $TARGET --example device --features device --release -- \
-C link-arg=-nostartfiles \
-C link-arg=-Wl,-Tlink.x

# linking with rustc's LLD
for ex in "${examples[@]}"; do
cargo rustc --target $TARGET --example $ex -- \
-C linker=rust-lld \
-Z linker-flavor=ld.lld \
-C link-arg=-Tlink.x

cargo rustc --target $TARGET --example $ex --release -- \
-C linker=rust-lld \
-Z linker-flavor=ld.lld \
-C link-arg=-Tlink.x
done

cargo rustc --target $TARGET --example device --features device -- \
-C linker=rust-lld \
-Z linker-flavor=ld.lld \
-C link-arg=-Tlink.x

cargo rustc --target $TARGET --example device --features device --release -- \
-C linker=rust-lld \
-Z linker-flavor=ld.lld \
-C link-arg=-Tlink.x
fi
}

Expand Down
45 changes: 45 additions & 0 deletions examples/alignment.rs
Original file line number Diff line number Diff line change
@@ -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) {}
Loading