template <class ElfLayout, template <typename> class SegmentContainer, AbiModuleInline InlineModule, DecodedModuleRelocInfo WithRelocInfo = DecodedModuleRelocInfo::kYes, template <class SegmentType> class SegmentWrapper = elfldltl::NoSegmentWrapper>

class DecodedModule

Defined at line 73 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

Public Members

static const bool kModuleInline
static const bool kRelocInfo

Public Methods

void DecodedModule<ElfLayout, SegmentContainer, InlineModule, WithRelocInfo, SegmentWrapper> ()

Derived types might or might not be default-constructed.

Defined at line 99 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

void DecodedModule<ElfLayout, SegmentContainer, InlineModule, WithRelocInfo, SegmentWrapper> (const DecodedModule<ElfLayout, SegmentContainer, InlineModule, WithRelocInfo, SegmentWrapper> & )

Derived types might or might not be copyable and/or movable, depending on

the SegmentContainer and SegmentWrapper semantics.

Defined at line 103 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

void DecodedModule<ElfLayout, SegmentContainer, InlineModule, WithRelocInfo, SegmentWrapper> (DecodedModule<ElfLayout, SegmentContainer, InlineModule, WithRelocInfo, SegmentWrapper> && )

Defined at line 104 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

DecodedModule<ElfLayout, SegmentContainer, InlineModule, WithRelocInfo, SegmentWrapper> & operator= (const DecodedModule<ElfLayout, SegmentContainer, InlineModule, WithRelocInfo, SegmentWrapper> & )

Defined at line 105 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

DecodedModule<ElfLayout, SegmentContainer, InlineModule, WithRelocInfo, SegmentWrapper> & operator= (DecodedModule<ElfLayout, SegmentContainer, InlineModule, WithRelocInfo, SegmentWrapper> && )

Defined at line 106 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

bool HasModule ()

When a module has been actually decoded at all, this returns true.

In default-constructed state, module() cannot be called. Once

HasModule() is true, then module() can be inspected and its

contains will be safe, but may be incomplete if decoding hit errors

but the Diagnostics object said to keep going.

Defined at line 113 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

Module & module ()

This should be used only after EmplaceModule or (successful) NewModule.

Defined at line 116 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

const Module & module ()

Defined at line 120 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

const auto & symbol_info ()

**NOTE:** Most methods below use module() and cannot be called unless

HasModule() returns true, i.e. after EmplaceModule / NewModule.

Defined at line 128 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

template <auto& diag>
LookupResult Lookup (auto & diag, elfldltl::SymbolName & name)

Defined at line 130 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

const Soname & soname ()

This is the DT_SONAME in the file or empty if there was none (or if

decoding was incomplete). This often matches the name by which the

module is known, but need not. There may be no SONAME at all (normal for

an executable or loadable module rather than a shared library), or the

embedded SONAME is not the same as the lookup name (file name, usually)

used to get the file.

Defined at line 140 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

LoadInfo & load_info ()

See

<lib

/elfldtl/load.h> for details; the LoadInfo provides information

on address layout. This is used to map file segments into memory and/or

to convert memory addresses to file offsets. The SegmentWrapper template

class may extend the load_info().segments() element types with holders of

segment data mapped or copied from the file (and maybe further prepared).

Defined at line 147 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

const LoadInfo & load_info ()

Defined at line 148 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

template <auto R = WithRelocInfo, typename = std::enable_if_t<R == DecodedModuleRelocInfo::kYes>>
RelocationInfo & reloc_info ()

See

<lib

/elfldtl/relocation.h> for details; the RelocationInfo provides

information need by the

<lib

/elfldtl/link.h> layer to drive dynamic

linking of this module. It doesn't need to be stored at all if a module

is being cached after relocation without concern for a separate dynamic

linking session reusing the same data.

Defined at line 156 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

template <auto R = WithRelocInfo, typename = std::enable_if_t<R == DecodedModuleRelocInfo::kYes>>
const RelocationInfo & reloc_info ()

Defined at line 160 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

template <class Diagnostics, class Memory, class... Observers>
fit::result<bool, std::span<const Dyn>> DecodeDynamic (Diagnostics & diag, Memory && memory, const std::optional<Phdr> & dyn_phdr, Observers &&... observers)

This fills out module() and (if present) reloc_info() from the PT_DYNAMIC

data read via the Memory object. Additional observers can be passed as

for ld::DecodeModuleDynamic, and the return value is the same as that.

Defined at line 168 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

template <class Diagnostics, class Memory, class... Observers>
fit::result<bool, std::span<const Dyn>> DecodeDynamic (Diagnostics & diag, Memory && memory, const std::optional<Phdr> & dyn_phdr, Observers &&... observers)

This fills out module() and (if present) reloc_info() from the PT_DYNAMIC

data read via the Memory object. Additional observers can be passed as

for ld::DecodeModuleDynamic, and the return value is the same as that.

Defined at line 168 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

template <class Diagnostics, class Memory>
bool SetTls (Diagnostics & diag, Memory & memory, const Phdr & tls_phdr, size_type modid)

Set up the Abi

<

>::TlsModule in tls_module() based on the PT_TLS segment.

The modid must be nonzero, but its only actual use is in the module() and

tls_module_id() values returned by this object. In a derived object only

used as a pure cache of the ELF file's metadata, constant 1 is fine.

Defined at line 188 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

size_type tls_module_id ()

This returns the TLS module ID assigned by SetTls, or zero if none is

set. In a derived type representing a pure cache of the ELF file's

metadata, this is just a flag where nonzero indicates it has a PT_TLS.

In a derived type for a module in a specific dynamic linking session,

this is the ABI's meaning of TLS module ID at runtime. In either case,

it's always nonzero if the module has a PT_TLS and zero if it doesn't.

Defined at line 227 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

const TlsModule & tls_module ()

This should only be called after SetTls.

Defined at line 230 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

template <bool Inline = InlineModule == AbiModuleInline::kYes, typename = std::enable_if_t<!Inline>>
void set_module (Module & module)

Defined at line 237 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

void SetAbiName (const Soname & name)

A derived class should wrap EmplaceModule and NewModule with calls to

SetAbiName passing the derived class's notion of primary name for the

module, so that the AbiModule representation always matches that name.

Defined at line 244 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

template <typename... Args, bool Inline = InlineModule == AbiModuleInline::kYes, typename = std::enable_if_t<Inline>>
void EmplaceModule (uint32_t modid, Args &&... args)

In an instantiation with InlineModule=kYes, EmplaceModule(..) just

constructs Module{...}). The modid is always required, though it need

not be meaningful. In a derived type representing a pure cache of the

ELF file's metadta, it could be zero in every module. In a derived type

representing a module in a specific dynamic linking scenario, it's useful

to assign the ld::abi::Abi::Module::symbolizer_modid value early and rely

on it corresponding to the module's order in the linking session's

"load-order" list of modules; this allows the index to serve as a means

of back-pointer from the module() object to a containing LoadModule sort

of object via reference to the session's primary module list.

Defined at line 261 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

template <typename... Args, bool Inline = InlineModule == AbiModuleInline::kYes, typename = std::enable_if_t<!Inline>>
void NewModule (uint32_t modid, Args &&... args)

In an instantiation with InlineModule=false, NewModule(a..., c...) does

new (a...) Module{c...}. See above about the modid argument. The last

argument in a... must be a fbl::AllocChecker that indicates whether `new`

succeeded.

Defined at line 273 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

template <class Container>
auto MakeNeededObserver (Container & needed_offsets)

This returns an observer that can be passed to DecodeDynamic to collect

DT_NEEDED entries into a container of size_type. (Container can be

anything that meets the

<lib

/elfldltl/container.h> template API with a

value_type of size_type.) This records just the offsets and so can be

used in the initial DecodeDynamic that also discovers DT_STRTAB et al.

The offsets can later be converted using ReifyNeeded (see below).

Defined at line 286 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

template <class Diagnostics>
fit::result<bool, Soname> ReifyNeeded (Diagnostics & diag, size_type offset)

This turns a DT_NEEDED offset (as collected via MakeNeededObserver) into

its string from the DT_STRTAB, normalized as a Soname object. It returns

failure for an invalid string table entry. The error value is the "keep

going" result from the Diagnostics object.

Defined at line 296 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h

template <template <typename> class Container, class Diagnostics, class Offsets>
std::optional<Container<Soname>> ReifyNeeded (Diagnostics & diag, Offsets && offsets)

This overload applies ReifyNeeded to each offset in a container of

size_type and returns a new container of Soname. It's invoked e.g.

```

std::optional needed_names =

ReifyNeeded

<elfldltl

::StdContainer

<std

::vector>::Container>(

diag, needed_offsets);

```

A return of std::nullopt means the Diagnostics object returned false after

a bad entry was diagnosed, or there was an allocation failure. If the

Diagnostics object returned true for a bad entry, that entry is just

omitted from the container it's success even with an empty container.

Defined at line 323 of file ../../sdk/lib/ld/include/lib/ld/decoded-module.h