class Bootstrap

Defined at line 69 of file ../../sdk/lib/ld/include/lib/ld/bootstrap.h

Just constructing the ld::Bootstrap object does all the bootstrapping work

for a startup dynamic linker itself or for any static PIE. It's expected to

be called first thing, before any code that might rely on dynamic linking,

including any calls into the vDSO as well as just any variables (even if

constinit and/or const) with dynamic relocations in their initializer data.

The diagnostics object will be used for assertion failures in case messages

can be printed, but it's not really expected to return from FormatError et

al and various kinds of failures might get crashes if FormatError ever

returns. It should be an object from TrapDiagnostics() or similar.

This mostly initializes the Module data structures for the preloaded

modules: this program itself, and the vDSO. It fills out only the name,

symbols, and vaddr bounds in each Module. The caller supplies the two

objects to fill. Each must be in LinkerZeroInitialized() state as regards

those members filled by Bootstrap, but other members may be set already.

The vdso_module() describes the vDSO, which is already fully loaded

according to its PT_LOAD segments, relocated and initialized in place as we

find it. The ELF image as loaded is presumed valid.

The constructor does all this program's own dynamic linking for simple

fixups and for symbolic references resolved in the vdso_module(). The

program's own ELF image is presumed valid and its PT_LOAD segments correctly

loaded; the diagnostics object is used for assertion failures, but not

expected to return after errors. The self_module() describes this program

itself, already loaded and now fully relocated; RELRO pages remain writable.

Additional observer arguments for elfldltl::DecodePhdr can be passed to the

constructor. These can collect e.g. PT_TLS and PT_GNU_RELRO from a static

PIE. The startup dynamic linker doesn't need those.

Public Methods

template <BootstrapPageSize PageSizeT, class... PhdrObservers, class... DynamicObservers, auto& diag>
void Bootstrap (auto & diag, const void * vdso_base, PageSizeT && get_page_size, Module & self_module_storage, Module & vdso_module_storage, std::tuple<PhdrObservers...> phdr_observers, std::tuple<DynamicObservers...> dynamic_observers)

Defined at line 88 of file ../../sdk/lib/ld/include/lib/ld/bootstrap.h

template <BootstrapPageSize PageSizeT, class... PhdrObservers, class... DynamicObservers, auto& diag>
void Bootstrap (auto & diag, const void * vdso_base, PageSizeT && get_page_size, Module & self_module_storage, Module & vdso_module_storage, std::tuple<PhdrObservers...> phdr_observers, std::tuple<DynamicObservers...> dynamic_observers)

Defined at line 88 of file ../../sdk/lib/ld/include/lib/ld/bootstrap.h

PreloadedList & preloaded ()

Defined at line 128 of file ../../sdk/lib/ld/include/lib/ld/bootstrap.h

Module & self_module ()

Defined at line 130 of file ../../sdk/lib/ld/include/lib/ld/bootstrap.h

const Module & self_module ()

Defined at line 131 of file ../../sdk/lib/ld/include/lib/ld/bootstrap.h

Module & vdso_module ()

Defined at line 133 of file ../../sdk/lib/ld/include/lib/ld/bootstrap.h

const Module & vdso_module ()

Defined at line 134 of file ../../sdk/lib/ld/include/lib/ld/bootstrap.h

size_t page_size ()

Defined at line 136 of file ../../sdk/lib/ld/include/lib/ld/bootstrap.h

template <auto&& f>
void OnWritablePages (std::invocable<uintptr_t, size_t> auto && f)

Call f(start, size) for each whole-page region in self_module() containing

writable PT_LOAD segment data.

Defined at line 140 of file ../../sdk/lib/ld/include/lib/ld/bootstrap.h

Records