template <class Elf = Elf<>, AbiPtrTraitsApi<const typename Elf::Addr, Elf> AbiTraits = LocalAbiTraits>
struct InitFiniInfo
Defined at line 36 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
This represents the information about either initializers or finalizers for
one ELF module. Two separate InitFiniInfo objects are used for a module's
initializers and finalizers.
This is normally populated by a call to elfldltl::DecodeDynamic using an
elfldltl::DynamicInitObserver or elfldltl::DynamicFiniObserver observer.
The VisitInit or VisitFini methods provide general ordered access to the
function addresses in each list. The correct method should be used for each
kind of list to get the appropriate ordering of elements.
The CallInit and CallFini methods directly call each function in order, for
immediate in-process uses.
Public Methods
void InitFiniInfo<Elf, AbiTraits> ()
Defined at line 41 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
void InitFiniInfo<Elf, AbiTraits> (const InitFiniInfo<Elf, AbiTraits> & )
Defined at line 42 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
void InitFiniInfo<Elf, AbiTraits> (std::span<const Addr> array)
InitFiniInfo can be default-constructed and then set_* called, or it can
be explicitly constructed from an array with no legacy singleton.
Defined at line 46 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
void InitFiniInfo<Elf, AbiTraits> (std::span<const Addr> array)
InitFiniInfo can be default-constructed and then set_* called, or it can
be explicitly constructed from an array with no legacy singleton.
Defined at line 46 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
void InitFiniInfo<Elf, AbiTraits> (std::span<const Addr> array)
InitFiniInfo can be default-constructed and then set_* called, or it can
be explicitly constructed from an array with no legacy singleton.
Defined at line 46 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
void InitFiniInfo<Elf, AbiTraits> (std::span<const Addr> array)
InitFiniInfo can be default-constructed and then set_* called, or it can
be explicitly constructed from an array with no legacy singleton.
Defined at line 46 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
void InitFiniInfo<Elf, AbiTraits> (std::span<const Addr> array)
InitFiniInfo can be default-constructed and then set_* called, or it can
be explicitly constructed from an array with no legacy singleton.
Defined at line 46 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
InitFiniInfo<Elf, AbiTraits> & operator= (const InitFiniInfo<Elf, AbiTraits> & )
Defined at line 51 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
std::span<const Addr> array ()
An array of function pointers, in the .init_array or .fini_array section,
which is normally part of the RELRO segment. So the pointers here are
unrelocated in the file, but dynamic relocation records apply simple
fixup. As this points directly into the load image in the Memory object,
if that image is being relocated in place, then these values will be
absolute function pointers after relocation. If the original file data
(or the load image before relocation) is being read, the these addresses
need the load bias added.
Defined at line 61 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
std::optional<Addr> legacy ()
A single function pointer, from the legacy DT_INIT or DT_FINI entry. This
is not contiguous with the array and is stored separately in the ELF
headers where no relocation records apply. So this address always needs
the load bias added to yield a runtime function pointer.
Defined at line 67 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
InitFiniInfo<Elf, AbiTraits> & set_array (std::span<const Addr> array)
Defined at line 74 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
InitFiniInfo<Elf, AbiTraits> & set_array (std::span<const Addr> array)
Defined at line 74 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
InitFiniInfo<Elf, AbiTraits> & set_array (std::span<const Addr> array)
Defined at line 74 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
InitFiniInfo<Elf, AbiTraits> & set_array (std::span<const Addr> array)
Defined at line 74 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
InitFiniInfo<Elf, AbiTraits> & set_array (std::span<const Addr> array)
Defined at line 74 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
InitFiniInfo<Elf, AbiTraits> & set_legacy (Addr legacy)
Defined at line 79 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
size_t size ()
Return the number of function pointers present.
Defined at line 85 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
bool empty ()
Defined at line 87 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
template <typename T>
void VisitInit (T && init, bool relocated)
Call init(Addr, bool) exactly size() times. The flag in each callback is
true iff Addr has already been relocated. The argument flag should be
true iff relocations affecting RELRO data have already been applied.
Defined at line 93 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
template <typename T>
void VisitFini (T && fini, bool relocated)
Same as VisitInit, but in the reverse order.
Defined at line 104 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
auto RelocatedCall (size_type bias)
This returns a callback suitable to pass to VisitInit or VisitFini to
directly call the functions right here.
Defined at line 115 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
void CallInit (size_type bias, bool relocated)
Call all the functions in initialization order.
Defined at line 127 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
void CallInit ()
The load bias is moot when relocated and no legacy DT_INIT can be set.
Defined at line 132 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
void CallFini (size_type bias, bool relocated)
Call all the functions in finalization order.
Defined at line 138 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h
void CallFini ()
Defined at line 142 of file ../../src/lib/elfldltl/include/lib/elfldltl/init-fini.h