pub type TlsInitializer = LocalStorageInitializer<Tls>;

Aliased Type§

struct TlsInitializer { /* private fields */ }

Implementations§

source§

impl<T> LocalStorageInitializer<T>where T: LocalStorage,

source

pub const fn new() -> Self

Creates an empty local storage initializer with no data sections.

source

pub fn add_existing_static_section( &mut self, section: LoadedSection, offset: usize, total_static_size: usize ) -> Result<StrongSectionRef, LocalStorageInitializerError>

Add a CLS/TLS section that has pre-determined offset, e.g., one that was specified in the statically-linked base kernel image.

This function modifies the tls_section’s starting virtual address field to hold the proper value such that this tls_section can be correctly used as the source of a relocation calculation (e.g., when another section depends on it).

  • On x86_64, that value will be the negative offset from the end of all the static TLS sections, i.e., where the TLS self pointer exists in memory, to the start of this section in the TLS image.
    • VirtAddr = -1 * (total_static_tls_size - offset);
  • On aarch64, that value will simply be the given offset.
    • VirtAddr = offset;.
    • However, on aarch64, the actual location of this section in the TLS data image is given by offset + max(16, TLS_segment_align). The ELF TLS ABI on aarch64 specifies that this augmented value is the real offset used to access this TLS variable from the TLS base address (from the beginning of all sections).
Arguments
  • section: the section present in base kernel image.
  • offset: the offset of this section as determined by the linker. This corresponds to the “value” of this section’s symbol in the ELF file.
  • total_static_size: the total size of all statically-known CLS/TLS sections, including both TLS BSS (.tbss) and TLS data (.tdata) sections for TLS.
Return
  • A reference to the newly added and properly modified section, if successful.
  • An error if inserting the given tls_section at the given offset would overlap with an existing section. An error occurring here would indicate a link-time bug or a bug in the symbol parsing code that invokes this function.
source

pub fn add_new_dynamic_section( &mut self, section: LoadedSection, alignment: usize ) -> Result<(usize, StrongSectionRef), LocalStorageInitializerError>

Inserts the given section into this CLS/TLS area at the next index (i.e., offset into the CLS/TLS area) where the section will fit.

This also modifies the virtual address field of the given section to hold the proper value based on that offset, which is necessary for calculating relocation entries that depend on this section.

Returns a tuple of:

  1. The index at which the new section was inserted, which is the offset from the beginning of the CLS/TLS area where the section data starts.
  2. The modified section as a StrongSectionRef.

Returns an Error if there is no remaining space that can fit the section.

source

pub fn invalidate(&mut self)

Invalidates the cached data image in this LocalStorageInitializer area.

This is useful for when a CLS/TLS section’s data has been modified, e.g., while performing relocations, and thus the data image needs to be re-created by re-reading the section data.

source

pub fn get_data(&mut self) -> LocalStorageDataImage<T>

Returns a new copy of the data image.

This function lazily generates the image data on demand, if needed.

Trait Implementations§

source§

impl<T> Clone for LocalStorageInitializer<T>where T: LocalStorage + Clone,

source§

fn clone(&self) -> LocalStorageInitializer<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T> Debug for LocalStorageInitializer<T>where T: LocalStorage + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more