diff --git a/intel-sgx/enclave-runner/Cargo.toml b/intel-sgx/enclave-runner/Cargo.toml index a09e3c428..72898d089 100644 --- a/intel-sgx/enclave-runner/Cargo.toml +++ b/intel-sgx/enclave-runner/Cargo.toml @@ -15,8 +15,6 @@ documentation = "https://edp.fortanix.com/docs/api/enclave_runner/" homepage = "https://edp.fortanix.com/" keywords = ["sgx", "enclave"] categories = ["os", "hardware-support"] -build = "build.rs" -exclude = ["fake-vdso/.gitignore", "fake-vdso/Makefile", "fake-vdso/main.S"] [dependencies] # Project dependencies diff --git a/intel-sgx/enclave-runner/build.rs b/intel-sgx/enclave-runner/build.rs deleted file mode 100644 index 1806a74b7..000000000 --- a/intel-sgx/enclave-runner/build.rs +++ /dev/null @@ -1,21 +0,0 @@ -use std::fs::File; -use std::io::Write; -use std::path::Path; - -fn main() { - if std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "linux" { - const LIBNAME: &str = "fortanix_enclave_runner_fake_vdso"; - // using var instead of var_os because we need to print it later - let out_dir = std::env::var("OUT_DIR").unwrap(); - - // FIXME: need to link to fake VDSO due to https://github.com/rust-lang/rust/issues/58713 - File::create(&Path::new(&out_dir) - .join(format!("lib{}.so", LIBNAME))) - .unwrap() - .write_all(include_bytes!("fake-vdso/fake-vdso.so")) - .unwrap(); - - println!("cargo:rustc-link-lib=dylib={}", LIBNAME); - println!("cargo:rustc-link-search=native={}", out_dir); - } -} diff --git a/intel-sgx/enclave-runner/fake-vdso/.gitignore b/intel-sgx/enclave-runner/fake-vdso/.gitignore deleted file mode 100644 index f87a4810c..000000000 --- a/intel-sgx/enclave-runner/fake-vdso/.gitignore +++ /dev/null @@ -1 +0,0 @@ -main.so diff --git a/intel-sgx/enclave-runner/fake-vdso/Makefile b/intel-sgx/enclave-runner/fake-vdso/Makefile deleted file mode 100644 index 2867c8562..000000000 --- a/intel-sgx/enclave-runner/fake-vdso/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -all: fake-vdso.so - -clean: - rm -f main.so fake-vdso.so - -main.so: main.S - gcc -fPIC -shared -Wl,-soname=linux-vdso.so.1 -Wl,--build-id=none -Wl,--no-ld-generated-unwind-info -Wl,-z,norelro -nostdlib $< -o $@ - -fake-vdso.so: main.so - cp $< $@ - strip $@ diff --git a/intel-sgx/enclave-runner/fake-vdso/fake-vdso.so b/intel-sgx/enclave-runner/fake-vdso/fake-vdso.so deleted file mode 100755 index 986002228..000000000 Binary files a/intel-sgx/enclave-runner/fake-vdso/fake-vdso.so and /dev/null differ diff --git a/intel-sgx/enclave-runner/fake-vdso/main.S b/intel-sgx/enclave-runner/fake-vdso/main.S deleted file mode 100644 index 0e1734954..000000000 --- a/intel-sgx/enclave-runner/fake-vdso/main.S +++ /dev/null @@ -1,8 +0,0 @@ -// Fake VDSO with symbols only used for linking -.global __vdso_sgx_enter_enclave -.type __vdso_sgx_enter_enclave, function -.global __vdso_clock_gettime -.type __vdso_clock_gettime, function -__vdso_clock_gettime: -__vdso_sgx_enter_enclave: -ret diff --git a/intel-sgx/enclave-runner/src/lib.rs b/intel-sgx/enclave-runner/src/lib.rs index 6145c6275..677bfe316 100644 --- a/intel-sgx/enclave-runner/src/lib.rs +++ b/intel-sgx/enclave-runner/src/lib.rs @@ -4,7 +4,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#![allow(non_local_definitions)] // Required by failure +#![feature(raw_dylib_elf)] +#![allow(non_local_definitions, incomplete_features)] // Required by failure #![deny(warnings)] #![doc( html_logo_url = "https://edp.fortanix.com/img/docs/edp-logo.svg", diff --git a/intel-sgx/enclave-runner/src/tcs.rs b/intel-sgx/enclave-runner/src/tcs.rs index a0f7703ba..bc13b749e 100644 --- a/intel-sgx/enclave-runner/src/tcs.rs +++ b/intel-sgx/enclave-runner/src/tcs.rs @@ -48,6 +48,11 @@ impl Usercall { } } +#[link(name = "linux-vdso.so.1", kind = "raw-dylib", modifiers = "+verbatim")] +unsafe extern "C" { + fn __vdso_sgx_enter_enclave(); +} + pub(crate) fn coenter( tcs: T, mut p1: u64, @@ -67,18 +72,6 @@ pub(crate) fn coenter( .weak __vdso_sgx_enter_enclave .type __vdso_sgx_enter_enclave, function mov __vdso_sgx_enter_enclave@GOTPCREL(%rip), {} - jmp 1f - - // Strongly link to another symbol in the VDSO, so that the - // linker will include a DT_NEEDED entry for `linux-vdso.so.1`. - // This doesn't happen automatically because rustc passes - // `--as-needed` to the linker. This is never executed because - // of the unconditional jump above. -.global __vdso_clock_gettime -.type __vdso_clock_gettime, function - call __vdso_clock_gettime@PLT - -1: ", out(reg) addr, options(nomem, nostack, att_syntax)); addr != 0 }