Skip to main content

TlsResolver

Trait TlsResolver 

Source
pub trait TlsResolver<Arch: RelocationArch>:
    Clone
    + Send
    + Sync
    + 'static {
    const OVERRIDE_TLS_GET_ADDR: bool = false;

    // Required methods
    fn register(&self, info: TlsInfo, request: TlsRequest) -> Result<ModuleTls>;
    fn publish(&self, source: TlsImageSource, mod_id: TlsModuleId) -> Result<()>;
    fn unregister(&self, mod_id: TlsModuleId);
    fn bind_tls_get_addr(&self) -> Result<VmAddr>;

    // Provided method
    fn bind_tlsdesc(&self, _request: TlsDescRequest) -> Result<TlsDescBinding> { ... }
}
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.

A loader retains a cloneable resolver handle, and every module produced by that loader uses the same instance for registration, relocation, address lookup, and cleanup. Implementations may therefore keep their TLS registry and runtime bindings directly in the resolver.

Provided Associated Constants§

Source

const OVERRIDE_TLS_GET_ADDR: bool = false

Whether this resolver should override __tls_get_addr symbol bindings.

Required Methods§

Source

fn register(&self, info: TlsInfo, request: TlsRequest) -> Result<ModuleTls>

Registers a TLS module using the requested placement.

§Errors

Returns an error if the requested placement cannot be satisfied.

Source

fn publish(&self, source: TlsImageSource, mod_id: TlsModuleId) -> Result<()>

Publishes the final relocated template for a registered TLS module.

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. The resolver decides when and where per-thread storage is instantiated.

Source

fn unregister(&self, mod_id: TlsModuleId)

Releases resources associated with the given module ID.

Source

fn bind_tls_get_addr(&self) -> 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.

Provided Methods§

Source

fn bind_tlsdesc(&self, _request: TlsDescRequest) -> Result<TlsDescBinding>

Returns a target-visible TLSDESC binding.

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 ()

Source§

fn register(&self, _info: TlsInfo, _request: TlsRequest) -> Result<ModuleTls>

Source§

fn publish(&self, _source: TlsImageSource, _mod_id: TlsModuleId) -> Result<()>

Source§

fn unregister(&self, _mod_id: TlsModuleId)

Source§

fn bind_tls_get_addr(&self) -> Result<VmAddr>

Implementors§