rustc_target/spec/base/
teeos.rs

1use crate::spec::{
2    Cc, LinkerFlavor, Lld, Os, PanicStrategy, RelroLevel, TargetOptions, add_link_args,
3};
4
5pub(crate) fn opts() -> TargetOptions {
6    let lld_args = &["-zmax-page-size=4096", "-znow", "-ztext", "--execute-only"];
7    let cc_args = &["-Wl,-zmax-page-size=4096", "-Wl,-znow", "-Wl,-ztext", "-mexecute-only"];
8
9    let mut pre_link_args = TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), lld_args);
10    add_link_args(&mut pre_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), cc_args);
11
12    TargetOptions {
13        os: Os::TeeOs,
14        dynamic_linking: true,
15        linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No),
16        // rpath hardcodes -Wl, so it can't be used together with ld.lld.
17        // C TAs also don't support rpath, so this is fine.
18        has_rpath: false,
19        // Note: Setting has_thread_local to true causes an error when
20        // loading / dyn-linking the TA
21        has_thread_local: false,
22        position_independent_executables: true,
23        relro_level: RelroLevel::Full,
24        crt_static_respected: true,
25        pre_link_args,
26        panic_strategy: PanicStrategy::Abort,
27        ..Default::default()
28    }
29}