Skip to content

Commit e5212e6

Browse files
committed
Change aarch64-unknown-none to generate static-PIE binaries by default
Currently, `aarch64-unknown-none` generates static position *dependent* binaries which must be loaded at a fixed address in memory. The [openVMM](https://github.com/microsoft/openvmm) project uses the `*-unknown-none` targets for an embedded-like environment but needs the binary to be loadable to any memory address. Currently, the `x86_64-unknown-none` target is configured to allow this by default but the `aarch64-unknown-none` target is not. This commit changes the defaults for the `aarch64-unknown-none` target to enable static-PIE binaries which aligns the target more closely with the corresponding `x86_64-unknown-none` target. If users prefer the prior behavior, they can request that via `-Crelocation-model=static`.
1 parent 83e49b7 commit e5212e6

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

compiler/rustc_target/src/spec/targets/aarch64_unknown_none.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// For example, `-C target-cpu=cortex-a53`.
88

99
use crate::spec::{
10-
Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, Target,
10+
Arch, Cc, LinkerFlavor, Lld, PanicStrategy, SanitizerSet, StackProbeType, Target,
1111
TargetMetadata, TargetOptions,
1212
};
1313

@@ -22,12 +22,13 @@ pub(crate) fn target() -> Target {
2222
),
2323
features: "+v8a,+strict-align,+neon".into(),
2424
supported_sanitizers: SanitizerSet::KCFI | SanitizerSet::KERNELADDRESS,
25-
relocation_model: RelocModel::Static,
2625
disable_redzone: true,
2726
max_atomic_width: Some(128),
2827
stack_probes: StackProbeType::Inline,
2928
panic_strategy: PanicStrategy::Abort,
3029
default_uwtable: true,
30+
position_independent_executables: true,
31+
static_position_independent_executables: true,
3132
..Default::default()
3233
};
3334
Target {

compiler/rustc_target/src/spec/targets/aarch64_unknown_none_softfloat.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
// For example, `-C target-cpu=cortex-a53`.
88

99
use crate::spec::{
10-
Abi, Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType,
11-
Target, TargetMetadata, TargetOptions,
10+
Abi, Arch, Cc, LinkerFlavor, Lld, PanicStrategy, SanitizerSet, StackProbeType, Target,
11+
TargetMetadata, TargetOptions,
1212
};
1313

1414
pub(crate) fn target() -> Target {
@@ -17,13 +17,14 @@ pub(crate) fn target() -> Target {
1717
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
1818
linker: Some("rust-lld".into()),
1919
features: "+v8a,+strict-align,-neon".into(),
20-
relocation_model: RelocModel::Static,
2120
disable_redzone: true,
2221
max_atomic_width: Some(128),
2322
supported_sanitizers: SanitizerSet::KCFI | SanitizerSet::KERNELADDRESS,
2423
stack_probes: StackProbeType::Inline,
2524
panic_strategy: PanicStrategy::Abort,
2625
default_uwtable: true,
26+
position_independent_executables: true,
27+
static_position_independent_executables: true,
2728
..Default::default()
2829
};
2930
Target {

tests/codegen-llvm/abi-efiapi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use minicore::*;
2323

2424
//x86_64: define win64cc void @has_efiapi
2525
//i686: define void @has_efiapi
26-
//aarch64: define dso_local void @has_efiapi
26+
//aarch64: define void @has_efiapi
2727
//arm: define dso_local arm_aapcscc void @has_efiapi
2828
//riscv: define dso_local void @has_efiapi
2929
#[no_mangle]

0 commit comments

Comments
 (0)