Patch file generation method, validation method, and device

By identifying and removing redundant symbols in the Go language patch source code, generating a small patch file, and adding jump instructions to the original file, the problems of large patch file data size and inability to implement hot patching are solved, thus achieving the goal of saving bandwidth and storage space while supporting hot patching in Go language.

CN122173121APending Publication Date: 2026-06-09HUAWEI TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HUAWEI TECH CO LTD
Filing Date
2024-12-06
Publication Date
2026-06-09

Smart Images

  • Figure CN122173121A_ABST
    Figure CN122173121A_ABST
Patent Text Reader

Abstract

The application provides a patch file generation method, an effective method and equipment, and relates to the technical field of computers. The method comprises the following steps: in each symbol included in patch source code of software, target symbols that need to be reserved are determined, wherein the target symbols comprise patch variables and / or patch functions, and in the case where the target symbols comprise patch functions, the target symbols further comprise an effective necessary function, an associated function of the effective necessary function and an associated function of the patch function. Furthermore, the symbols in the patch source code except the target symbols are deleted, and the patch source code after the deletion processing is compiled to obtain a patch file. The patch file generated by the application has a small amount of data, so that the computing device installed with the software can effectively save bandwidth resources when downloading the patch file.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method for generating a patch file, a method for applying the patch, and a device. Background Technology

[0002] Go is a concise and efficient programming language widely used in the programming of various software applications, including microservice architectures, storage product components, and data communication firewall components. When bugs occur in these software applications, they can be fixed by applying patches.

[0003] Currently, patching the aforementioned software typically involves modifying the full source code to obtain patch source code, compiling the patch source code, and generating a patch file. Devices with the software installed can then download the patch file and replace all the original files on their local devices with the patch file, thus patching the software.

[0004] However, the patch files generated after compiling the full patch source code are very large, usually tens of MB or even hundreds of MB. When the device downloads the patch files, it will consume a lot of bandwidth resources. Summary of the Invention

[0005] This application provides a method for generating and applying patch files, as well as a device for doing so, which can reduce the data size of patch files and save bandwidth resources of computing devices. The technical solution is as follows:

[0006] Firstly, a method for generating patch files is provided, the method including:

[0007] In the software patch source code, target symbols are identified. The patch source code is obtained by modifying the software source code. Target symbols include patch variables and / or patch functions. If the target symbols include patch functions, they also include necessary functions, associated functions of the necessary functions, and associated functions of the patch functions. Then, all symbols except the target symbols are removed from the patch source code, resulting in a shortened patch source code. Finally, the shortened patch source code is compiled to obtain the software patch file.

[0008] In the technical solution provided in this application, the patch source code is obtained by modifying the full source code of the software. The purpose of this modification can be to fix bugs, add new features, etc. In the patch source code, target symbols that need to be retained are first selected, and then all other symbols in the patch source code are deleted. The data size of the patch source code after deletion is smaller than that of the full patch source code. Therefore, compared with patch files generated by compiling the full patch source code in related technologies, the patch file generated using this technical solution has a smaller data size. This effectively saves bandwidth resources when the computing device downloads the patch file, and the storage space occupied by the patch file after downloading to the computing device is also relatively small.

[0009] In one possible implementation, the patch function and patch variable in the patch source code have corresponding comments. Accordingly, the process for determining the target symbol can be as follows:

[0010] Among the symbols included in the software patch source code, those with corresponding specified comment information are identified as target symbols. For each symbol with corresponding specified comment information, if the symbol is a function, the associated function of the symbol is identified as the target symbol, and the necessary function and the associated function of the necessary function are identified as target symbols.

[0011] In the technical solution provided in this application, specified comment information can be added to the patch functions and patch variables in the patch source code, so that the corresponding patch functions and patch variables can be identified in the patch source code based on the specified comment information. Here, the specified comment information can be added manually by the developer or automatically by the computing device.

[0012] In one possible implementation, the programming language of the patch source code is Go. Accordingly, not all of the associated functions need to be retained; only functions of a specified type can be selected as target symbols. Specifically, the processing can be as follows:

[0013] The assertion functions, anonymous functions, and interface functions in the associated functions of the symbol are identified as target symbols, and the assertion functions, anonymous functions, and interface functions in the associated functions of the necessary functions are also identified as target symbols.

[0014] In related technologies, patching software written in Go requires compiling the entire source code to generate a patch file. This patch file contains all functions and variables, necessitating terminating the software process, replacing the original files with the patch file, and then restarting the process. This fails to achieve Go's hot patching functionality. However, the technical solution presented in this application offers a strategy for reducing the size of the patch source code. This strategy further identifies assertion functions, anonymous functions, and interface functions within the patch functions and retains these as target symbols, without reduction. This strategy satisfies Go's syntax, which stipulates that if function A is an associated function of function B, and function A is an assertion function, anonymous function, or interface function, then function A and function B must be implemented in the same file. The technical solution provided in this application, by reducing the size of the patch source code according to Go's syntax before compiling it into a patch file, results in fewer functions and variables in the patch file, providing a foundation for implementing Go's hot patching functionality.

[0015] In one possible implementation, if the patch function is an inline function of the first function in the patch source code, the target symbol also includes the first function and inline functions of the first function in the patch source code other than the patch function.

[0016] The technical solution provided in this application also supports patching inline functions. An inline function refers to a function B that, if called by function A, can be inserted into function A and directly become part of function A. In this case, function B is called an inline function of function B.

[0017] In one possible implementation, the necessary functions for activation include constructing the destructor.

[0018] Constructing destructors is used to request and release resources for executing patch files. Resources can include storage resources, computing resources, etc.

[0019] Secondly, a method for applying patch files is provided, which includes:

[0020] Obtain the software patch file. For the target function in the patch file, find the source function with the same name as the target function in the software's source file. The target function is any function other than those necessary for the function to take effect. Then, add a jump instruction at the beginning of the source function in the source file. This jump instruction is used to jump to execute the corresponding target function in the patch file when the source function is executed.

[0021] In the technical solution provided in this application, for functions that need to be patched, a source function with the same name is found in the original file, and a jump instruction is added at the beginning of the source function. Thus, when the source function is executed subsequently, the jump instruction is executed first to jump to and execute the corresponding function in the patch file. This solution does not require replacing the entire source file with the patch file, and therefore does not require terminating (killing) the process, thus achieving hot patching functionality.

[0022] In one possible implementation, before adding the jump instruction at the beginning of the original function, the method may also include the following processing:

[0023] Prevent the execution of the original function corresponding to each objective function.

[0024] Accordingly, after adding jump instructions at the beginning of all original functions, the method can also include the following processing:

[0025] Remove the block on execution of the original function corresponding to each objective function.

[0026] In the technical solution provided in this application, in order to make the target functions in the patch file take effect together, before adding the jump instruction at the beginning of the original function, the execution of the original function corresponding to each target function can be prevented first, and after adding the jump instruction at the beginning of all the original functions, the execution of the original function corresponding to each target function can be unblocked.

[0027] In one possible implementation, before adding the jump instruction at the beginning of the original function, the method may also include the following processing:

[0028] Pause all coroutines in the software process.

[0029] Accordingly, after adding jump instructions at the beginning of all original functions, the method can also include the following:

[0030] Wake up all coroutines.

[0031] In the technical solution provided in this application, in order to make the target functions in the patch file take effect together, before adding jump instructions at the beginning of the original function, the stopTheWorld mechanism can be used to pause all coroutines in the software process. After adding jump instructions at the beginning of all original functions, the startTheWorld mechanism can be used to wake up the coroutines that were paused.

[0032] In one possible implementation, adding a jump instruction at the beginning of the original function in the original file can be done as follows:

[0033] In the original file, the first N bytes of the original function are replaced with jump instructions, where N is the number of bytes of jump instructions.

[0034] In one possible implementation, replacing the first N bytes of the original function with jump instructions can be done as follows:

[0035] If the address stored in the program counter (PC) register does not overlap with the address of the first N bytes of the original function in the original file, the first N bytes will be replaced with a jump instruction.

[0036] The address stored in the PC register is the address of the next instruction to be executed. If the content to be replaced happens to be all or part of the next instruction to be executed, a program error is very likely to occur if the time of the replacement operation and the time of the execution of the next instruction overlap. Therefore, in the technical solution provided in this application, to avoid the above situation, it is first determined whether the address stored in the PC register and the address of the first N bytes of the original function in the original file have overlapping addresses. The replacement operation is only performed if the address stored in the PC register and the address of the first N bytes of the original function in the original file do not have overlapping addresses.

[0037] Thirdly, a patch file generation apparatus is provided, the apparatus comprising:

[0038] A determination module is used to determine target symbols among the symbols included in the patch source code of the software, wherein the target symbols include patch variables and / or patch functions, and if the target symbols include the patch functions, the target symbols further include functions necessary for effectiveness, associated functions of the functions necessary for effectiveness, and associated functions of the patch functions;

[0039] The deletion module is used to delete symbols other than the target symbol from the patch source code to obtain the reduced patch source code.

[0040] The compilation module is used to compile the reduced patch source code to obtain the patch file for the software.

[0041] In one possible implementation, the patch function and the patch variable in the patch source code have specified comment information.

[0042] The determining module is used for:

[0043] Among the symbols included in the software patch source code, the symbols that correspond to the specified comment information are identified as target symbols;

[0044] For each symbol corresponding to the specified annotation information, if the symbol is a function, then the associated function of the symbol is determined as the target symbol, and the necessary function and the associated function of the necessary function are determined as the target symbol.

[0045] In one possible implementation, the programming language of the patch source code is Go.

[0046] The determining module is used for:

[0047] The assertion function, anonymous function, and interface function in the associated functions of the symbol are identified as target symbols, and the function necessary for effectiveness, as well as the assertion function, anonymous function, and interface function in the associated functions of the function necessary for effectiveness, are identified as target symbols.

[0048] In one possible implementation, if the patch function is an inline function of the first function in the patch source code, then the target symbol also includes the first function and inline functions of the first function in the patch source code other than the patch function.

[0049] In one possible implementation, the necessary functions for activation include constructing a destructor.

[0050] Fourthly, a means for applying a patch file is provided, the means comprising:

[0051] The acquisition module is used to acquire software patch files;

[0052] The search module is used to search for a source function with the same function name as the target function in the source file of the software for the target function in the patch file, wherein the target function is a function other than the function necessary for the effect to take effect;

[0053] An add module is used to add a jump instruction at the beginning of the original function in the original file, wherein the jump instruction is used to jump to execute the corresponding target function in the patch file when the original function is executed.

[0054] In one possible implementation, before adding the jump instruction at the beginning of the original function, the device further includes a management module for:

[0055] Prevent the execution of the original function corresponding to each objective function;

[0056] After adding jump instructions at the beginning of all original functions, the execution block for the original function corresponding to each target function is lifted.

[0057] In one possible implementation, before adding the jump instruction at the beginning of the original function, the device further includes a management module for:

[0058] Pause all coroutines in the process of the software;

[0059] After adding jump instructions at the beginning of all original functions, all the coroutines are awakened.

[0060] In one possible implementation, the added module is used for:

[0061] In the original file, the first N bytes of the original function are replaced with the jump instruction, where N is the number of bytes in the jump instruction.

[0062] In one possible implementation, the added module is used for:

[0063] If the address stored in the PC register does not overlap with the address of the first N bytes of the original function in the original file, the first N bytes are replaced with the jump instruction.

[0064] Fifthly, a computing device is provided, the computing device including a processor and a memory;

[0065] The processor of the computing device is configured to execute instructions stored in the memory of the at least one forwarding device to cause the computing device to perform the method described in the first aspect and any possible implementation thereof or the second aspect and any possible implementation thereof.

[0066] In a sixth aspect, a computer-readable storage medium is provided, comprising computer program instructions that, when executed by a computing device, the forwarding device performs the method described in the first aspect and any possible implementation thereof, or in the second aspect and any possible implementation thereof.

[0067] In a seventh aspect, a computer program product comprising instructions is provided, which, when executed by a computing device, cause the computing device to perform the method described in the first aspect and any possible implementation thereof, or in the second aspect and any possible implementation thereof. Attached Figure Description

[0068] Figure 1 This is a schematic diagram of an implementation scenario provided in an embodiment of this application;

[0069] Figure 2 This is a schematic diagram of a patch file generation method provided in an embodiment of this application;

[0070] Figure 3This is a schematic diagram of a function call provided in an embodiment of this application;

[0071] Figure 4 This is a schematic diagram of a function inlining provided in an embodiment of this application;

[0072] Figure 5 This is a schematic diagram of a method for applying a patch function according to an embodiment of this application;

[0073] Figure 6 This is a schematic diagram illustrating a jump instruction replacement provided in an embodiment of this application;

[0074] Figure 7 This is a schematic diagram illustrating the direct relationship between a function and a PC register address, provided in an embodiment of this application.

[0075] Figure 8 This is a schematic diagram illustrating the direct relationship between a function and a PC register address, provided in an embodiment of this application.

[0076] Figure 9 This is a schematic diagram illustrating the direct relationship between a function and a PC register address, provided in an embodiment of this application.

[0077] Figure 10 This is a schematic diagram illustrating the direct relationship between a function and a PC register address, provided in an embodiment of this application.

[0078] Figure 11 This is a schematic diagram of a patch file generation method provided in an embodiment of this application;

[0079] Figure 12 This is a schematic flowchart of a patch file uninstallation method provided in an embodiment of this application;

[0080] Figure 13 This is a schematic diagram of a patch file generation device provided in an embodiment of this application;

[0081] Figure 14 This is a schematic diagram of the structure of a patch function activation device provided in an embodiment of this application;

[0082] Figure 15 This is a schematic diagram of the structure of a computing device provided in an embodiment of this application. Detailed Implementation

[0083] The terminology used in the embodiments section of this application is only for explaining specific embodiments of this application and is not intended to limit this application.

[0084] To facilitate understanding of this application, the terms used in this application are explained below.

[0085] Go programming language

[0086] Go, also known as Golang, is a statically typed, compiled, open-source programming language. Source code written in Go needs to be compiled into machine code (binary code) to run.

[0087] source code

[0088] Source code, also known as source code or source program, refers to code written in a high-level programming language. It is a human-readable form of code. For example, source code could be code written in the Go programming language.

[0089] symbol

[0090] In code, variables and functions are usually represented by symbols consisting of letters, numbers, and underscores, hence they are often called "symbols".

[0091] patch function

[0092] When developers modify a function in the source code while creating a patch, that modified function is called the patch function. Alternatively, if developers add a new function to the source code while creating a patch, that new function is also called the patch function.

[0093] Patch Variables

[0094] When developers modify the value of a variable in the source code while creating a patch, that variable is called a patch variable. Alternatively, if developers add a variable to the source code while creating a patch, that added variable is also called a patch variable.

[0095] Patch source code

[0096] Patch source code refers to the code obtained by making patch-related modifications to the original source code, such as adding patch functions, adding patch variables, modifying original functions into patch functions, and changing the values ​​of patch variables.

[0097] Function inlining

[0098] Function inlining is a compiler optimization technique that inserts function code directly into the place where the function is called, instead of calling the function at runtime. This reduces the overhead of function calls, especially when the function body is small and the calls are frequent, thus improving program execution efficiency.

[0099] The following describes the implementation scenarios of the embodiments of this application:

[0100] like Figure 1As shown, in this implementation scenario, it can include computing devices on the software developer's side, servers, and computing devices with the software installed. The software can be a storage medium component, firewall software, database software, cloud service software, etc. The computing devices on the developer's side can be terminal devices such as desktop computers, laptops, tablets, and mobile phones. The server can be a single server or a server cluster. The computing devices with the software installed can be desktop computers, laptops, tablets, mobile phones, servers, etc.

[0101] After the software has been launched, if a bug appears, the developers need to create a patch file to address the bug, upload it to the server, and then the computing devices with the software installed will download and run the patch file to resolve the problem.

[0102] When developers create patch files, they typically modify the software's source code directly to obtain the patch source code. Modifications can take many forms, such as adding patch functions, adding patch variables, changing original functions to patch functions, or modifying the values ​​of patch variables.

[0103] In related technologies, after developers create the patch source code, they directly compile the entire source code to generate a patch file. This results in a very large patch file, typically tens or even hundreds of megabytes in size. In this case, the computing device with the software installed will consume significant bandwidth resources when downloading the patch file, and the downloaded patch file will also occupy a large amount of storage space on the computing device.

[0104] In another related technique, developers first compile the software's source code to obtain a compiled file, and then compile the source code for a patch to obtain another compiled file. The two compiled files are then compared, and the differences are extracted into a single file as the patch file. This technique is applicable to some programming languages ​​with simple syntax; however, for some programming languages ​​with relatively complex syntax, simply retaining the differences may not meet the syntactic requirements of the programming language.

[0105] This application provides a method for generating patch files, which can be applied to various programming languages, such as Go and Rust. In the patch file generation method provided in this application, target symbols that need to be retained are first determined from the symbols included in the patch source code of the software. These target symbols include patch variables and / or patch functions. If the target symbols include patch functions, they also include necessary functions, associated functions of the necessary functions, and associated functions of the patch functions. Then, all symbols except the target symbols are deleted from the patch source code, and the deleted patch source code is compiled to obtain the patch file. Because redundant symbols in the patch source code are deleted, the compiled patch file has a smaller data size. This effectively saves bandwidth resources when the computing device with the software installed downloads the patch file, and the storage space occupied by the patch file on the computing device is also relatively small.

[0106] Furthermore, in the patch file generation method provided in the application embodiments, on the one hand, the patch source code is directly reduced, eliminating the need to compile both the full source code of the software and the full patch source code, thus saving compilation time. On the other hand, the retained symbols are not limited to differing patch functions or patch variables, but can also include associated functions of patch functions, functions necessary for their effectiveness, etc., which can better meet the syntactic characteristics of some programming languages ​​(such as Go), and have a wider range of applications.

[0107] The method for generating patch files according to embodiments of this application will be described below with reference to the accompanying drawings. This method can be applied to computing devices; see [link to documentation]. Figure 2 The method may include the following processing steps:

[0108] Step 101: Identify the target symbol from the symbols included in the software patch source code.

[0109] The target symbol includes patch variables and / or patch functions. If the target symbol includes patch functions, it also includes functions necessary for effectiveness, associated functions of the functions necessary for effectiveness, and associated functions of the patch functions.

[0110] In implementation, developers, based on the software's source code, perform operations such as adding patch functions, adding patch variables, replacing original functions with patch functions, and replacing the original values ​​of patch variables with patch values, according to actual needs, to obtain patched source code.

[0111] Then, the computing device identifies the patch variables and patch functions in the patch source code.

[0112] Upon identifying the patch function, the computing device further identifies its associated functions, essential functions for activation, and related functions of the essential functions. The essential functions for activation include constructors and destructors. These constructors and destructors are used to request and release resources for executing the patch file; these resources may include storage resources, computing resources, etc.

[0113] If the patch variable is newly added, then the init function and its associated functions also need to be identified. The init function is used to initialize the newly added patch variable.

[0114] The init function and the constructor / destructor mentioned above have specific function names, and the computing device can directly identify the init function and the constructor / destructor based on their function names.

[0115] The identification of the patch function and patch variable mentioned above is explained below:

[0116] When developers create patch source code, they can add specific comments to patch functions and patch variables. The specific placement of these comments depends on the programming language's conventions; the purpose here is simply to allow developers to later identify the patch functions and variables based on the specified comments.

[0117] The specified comment information added to the patch function and the specified comment information added to the patch variable can be the same or different. The specified comment information added to different patch functions can be the same or different. The specified comment information added to different variables can be the same or different. The specific limitations on the location and form of adding the specified comment information are different in the embodiments of this application.

[0118] The following example illustrates how to add specific comments to patch functions and patch variables:

[0119] 1. Add specified comment information to the patch function.

[0120] / / go:hotpatch

[0121] func MyFunction(a,b int)int{

[0122] return a+b

[0123] }

[0124] See the code example above, where:

[0125] " / / go:hotpatch" specifies the comment information;

[0126] "func MyFunction(a,b int)int{

[0127] return a+b

[0128] } is the patch function.

[0129] 2. Add specified comment information to patch variables

[0130] / / go:hotpatch

[0131] var maxConnections int = 100

[0132] See the code example above, where:

[0133] " / / go:hotpatch" specifies the comment information;

[0134] “var maxConnections int=100” is a patch variable.

[0135] In one possible implementation, the specified annotation information for patch functions and patch variables can be automatically added by the computing device. In this case, the developer needs to provide a list of patch functions and patch variables, which contains the function names of the patch functions and the variable names of the patch variables. Correspondingly, the computing device obtains the list of patch functions and patch variables, queries the patch source code to find the recorded patch functions and patch variables in the list, and adds the specified annotation information according to pre-configured annotation rules.

[0136] The methods for identifying the associated functions of patch functions and the associated functions of functions that are necessary for effectiveness can be as follows:

[0137] For the patch function, reachability analysis is performed in the patch source code, with the patch function as the root, to find the functions in the call chain of the patch function, which are the associated functions of the patch function.

[0138] like Figure 3 As shown, function 1 is a patch function. Reachability analysis is performed with function 1 as the root. The analysis shows that function 1 calls function 10 and function 11, function 10 calls function 110, and function 110 calls function 1100 and function 1101. Therefore, function 10, function 11, function 110, function 1100, and function 1101 are all functions on the call chain with function 1 as the root, that is, they are the associated functions of function 1.

[0139] Similarly, for functions that are necessary for activation, reachability analysis is performed in the patch source code, with the necessary functions as the root, to find the functions in the call chain of the necessary functions, which are the associated functions of the necessary functions.

[0140] In one possible implementation, assuming the source code is programmed in Go, for the identified associated functions, functions of a specific type can be further searched among these associated functions as target symbols, instead of using all associated functions as target symbols. The specified type of function can be a function that needs to satisfy consistency requirements; for example, functions of a specified type can include interface functions, assertion functions, and anonymous functions.

[0141] Here, taking the patch function as an example, satisfying the consistency requirement means that the patch function needs to be in the same file as the specified function mentioned above in its associated function.

[0142] In another possible implementation, if inlining optimization is enabled at compile time, the source code can be compiled first. The compiler can then output inlining information, which records the inlining relationships between functions—that is, which function is an inline function of another function. The following example illustrates inlining functions:

[0143] like Figure 4 As shown, function 60 is the patch function, and function 6 calls function 60. Function 6 is called the calling function. During inlining optimization, function 60 is inserted into function 6 as an inline function. Therefore, after inlining optimization, function 6 contains function 60.

[0144] When the inlining optimization function is enabled during compilation, the inlining information can be obtained when determining the target symbol in step 101. The inlining information can be used to check if there is a patch function as an inline function for other functions. If the patch function is found to be an inline function of the first function, then the first function and the inline functions of the first function in the patch source code other than the patch function are also used as target symbols.

[0145] For example, Table 1 below shows a list of inline information.

[0146] Table 1

[0147] Calling functions Inline functions Function 6 Functions 60, 61, and 62 Function 8 Function 88, Function 86 Function 9 Function 92 …… ……

[0148] Among them, function 60 is a patch function. According to Table 1 above, function 60 is an inline function of function 6. In addition, the inline functions of function 6 also include functions 61 and 62. Therefore, functions 6, 61 and 62 are also used as target symbols.

[0149] Step 102: Delete all symbols except the target symbol from the patch source code to obtain the patch source code after deletion.

[0150] In implementation, after the target symbol is identified in step 101, all symbols except the target symbol are deleted from the patch source code, resulting in the abbreviated patch source code. For patch variables, the remaining assignment statements are the ones that can be used to assign values ​​to variables, such as "var maxConnections int = 100" in the code example above.

[0151] Step 103: Compile the deleted patch source code to obtain the software patch file.

[0152] In implementation, the source code of the patch after deletion is compiled using a compiler to generate patch files. These patch files can then be packaged into a patch package and uploaded to a server for download and use by computing devices with the software installed.

[0153] This application also provides a method for applying a patch file, which can be implemented by a computing device. See [link to relevant documentation]. Figure 5 The method may include the following processing steps:

[0154] Step 401: Obtain the software patch file.

[0155] In practice, a computing device with the software installed can download a patch file for the software from a server. This patch file is generated using the patch file generation method provided in the embodiments of this application.

[0156] When a computing device detects an update trigger event, it retrieves a patch package from the server, decompresses the patch package to obtain a patch file, and then calls the patch loading interface to load the patch file into a specified storage area. Here, the update trigger event can be receiving an update command, detecting an update operation, or reaching a specified update cycle, etc., and this application embodiment does not limit it in this way.

[0157] Step 402: For the target function in the patch file, find the source function with the same function name as the target function in the source file of the software.

[0158] The objective function is any function other than the function required for the function to take effect.

[0159] In implementation, if the patch file contains functions necessary for activation, these functions can be executed first. For example, the constructor and destructor functions can be executed first to allocate resources, and the `init` function can be executed for initialization. Then, for functions in the patch file other than the necessary functions, the source files of the software can be searched for source functions with the same function names as the target functions, and then the replacement operation in step 403 can be performed.

[0160] Step 403: Add a jump instruction at the beginning of the original function in the original file.

[0161] The jump instruction is used to jump to the corresponding target function when the original function is being executed.

[0162] In implementation, for a target function with a corresponding original function, the first N bytes of the original function can be replaced with jump instructions, where the length of the jump instructions is N bytes. The specific value of N can be configured by relevant personnel according to the processor type. Different processor types correspond to different jump instruction lengths; for example, N can be 16.

[0163] The following example illustrates this:

[0164] See Figure 6 Patch function 1 corresponds to original function 10. The first 16 bytes of original function 10 can be replaced with jump instructions. In this way, when original function 10 is executed later, the jump instructions will be executed first to jump to patch function 1.

[0165] In one possible implementation, before performing the replacement, the execution of the original function corresponding to each target function can be prevented. After adding jump instructions at the beginning of all original functions, the execution of the original function corresponding to each target function can be unblocked.

[0166] Specifically, when the programming language is Go, the stopTheWorld mechanism can be used to pause all coroutines in the software process, add jump instructions at the beginning of all original functions, and then use the startTheWorld mechanism to wake up the coroutines that were paused.

[0167] In one possible implementation, during the substitution operation, if the address stored in the program counter (PC) register does not overlap with the addresses of the first N bytes of the corresponding original functions, then the first N bytes of these original functions can be replaced with jump instructions. The PC register stores the address of the next instruction to be executed.

[0168] The following example illustrates the case where the address stored in the PC register overlaps with the address of the first N bytes of the original function:

[0169] Case 1: The next instruction to be executed is the first instruction of the original function.

[0170] like Figure 7 As shown, the starting address stored in the PC register is the starting address of the original function, and the first instruction of the original function is also N bytes.

[0171] like Figure 8 As shown, the starting address stored in the PC register is the starting address of the original function, and the length of the first instruction of the original function is less than N bytes.

[0172] like Figure 9 As shown, the starting address stored in the PC register is the starting address of the original function, and the length of the first instruction of the original function is greater than N bytes.

[0173] Case 2: The next instruction to be executed is the Mth instruction of the original function, where M is an integer greater than 1.

[0174] like Figure 10 As shown, the starting address stored in the PC register is not the starting address of the original function, and the starting address stored in the PC register is within the range of the addresses of the first N bytes of the original function.

[0175] In another possible implementation, where the software uses a stack pointer (SP) register, during the replacement operation, if the address stored in the PC register does not overlap with the addresses of the first N bytes of the corresponding original functions for all target functions, and the address pointed to by the stack pointer (SP) register does not overlap with the addresses of the first N bytes of the corresponding original functions for all target functions, then the first N bytes of these original functions can be replaced with jump instructions. Here, the address pointed to by the SP register is the return address of the currently executed instruction.

[0176] Here, the process of determining whether the address indicated by the SP register coincides with the address of the first N bytes of the original function corresponding to all target functions is the same as the process of determining whether the address indicated by the PC register coincides with the address of the first N bytes of the original function corresponding to all target functions, and will not be repeated here.

[0177] In one possible implementation, when the patch file takes effect, newly added patch functions can be run directly or called by others. For patch variables that require modification, the value of the patch variable in the original file can be directly changed to the value of the patch variable in the patch file.

[0178] In one possible implementation, see Figure 11 The processing in step 403 above may include the following steps:

[0179] Step 4031: Pause all coroutines in the software process.

[0180] Step 4032: Determine whether the address stored in the PC register and the address of the first N bytes of the original function corresponding to all target functions do not overlap.

[0181] Step 4033: If the address stored in the PC register does not overlap with the address of the first N bytes of the original function corresponding to all target functions, then replace the first N bytes of the original function in the original file with a jump instruction.

[0182] Step 4034: After all the original functions corresponding to the target functions have been replaced, wake up the suspended coroutines mentioned above.

[0183] Step 4035: If the address stored in the PC register overlaps with the address of the first N bytes of the original function corresponding to at least one target function, then wake up the suspended coroutine and, after a first delay, proceed to step 4031.

[0184] The first duration can be configured by relevant personnel according to actual needs; for example, the first duration can be configured to 1ms.

[0185] Here, if step 4034 still fails to meet the requirements after M checks, a patch failure message will be displayed. The value of M can be configured by relevant personnel; for example, M can be set to 7.

[0186] Furthermore, for cases where the software uses the SP register, step 4032 above can be:

[0187] Determine whether the address stored in the PC register does not overlap with the address of the first N bytes of the original function corresponding to all target functions, and also determine whether the address indicated by the SP register does not overlap with the address of the first N bytes of the original function corresponding to all target functions.

[0188] Step 4033 above can be:

[0189] If the address stored in the PC register does not overlap with the address of the first N bytes of the original function corresponding to all target functions, and the address indicated by the SP register does not overlap with the address of the first N bytes of the original function corresponding to all target functions, then the first N bytes of the aforementioned original function in the original file will be replaced with a jump instruction.

[0190] Step 4035 above can be:

[0191] If the address stored in the PC register overlaps with the address of the first N bytes of the original function corresponding to at least one objective function, or if the address stored in the SP register overlaps with the address of the first N bytes of the original function corresponding to at least one objective function, then the suspended coroutine is awakened, and after a delay of the first duration, the process proceeds to step 4031.

[0192] In one possible implementation, this application also provides a method for patch uninstallation, see [link to relevant documentation]. Figure 12 The processing method can be described by the following steps:

[0193] Step 701: Pause all coroutines in the process.

[0194] Step 702: Determine whether the address stored in the PC register and the address of the first N bytes of the original function corresponding to all target functions do not overlap.

[0195] Step 703: If the address stored in the PC register does not overlap with the address of the first N bytes of the original function corresponding to all target functions, then perform a patch rollback operation on the first N bytes of the original function in the original file to restore the values ​​of the original function and patch variable corresponding to the target function to the content before this patch modification, and delete the patch file.

[0196] Step 704: After all the original functions corresponding to the objective functions have completed their rollbacks, wake up the suspended coroutines mentioned above.

[0197] Step 705: If the address stored in the PC register overlaps with the address of the first N bytes of the original function corresponding to at least one target function, then wake up the suspended coroutine and, after a second delay, proceed to step 701.

[0198] The second duration can be configured by relevant personnel according to actual needs. The first duration and the second duration can be the same or different. For example, the second duration can be configured as 1ms.

[0199] Furthermore, for cases where the software uses the SP register, step 702 above can be:

[0200] Determine whether the address stored in the PC register does not overlap with the address of the first N bytes of the original function corresponding to all target functions, and also determine whether the address indicated by the SP register does not overlap with the address of the first N bytes of the original function corresponding to all target functions.

[0201] Step 703 above can be:

[0202] If the address stored in the PC register does not overlap with the address of the first N bytes of the original function corresponding to all target functions, and the address indicated by the SP register does not overlap with the address of the first N bytes of the original function corresponding to all target functions, then a patch rollback operation is performed on the first N bytes of the original function in the original file to restore the values ​​of the original function corresponding to the target function and the patch variable to the content before this patch modification.

[0203] Step 705 above can be:

[0204] If the address stored in the PC register overlaps with the address of the first N bytes of the original function corresponding to at least one objective function, or if the address stored in the SP register overlaps with the address of the first N bytes of the original function corresponding to at least one objective function, then the suspended coroutine is awakened, and after a second delay, the process proceeds to step 701.

[0205] In the patch file activation method provided in this application embodiment, the patch file is activated by adding a jump instruction at the beginning of the original function. The original software file does not need to be replaced with the patch file, and the process does not need to be terminated (killed), thus achieving the hot patch function.

[0206] This application also provides a patch file generation apparatus, which can be applied to computing devices, such as... Figure 13 As shown, the device includes a determination module 1310, a deletion module 1320, and a compilation module 1330, wherein:

[0207] The determination module 1310 is used to determine target symbols among the symbols included in the patch source code of the software. The target symbols include patch variables and / or patch functions. If the target symbols include the patch functions, the target symbols also include necessary functions, associated functions of the necessary functions, and associated functions of the patch functions. Specifically, this module can implement the functions of step 101 and its implicit steps.

[0208] The deletion module 1320 is used to delete symbols other than the target symbol from the patch source code to obtain the reduced patch source code; specifically, this module can implement the functions of the above step 102 and its implicit steps.

[0209] The compilation module 1330 is used to compile the deleted patch source code to obtain the patch file for the software. Specifically, this module can implement the functions of step 103 and its implicit steps mentioned above.

[0210] In one possible implementation, the patch function and the patch variable in the patch source code have specified comment information.

[0211] The determining module 1310 is used for:

[0212] Among the symbols included in the software patch source code, the symbols that correspond to the specified comment information are identified as target symbols;

[0213] For each symbol corresponding to the specified annotation information, if the symbol is a function, then the associated function of the symbol is determined as the target symbol, and the necessary function and the associated function of the necessary function are determined as the target symbol.

[0214] In one possible implementation, the programming language of the patch source code is Go.

[0215] The determining module 1310 is used for:

[0216] The assertion function, anonymous function, and interface function in the associated functions of the symbol are identified as target symbols, and the function necessary for effectiveness, as well as the assertion function, anonymous function, and interface function in the associated functions of the function necessary for effectiveness, are identified as target symbols.

[0217] In one possible implementation, if the patch function is an inline function of the first function in the patch source code, then the target symbol also includes the first function and inline functions of the first function in the patch source code other than the patch function.

[0218] In one possible implementation, the necessary functions for activation include constructing a destructor.

[0219] In the technical solution provided in this application embodiment, the target symbols that need to be retained are first determined from the symbols included in the patch source code of the software. Then, all symbols except the target symbols are deleted from the patch source code, and the patch source code after deletion is compiled to obtain a patch file. Since redundant symbols in the patch source code are deleted, the data size of the compiled patch file is smaller. Thus, when the computing device with the software installed downloads the patch file, bandwidth resources can be effectively saved. In addition, the storage space occupied by the patch file after it is downloaded to the computing device is also relatively small.

[0220] It should be noted that the patch file generation apparatus provided in the above embodiments is only illustrated by the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the computing device can be divided into different functional modules to complete all or part of the functions described above. In addition, the patch file generation apparatus and the patch file generation method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process can be found in the method embodiments, which will not be repeated here.

[0221] This application also provides a patch file generation apparatus, which can be applied to computing devices, such as... Figure 14 As shown, the device includes:

[0222] Module 1410 is used to obtain software patch files;

[0223] The search module 1420 is used to search for a source function with the same function name as the target function in the source file of the software for the target function in the patch file, wherein the target function is a function other than the function necessary for the effect to take effect;

[0224] Add module 1430, which is used to add a jump instruction at the beginning of the original function in the original file, wherein the jump instruction is used to jump to execute the corresponding target function in the patch file when the original function is executed.

[0225] In one possible implementation, before adding the jump instruction at the beginning of the original function, the device further includes a management module for:

[0226] Prevent the execution of the original function corresponding to each objective function;

[0227] After adding jump instructions at the beginning of all original functions, the execution block for the original function corresponding to each target function is lifted.

[0228] In one possible implementation, before adding the jump instruction at the beginning of the original function, the device further includes a management module for:

[0229] Pause all coroutines in the process of the software;

[0230] After adding jump instructions at the beginning of all original functions, all the coroutines are awakened.

[0231] In one possible implementation, the adding module 1430 is used for:

[0232] In the original file, the first N bytes of the original function are replaced with the jump instruction, where N is the number of bytes in the jump instruction.

[0233] In one possible implementation, the adding module 1430 is used for:

[0234] If the address stored in the program counter (PC) register does not overlap with the address of the first N bytes of the original function in the original file, the first N bytes are replaced with the jump instruction.

[0235] In the patch file activation method provided in this application embodiment, the patch file is activated by adding a jump instruction. The original software file does not need to be completely replaced with the patch file, and the process does not need to be terminated (killed), thus achieving the hot patch function.

[0236] It should be noted that the patch file activation device provided in the above embodiments is only illustrated by the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the computing device can be divided into different functional modules to complete all or part of the functions described above. In addition, the patch file activation device and the patch file activation method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.

[0237] See Figure 15 , Figure 15 A schematic diagram of an exemplary computing device 1600 of this application is shown. The computing device 1600 can be the computing device on the developer's side, or it can be the computing device with software installed. The computing device 1600 includes at least one processor 1601, a memory 1603, and at least one network interface 1604.

[0238] Processor 1601 may be, for example, a general-purpose central processing unit (CPU), a digital signal processor (DSP), a network processor (NP), a GPU, a neural-network processing unit (NPU), a data processing unit (DPU), a microprocessor, or one or more integrated circuits or application-specific integrated circuits (ASICs), programmable logic devices (PLDs), other general-purpose processors or other programmable logic devices, discrete gates, transistor logic devices, discrete hardware components, or any combination thereof for implementing the scheme of this application. A PLD may be, for example, a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), generic array logic (GAL), or any combination thereof. A general-purpose processor may be a microprocessor or any conventional processor. It is worth noting that the processor may be a processor supporting an advanced reduced instruction set machine (RISC) machine (ARM) architecture. It can implement or execute various logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0239] Optionally, the computing device 1600 also includes a bus 1602. The bus 1602 is used to transfer information between the components of the computing device 1600. The bus 1602 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus 1602 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 15 The symbol is represented by only one line, but this does not mean that there is only one bus or one type of bus.

[0240] The memory 1603 may be, for example, volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory may be random access memory (RAM), which is used as an external cache.

[0241] By way of example, but not limitation, many forms of ROM and RAM are available. For example, ROM is a compact disc read-only memory (CD-ROM). RAM includes, but is not limited to, static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM).

[0242] The memory 1603 can also be other types of storage devices capable of storing static information and instructions. Alternatively, it can be other types of dynamic storage devices capable of storing information and instructions. It can also be other optical disc storage, optical disk storage (including compressed optical discs, laser discs, optical discs, digital versatile optical discs, Blu-ray discs, etc.), magnetic disk storage media, or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but is not limited thereto. The memory 1603 may exist independently, for example, and be connected to the processor 1601 via bus 1602. The memory 1603 may also be integrated with the processor 1601.

[0243] Network interface 1604 uses any transceiver-like device for communicating with other devices or communication networks, such as Ethernet, radio access network (RAN), or wireless local area network (WLAN). Network interface 1604 may include wired network interfaces and wireless network interfaces. Specifically, network interface 1604 can be an Ethernet interface, such as Fast Ethernet (FE), Gigabit Ethernet (GE), Asynchronous Transfer Mode (ATM), WLAN, cellular network, or combinations thereof. The Ethernet interface can be an optical interface, an electrical interface, or a combination thereof. In some embodiments of this application, network interface 1604 can be used for computing device 1600 to communicate with other devices.

[0244] In specific implementations, as some embodiments, the processor 1601 may include one or more CPUs, such as Figure 15 The CPU0 and CPU1 shown are examples of processors. Each of these processors can be a single-core processor or a multi-core processor. A processor here can refer to one or more devices, circuits, and / or processing cores used to process data (e.g., computer program instructions).

[0245] In specific implementations, as some embodiments, the computing device 1600 may include multiple processors, such as... Figure 15 The processors 1601 and 1605 are shown. Each of these processors may be a single-core processor or a multi-core processor. Here, "processor" may refer to one or more devices, circuits, and / or processing cores used to process data (such as computer program instructions).

[0246] In some embodiments, memory 1603 is used to store program instructions 1610 for executing the scheme of this application, and processor 1601 can execute the program instructions 1610 stored in memory 1603. That is, computing device 1600 can implement the patch file generation method provided in the method embodiment through processor 1601 and program instructions 1610 in memory 1603, i.e. Figure 2 The method shown, or the method for implementing the patch file provided in the method embodiment, i.e. Figure 5 The method is illustrated. Program instructions 1610 may include one or more software modules. Optionally, processor 1601 itself may also store program instructions for executing the scheme of this application.

[0247] In specific implementation, the computing device 1600 of this application can correspond to a patch file generation device for executing the above method. The processor 1601 in the computing device 1600 reads instructions from the memory 1603, causing... Figure 15 The computing device 1600 shown is capable of executing all or part of the steps in the method embodiments. The computing device 1600 of this application may also correspond to an activation device for a patch file used to execute the above-described method. The processor 1601 in the computing device 1600 reads instructions from the memory 1603, causing... Figure 15 The computing device 1600 shown is capable of performing all or part of the steps in the method embodiments.

[0248] The computing device 1600 can also correspond to the above. Figure 13 The device shown, Figure 13 Each functional module in the illustrated device is implemented using software from a computing device 1600. In other words, Figure 13 The device shown includes functional modules generated by the processor 1601 of the computing device 1600 after reading the program instructions 1610 stored in the memory 1603.

[0249] The computing device 1600 can also correspond to the above. Figure 14 The device shown, Figure 14 Each functional module in the illustrated device is implemented using software from a computing device 1600. In other words, Figure 14 The device shown includes functional modules generated by the processor 1601 of the computing device 1600 after reading the program instructions 1610 stored in the memory 1603.

[0250] In the above embodiments, each step of the method is implemented through integrated logic circuits in the hardware of the processor of the computing device 1600 or through software instructions. The steps of the method embodiments disclosed in this application can be directly implemented by the hardware processor, or implemented by a combination of hardware and software modules in the processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. Since the storage medium is located in memory, the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method embodiments; to avoid repetition, these will not be described in detail here.

[0251] In an exemplary embodiment, a computer program (product) is provided, comprising: computer program code, which, when executed by a computer, causes the computer to perform the methods described above.

[0252] In an exemplary embodiment, a computer-readable storage medium is provided that stores a program or instructions, which, when run on a computer, enable the computer to perform the methods described above.

[0253] In an exemplary embodiment, a chip is provided, including a processor for retrieving and executing instructions stored in a memory, causing a computer with the chip installed to perform the methods described above.

[0254] In an exemplary embodiment, another chip is provided, including: an input interface, an output interface, a processor, and a memory. The input interface, output interface, processor, and memory are connected through an internal connection path. The processor is used to execute code in the memory. When the code is executed, a computer with the chip installed performs the method described in the above embodiment.

[0255] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a computing device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive).

[0256] In this application, the terms "first," "second," etc., are used to distinguish identical or similar items that have essentially the same function. It should be understood that there is no logical or temporal dependency between "first," "second," and "nth," nor does it limit the quantity or order of execution. It should also be understood that although the following description uses the terms "first," "second," etc., to describe various elements, these elements should not be limited by the terms. These terms are merely used to distinguish one element from another.

[0257] It should also be understood that, in the various embodiments of this application, the sequence number of each process does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0258] In this application, the term "at least one" means one or more, and the term "multiple" means two or more. For example, multiple second devices means two or more second devices. The terms "system" and "network" are often used interchangeably herein.

[0259] It should be understood that the terminology used in the description of the various examples herein is for the purpose of describing particular examples only and is not intended to be limiting. As used in the description of the various examples and the appended claims, the singular forms “a” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise.

[0260] It should also be understood that the term "and / or" as used herein refers to and covers any and all possible combinations of one or more of the associated listed items. The term "and / or" describes an association between related objects, indicating that three relationships can exist; for example, A and / or B can represent: A alone, A and B simultaneously, or B alone. Additionally, the character " / " in this application generally indicates that the preceding and following related objects are in an "or" relationship.

[0261] It should also be understood that the terms “if” and “if” can be interpreted as meaning “when” or “upon”, or “in response to determination” or “in response to detection”. Similarly, depending on the context, the phrases “if determination…” or “if detection [the stated condition or event]” can be interpreted as meaning “when determination…”, or “in response to determination…”, or “when detection [the stated condition or event]” or “in response to detection [the stated condition or event]”.

[0262] The above description is merely an embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the principles of this application should be included within the protection scope of this application.

Claims

1. A method for generating a patch file, characterized in that, The method includes: Among the symbols included in the software patch source code, target symbols are identified, wherein the patch source code is code obtained by modifying the software source code, and the target symbols include patch variables and / or patch functions. If the target symbols include the patch functions, the target symbols also include functions necessary for effectiveness, associated functions of the functions necessary for effectiveness, and associated functions of the patch functions. Remove all symbols except the target symbol from the patch source code to obtain the abridged patch source code. The modified patch source code is compiled to obtain the patch file for the software.

2. The method according to claim 1, characterized in that, In the patch source code, the patch function and the patch variable have corresponding specified comment information; The process of identifying target symbols from the symbols included in the software patch source code includes: Among the symbols included in the software patch source code, the symbols that correspond to the specified comment information are identified as target symbols; For each symbol corresponding to the specified annotation information, if the symbol is a function, then the associated function of the symbol is determined as the target symbol, and the necessary function and the associated function of the necessary function are determined as the target symbol.

3. The method according to claim 2, characterized in that, The programming language of the patch source code is Go. The step of determining the association function of the symbol as the target symbol, and determining the effective necessary function and the association function of the effective necessary function as the target symbol, includes: The assertion function, anonymous function, and interface function in the associated functions of the symbol are identified as target symbols, and the function necessary for effectiveness, as well as the assertion function, anonymous function, and interface function in the associated functions of the function necessary for effectiveness, are identified as target symbols.

4. The method according to any one of claims 1-3, characterized in that, In the patch source code, if the patch function is an inline function of the first function, then the target symbol also includes the first function and inline functions of the first function in the patch source code other than the patch function.

5. The method according to any one of claims 1-4, characterized in that, The necessary functions for the activation include constructing the destructor.

6. A method for applying a patch file, characterized in that, The method includes: Obtain the software patch file; For the target function in the patch file, find the original function with the same function name as the target function in the original file of the software, wherein the target function is a function other than the function necessary for the effect to take effect; Add a jump instruction at the beginning of the original function in the original file, wherein the jump instruction is used to jump to execute the corresponding target function in the patch file when the original function is executed.

7. The method according to claim 6, characterized in that, Before adding the jump instruction at the beginning of the original function, the method further includes: Prevent the execution of the original function corresponding to each objective function; After adding jump instructions at the beginning of all original functions, the method further includes: Remove the block on execution of the original function corresponding to each objective function.

8. The method according to claim 6, characterized in that, Before adding the jump instruction at the beginning of the original function, the method further includes: Pause all coroutines in the process of the software; After adding jump instructions at the beginning of all original functions, the method further includes: Wake up all the aforementioned coroutines.

9. The method according to any one of claims 6-8, characterized in that, Adding a jump instruction at the beginning of the original function in the original file includes: In the original file, the first N bytes of the original function are replaced with the jump instruction, where N is the number of bytes in the jump instruction.

10. The method according to claim 9, characterized in that, The step of replacing the first N bytes of the original function with the jump instruction includes: If the address stored in the program counter (PC) register does not overlap with the address of the first N bytes of the original function in the original file, the first N bytes are replaced with the jump instruction.

11. A patch file generation apparatus, characterized in that, The device includes: A determination module is used to determine target symbols among the symbols included in the patch source code of the software, wherein the patch source code is code obtained by modifying the source code of the software, and the target symbol includes patch variables and / or patch functions. If the target symbol includes the patch function, the target symbol also includes an essential function for activation, an associated function of the essential function for activation, and an associated function of the patch function. The deletion module is used to delete symbols other than the target symbol from the patch source code to obtain the reduced patch source code. The compilation module is used to compile the reduced patch source code to obtain the patch file for the software.

12. The apparatus according to claim 11, characterized in that, In the patch source code, the patch function and the patch variable have corresponding specified comment information; The determining module is used for: Among the symbols included in the software patch source code, the symbols that correspond to the specified comment information are identified as target symbols; For each symbol corresponding to the specified annotation information, if the symbol is a function, then the associated function of the symbol is determined as the target symbol, and the necessary function and the associated function of the necessary function are determined as the target symbol.

13. The apparatus according to claim 11 or 12, characterized in that, In the patch source code, if the patch function is an inline function of the first function, then the target symbol also includes the first function and inline functions of the first function in the patch source code other than the patch function.

14. A device for applying a patch file, characterized in that, The device includes: The acquisition module is used to acquire software patch files; The search module is used to search for a source function with the same function name as the target function in the source file of the software for the target function in the patch file, wherein the target function is a function other than the function necessary for the effect to take effect; An add module is used to add a jump instruction at the beginning of the original function in the original file, wherein the jump instruction is used to jump to execute the corresponding target function in the patch file when the original function is executed.

15. The apparatus according to claim 14, characterized in that, Before adding the jump instruction at the beginning of the original function, the device further includes a management module for: Pause all coroutines in the process of the software; After adding jump instructions at the beginning of all original functions, all the coroutines are awakened.

16. The apparatus according to claim 15, characterized in that, The added module is used for: If the address stored in the program counter (PC) register does not overlap with the address of the first N bytes of the original function in the original file, the first N bytes are replaced with the jump instruction.

17. A computing device, characterized in that, The computing device includes a processor and memory; The processor of the computing device is configured to execute instructions stored in the memory of the at least one forwarding device to cause the computing device to perform the method as described in any one of claims 1-10.

18. A computer-readable storage medium, characterized in that, It includes computer program instructions, which, when executed by a computing device, cause the computing device to perform the method as described in any one of claims 1-10.

19. A computer program product containing instructions, characterized in that, When the instruction is executed by the computing device, the computing device performs the method as described in any one of claims 1-10.