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