pub trait TlsResolver<Arch: RelocationArch>: 'static {
const OVERRIDE_TLS_GET_ADDR: bool = false;
// Required methods
fn register(tls_info: &TlsInfo) -> Result<TlsModuleId>;
fn register_static(tls_info: &TlsInfo) -> Result<(TlsModuleId, TlsTpOffset)>;
fn add_static_tls(
tls_info: &TlsInfo,
offset: TlsTpOffset,
) -> Result<TlsModuleId>;
fn init_tls(
source: TlsImageSource,
mod_id: TlsModuleId,
offset: Option<TlsTpOffset>,
) -> Result<()>;
fn unregister(mod_id: TlsModuleId);
fn bind_tls_get_addr() -> Result<VmAddr>;
fn resolve_tls_addr(ti: TlsIndex) -> Result<VmAddr>;
// Provided methods
fn bind_static_tlsdesc(_tpoff: usize) -> Result<TlsDescValue> { ... }
fn bind_dynamic_tlsdesc(_ti: TlsIndex) -> Result<TlsDescValue> { ... }
fn bind_undefweak_tlsdesc(_addend: usize) -> Result<TlsDescValue> { ... }
}Expand description
A trait for resolving TLS (Thread Local Storage) information.
Implement this trait to provide custom TLS module IDs and thread pointer offsets. This is essential for supporting TLS in environments with custom thread management, such as operating system kernels or bare-metal systems.
Provided Associated Constants§
Sourceconst OVERRIDE_TLS_GET_ADDR: bool = false
const OVERRIDE_TLS_GET_ADDR: bool = false
Whether this resolver should override __tls_get_addr symbol bindings.
Required Methods§
Sourcefn register(tls_info: &TlsInfo) -> Result<TlsModuleId>
fn register(tls_info: &TlsInfo) -> Result<TlsModuleId>
Registers a module with dynamic TLS and returns the allocated module ID.
§Errors
Returns an error if the module ID cannot be allocated.
Sourcefn register_static(tls_info: &TlsInfo) -> Result<(TlsModuleId, TlsTpOffset)>
fn register_static(tls_info: &TlsInfo) -> Result<(TlsModuleId, TlsTpOffset)>
Registers a module with static TLS, returning the module ID and its thread pointer offset.
§Errors
Returns an error if space cannot be allocated in the static TLS area.
Sourcefn add_static_tls(
tls_info: &TlsInfo,
offset: TlsTpOffset,
) -> Result<TlsModuleId>
fn add_static_tls( tls_info: &TlsInfo, offset: TlsTpOffset, ) -> Result<TlsModuleId>
Records an existing static TLS module and returns its allocated module ID.
This is used when the TLS block is already set up and its offset from the thread pointer is known.
Sourcefn init_tls(
source: TlsImageSource,
mod_id: TlsModuleId,
offset: Option<TlsTpOffset>,
) -> Result<()>
fn init_tls( source: TlsImageSource, mod_id: TlsModuleId, offset: Option<TlsTpOffset>, ) -> Result<()>
Initializes a TLS module from a source that can provide the final relocated template on demand.
TLS layout may be assigned before dynamic relocations have been applied. This hook is called once the template bytes are ready for future TLS block initialization. Static resolvers may also copy the template into the current thread’s static TLS area.
Sourcefn unregister(mod_id: TlsModuleId)
fn unregister(mod_id: TlsModuleId)
Releases resources associated with the given module ID.
Sourcefn bind_tls_get_addr() -> Result<VmAddr>
fn bind_tls_get_addr() -> Result<VmAddr>
Returns the target-visible __tls_get_addr entry point.
Native same-process resolvers can return a host function pointer. Remote or guest runtimes should return an address inside the target runtime.
Sourcefn resolve_tls_addr(ti: TlsIndex) -> Result<VmAddr>
fn resolve_tls_addr(ti: TlsIndex) -> Result<VmAddr>
Resolves the current thread’s host-visible address for a TLS variable.
This is used by host APIs such as symbol lookup. Unlike
bind_tls_get_addr, the returned address must
be meaningful to the caller in this process.
Provided Methods§
Sourcefn bind_static_tlsdesc(_tpoff: usize) -> Result<TlsDescValue>
fn bind_static_tlsdesc(_tpoff: usize) -> Result<TlsDescValue>
Returns the target-visible TLSDESC binding for a static TLS access.
Sourcefn bind_dynamic_tlsdesc(_ti: TlsIndex) -> Result<TlsDescValue>
fn bind_dynamic_tlsdesc(_ti: TlsIndex) -> Result<TlsDescValue>
Returns the target-visible TLSDESC binding for a dynamic TLS access.
Sourcefn bind_undefweak_tlsdesc(_addend: usize) -> Result<TlsDescValue>
fn bind_undefweak_tlsdesc(_addend: usize) -> Result<TlsDescValue>
Returns the target-visible TLSDESC binding for an undefined weak TLS symbol.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<Arch: RelocationArch> TlsResolver<Arch> for ()
impl<Arch: RelocationArch> TlsResolver<Arch> for ()
fn register(_tls_info: &TlsInfo) -> Result<TlsModuleId>
fn register_static(_tls_info: &TlsInfo) -> Result<(TlsModuleId, TlsTpOffset)>
fn add_static_tls( _tls_info: &TlsInfo, _offset: TlsTpOffset, ) -> Result<TlsModuleId>
fn init_tls( _source: TlsImageSource, _mod_id: TlsModuleId, _offset: Option<TlsTpOffset>, ) -> Result<()>
fn unregister(_mod_id: TlsModuleId)
fn bind_tls_get_addr() -> Result<VmAddr>
fn resolve_tls_addr(_ti: TlsIndex) -> Result<VmAddr>
Implementors§
Source§impl TlsResolver<X86_64Arch> for DefaultTlsResolver
Available on crate feature tls only.
impl TlsResolver<X86_64Arch> for DefaultTlsResolver
tls only.