CN108132799A - Interprocedual static program analysis information extracting method, device and equipment - Google Patents

Interprocedual static program analysis information extracting method, device and equipment Download PDF

Info

Publication number
CN108132799A
CN108132799A CN201711423522.2A CN201711423522A CN108132799A CN 108132799 A CN108132799 A CN 108132799A CN 201711423522 A CN201711423522 A CN 201711423522A CN 108132799 A CN108132799 A CN 108132799A
Authority
CN
China
Prior art keywords
function
instructions
call
information
llvm
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201711423522.2A
Other languages
Chinese (zh)
Other versions
CN108132799B (en
Inventor
衷璐洁
莫培弘
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Capital Normal University
Original Assignee
Capital Normal University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Capital Normal University filed Critical Capital Normal University
Priority to CN201711423522.2A priority Critical patent/CN108132799B/en
Publication of CN108132799A publication Critical patent/CN108132799A/en
Application granted granted Critical
Publication of CN108132799B publication Critical patent/CN108132799B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/75Structural analysis for program understanding

Abstract

The embodiment of the present invention provides a kind of interprocedual static program analysis information extracting method, device and equipment, wherein, this method includes:Traverse the instruction in LLVM IR files;Based on br instructions and ret instructions, extraction process internal program analysis information;Determine whether the instructions of the call in LLVM IR files are the relevant call instructions of function pointer;Wherein, if it is not, the information that then extraction direct function calls from call instructions;If so, store instructions and load instructions before being instructed according to call, the directional information of function pointer in extraction call instructions;After traversal, the information and the directional information of function pointer called based on the process internal program analysis information extracted and all direct functions, static program analysis information between generating process.So as to solve the problems, such as that function pointer directional information obtains not accurate enough in static program analysis.

Description

Interprocedual static program analysis information extracting method, device and equipment
Technical field
The present embodiments relate to field of computer technology more particularly to a kind of interprocedual static program analysis information extractions Method, apparatus and equipment.
Background technology
The complexity of modern software system is more and more prominent, and the scale of program is also increasing, it is difficult to be visually known journey The codimg logic structure of sequence.Information can reflect the program code logic in software systems in interprocedual information and process, Test, debugging and the maintenance of understanding and analysis, software to program, compiling optimization, location of mistake, program error (bug) lookup, Interprocedural data flow analysis, backtracking test etc. suffer from being widely applied in field of software engineering, complete interprocedual information and Information preferably auxiliary program verification and program debugging in process improves the quality of program analysis.
In the prior art, Source Insight are the program editor and code browser of a project guide, are had The programs analysis information visuallization such as reference tree, Similar integral figure and call-tree is supported, and can be with generating function calling figure. CodeViz is a C source code static analysis tools, visual function call graph is generated for c program, by beating benefit to GCC Fourth, when compiling source file, dump goes out function call information, then extract function call information by perl script.Cflow is one A C source codes Program Static Analysis tool, it can generate two kinds of function call graphs of forward and backward, directly source code is divided Analysis generates the external reference set of the function call information of a c program.CallTree is a C source code static calls tree life It grows up to be a useful person, by analyzing C source codes, extracts function call information.These methods and techniques cannot obtain the letter of function pointer direction Breath, existence function recalls information obtain the problem of incomplete:Source Insight and CodeViz cannot obtain function pointer The information of direction;CallTree cannot obtain the real information of function pointer direction;CodeViz, CallTree and Cflow are not Library function call information can be handled perfectly.
Invention content
The embodiment of the present invention provides a kind of interprocedual static program analysis information extracting method, device and equipment, to solve Certainly function pointer directional information obtains the problem of not accurate enough in static program analysis.
First aspect of the embodiment of the present invention provides a kind of interprocedual static program analysis information extracting method, this method packet It includes:
Traverse the instruction in LLVM IR files;
It is instructed based on the br instructions in the LLVM IR files and ret, from the LLVM IR files in extraction process Program analyzes information;
Determine whether the instructions of the call in the LLVM IR files are the relevant call instructions of function pointer;
Wherein, if it is not, the information that then extraction direct function calls from call instructions;
If so, the store instructions and load before being instructed according to the call instruct, extract in the call instructions The directional information of function pointer;
After traversal, based on the process internal program analysis information extracted and the letter of all direct functions calling The directional information of breath and function pointer, static program analysis information between generating process.
Optionally, the information that extraction direct function calls in the instruction from the call, including:
The title of function during the call is instructed is matched with pre-stored library function title;
Wherein, if matching, the library function for extracting the call instructions directly invokes information;
If mismatching, the generic function for extracting the call instructions directly invokes information, and wherein generic function is directly adjusted With directly invoking for other functions referred to other than library function.
Optionally, the store instructions before the instruction according to the call and load are instructed, and extract the call instructions The directional information of middle function pointer, including:
Store instructions and load instructions before being instructed according to the call, determine function pointer in the call instructions The function of direction, and determine whether the function is library function;
Wherein, if so, extracting the name information of the function pointed by the function pointer of call instruction and described Function is the information that library function directly invokes;
If it is not, then extract the name information of the function pointed by the function pointer of the call instructions and the letter The information that number is directly invoked for generic function.
Optionally, the br instructions and ret instructions based in the LLVM IR files, from the LLVM IR files Extraction process internal program analyzes information, including:
Based on the br instructions in the LLVM IR files and ret instructions, the base of function in the LLVM IR files is obtained This block, extraction process internal program analyzes information in the basic block of function from the LLVM IR files.
Second aspect of the embodiment of the present invention provides a kind of interprocedual static program analysis information extracting device, including:
Spider module, for traversing the instruction in LLVM IR files;
First extraction module, for being instructed based on the br instructions in the LLVM IR files and ret, from the LLVM IR Extraction process internal program analyzes information in file;
Determining module, for determining whether the instructions of the call in the LLVM IR files are the relevant call of function pointer Instruction;
Second extraction module, for when call instructions are not function pointer relevant call instructions, from described The information that extraction direct function calls in call instructions;
Third extraction module, for when call instructions are function pointer relevant call instructions, according to described The directional information of function pointer in the call instructions is extracted in store instructions and load instructions before call instructions;
Generation module, for after traversal, based on the process internal program analysis information extracted and it is all directly The information of function call and the directional information of function pointer, static program analysis information between generating process.
Optionally, second extraction module, including:
Matched sub-block, for the title of the function in call instructions to be carried out with pre-stored library function title Matching;
First extracting sub-module, the library function in matching, extracting the call instructions directly invoke information;
Second extracting sub-module, the generic function for when mismatching, taking the call instructions directly invoke information, Middle generic function, which directly invokes, refers to directly invoking for other functions other than library function.
Optionally, the third extraction module, is specifically used for
Store instructions and load instructions before being instructed according to the call, determine function pointer in the call instructions The function of direction, and determine whether the function is library function;
Wherein, if so, extracting the name information of the function pointed by the function pointer of call instruction and described Function is the information that library function directly invokes;
If it is not, then extract the name information of the function pointed by the function pointer of the call instructions and the letter The information that number is directly invoked for generic function.
Optionally, first extraction module, is specifically used for:
Based on the br instructions in the LLVM IR files and ret instructions, the base of function in the LLVM IR files is obtained This block, extraction process internal program analyzes information in the basic block of function from the LLVM IR files.
The third aspect of the embodiment of the present invention provides a kind of program analytical equipment, including:
Processor:
For storing the memory of the processor-executable instruction;
When the processor performs the executable instruction, following method is performed:
Traverse the instruction in LLVM IR files;
It is instructed based on the br instructions in the LLVM IR files and ret, from the LLVM IR files in extraction process Program analyzes information;
Determine whether the instructions of the call in the LLVM IR files are the relevant call instructions of function pointer;
Wherein, if it is not, the information that then extraction direct function calls from call instructions;
If so, the store instructions and load before being instructed according to the call instruct, extract in the call instructions The directional information of function pointer;
After traversal, based on the process internal program analysis information extracted and the letter of all direct functions calling The directional information of breath and function pointer, static program analysis information between generating process.
Fourth aspect of the embodiment of the present invention provides a kind of computer readable storage medium, including instruction, when described instruction exists When being run on the computer, the computer performs following method:
Traverse the instruction in LLVM IR files;
It is instructed based on the br instructions in the LLVM IR files and ret, from the LLVM IR files in extraction process Program analyzes information;
Determine whether the instructions of the call in the LLVM IR files are the relevant call instructions of function pointer;
Wherein, if it is not, the information that then extraction direct function calls from call instructions;
If so, the store instructions and load before being instructed according to the call instruct, extract in the call instructions The directional information of function pointer;
After traversal, based on the process internal program analysis information extracted and the letter of all direct functions calling The directional information of breath and function pointer, static program analysis information between generating process.
In embodiments of the present invention, by traversing the instruction in LLVM IR files;Referred to based on the br in LLVM IR files It enables and ret is instructed, extraction process internal program analyzes information from LLVM IR files;Determine the call instructions in LLVM IR files Whether it is the relevant call instructions of function pointer;Wherein, if it is not, the letter that then extraction direct function calls from call instructions Breath;If so, store instructions and load instructions before being instructed according to call, the direction of function pointer in extraction call instructions Information;After traversal, based on extract process internal program analysis information and all direct functions call information and The directional information of function pointer, static program analysis information between generating process.Refer to so as to solve function in static program analysis Needle directional information obtains the inaccurate and incomplete problem of library function call information processing.
Description of the drawings
In order to illustrate more clearly about the embodiment of the present invention or technical scheme of the prior art, to embodiment or will show below There is attached drawing needed in technology description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this Some embodiments of invention, for those of ordinary skill in the art, without having to pay creative labor, may be used also To obtain other attached drawings according to these attached drawings.
Fig. 1 is a kind of flow chart of interprocedual static program analysis information extracting method provided in an embodiment of the present invention;
Fig. 2 is the execution method flow diagram of step 104 provided in an embodiment of the present invention;
Fig. 3 is a kind of structural representation of interprocedual static program analysis information extracting device provided in an embodiment of the present invention Figure;
Fig. 4 is the structure diagram of the second extraction module 14 provided in an embodiment of the present invention.
Specific embodiment
Below in conjunction with the attached drawing in the embodiment of the present invention, the technical solution in the embodiment of the present invention is carried out clear, complete Site preparation describes, it is clear that described embodiment is only part of the embodiment of the present invention, instead of all the embodiments.It is based on Embodiment in the present invention, those of ordinary skill in the art are obtained every other without making creative work Embodiment shall fall within the protection scope of the present invention.
The term " comprising " and " having " of description and claims of this specification and their any deformation, it is intended that Be to cover it is non-exclusive include, for example, the device of process or structure for containing series of steps is not necessarily limited to clearly arrange It is that those structures or step for going out but may include are not listed clearly or for the intrinsic other steps of these processes or device Rapid or structure.
In order to describe it is clear first below to involved in the embodiment of the present invention to keyword explain:
It is analyzed in process:Refer to by process in program or the analysis as unit of function;
Interprocedural analysis:Refer to the analysis using Whole Process as range, include process or function all in program;
LLVM:English full name is Low Level Virtual Machine, and Chinese is low layer virtual machine
LLVM IR:English full name is LLVM Intermediate Representation, and Chinese meaning is in LLVM Between represent.
Fig. 1 is a kind of flow chart of interprocedual static program analysis information extracting method provided in an embodiment of the present invention, should Method can perform (hereinafter referred to as extraction element) by a kind of interprocedual static program analysis information extracting device, extraction dress Put installation in a computer.As shown in Figure 1, this method includes:
Instruction in step 101, traversal LLVM IR files.
In the present embodiment, LLVM IR are the intermediate representations of LLVM, are an important components of LLVM compiler frameworks. Comprising abundant program analysis information in LLVM IR, it is made of information such as module, global variable, function and connection types.Its In, in these program informations comprising information (information of basic block in function and function) in process and interprocedual information (in process The directional information of information, function call and function pointer).LLVM IR files are made of LLVM instructions.LLVM instructions are included but not It is confined to:Termination instruction, br instructions, switch instructions.
Step 102 is instructed based on the br instructions in the LLVM IR files and ret, is extracted from the LLVMIR files Process internal program analyzes information.
The present embodiment is using LLVM IR files as input, the extraction of static program analysis information between implementation process.Interprocedual is quiet The extraction of state program analysis information is based on the extraction of process internal program analysis information.Refer in function in process, each function Be made of one or several basic blocks, a basic block is made of one or several sentences, in LLVM IR with The information of basic block in the terminations such as switch, ret, br instruction differentiation process.
When performing the operation that traversal LLVM IR documents enable, first by the basic block language of function in LLVM IR files Sentence is converted to the instruction in LLVM, each basic block is made of a plurality of LLVM instructions, and is instructed and divided with terminations such as br, ret Basic block.The entrance basic block (entry basic blocks) of function is instructed with br to be terminated and indicates successor basic blocks by label Number and title, the corresponding successor basic blocks of label instructions in the present embodiment, are deposited in the br instructions of entry basic blocks It is instructed in two label, i.e., there are two subsequent basic blocks.The extraction of process internal program analysis information is to pass through traversal Each function in LLVMIR files obtains the termination instruction (such as br, ret etc.) of each basic block, according to the end of basic block The information of information extraction successor basic blocks in knot instruction, extraction process internal program analyzes information from the basic block of function.Tool Body, the extracting method of process internal program analysis information may refer to the prior art in the present embodiment, not repeat herein.
Step 103 determines whether the call instructions in the LLVM IR files are the relevant call instructions of function pointer, Wherein, if it is not, then performing step 104, otherwise performing step 105.
Optionally, the present embodiment determines whether call instructions are function pointer phases according to the specific form type that call is instructed The call instructions of pass, for example, the call of non-functional pointer related (i.e. direct function calls) is instructed, form type generally can be with It is expressed as:Call...@function names (parameter list), the call instructions of function pointer correlation (i.e. indirect function call), form shape Formula can generally be expressed as call%1 (parameter list), wherein, %1 represents temporary variable, therefore, passes through the specific of call instructions Form type, it may be determined that call instructions include direct function calling or indirect function call.Certainly it is only for examples Illustrate rather than to unique restriction of the invention.
Step 104, the information that extraction direct function calls from call instructions.
Specifically, Fig. 2 is the execution method flow diagram of step 104 provided in an embodiment of the present invention, as shown in Fig. 2, step 104 include following sub-step:
Step 201 matches the title of the function in call instructions with pre-stored library function title.
If step 202, matching, the library function for extracting the call instructions directly invokes information.
If step 203 mismatches, the generic function for extracting the call instructions directly invokes information, wherein general letter Number, which directly invokes, refers to directly invoking for other functions other than library function.
Optionally, during traversal LLVM IR documents enable, if the call instructions traversed are non-functional pointer The call instructions of related (i.e. direct function calls), then title and the pre-stored library function of the function during the call is instructed Title matched, determine to have carried out library function in call instructions and directly invoke if matching, extraction obtains the call and refers to The library function of order directly invokes information (such as the title of library function, but be not limited only to the title of library function), true if mismatching Function call in fixed call instructions is called for generic function, at this point, the generic function that extraction obtains call instructions is directly adjusted With information (such as the title of generic function, but be not limited only to the title of library function), wherein generic function, which directly invokes, refers to library Other functions other than function directly invoke.
For example, if the form of call instructions is call...@functions a (parameter list), wherein function a is library function, then extracts Call instructs the information for directly invoking library function a.Certainly unique restriction it is only for illustrating rather than to the present invention.
Step 105 is instructed according to the store instructions before call instructions and load, is extracted in the call instructions The directional information of function pointer.
In actual scene, if the call instructions that traversal obtains are the relevant call instructions of function pointer, then usually exist All include instructing associated store instruction and load instructions with call before call instructions, for example, relevant instruction type can be with It represents as follows:
Store...@actual functions name B ...@function pointer names A
%1=load... ...@function pointer names A
Call%1 (parameter list)
Certainly the merely illustrative explanation of instruction type here rather than unique restriction to the present invention.Therefore, when traversal obtains When the call instructions obtained are instructed for the relevant call of function pointer, the present embodiment can be by searching in the instruction before call Associated store instructions and load is instructed to instruct with call, instructed, determined according to the store instructions and load of searching acquisition Function in call instructions pointed by function pointer, so as to obtain the directional information of function pointer in call instructions (for example, being directed toward Function title).
Optionally, after determining the function in call instructions pointed by function pointer, the present embodiment can also further be sentenced Function pointed by disconnected function pointer is library function or generic function, when the function that function pointer is directed toward is library function, is carried The name information and the function for taking the function pointed by the function pointer that call instructs are the information that directly invokes of library function, When the function that function pointer is directed toward is generic function, the title letter of the function pointed by the function pointer of extraction call instructions Breath and the function are the information that generic function directly invokes.
Step 106, after traversal, based on the process internal program analysis information and all direct functions extracted The information of calling and the directional information of function pointer, static program analysis information between generating process.
In the present embodiment based on extract process internal program analysis information and all direct functions call information and The directional information of function pointer, the method for static program analysis information may refer to the prior art between generating process, herein not It repeats again.
In the present embodiment, by traversing the instruction in LLVM IR files;Based in LLVM IR files br instruction and Ret is instructed, and extraction process internal program analyzes information from LLVM IR files;Determine in LLVM IR files call instruction whether It is the relevant call instructions of function pointer;Wherein, if it is not, the information that then extraction direct function calls from call instructions;If Be, then, store instructions and load instructions before being instructed according to call, the directional information of function pointer in extraction call instructions; After traversal, the information and function called based on the process internal program analysis information extracted and all direct functions The directional information of pointer, static program analysis information between generating process.Refer to so as to solve function pointer in static program analysis To acquisition of information inaccuracy and the incomplete problem of library function call information processing.
Fig. 3 is a kind of structural representation of interprocedual static program analysis information extracting device provided in an embodiment of the present invention Figure, as shown in figure 3, the device includes:
Spider module 11, for traversing the instruction in LLVM IR files;
First extraction module 12, for being instructed based on the br instructions in the LLVM IR files and ret, from the LLVM Extraction process internal program analyzes information in IR files;
Determining module 13, for determining whether the instructions of the call in the LLVM IR files are that function pointer is relevant Call is instructed;
Second extraction module 14, for when call instructions are not function pointer relevant call instructions, from described The information that extraction direct function calls in call instructions;
Third extraction module 15, for when call instructions are function pointer relevant call instructions, according to described The directional information of function pointer in the call instructions is extracted in store instructions and load instructions before call instructions;
Generation module 16, for after traversal, based on the process internal program analysis information extracted and all straight Connect the information of function call and the directional information of function pointer, static program analysis information between generating process.
Optionally, the third extraction module 15, is specifically used for
Store instructions and load instructions before being instructed according to the call, determine function pointer in the call instructions The function of direction, and determine whether the function is library function;
Wherein, if so, extracting the name information of the function pointed by the function pointer of call instruction and described Function is the information that library function directly invokes;
If it is not, then extract the name information of the function pointed by the function pointer of the call instructions and the letter The information that number is directly invoked for generic function.
Optionally, first extraction module 12, is specifically used for:
Based on the br instructions in the LLVM IR files and ret instructions, the base of function in the LLVM IR files is obtained This block, extraction process internal program analyzes information in the basic block of function from the LLVM IR files.
Interprocedual static program analysis information extracting device provided in this embodiment can be used in performing the side of Fig. 1 embodiments Method, specific executive mode is similar with advantageous effect, repeats no more herein.
Fig. 4 is the structure diagram of the second extraction module 14 provided in an embodiment of the present invention, as shown in figure 4, implementing in Fig. 3 On the basis of example, the second extraction module 14 includes:
Matched sub-block 141, for title and the pre-stored library function title of the function during the call is instructed It is matched;
First extracting sub-module 142, the library function in matching, extracting the call instructions directly invoke information;
Second extracting sub-module 143, the generic function for when mismatching, taking the call instructions directly invoke letter Breath, wherein generic function, which directly invokes, refers to directly invoking for other functions other than library function.
Interprocedual static program analysis information extracting device provided in this embodiment can be used in performing the side of Fig. 2 embodiments Method, specific executive mode is similar with advantageous effect, repeats no more herein.
The embodiment of the present invention also provides a kind of program analytical equipment, including:
Processor:
For storing the memory of the processor-executable instruction;
When the processor performs the executable instruction, following method is performed:
Traverse the instruction in LLVM IR files;
It is instructed based on the br instructions in the LLVM IR files and ret, from the LLVM IR files in extraction process Program analyzes information;
Determine whether the instructions of the call in the LLVM IR files are the relevant call instructions of function pointer;
Wherein, if it is not, the information that then extraction direct function calls from call instructions;
If so, the store instructions and load before being instructed according to the call instruct, extract in the call instructions The directional information of function pointer;
After traversal, based on the process internal program analysis information extracted and the letter of all direct functions calling The directional information of breath and function pointer, static program analysis information between generating process.
The embodiment of the present invention provides a kind of computer readable storage medium, including instruction, when described instruction is in the calculating When being run on machine, the computer performs following method:
Traverse the instruction in LLVM IR files;
It is instructed based on the br instructions in the LLVM IR files and ret, from the LLVM IR files in extraction process Program analyzes information;
Determine whether the instructions of the call in the LLVM IR files are the relevant call instructions of function pointer;
Wherein, if it is not, the information that then extraction direct function calls from call instructions;
If so, the store instructions and load before being instructed according to the call instruct, extract in the call instructions The directional information of function pointer;
After traversal, based on the process internal program analysis information extracted and the letter of all direct functions calling The directional information of breath and function pointer, static program analysis information between generating process.
It is last it should be noted that one of ordinary skill in the art will appreciate that whole in above-described embodiment method or Part flow is that relevant hardware can be instructed to complete by computer program, and the program can be stored in a computer In readable storage medium storing program for executing, the program is when being executed, it may include such as the flow of the embodiment of above-mentioned each method.Wherein, it is described to deposit Storage media can be disk, CD, read-only memory (ROM) or random access memory (RAM) etc..
Each functional unit in the embodiment of the present invention can be integrated in a processing module or each unit Individually be physically present, can also two or more units be integrated in a module.Above-mentioned integrated module both can be with It is realized, can also be realized in the form of software function module in the form of hardware.If the integrated module is with software The form of function module realizes, and is independent product and sells or computer-readable deposited in use, one can also be stored in In storage media.Storage medium mentioned above can be read-only memory, disk or CD etc..
The above embodiments are only used to illustrate the technical solution of the present invention., rather than its limitations;Although with reference to aforementioned each reality Example is applied the present invention is described in detail, it will be understood by those of ordinary skill in the art that:It still can be to aforementioned each Technical solution recorded in embodiment modifies and either carries out equivalent replacement to which part or all technical features;And These modifications are replaced, the range for various embodiments of the present invention technical solution that it does not separate the essence of the corresponding technical solution.

Claims (10)

1. a kind of interprocedual static program analysis information extracting method, which is characterized in that including:
Traverse the instruction in LLVM IR files;
Based on the br instructions in the LLVM IR files and ret instructions, the extraction process internal program from the LLVM IR files Analyze information;
Determine whether the instructions of the call in the LLVM IR files are the relevant call instructions of function pointer;
Wherein, if it is not, the information that then extraction direct function calls from call instructions;
If so, the store instructions and load before being instructed according to the call instruct, function in the call instructions is extracted The directional information of pointer;
After traversal, based on extract process internal program analysis information and all direct functions call information and The directional information of function pointer, static program analysis information between generating process.
2. according to the method described in claim 1, it is characterized in that, extraction direct function calls in the instruction from the call Information, including:
The title of function during the call is instructed is matched with pre-stored library function title;
Wherein, if matching, the library function for extracting the call instructions directly invokes information;
If mismatching, the generic function for extracting the call instructions directly invokes information, and wherein generic function, which directly invokes, is Refer to directly invoking for other functions other than library function.
3. according to the method described in claim 1, it is characterized in that, the store before the instruction according to the call is instructed And load is instructed, and extracts the directional information of function pointer in the call instructions, including:
Store instructions and load instructions before being instructed according to the call determine that function pointer is directed toward in the call instructions Function, and determine the function whether be library function;
Wherein, if so, extracting the name information of the function pointed by the function pointer of the call instructions and the function The information directly invoked for library function;
If it is not, then extracting the name information of the function pointed by the function pointer of call instruction and the function is The information that generic function directly invokes.
4. method according to any one of claim 1-3, which is characterized in that described based in the LLVM IR files Br instruction and ret instruction, from the LLVM IR files extraction process internal program analyze information, including:
Based on the br instructions in the LLVM IR files and ret instructions, the basic block of function in the LLVM IR files is obtained, Extraction process internal program analyzes information in the basic block of function from the LLVM IR files.
5. a kind of interprocedual static program analysis information extracting device, which is characterized in that including:
Spider module, for traversing the instruction in LLVM IR files;
First extraction module, for being instructed based on the br instructions in the LLVM IR files and ret, from the LLVM IR files Middle extraction process internal program analyzes information;
Determining module, for determining whether the instructions of the call in the LLVM IR files are the relevant call instructions of function pointer;
Second extraction module, for when call instructions are not that the relevant call of function pointer is instructed, referring to from the call The information that direct function calls is extracted in order;
Third extraction module, for when call instructions are that the relevant call of function pointer is instructed, being referred to according to the call The directional information of function pointer in the call instructions is extracted in store instructions and load instructions before order;
Generation module, for after traversal, information and all direct functions to be analyzed based on the process internal program extracted The information of calling and the directional information of function pointer, static program analysis information between generating process.
6. device according to claim 5, which is characterized in that second extraction module, including:
Matched sub-block carries out for title and the pre-stored library function title of the function during the call is instructed Match;
First extracting sub-module, the library function in matching, extracting the call instructions directly invoke information;
Second extracting sub-module, the generic function for when mismatching, taking the call instructions directly invokes information, wherein one As function directly invoke and refer to directly invoking for other functions other than library function.
7. device according to claim 5, which is characterized in that the third extraction module is specifically used for
Store instructions and load instructions before being instructed according to the call determine that function pointer is directed toward in the call instructions Function, and determine the function whether be library function;
Wherein, if so, extracting the name information of the function pointed by the function pointer of the call instructions and the function The information directly invoked for library function;
If it is not, then extracting the name information of the function pointed by the function pointer of call instruction and the function is The information that generic function directly invokes.
8. according to the device described in any one of claim 5-7, which is characterized in that first extraction module is specifically used for:
Based on the br instructions in the LLVM IR files and ret instructions, the basic block of function in the LLVM IR files is obtained, Extraction process internal program analyzes information in the basic block of function from the LLVM IR files.
9. a kind of program analytical equipment, which is characterized in that including:
Processor:
For storing the memory of the processor-executable instruction;
When the processor performs the executable instruction, following method is performed:
Traverse the instruction in LLVM IR files;
Based on the br instructions in the LLVM IR files and ret instructions, the extraction process internal program from the LLVM IR files Analyze information;
Determine whether the instructions of the call in the LLVM IR files are the relevant call instructions of function pointer;
Wherein, if it is not, the information that then extraction direct function calls from call instructions;
If so, the store instructions and load before being instructed according to the call instruct, function in the call instructions is extracted The directional information of pointer;
After traversal, based on extract process internal program analysis information and all direct functions call information and The directional information of function pointer, static program analysis information between generating process.
10. a kind of computer readable storage medium, including instruction, when described instruction on the computer when running, the meter Calculation machine performs following method:
Traverse the instruction in LLVM IR files;
Based on the br instructions in the LLVM IR files and ret instructions, the extraction process internal program from the LLVM IR files Analyze information;
Determine whether the instructions of the call in the LLVM IR files are the relevant call instructions of function pointer;
Wherein, if it is not, the information that then extraction direct function calls from call instructions;
If so, the store instructions and load before being instructed according to the call instruct, function in the call instructions is extracted The directional information of pointer;
After traversal, based on extract process internal program analysis information and all direct functions call information and The directional information of function pointer, static program analysis information between generating process.
CN201711423522.2A 2017-12-25 2017-12-25 Inter-process static program analysis information extraction method, device and equipment Active CN108132799B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711423522.2A CN108132799B (en) 2017-12-25 2017-12-25 Inter-process static program analysis information extraction method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711423522.2A CN108132799B (en) 2017-12-25 2017-12-25 Inter-process static program analysis information extraction method, device and equipment

Publications (2)

Publication Number Publication Date
CN108132799A true CN108132799A (en) 2018-06-08
CN108132799B CN108132799B (en) 2021-03-16

Family

ID=62392404

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711423522.2A Active CN108132799B (en) 2017-12-25 2017-12-25 Inter-process static program analysis information extraction method, device and equipment

Country Status (1)

Country Link
CN (1) CN108132799B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109933365A (en) * 2018-12-28 2019-06-25 蜂巢能源科技有限公司 A kind of generation method and device of function call tree
CN112100059A (en) * 2020-08-20 2020-12-18 浙江大学 C language pointer type analysis method

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080046870A1 (en) * 2006-08-15 2008-02-21 International Business Machines Corporation Compile time evaluation of library functions
CN104331368A (en) * 2014-11-18 2015-02-04 合肥康捷信息科技有限公司 Method for performing static analysis on C++ virtual function call upon cfg (configuration) files
US9390260B2 (en) * 2014-06-09 2016-07-12 Lehigh University Methods for enforcing control flow of a computer program
CN106599516A (en) * 2016-12-30 2017-04-26 北京航天测控技术有限公司 Method and device for automatically generating test vectors based on circuit board

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080046870A1 (en) * 2006-08-15 2008-02-21 International Business Machines Corporation Compile time evaluation of library functions
US9390260B2 (en) * 2014-06-09 2016-07-12 Lehigh University Methods for enforcing control flow of a computer program
CN104331368A (en) * 2014-11-18 2015-02-04 合肥康捷信息科技有限公司 Method for performing static analysis on C++ virtual function call upon cfg (configuration) files
CN106599516A (en) * 2016-12-30 2017-04-26 北京航天测控技术有限公司 Method and device for automatically generating test vectors based on circuit board

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
王维明: "基于编译器的内核控制流程图获取方法研究", 《中国优秀硕士学位论文全文数据库(电子期刊)信息科技辑》 *
雷涛: "可执行程序的反编译", 《中国优秀硕士学位论文全文数据库(电子期刊)信息科技辑》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109933365A (en) * 2018-12-28 2019-06-25 蜂巢能源科技有限公司 A kind of generation method and device of function call tree
CN109933365B (en) * 2018-12-28 2022-08-19 蜂巢能源科技有限公司 Method and device for generating function call tree
CN112100059A (en) * 2020-08-20 2020-12-18 浙江大学 C language pointer type analysis method
CN112100059B (en) * 2020-08-20 2021-09-14 浙江大学 C language pointer type analysis method

Also Published As

Publication number Publication date
CN108132799B (en) 2021-03-16

Similar Documents

Publication Publication Date Title
CN110059009B (en) Method and apparatus for testing code files
US8966449B2 (en) Test case pattern matching
US10303467B2 (en) Target typing-dependent combinatorial code analysis
CN110543421A (en) Unit test automatic execution method based on test case automatic generation algorithm
Troya et al. Towards systematic mutations for and with ATL model transformations
CN103077064A (en) Method and interpretation device for analyzing and executing program language
CN108062474B (en) File detection method and device
CN105512021A (en) Method and device for Diff analysis used for software testing
CN108563561B (en) Program implicit constraint extraction method and system
CN114911711A (en) Code defect analysis method and device, electronic equipment and storage medium
CN109388573A (en) A kind of driving program Runtime error checking method and system of the interruption that nothing is failed to report
CN108132799A (en) Interprocedual static program analysis information extracting method, device and equipment
KR102013657B1 (en) Apparatus for statically analyzing assembly code including assoxiated multi files
US20150020051A1 (en) Method and apparatus for automated conversion of software applications
Hayashi et al. Search-based refactoring detection from source code revisions
De Lucia et al. ePadEvo: A tool for the detection of behavioral design patterns
CN115629762A (en) JSON data processing method and device, electronic equipment and storage medium
CN111666216B (en) Intelligent contract analysis method and device
CN110457046B (en) Disassembles method, disassembles device, storage medium and disassembles terminal for hybrid instruction set programs
CN114125342A (en) Emergency operation recording method and device
JP6116983B2 (en) Entry point extraction device
CN113282495A (en) Java software fault positioning method based on track monitoring
Nahar et al. SSTF: A novel automated test generation framework using software semantics and syntax
Feng et al. DOC2DIAL: A framework for dialogue composition grounded in business documents
Duarte et al. Extraction of probabilistic behaviour models based on contexts

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant