rustc_target/spec/targets/armv7a_none_eabi.rs
1// Generic ARMv7-A target for bare-metal code - floating point disabled
2//
3// This is basically the `armv7-unknown-linux-gnueabi` target with some changes
4// (listed below) to bring it closer to the bare-metal `thumb` & `aarch64`
5// targets:
6//
7// - `TargetOptions.features`: added `+strict-align`. rationale: unaligned
8// memory access is disabled on boot on these cores
9// - linker changed to LLD. rationale: C is not strictly needed to build
10// bare-metal binaries (the `gcc` linker has the advantage that it knows where C
11// libraries and crt*.o are but it's not much of an advantage here); LLD is also
12// faster
13// - `panic_strategy` set to `abort`. rationale: matches `thumb` targets
14// - `relocation-model` set to `static`; also no PIE, no relro and no dynamic
15// linking. rationale: matches `thumb` targets
16
17use crate::spec::{
18 Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata,
19 TargetOptions,
20};
21
22pub(crate) fn target() -> Target {
23 let opts = TargetOptions {
24 abi: "eabi".into(),
25 llvm_floatabi: Some(FloatAbi::Soft),
26 linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
27 linker: Some("rust-lld".into()),
28 features: "+v7,+thumb2,+soft-float,-neon,+strict-align".into(),
29 relocation_model: RelocModel::Static,
30 disable_redzone: true,
31 max_atomic_width: Some(64),
32 panic_strategy: PanicStrategy::Abort,
33 emit_debug_gdb_scripts: false,
34 c_enum_min_bits: Some(8),
35 ..Default::default()
36 };
37 Target {
38 llvm_target: "armv7a-none-eabi".into(),
39 metadata: TargetMetadata {
40 description: Some("Bare Armv7-A".into()),
41 tier: Some(2),
42 host_tools: Some(false),
43 std: Some(false),
44 },
45 pointer_width: 32,
46 data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
47 arch: "arm".into(),
48 options: opts,
49 }
50}