template <class Elf = elfldltl::Elf<>>
class RemoteDecodedModule
Defined at line 216 of file ../../sdk/lib/ld/include/lib/ld/remote-decoded-module.h
ld::RemoteDecodedModule represents an ELF file and all the metadata
extracted from it. It's specifically meant only to hold a cache of
information distilled purely from the file's contents. So it doesn't
include a name, runtime load address, symbolizer module ID, or TLS module
ID. The tls_module_id() method returns 1 if the module has a PT_TLS at all.
The RemoteDecodedModule object owns a read-and-execute-only VMO handle for
the file's immutable contents and a mapping covering all its segments
(perhaps the whole file). The VMO is supplied at construction and is owned
for the lifetime of the RemoteDecodedModule. The Init method decodes the
ELF file's metadata and prepares the RemoteDecodedModule for use. All other
methods are const.
If Init encountered errors then the object may be in a partially-initialized
state where HasModule() returns false, or where it returns true but the
mapped_vmo() and/or module() and/or load_info() data is incomplete. How
much partial work might be done (and the return value of Init) depends on
when the Diagnostics object says to keep going. An incomplete object that
won't be used should be destroyed because it may use substantial resources
(like mapping the whole file VMO into the local address space).
It's a movable object, but moving it does not invalidate all the metadata
pointers. For the lifetime of the RemoteDecodedModule, other objects can
point into the mapped file's metadata such as by doing shallow copies of
`.module()`. The `.load_info()` object may own move-only zx::vmo handles to
VMOs in `.segments()` via elfldltl::SegmentWithVmo::Copy. (The distinction
between NoCopy and Copy doesn't really matter here, since the segments in
RemoteDecodedModule should never be passed to a VmarLoader. Using Copy just
expresses the abstract intent that RemoteDecodedModule be used in a const
fashion, including never modifying contents of VMOs it owns after Init.) As
no relocations are performed on these segments, such a VMO will only exist
when a DataWithZeroFillSegment with a partial page of bss is adjusted by
elfldltl::SegmentWithVmo::AlignSegments with a separate VMO. Any new VMO
becomes immutable (with no ZX_RIGHT_WRITE on the only handle) once its final
partial page has been zeroed.
Public Methods
void RemoteDecodedModule<Elf> ()
A default-constructed object is just an empty placeholder that can be
move-assigned. An empty object (where `!this->vmo()`) could be used as a
negative cache entry in a file identity -> RemoteDecodedModule map without
holding onto a VMO handle for the invalid file.
Defined at line 252 of file ../../sdk/lib/ld/include/lib/ld/remote-decoded-module.h
void RemoteDecodedModule<Elf> (RemoteDecodedModule<Elf> && )
RemoteDecodedModule is move-constructible and move-assignable.
Defined at line 255 of file ../../sdk/lib/ld/include/lib/ld/remote-decoded-module.h
RemoteDecodedModule<Elf> & operator= (RemoteDecodedModule<Elf> && )
Defined at line 257 of file ../../sdk/lib/ld/include/lib/ld/remote-decoded-module.h
RemoteDecodedFile::Ptr AsFile ()
This upcasts to an ld::RemoteDecodedFile::Ptr (with its own reference).
Defined at line 260 of file ../../sdk/lib/ld/include/lib/ld/remote-decoded-module.h
const ExecInfo & exec_info ()
This has the information relevant for a main executable.
Defined at line 265 of file ../../sdk/lib/ld/include/lib/ld/remote-decoded-module.h
elfldltl::ElfMachine machine ()
This reports the e_machine field. Decoding does not care which machine
it's for, but consuming it likely will.
Defined at line 269 of file ../../sdk/lib/ld/include/lib/ld/remote-decoded-module.h
const Ehdr & ehdr ()
This yields the whole Ehdr for the file.
Defined at line 272 of file ../../sdk/lib/ld/include/lib/ld/remote-decoded-module.h
const NeededList & needed ()
After Init, this is the list of direct DT_NEEDED dependencies in this
object. Each element's .str() / .c_str() pointers point into the mapped
file image and are valid for the lifetime of this RemoteDecodedModule (or
until it's assigned).
Defined at line 283 of file ../../sdk/lib/ld/include/lib/ld/remote-decoded-module.h
template <class Diagnostics>
Ptr Create (Diagnostics & diag, zx::vmo vmo, size_type page_size)
This creates and initializes a new RemoteDecodedModule from a VMO. See
Init() below for details about interaction with the Diagnostics object.
This returns a null pointer if Init() returned false. In all cases, the
VMO handle is consumed.
Defined at line 290 of file ../../sdk/lib/ld/include/lib/ld/remote-decoded-module.h
MetadataMemory metadata_memory ()
Create and return a memory-adaptor object that serves as a wrapper around
this module's LoadInfo and MappedVmoFile. This is used to translate
vaddrs into file-relative offsets in order to read from the VMO.
Defined at line 301 of file ../../sdk/lib/ld/include/lib/ld/remote-decoded-module.h