IP Library Granted Patent US 9,342,285
Granted Patent B2
US 9,342,285 · App. 14/088,658 · Granted May 17, 2016

Method and apparatus for detecting code change

Inventor: Jun Li (Hangzhou, CN)
Assignee: Huawei Technologies Co., Ltd.
G06F8/48G06F8/67G06F8/68
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 9,342,285
App. No.
14/088,658
Granted
May 17, 2016
Kind
B2
Abstract

The present invention provides a method and an apparatus for detecting a code change. The method includes adding a tag to a function to be changed in a source code, and compiling the source code to acquire, according to the tag, position information and relocation information of the function to be changed in the compiled source code. In embodiments of the present invention, a tag is added to a function to be changed, a source code is compiled into a binary file, and position information and relocation information of the function to be changed in the binary file are acquired by using the tag, so that in subsequent operations, a hot patch file modifies, according to the position information and the relocation information, the function to be changed in software.

Claims (45)

1. A method implemented for executing computer instructions stored in a memory for detecting a code change, comprising:

adding a tag to a function to be changed in a source code, wherein the tag is used to locate the function to be changed in a binary file obtained after the source code is compiled, and wherein the tag comprises a code or a macro for extracting information, and the tag further comprises an external interface; and

compiling the source code into the binary file to acquire, according to the tag, position information and relocation information of the function to be changed in the binary file,

wherein acquiring, according to the tag, position information of the function to be changed in the binary file comprises:

executing the tag to acquire information of the function to be changed in the binary file, wherein the information of the function to be changed comprises a function name of the function to be changed in the binary file or a start address of the function to be changed in the binary file;

comparing the information with a symbol table in the binary file; and

acquiring, according to a comparison result, the position information of the function to be changed in the binary file.

2. The method according to claim 1 , wherein acquiring, according to the tag, relocation information of the function to be changed in the binary file comprises:

adding a compilation attribute to the function to be changed, wherein the added compilation attribute is used to store the function to be changed in an independent segment of the binary file; and

compiling, according to the compilation attribute, the source code into the binary file again to acquire the relocation information of the function to be changed in the binary file.

3. The method according to claim 1 , wherein comparing the information with the symbol table in the binary file, and acquiring, according to a comparison result, the position information of the function to be changed in the binary file comprises:

comparing the function name of the function to be changed in the binary file with the symbol table in the binary file to acquire the start address of the function to be changed in the binary file when the information is the function name of the function to be changed in the binary file;

comparing the start address of the function to be changed in the binary file with the symbol table in the binary file to acquire the function name of the function to be changed in the binary file when the information is the start address of the function to be changed in the binary file; and

using the function name and the start address of the function to be changed in the binary file as the position information of the function to be changed in the binary file.

4. The method according to claim 1 , wherein the tag is added to the function to be changed in the source code using the external interface.

5. An apparatus having executable instructions stored in a memory for detecting a code change, comprising:

a tag adding unit stored in the memory and configured to add a tag to a function to be changed in a source code, wherein the tag is used to locate the function to be changed in a binary file obtained after the source code is compiled, and wherein the tag is a code or a macro for extracting information, and the tag further comprises an external interface;

a compiling unit stored in the memory and configured to compile the source code with the tag added by the tag adding unit into the binary file; and

an information acquiring unit stored in the memory and configured to:

acquire information of the function to be changed in the binary file using the tag, wherein the information of the function to be changed in the binary file comprises a function name of the function to be changed in the binary file or a start address of the function to be changed in the binary file;

compare the information with a symbol table in the binary file; and

acquire, according to a comparison result, the position information of the function to be changed in the binary file.

6. The apparatus according to claim 5 , wherein the information acquiring unit is further configured to:

add a compilation attribute to the function to be changed, wherein the added compilation attribute is used to store the function to be changed in an independent segment of the binary file; and

compile, according to the compilation attribute, the source code into the binary file again to acquire the relocation information of the function to be changed in the binary file.

7. The apparatus according to claim 5 , wherein the information acquiring unit is further configured to:

compare the function name of the function to be changed in the binary file with the symbol table in the binary file to acquire the start address of the function to be changed in the binary file when the information acquired using the tag is the function name of the function to be changed in the binary file;

compare the start address of the function to be changed in the binary file with the symbol table in the binary file to acquire the function name of the function to be changed in the binary file when the information acquired using the tag is the start address of the function to be changed in the binary file; and

use the function name and the start address of the function to be changed in the binary file as the position information of the function to be changed in the binary file.

8. The apparatus according to claim 5 , wherein the tag is added to the function to be changed in the source code using the external interface.

9. A method implemented for executing computer instructions stored in a memory for detecting a code change, comprising:

adding a tag to a function to be changed in a source code, wherein the tag is used to locate the function to be changed in a binary file obtained after the source code is compiled, wherein the tag comprises a code or a macro for extracting information, and the tag further comprises an external interface, and wherein the tag is added to the function to be changed in the source code using the external interface; and

compiling the source code into the binary file to acquire, according to the tag, position information and relocation information of the function to be changed in the binary file,

wherein acquiring, according to the tag, position information of the function to be changed in the binary file comprises:

executing the tag to acquire information of the function to be changed in the binary file, wherein the information of the function to be changed comprises a function name of the function to be changed in the binary file or a start address of the function to be changed in the binary file;

comparing the information with a symbol table in the binary file; and

acquiring, according to a comparison result, the position information of the function to be changed in the binary file.

10. The method according to claim 9 , wherein acquiring, according to the tag, relocation information of the function to be changed in the binary file comprises:

adding a compilation attribute to the function to be changed, wherein the added compilation attribute is used to store the function to be changed in an independent segment of the binary file; and

compiling, according to the compilation attribute, the source code into the binary file again to acquire the relocation information of the function to be changed in the binary file.

11. The method according to claim 9 , wherein comparing the information with the symbol table in the binary file, and acquiring, according to a comparison result, the position information of the function to be changed in the binary file comprises:

comparing the function name of the function to be changed in the binary file with the symbol table in the binary file to acquire the start address of the function to be changed in the binary file when the information is the function name of the function to be changed in the binary file;

comparing the start address of the function to be changed in the binary file with the symbol table in the binary file to acquire the function name of the function to be changed in the

binary file when the information is the start address of the function to be changed in the binary file; and

using the function name and the start address of the function to be changed in the binary file as the position information of the function to be changed in the binary file.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Dec 5, 2013
From: LI, JUN
To: HUAWEI TECHNOLOGIES CO., LTD.
Reel/Frame 031725/0297 →
Priority Claims (1)
CN 2012 1 0504577 · Nov 30, 2012 · national
Continuity (2)
Continuation PCTCN2013074723 · Apr 25, 2013
Related Publication 20140157232A1 · Jun 5, 2014