pub struct Patch {
pub before: u32,
pub pad: Opcode,
pub after: Option<Inst>,
}Expand description
Where the room a patcher was promised at the top of a function is.
What -fpatchable-function-entry= asks for. The room is a run of the shortest instruction that
does nothing, and the point of it is that something else is written over it once the program is
running, so what has to survive to the writers is where it starts and how much of it there is.
Two halves, because the room can be on either side of the function’s own label and the two sides reach the writers differently. What is after the label is in the instruction stream like anything else, so it is named by the first instruction of it. What is in front of the label is not in the stream at all, since the stream starts at the label, so it is a count the writer lays down itself, out of the one opcode kept here for it.
The address the room is recorded under is its start, which is the front of the half in front of the label in a function that has one and the front of the other half otherwise. The two halves are not always next to each other: a function that also opens with a landing pad has the pad between them, because the pad has to be the first thing after the label and the room does not.
Fields§
§before: u32How many bytes go in front of the function’s own label.
pad: OpcodeWhat one of those is written as, which is the instruction that does nothing.
Kept because they are the only instructions in a finished function that are not in a block, so there is nowhere else for a writer to read the opcode off. The ones after the label are in the stream and this is the opcode they carry too.
after: Option<Inst>The first instruction of the room after the label, or None in a function whose room is all
in front of it.