class Patcher

Defined at line 60 of file ../../zircon/kernel/lib/code-patching/include/lib/code-patching/code-patching.h

Patcher helps to facilitate code patching. It is constructed from a BOOTFS

directory with the following expected contents:

* code-patches.bin

This is raw binary comprised of an array of patch directives (in practice,

removed as a section from the executable to patch).

* code-patches/

A subdirectory under which patch alternatives are found.

Patcher provides methods for patching provided instruction ranges in the

supported ways (e.g., nop-fill or wholesale replacement by an alternative).

This just modifies code in memory and does no synchronization.

No synchronization is usually required when modifying code just

loaded into memory pages that have never been executed yet.

Public Members

static basic_string_view kPatchesBin
static basic_string_view kPatchAlternativeDir

Public Methods

fit::result<Error> Init (BootfsDir bootfs)

Initializes the Patcher. The associated BOOTFS directory namespace must be

nonempty. Must be called before any other method. On initialization, the

lifetime of the Patcher is bound to that of the original BootfsView input.

fit::result<Error> Init (BootfsDir bootfs)

Initializes the Patcher. The associated BOOTFS directory namespace must be

nonempty. Must be called before any other method. On initialization, the

lifetime of the Patcher is bound to that of the original BootfsView input.

Defined at line 20 of file ../../zircon/kernel/lib/code-patching/code-patching.cc

fit::result<Error> Init (BootfsDir bootfs)

Initializes the Patcher. The associated BOOTFS directory namespace must be

nonempty. Must be called before any other method. On initialization, the

lifetime of the Patcher is bound to that of the original BootfsView input.

fit::result<Error> PatchWithAlternative (ktl::span<ktl::byte> instructions, ktl::string_view alternative)

Replaces a range of instructions with the given patch alternative.

fit::result<Error> PatchWithAlternative (ktl::span<ktl::byte> instructions, ktl::string_view alternative)

Replaces a range of instructions with the given patch alternative.

Defined at line 47 of file ../../zircon/kernel/lib/code-patching/code-patching.cc

fit::result<Error> PatchWithAlternative (ktl::span<ktl::byte> instructions, ktl::string_view alternative)

Replaces a range of instructions with the given patch alternative.

void MandatoryPatchWithAlternative (ktl::span<ktl::byte> instructions, ktl::string_view alternative)

Calls PatchWithAlternative and panics if it fails.

void MandatoryPatchWithAlternative (ktl::span<ktl::byte> instructions, ktl::string_view alternative)

Calls PatchWithAlternative and panics if it fails.

Defined at line 66 of file ../../zircon/kernel/lib/code-patching/code-patching.cc

void MandatoryPatchWithAlternative (ktl::span<ktl::byte> instructions, ktl::string_view alternative)

Calls PatchWithAlternative and panics if it fails.

void NopFill (ktl::span<ktl::byte> instructions)

Overwrites a range of instuctions with the minimal number of `nop`

instructions.

void Patcher ()

Defined at line 74 of file ../../zircon/kernel/lib/code-patching/include/lib/code-patching/code-patching.h

void NopFill (ktl::span<ktl::byte> instructions)

Overwrites a range of instuctions with the minimal number of `nop`

instructions.

Defined at line 77 of file ../../zircon/kernel/lib/code-patching/code-patching.cc

void NopFill (ktl::span<ktl::byte> instructions)

Overwrites a range of instuctions with the minimal number of `nop`

instructions.

ktl::span<const Directive> patches ()

The associated patch directives.

Defined at line 82 of file ../../zircon/kernel/lib/code-patching/include/lib/code-patching/code-patching.h

Protected Methods

void Patcher (SyncFunction sync)

Defined at line 99 of file ../../zircon/kernel/lib/code-patching/include/lib/code-patching/code-patching.h

void Patcher (SyncFunction sync)

Defined at line 99 of file ../../zircon/kernel/lib/code-patching/include/lib/code-patching/code-patching.h

void Patcher (SyncFunction sync)

Defined at line 99 of file ../../zircon/kernel/lib/code-patching/include/lib/code-patching/code-patching.h