]> git.proxmox.com Git - rustc.git/blame - compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs
New upstream version 1.49.0~beta.4+dfsg1
[rustc.git] / compiler / rustc_target / src / spec / x86_64_fortanix_unknown_sgx.rs
CommitLineData
a1dfa0c6
XL
1use std::iter;
2
60c5eb7d 3use super::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions};
a1dfa0c6 4
29967ef6 5pub fn target() -> Target {
a1dfa0c6 6 const PRE_LINK_ARGS: &[&str] = &[
60c5eb7d 7 "--as-needed",
dfeec247
XL
8 "-z",
9 "noexecstack",
10 "-e",
11 "elf_entry",
60c5eb7d
XL
12 "-Bstatic",
13 "--gc-sections",
dfeec247
XL
14 "-z",
15 "text",
16 "-z",
17 "norelro",
60c5eb7d
XL
18 "--no-undefined",
19 "--error-unresolved-symbols",
20 "--no-undefined-version",
21 "-Bsymbolic",
22 "--export-dynamic",
532ac7d7
XL
23 // The following symbols are needed by libunwind, which is linked after
24 // libstd. Make sure they're included in the link.
dfeec247
XL
25 "-u",
26 "__rust_abort",
27 "-u",
28 "__rust_c_alloc",
29 "-u",
30 "__rust_c_dealloc",
31 "-u",
32 "__rust_print_err",
33 "-u",
34 "__rust_rwlock_rdlock",
35 "-u",
36 "__rust_rwlock_unlock",
37 "-u",
38 "__rust_rwlock_wrlock",
a1dfa0c6 39 ];
0731742a 40
a1dfa0c6
XL
41 const EXPORT_SYMBOLS: &[&str] = &[
42 "sgx_entry",
43 "HEAP_BASE",
44 "HEAP_SIZE",
45 "RELA",
46 "RELACOUNT",
47 "ENCLAVE_SIZE",
48 "CFGDATA_BASE",
49 "DEBUG",
f035d41b
XL
50 "EH_FRM_HDR_OFFSET",
51 "EH_FRM_HDR_LEN",
52 "EH_FRM_OFFSET",
53 "EH_FRM_LEN",
0731742a
XL
54 "TEXT_BASE",
55 "TEXT_SIZE",
a1dfa0c6
XL
56 ];
57 let opts = TargetOptions {
29967ef6
XL
58 os: "unknown".into(),
59 env: "sgx".into(),
60 vendor: "fortanix".into(),
61 linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
a1dfa0c6
XL
62 dynamic_linking: false,
63 executables: true,
64 linker_is_gnu: true,
60c5eb7d 65 linker: Some("rust-lld".to_owned()),
a1dfa0c6 66 max_atomic_width: Some(64),
0731742a 67 panic_strategy: PanicStrategy::Unwind,
a1dfa0c6 68 cpu: "x86-64".into(),
f035d41b
XL
69 features: "+rdrnd,+rdseed,+lvi-cfi,+lvi-load-hardening".into(),
70 llvm_args: vec!["--x86-experimental-lvi-inline-asm-hardening".into()],
a1dfa0c6 71 position_independent_executables: true,
0731742a 72 pre_link_args: iter::once((
60c5eb7d 73 LinkerFlavor::Lld(LldFlavor::Ld),
0731742a
XL
74 PRE_LINK_ARGS.iter().cloned().map(String::from).collect(),
75 ))
76 .collect(),
a1dfa0c6 77 override_export_symbols: Some(EXPORT_SYMBOLS.iter().cloned().map(String::from).collect()),
60c5eb7d 78 relax_elf_relocations: true,
a1dfa0c6
XL
79 ..Default::default()
80 };
29967ef6 81 Target {
416331ca 82 llvm_target: "x86_64-elf".into(),
29967ef6 83 pointer_width: 64,
dfeec247
XL
84 data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
85 .into(),
a1dfa0c6 86 arch: "x86_64".into(),
a1dfa0c6 87 options: opts,
29967ef6 88 }
a1dfa0c6 89}