Rollup merge of #139795 - jethrogb:jb/sgx-linkage-comments, r=joboet
Clarify why SGX code specifies linkage/symbol names for certain statics Specifying linkage/symbol name is solely to ensure a single instance between the `std` crate and its unit tests. Also update the symbol names as items have moved around a bit. The actual name isn't that important, it just needs to be unique. But for debugging it can be useful for it to point to the right place.
This commit is contained in:
commit
cac8bc3d1f
5 changed files with 14 additions and 6 deletions
|
@ -10,8 +10,10 @@ use crate::sys::pal::waitqueue::SpinMutex;
|
|||
// The current allocator here is the `dlmalloc` crate which we've got included
|
||||
// in the rust-lang/rust repository as a submodule. The crate is a port of
|
||||
// dlmalloc.c from C to Rust.
|
||||
//
|
||||
// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests
|
||||
#[cfg_attr(test, linkage = "available_externally")]
|
||||
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx5alloc8DLMALLOCE")]
|
||||
#[unsafe(export_name = "_ZN16__rust_internals3std3sys5alloc3sgx8DLMALLOCE")]
|
||||
static DLMALLOC: SpinMutex<dlmalloc::Dlmalloc<Sgx>> =
|
||||
SpinMutex::new(dlmalloc::Dlmalloc::new_with_allocator(Sgx {}));
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ use crate::sys::pal::abi::usercalls::raw::ByteBuffer;
|
|||
use crate::sys_common::FromInner;
|
||||
use crate::{fmt, slice};
|
||||
|
||||
// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests
|
||||
#[cfg_attr(test, linkage = "available_externally")]
|
||||
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx4args4ARGSE")]
|
||||
static ARGS: AtomicUsize = AtomicUsize::new(0);
|
||||
|
|
|
@ -11,15 +11,17 @@ const USIZE_BITS: usize = 64;
|
|||
const TLS_KEYS: usize = 128; // Same as POSIX minimum
|
||||
const TLS_KEYS_BITSET_SIZE: usize = (TLS_KEYS + (USIZE_BITS - 1)) / USIZE_BITS;
|
||||
|
||||
// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests
|
||||
#[cfg_attr(test, linkage = "available_externally")]
|
||||
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx3abi3tls14TLS_KEY_IN_USEE")]
|
||||
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3pal3sgx3abi3tls14TLS_KEY_IN_USEE")]
|
||||
static TLS_KEY_IN_USE: SyncBitset = SYNC_BITSET_INIT;
|
||||
macro_rules! dup {
|
||||
((* $($exp:tt)*) $($val:tt)*) => (dup!( ($($exp)*) $($val)* $($val)* ));
|
||||
(() $($val:tt)*) => ([$($val),*])
|
||||
}
|
||||
// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests
|
||||
#[cfg_attr(test, linkage = "available_externally")]
|
||||
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx3abi3tls14TLS_DESTRUCTORE")]
|
||||
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3pal3sgx3abi3tls14TLS_DESTRUCTORE")]
|
||||
static TLS_DESTRUCTOR: [AtomicUsize; TLS_KEYS] = dup!((* * * * * * *) (AtomicUsize::new(0)));
|
||||
|
||||
unsafe extern "C" {
|
||||
|
|
|
@ -73,11 +73,13 @@ pub fn current_exe() -> io::Result<PathBuf> {
|
|||
unsupported()
|
||||
}
|
||||
|
||||
// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests
|
||||
#[cfg_attr(test, linkage = "available_externally")]
|
||||
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx2os3ENVE")]
|
||||
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3pal3sgx2os3ENVE")]
|
||||
static ENV: AtomicUsize = AtomicUsize::new(0);
|
||||
// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests
|
||||
#[cfg_attr(test, linkage = "available_externally")]
|
||||
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx2os8ENV_INITE")]
|
||||
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3pal3sgx2os8ENV_INITE")]
|
||||
static ENV_INIT: Once = Once::new();
|
||||
type EnvStore = Mutex<HashMap<OsString, OsString>>;
|
||||
|
||||
|
|
|
@ -45,8 +45,9 @@ mod task_queue {
|
|||
}
|
||||
}
|
||||
|
||||
// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests
|
||||
#[cfg_attr(test, linkage = "available_externally")]
|
||||
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx6thread10TASK_QUEUEE")]
|
||||
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3pal3sgx6thread10TASK_QUEUEE")]
|
||||
static TASK_QUEUE: Mutex<Vec<Task>> = Mutex::new(Vec::new());
|
||||
|
||||
pub(super) fn lock() -> MutexGuard<'static, Vec<Task>> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue