|
| 1 | +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT |
| 2 | +// file at the top-level directory of this distribution and at |
| 3 | +// http://rust-lang.org/COPYRIGHT. |
| 4 | +// |
| 5 | +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 6 | +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 7 | +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 8 | +// option. This file may not be copied, modified, or distributed |
| 9 | +// except according to those terms. |
| 10 | + |
| 11 | +use std::iter; |
| 12 | + |
| 13 | +use super::{LinkerFlavor, Target, TargetOptions, PanicStrategy}; |
| 14 | + |
| 15 | +pub fn target() -> Result<Target, String> { |
| 16 | + const PRE_LINK_ARGS: &[&str] = &[ |
| 17 | + "-Wl,--as-needed", |
| 18 | + "-Wl,-z,noexecstack", |
| 19 | + "-m64", |
| 20 | + "-fuse-ld=gold", |
| 21 | + "-nostdlib", |
| 22 | + "-shared", |
| 23 | + "-Wl,-e,sgx_entry", |
| 24 | + "-Wl,-Bstatic", |
| 25 | + "-Wl,--gc-sections", |
| 26 | + "-Wl,-z,text", |
| 27 | + "-Wl,-z,norelro", |
| 28 | + "-Wl,--rosegment", |
| 29 | + "-Wl,--no-undefined", |
| 30 | + "-Wl,--error-unresolved-symbols", |
| 31 | + "-Wl,--no-undefined-version", |
| 32 | + "-Wl,-Bsymbolic", |
| 33 | + "-Wl,--export-dynamic", |
| 34 | + ]; |
| 35 | + const EXPORT_SYMBOLS: &[&str] = &[ |
| 36 | + "sgx_entry", |
| 37 | + "HEAP_BASE", |
| 38 | + "HEAP_SIZE", |
| 39 | + "RELA", |
| 40 | + "RELACOUNT", |
| 41 | + "ENCLAVE_SIZE", |
| 42 | + "CFGDATA_BASE", |
| 43 | + "DEBUG", |
| 44 | + ]; |
| 45 | + let opts = TargetOptions { |
| 46 | + dynamic_linking: false, |
| 47 | + executables: true, |
| 48 | + linker_is_gnu: true, |
| 49 | + max_atomic_width: Some(64), |
| 50 | + panic_strategy: PanicStrategy::Abort, |
| 51 | + cpu: "x86-64".into(), |
| 52 | + position_independent_executables: true, |
| 53 | + pre_link_args: iter::once( |
| 54 | + (LinkerFlavor::Gcc, PRE_LINK_ARGS.iter().cloned().map(String::from).collect()) |
| 55 | + ).collect(), |
| 56 | + override_export_symbols: Some(EXPORT_SYMBOLS.iter().cloned().map(String::from).collect()), |
| 57 | + ..Default::default() |
| 58 | + }; |
| 59 | + Ok(Target { |
| 60 | + llvm_target: "x86_64-unknown-linux-gnu".into(), |
| 61 | + target_endian: "little".into(), |
| 62 | + target_pointer_width: "64".into(), |
| 63 | + target_c_int_width: "32".into(), |
| 64 | + target_os: "unknown".into(), |
| 65 | + target_env: "sgx".into(), |
| 66 | + target_vendor: "fortanix".into(), |
| 67 | + data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".into(), |
| 68 | + arch: "x86_64".into(), |
| 69 | + linker_flavor: LinkerFlavor::Gcc, |
| 70 | + options: opts, |
| 71 | + }) |
| 72 | +} |
0 commit comments