template <RemoteZygoteVmo, class>

class RemoteZygote

Defined at line 125 of file ../../sdk/lib/ld/include/lib/ld/remote-zygote.h

The zygote is default-constructible and movable, but not copyable.

Underneath it just holds a std::vector, so it's cheaper to just move it

around or leave an unused default-constructed one around than to use

something like std::unique_ptr

<ld

::RemoteZygote>.

Public Methods

void RemoteZygote<Vmo, Elf> ()

Defined at line 136 of file ../../sdk/lib/ld/include/lib/ld/remote-zygote.h

void RemoteZygote<Vmo, Elf> (RemoteZygote<Vmo, Elf> && )

Defined at line 137 of file ../../sdk/lib/ld/include/lib/ld/remote-zygote.h

RemoteZygote<Vmo, Elf> & operator= (RemoteZygote<Vmo, Elf> && )

Defined at line 138 of file ../../sdk/lib/ld/include/lib/ld/remote-zygote.h

RemoteZygote<Vmo, Elf> & operator+= (RemoteZygote<Vmo, Elf> other)

Two zygotes can be spliced together by consuming the other one and moving

all its modules into *this, which is the same as if all the Insert()

options done on other had been done on *this instead.

Defined at line 143 of file ../../sdk/lib/ld/include/lib/ld/remote-zygote.h

RemoteZygote<Vmo, Elf> operator+ (RemoteZygote<Vmo, Elf> other)

std::move(zygote1) + std::move(zygote2) + ...

Defined at line 151 of file ../../sdk/lib/ld/include/lib/ld/remote-zygote.h

bool empty ()

A default-constructed zygote is empty and does not take much space.

Defined at line 157 of file ../../sdk/lib/ld/include/lib/ld/remote-zygote.h

void clear ()

This does the same as `*this = {};`.

Defined at line 160 of file ../../sdk/lib/ld/include/lib/ld/remote-zygote.h

zx::result<Domain> Insert (Linker linker)

This consumes a Linker, distilling its dynamic linking session into the

zygote and a Domain object. The Linker should already have been used to

Load and Commit in the initial process whose VMARs were used to do the

address layout for the zygote. (The state of that process no longer

matters. No handles to its VMARs are held after Commit.) Processes

loaded by the new zygote will start out identical to that process and

share both its VMOs for read-only segments (including RELRO) and its

parent VMOs (and their unmodified pages) for relocated data.

This can be used multiple times to add additional dynamic linking domains

from separate dynamic linking sessions. That modifies the zygote so that

a process loaded from it loads both sessions' modules, including each

session's own stub dynamic linker providing its own passive ABI view.

Inserting multiple sessions into one zygote and then calling Load() is no

different from creating separate zygote objects for each session and

calling Load() on all of them.

The only error return is for a failure to duplicate a VMO handle. If

RemoteZygoteVmo::kDecodedPtr is used, then no error is possible. The

returned Domain object gives the entry point and stack size request for

the main module, which is the first root module in the dynamic linker

session, such as the main executable; and the passive ABI root addresses.

Defined at line 184 of file ../../sdk/lib/ld/include/lib/ld/remote-zygote.h

zx::result<> Splice (RemoteZygote<RemoteZygoteVmo::kDecodedPtr, Elf> other)

If this is a RemoteZygoteVmo::kVmo object, then another zygote object of

the RemoteZygoteVmo::kDecodedPtr flavor can also be spliced in. This

always consumes that object and will drop all its ld::RemoteDecodedModule

references. It can fail when duplicating the VMO handles owned by them.

Defined at line 222 of file ../../sdk/lib/ld/include/lib/ld/remote-zygote.h

template <class Diagnostics>
bool Load (Diagnostics & diag, zx::unowned_vmar vmar)

Clone the prototype process into another new process. The VMAR must be

some process's root VMAR or a sub-VMAR covering the same address space

bounds as the prototype process VMAR passed to Linker::Allocate.

This is non-destructive to the RemoteZygote object, and no references to

this object are made so its lifetime has no effect on the target process.

There is no separate Commit phase. When this returns false after an error

in loading, any sub-VMARs already created will have been destroyed.

On success, a closed VMAR for each module has all its mappings in place;

they cannot be modified. While zx_vmar_destroy cannot be used since there

is no handle to them, it's always possible to destroy a whole VMAR as an

atomic unit with a zx_vmar_unmap call on a handle to a containing VMAR.

It's not advised to use a Diagnostics object that says to keep going for

errors in this call. If the Diagnostics object does say to keep going,

this call will fail and return early for some errors but for others it

will keep going as directed and if it returned true after errors it may

have left partial mappings in the process.

Defined at line 260 of file ../../sdk/lib/ld/include/lib/ld/remote-zygote.h