Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions runtime/src/abort.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//! Abort shim for the Fortanix SGX target.
//!
//! Why this exists:
//!
//! Some native libraries assume the standard C function `abort()` is
//! available. In our case, the `wasm3` runtime (via `wasm3-sys`) calls
//! `abort()` from C code (`m3_core.c` -> `m3_Abort`).
//!
//! When linking for `x86_64-fortanix-unknown-sgx`, there is no libc
//! providing the `abort` symbol, so linking fails with:
//!
//! rust-lld: error: undefined symbol: abort
//!
//! This shim exports a C-compatible symbol named `abort` and forwards
//! execution to Rust's internal abort routine (`__rust_abort`), which
//! terminates the enclave/process immediately and never returns.

#[no_mangle]
pub extern "C" fn abort() -> ! {
extern "C" {
fn __rust_abort() -> !;
}

unsafe { __rust_abort() }
}
3 changes: 3 additions & 0 deletions runtime/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use oasis_runtime_sdk::Runtime;

#[cfg(all(target_env = "sgx", target_vendor = "fortanix"))]
mod abort;

fn main() {
cipher_paratime::Runtime::start();
}
Loading