Method for branch slamming as a safe mechanism for binary code editing
AssigneeSun Microsystems, Inc.
InventorJan Civlin
Life of this patent
Estimating the term…
Abstract
A method is provided for safely editing a binary code to be executed on a computer system. Broadly speaking, the method allows a binary code to be directly edited without compromising its integrity. The method provides for using a branch slamming operation to displace a binary instruction contained within the binary code with a branch to a binary patch. The binary instruction displaced by the branch is preserved in the binary patch. Upon completion of the binary patch execution, the binary code continues its execution with a binary instruction immediately following the branch. The method also provides for use of multiple branches and multiple binary patches to edit the binary code.
Claims24
A method for editing a binary code, comprising:
- preparing a binary patch, the binary patch containing supplemental instructions to be included in the binary code;
- identifying an instruction in the binary code;
- and
- replacing the instruction in the binary code with a branch, the branch directing a control of the binary code to the binary patch.
A method for inserting a binary patch into a binary code, comprising:
- identifying a first instruction in the binary code to be replaced by a branch to the binary patch, the branch directing a program control to an initial instruction in the binary patch;
- preparing the binary patch, the binary patch containing supplemental instructions to be included in the binary code, the initial instruction in the binary patch being the first instruction in the binary code to be replaced by the branch, a final instruction in the binary patch directing the program control to a second instruction in the binary code, the second instruction immediately following the first instruction in the binary code that is to be replaced by the branch;
- and
- replacing the first instruction in the binary code with the branch.
A method for inserting a plurality of binary patches into a binary code, comprising:
- identifying a plurality of instructions in the binary code to be replaced by a plurality of branches, the plurality of instructions occurring sequentially in the binary code, the plurality of branches corresponding to the plurality of binary patches, a first instruction of the plurality of instructions directing a program control to an initial instruction in a first binary patch of the plurality of binary patches;
- preparing the plurality of binary patches, wherein the plurality of binary patches contain supplemental instructions to be included in the binary code, the initial instruction in the first binary patch of the plurality of binary patches being the first instruction of the plurality of instructions in the binary code to be replaced by the plurality of branches, a final instruction in each of the plurality of binary patches directing the program control to an initial instruction in a subsequent binary patch of the plurality of binary patches, the initial instruction in a subsequent binary patch of the plurality of binary patches being a subsequent instruction of the plurality of instructions in the binary code to be replaced by the plurality of branches, a final instruction in a last binary patch of the plurality of binary patches directing the program control to an instruction in the binary code immediately following the plurality of instructions in the binary code to be replaced by the plurality of branches;
- and
- replacing each of the plurality of instructions in the binary code with one of the plurality of branches.
A method for inserting two binary patches into a binary code, comprising:
- identifying a first instruction in the binary code to be replaced by a first branch, the first branch corresponding to a first binary patch, the first branch directing a program control to an initial instruction in the first binary patch;
- identifying a second instruction in the binary code to be replaced by a second branch, the second instruction immediately following the first instruction in the binary code, the second branch corresponding to a second binary patch;
- preparing the first binary patch, wherein the first binary patch contains supplemental instructions to be included in the binary code, the initial instruction in the first binary patch being the first instruction in the binary code to be replaced by the first branch, a final instruction in the first binary patch directing the program control to an initial instruction in the second binary patch;
- preparing the second binary patch, wherein the second binary patch contains supplemental instructions to be included in the binary code, the initial instruction in the second binary patch being the second instruction in the binary code to be replaced by the second branch, a final instruction in the second binary patch directing the program control to an instruction in the binary code immediately following the second instruction in the binary code to be replaced by the second branch;
- replacing the first instruction in the binary code with the first branch;
- and
- replacing the second instruction in the binary code with the second branch.
Dependencies are inferred from the claim text.