Patent ID: 9075692
Filing Date: 2015-07-07
Classification: G06F

Abstract:
1. A method for activating an on-line patch, the method comprising: reserving, while a to-be-patched program is compiled, a middle segment adjacent an entry position of each function of one or more to-be-patched functions of the to-be-patched program; determining an address of a patch function and an entry address of the to-be-patched function; writing, in the middle segment, a long-jump instruction for jumping to the patch function based on the address of the patch function and the entry address of the to-be-patched function, wherein the middle segment is a storage space, which is located adjacent the entry position of the to-be-patched function and is capable of at least storing one long jump instruction, and the entry address of the to-be-patched function represents the entry position of the to-be-patched function; and modifying an instruction at the entry position of the to-be-patched function to a short-jump instruction for jumping to the middle segment, wherein the short-jump instruction at the entry position of the to-be-patched function is executed to jump to the middle segment, and then the long jump instruction for jumping to the patch function is executed to jump to the patch function and then the patch function is executed, wherein the middle segment includes one or more instructions, and the long jump instruction for jumping to the patch function is one of the one or more instructions; wherein the process of reserving, while the to-be-patched program is compiled, the middle segment adjacent an entry position of each function of one or more to-be-patched functions of the to-be-patched program comprises: after a source file of the to-be-patched program is compiled to generate an assembly file, searching for a keyword string representing a function in the assembly file, wherein the searched keyword string-is used for positioning the entry position of the function; inserting an all-zero instruction with a specified number of bytes, adjacent to the entry position of the function positioned-by the searched keyword string, to reserve the middle segment, wherein the specified number of bytes represents the size of the middle segment; and when the all-zero instruction with the specified number of bytes has been inserted adjacent the entry position of each function of the one or more to-be-patched functions, recompiling the assembly file inserted with the all-zero instruction to generate a new assembly file, compiling the new assembly file to generate a target file, and linking a plurality of target files to generate an executable file of the to-be-patched program.