CN111625279A - Dynamic and static fusion binary translation method and system based on dynamic link library - Google Patents

Dynamic and static fusion binary translation method and system based on dynamic link library Download PDF

Info

Publication number
CN111625279A
CN111625279A CN202010345949.0A CN202010345949A CN111625279A CN 111625279 A CN111625279 A CN 111625279A CN 202010345949 A CN202010345949 A CN 202010345949A CN 111625279 A CN111625279 A CN 111625279A
Authority
CN
China
Prior art keywords
function
dynamic
static
translation
program
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.)
Pending
Application number
CN202010345949.0A
Other languages
Chinese (zh)
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.)
Information Engineering University of PLA Strategic Support Force
Original Assignee
Information Engineering University of PLA Strategic Support Force
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 Information Engineering University of PLA Strategic Support Force filed Critical Information Engineering University of PLA Strategic Support Force
Priority to CN202010345949.0A priority Critical patent/CN111625279A/en
Publication of CN111625279A publication Critical patent/CN111625279A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/76Adapting program code to run in a different environment; Porting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The invention belongs to the field of software transplantation, and particularly relates to a dynamic and static fusion binary translation method and system based on a dynamic link library, wherein a program is divided by taking a function as a unit, and if the function is a third-party library function, the program is executed in a local library replacement mode; if the function has an indirect jump branch instruction, the function is placed in a dynamic translator to be translated and executed, if the function does not exist, the function is statically translated by taking a basic block as a unit, relocation information after translation of the function is recorded, and a function relocation information table is generated; analyzing and optimizing the translated target code according to the static analysis information and the relocation information, and generating a dynamic link library for calling the target program in the dynamic execution process; and when the dynamic execution is carried out, the optimized function is preferentially executed according to the relocation information table and the dynamic link library. The invention fully utilizes the advantage of offline optimization of static binary translation, puts the codes to be translated and optimized during dynamic execution in static execution, reduces the translation overhead and improves the execution efficiency.

Description

Dynamic and static fusion binary translation method and system based on dynamic link library
Technical Field
The invention belongs to the technical field of software transplantation, and particularly relates to a dynamic and static fusion binary translation method and system based on a dynamic link library.
Background
The processor is a core component in the modern computer architecture, and the design and manufacture technology of the processor is the core technology of the whole information industry. Aiming at different functional requirements and application scenes, a large number of processor architectures including x86, Alpha, PowerPC, IA-64, ARM, MIPS, Shenwei, Loongson and the like are developed. Different processor architecture designs adopt different instruction sets, which brings software compatibility problem, that is, a binary executable program generated by a certain processor cannot be directly run on other processors with incompatible instruction sets. In which case binary translation techniques are used. Binary translation (binary translation) techniques may translate a sequence of instructions on one Instruction Set Architecture (ISA) into a sequence of instructions on another Instruction set architecture. At present, binary translation technology has been widely applied to the fields of software security analysis, program behavior analysis, software reverse engineering, system virtualization, cloud computing, and the like. In terms of operation flow, binary translation is a special compiling technology, and the input of the binary translation technology is a high-level language different from the traditional compiling technology, and the input of the binary translation technology is a binary program. According to the difference of the binary translator system architecture and the implementation mode, the binary translation system can be roughly divided into three types, namely a static binary translation system, a dynamic binary translation system and a dynamic and static fused binary translation system. The method aims to comprehensively utilize the advantages of static binary translation and dynamic binary translation and avoid respective disadvantages so as to achieve better execution efficiency and wider application range, and can be divided into a static translation system taking a dynamic as an auxiliary system and a dynamic translation system taking a static as an auxiliary system according to a combination mode.
The static translator taking the dynamic state as the auxiliary is mainly used for solving the problem of code discovery which cannot be solved by the static translator, and the specific implementation is that when a program is executed, the determination of an indirect jump target address is completed by calling an interpretation type or dynamic binary translator. The dynamic translator taking the static state as the auxiliary is mainly used for analyzing and processing codes of a binary program of a source platform in advance, and the quality of the generated codes is higher by using a higher-level analysis technology and an optimization means, and meanwhile, the running cost is not increased, and the better running efficiency is achieved. However, in the existing dynamic and static combined binary translation, due to the limitation of various factors in the execution process of the dynamic and static parts, the proportion of static execution is about 20%, the optimization characteristics of the static execution cannot be fully utilized, and the translation execution efficiency and the translation overhead are influenced.
Disclosure of Invention
Therefore, the dynamic and static fusion binary translation method and system based on the dynamic link library fully utilize the advantage that the static binary translation can be optimized in an off-line mode, put codes needing translation and optimization during dynamic execution in static execution, reduce the translation and optimization overhead during program operation, and improve the execution efficiency of a translated target program.
According to the design scheme provided by the invention, the dynamic and static fusion binary translation method based on the dynamic link library comprises the following contents:
dividing a program by taking a function as a unit, and determining a function execution process according to function characteristics, wherein the method specifically comprises the following steps: judging whether the function is a third-party library function, if so, replacing and executing the function by adopting a local same library function, otherwise, judging whether an indirect jump branch instruction exists in the function, if not, translating a source machine code into a target code by taking a basic block as a unit in a static translation stage, and if so, putting the function in a dynamic translation execution stage for execution;
in the static translation stage, a target executable program is statically analyzed, and a dynamic link library used for calling the target program in the dynamic execution process is generated; collecting relocation information of the function after the static translation, and generating a relocation information table;
and a dynamic translation executing stage, which is used for dynamically executing the function after the translation optimization in the static translation stage according to the relocation information table and the dynamic link library.
As the dynamic and static fusion binary translation method based on the dynamic link library, further, a target executable program is statically analyzed, the translated target code is analyzed and optimized according to the recorded information, and a dynamic link library used for calling the target program in the dynamic execution process is generated; and collecting repositioning information of the Chinese book after the static translation, recording library functions and other function names and addresses, and generating a repositioning information table.
As the dynamic and static fusion binary translation method based on the dynamic link library, each function name needing to be positioned and the offset, the repositioning type and the backfill address of the function name in the memory are further recorded in the repositioning information table.
As the dynamic and static fusion binary translation method based on the dynamic link library, further, in the dynamic translation execution process, if the executed function is already translated and optimized in the static translation stage during the execution of the function, the program after the translation optimization is preferentially executed according to the relocation information table and the dynamic link library; if the function is not translated in the static phase, the function is directly translated and executed.
Further, the present invention also provides a dynamic and static fusion binary translation system based on dynamic link library, comprising: a processing module, a static analysis module and a dynamic execution module, wherein,
the processing module divides the program by taking the function as a unit and determines a function execution process according to the function characteristics, and the processing module specifically comprises the following steps: judging whether the function is a third-party library function, if so, replacing and executing the function by adopting a local same library function, otherwise, judging whether an indirect jump branch instruction exists in the function, if not, translating a source machine code into a target code by taking a basic block as a unit in a static translation stage, and if so, putting the function in a dynamic translation execution stage for execution;
the static analysis module is used for statically analyzing the target executable program and generating a dynamic link library for calling the target program in the dynamic execution process; collecting relocation information of the function after the static translation, and generating a relocation information table;
and the dynamic execution module is used for dynamically executing the function after the translation optimization in the static translation stage according to the relocation information table and the dynamic link library.
The invention has the beneficial effects that:
the method takes the functions and the basic blocks as basic units to statically translate the source program, adopts a local library replacement mode to execute the third-party library functions to reduce the expansion rate of code translation, and carries out deep and permanent optimization on translated codes to generate a dynamic link library for subsequent programs to run and load the optimized target codes; the method has obvious optimization effect on the conditions of a calculation intensive program and the need of executing the program for multiple times, can save the translation and optimization overhead from a source program to a target program, and fully adopts code optimization in a static translation stage to obtain better code optimization effect; the static optimization replaces partial dynamic execution, the dynamic link library is called to realize the processing of the original function level, the advantage that the static binary translation can be used for off-line optimization can be fully utilized, the codes which need to be translated and optimized during the dynamic execution period are placed in the static execution, the translation and optimization overhead during the program operation is reduced, the execution efficiency of the translated target program is improved, and the code quality and the overall performance of the system can be greatly improved.
Description of the drawings:
FIG. 1 is a schematic flow chart of a dynamic and static fusion binary translation method in an embodiment;
FIG. 2 is a block diagram of a dynamic-static fusion binary translation system in an embodiment.
The specific implementation mode is as follows:
in order to make the objects, technical solutions and advantages of the present invention clearer and more obvious, the present invention is further described in detail below with reference to the accompanying drawings and technical solutions.
The binary translation process is similar to the traditional compilation process and can be divided into three stages, namely a front-end decoder, a middle-end decoder and a back-end decoder, wherein the three stages are 1) the front-end decoder of the source binary code: according to the instruction structure characteristics of the source machine and the format specification of the executable file, the binary codes are processed through instruction pattern matching, and the function similar to disassembly is completed. This part needs to decode the binary code accurately, and deal with the problems of indirect jump/indirect call, self-modifying code, and identification and analysis of data content. The output of the decoder is some form of abstract intermediate representation to facilitate its analysis and optimization. 2) The middle-end analysis optimizer: the primary task of this section is to implement equivalent transformation of the two intermediate representations and to implement optimization of the intermediate code. In the binary translation system, the characteristics that different machine platforms can be properly isolated by adopting intermediate representation are adopted, so that the design and the implementation of the binary translation system are facilitated. Moreover, the adoption of the explicit middle-end analysis optimizer has the advantage of facilitating the migration of the binary translation system: whether the source machine is changed or the target machine is changed, only the front-end decoder or the back-end optimization encoder needs to be adjusted correspondingly, and then the binary translation system suitable for the new machine can be realized. 3) The back-end optimization encoder: similar to a general compiler, the function of this module is to generate optimized object machine code from an intermediate language. The back-end optimization encoder needs to translate the intermediate representation into executable binary codes on the target machine according to the characteristics of the target machine and the operating system of the target machine, integrates the functions of a back-end code optimization and generator, a linker and the like in a conventional compiling system, and even further comprises the function of program loading. The realization of a back-end optimization encoder also relates to the problem of program translation efficiency, if a static binary translation strategy is adopted, the functions of the part can be directly finished by the back end of a conventional compiler; however, if a dynamic binary translation strategy is adopted, the back-end optimization encoder must be implemented by adopting an efficient algorithm. (1) A static binary translation system that can extract, analyze, and translate an executable file of a source platform without running a program. Because the translation time and execution time of the static binary translation are separated from each other, it can generate high-quality code using more complex code analysis and optimization algorithms; in addition, the characteristic of having multiple static translations performed in one translation is also well suited for translation of high performance computing programs. Unfortunately, static binary translation has difficulty dealing with the following code discovery and code localization problems. Some addresses of executable files can only be accessed through indirect branches, the target address of the branch can only be known at the runtime, and the static binary translator can not solve the problem. (2) The dynamic binary translation system can well solve the problems of code discovery and self-modification, has good usability, takes a target binary file as input, loads the target binary file into a host machine memory, and translates and executes a program along a program control flow by using a loop of dynamically discovering the code, translating the code and generating a local machine code. The code translation and optimization time of the dynamic binary translation system occupies the whole execution time of a program, the method is not suitable for adopting a deep optimization method, and even after numerous optimization means such as hot path optimization, register allocation optimization, multithreading parallel optimization, memory access optimization and the like are adopted in the dynamic binary translation, the problem of low dynamic binary translation efficiency is still outstanding. 3) The back-end optimization encoder: similar to a general compiler, the function of this module is to generate optimized object machine code from an intermediate language. The back-end optimization encoder needs to translate the intermediate representation into executable binary codes on the target machine according to the characteristics of the target machine and the operating system of the target machine, integrates the functions of a back-end code optimization and generator, a linker and the like in a conventional compiling system, and even further comprises the function of program loading. The realization of a back-end optimization encoder also relates to the problem of program translation efficiency, if a static binary translation strategy is adopted, the functions of the part can be directly finished by the back end of a conventional compiler; however, if a dynamic binary translation strategy is adopted, the back-end optimization encoder must be implemented by adopting an efficient algorithm. According to the difference of the binary translator system architecture and the implementation mode, the binary translation system can be roughly divided into three types, namely a static binary translation system, a dynamic binary translation system and a dynamic and static fused binary translation system. Wherein (1) the static binary translation system, the static binary translation can extract, analyze and translate an executable file of a source platform without running a program. Because the translation time and execution time of the static binary translation are separated from each other, it can generate high-quality code using more complex code analysis and optimization algorithms; in addition, the characteristic of having multiple static translations performed in one translation is also well suited for translation of high performance computing programs. Unfortunately, static binary translation has difficulty dealing with the following code discovery and code localization problems. Some addresses of executable files can only be accessed through indirect branches, the target address of the branch can only be known at the runtime, and the static binary translator can not solve the problem. (2) The dynamic binary translation system can well solve the problems of code discovery and self-modification, has good usability, takes a target binary file as input, loads the target binary file into a host machine memory, and translates and executes a program along a program control flow by using a loop of dynamically discovering the code, translating the code and generating a local machine code. The code translation and optimization time of the dynamic binary translation system occupies the whole execution time of a program, the method is not suitable for adopting a deep optimization method, and even after numerous optimization means such as hot path optimization, register allocation optimization, multithreading parallel optimization, memory access optimization and the like are adopted in the dynamic binary translation, the problem of low dynamic binary translation efficiency is still outstanding. (3) The dynamic and static fused binary translation system aims to comprehensively utilize the advantages of static binary translation and dynamic binary translation and avoid respective disadvantages so as to achieve better execution efficiency and wider application range. The embodiment of the invention, as shown in fig. 1, provides a dynamic and static fusion binary translation method based on a dynamic link library, which comprises the following contents:
s101, dividing a program by taking a function as a unit, and determining a function execution process according to function characteristics, wherein the method specifically comprises the following steps: judging whether the function is a third-party library function, if so, replacing and executing the function by adopting a local same library function, otherwise, judging whether an indirect jump branch instruction exists in the function, if not, translating a source machine code into a target code by taking a basic block as a unit in a static translation stage, and if so, putting the function in a dynamic translation execution stage for execution;
s102, in a static translation stage, statically analyzing a target executable program to generate a dynamic link library for calling the target program in a dynamic execution process; collecting relocation information of the function after the static translation, and generating a relocation information table;
s103, a dynamic translation executing stage, wherein aiming at the function after the translation optimization in the static translation stage, the dynamic translation is executed according to the relocation information table and the dynamic link library.
The static translation source program with the function and the basic block as basic units is executed by adopting a local library replacement mode for the third-party library function, so that the code translation expansion rate can be reduced, the translated code is subjected to deep persistent optimization and a dynamic link library is generated, and the optimized target codes are loaded by the subsequent program; the method has obvious optimization effect on the conditions of a calculation intensive program and the need of executing the program for multiple times, can save the translation and optimization overhead from a source program to a target program, and fully adopts code optimization in a static translation stage to obtain better code optimization effect; the static optimization replaces partial dynamic execution, the dynamic link library is called to realize the processing of the original function level, the advantage that the static binary translation can be used for off-line optimization can be fully utilized, the codes which need to be translated and optimized during the dynamic execution period are placed in the static execution, the translation and optimization overhead during the program operation is reduced, the execution efficiency of the translated target program is improved, and the code quality and the overall performance of the system can be greatly improved.
And statically translating the source program by taking the function and the basic block as basic units, performing deep persistent optimization on the translated codes, and generating a dynamic link library for a subsequent program to run and load the optimized target codes. In the actual implementation process, a program is divided by taking a function as a unit, and if the function is a third-party library function, the function is not translated and is directly replaced and executed by a local library function; otherwise, performing static analysis on the executable program to be translated, and if the function is not a library function and has an indirect jump branch instruction, directly executing the function in a dynamic translation execution stage; if no indirect jump branch instruction exists in the function, in a static translation stage, the function is translated into a target platform code by taking a basic block as a unit, deep optimization is carried out by combining static analysis information, and then the function is compiled into a dynamic link library for direct execution in a dynamic execution process; collecting relocation information of the target code after the static translation, generating a relocation information table, recording library functions and other function names and addresses, and providing information for a dynamic execution stage; and preferentially executing the function after the translation optimization according to the relocation information table and the dynamic link library, and if the function is not translated and optimized before, performing translation execution in a dynamic translation execution stage.
As the dynamic and static fusion binary translation method based on the dynamic link library in the embodiment of the invention, further, the offset, the relocation type and the backfill address of each function or basic block needing to be located in the memory are recorded in the relocation information table.
The relocation information table records each function name to be relocated and the information needed to be used, such as the offset, relocation type, backfill address information and the like of the function name in the memory. In the stage of statically translating a source program, analyzing and optimizing translated target codes by using a plurality of code optimization methods according to static analysis information, and storing the optimized codes in a file by a function name; then, generating a dynamic link library by the optimized function code for a subsequent target program to call in the dynamic execution process; when the program is translated, firstly searching a relocation information table to execute a function after static translation optimization, if a certain function is not translated and optimized, dynamically translating the function and continuously executing the function; and finishing the dynamic and static combined binary translation until the program can be normally executed.
In the embodiment, most of the load execution in the translation process is the target code after the static translation optimization, so that the code translation and code optimization time is saved, and most of the load execution is the code after the static full optimization, and the code execution efficiency is effectively improved. The method has obvious optimization effect on the conditions of a calculation intensive program and the need of executing the program for multiple times, firstly can save the translation and optimization overhead from a source program to a target program, and secondly can fully adopt a code optimization method to obtain better code optimization in a static translation stage.
Further, based on the above method, an embodiment of the present invention further provides a dynamic and static fusion binary translation system based on a dynamic link library, including: a processing module, a static analysis module and a dynamic execution module, wherein,
the processing module divides the program by taking the function as a unit and determines a function execution process according to the function characteristics, and the processing module specifically comprises the following steps: judging whether the function is a third-party library function, if so, replacing and executing the function by adopting a local same library function, otherwise, judging whether an indirect jump branch instruction exists in the function, if not, translating a source machine code into a target code by taking a basic block as a unit in a static translation stage, and if so, putting the function in a dynamic translation execution stage for execution;
the static analysis module is used for statically analyzing the target executable program and generating a dynamic link library for calling the target program in the dynamic execution process; collecting relocation information of the function after the static translation, and generating a relocation information table;
and the dynamic execution module is used for dynamically executing the function after the translation optimization in the static translation stage according to the relocation information table and the dynamic link library.
In the actual implementation process, the method can be implemented based on a dynamic binary translator QEMU (quick Emulator), and the target program of the translation can also be a domestic Shenwei processor. QEMU is originally one more than one dynamic binary translator, and as shown in fig. 2, an embodiment of the present invention can be modified into a dynamic and static fused binary translator SWBT. The SWBT system framework can be divided into a static binary translation part, a dynamic binary translation part and a dynamic and static fusion part based on a dynamic link library, a static translation source program takes a function and a basic block as a basic unit, the translated code is subjected to deep persistent optimization, the dynamic link library used for dynamic execution calling is generated, and the optimized target codes are loaded by the subsequent program in a running mode. The method has the advantages that the code discovery problem of static binary translation is solved, the program translation optimization time and the execution time of a target program are separated to a great extent, the code optimization is carried out by adopting a deep code optimization method in the static translation stage of the program, the expansion rate of translated codes is effectively reduced, the code translation work is reduced by locally replacing and calling library functions, the expansion rate of the codes is further reduced, and the execution efficiency of the translated target program is remarkably improved.
Unless specifically stated otherwise, the relative steps, numerical expressions, and values of the components and steps set forth in these embodiments do not limit the scope of the present invention.
Based on the foregoing system, an embodiment of the present invention further provides a server, including: one or more processors; a storage device to store one or more programs that, when executed by the one or more processors, cause the one or more processors to implement the system as described above.
Based on the above system, the embodiment of the present invention further provides a computer readable medium, on which a computer program is stored, wherein the program, when executed by a processor, implements the above system.
The device provided by the embodiment of the present invention has the same implementation principle and technical effect as the system embodiment, and for the sake of brief description, reference may be made to the corresponding content in the system embodiment for the part where the device embodiment is not mentioned.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the system and the apparatus described above may refer to the corresponding processes in the foregoing system embodiments, and are not described herein again.
In all examples shown and described herein, any particular value should be construed as merely exemplary, and not as a limitation, and thus other examples of example embodiments may have different values.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus, and system may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the system according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Finally, it should be noted that: the above-mentioned embodiments are only specific embodiments of the present invention, which are used for illustrating the technical solutions of the present invention and not for limiting the same, and the protection scope of the present invention is not limited thereto, although the present invention is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present invention, and they should be construed as being included therein. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (7)

1. A dynamic and static fusion binary translation method based on a dynamic link library is characterized by comprising the following contents:
dividing a program by taking a function as a unit, and determining a function execution process according to function characteristics, wherein the method specifically comprises the following steps: judging whether the function is a third-party library function, if so, replacing and executing the function by adopting a local same library function, otherwise, judging whether an indirect jump branch instruction exists in the function, if not, translating a source machine code into a target code by taking a basic block as a unit in a static translation stage, and if so, putting the function in a dynamic translation execution stage for execution;
in the static translation stage, a target executable program is statically analyzed, and a dynamic link library used for calling the target program in the dynamic execution process is generated; collecting relocation information of the function after the static translation, and generating a relocation information table;
and a dynamic translation executing stage, which is used for dynamically executing the function after the translation optimization in the static translation stage according to the relocation information table and the dynamic link library.
2. The dynamic and static fusion binary translation method based on the dynamic link library according to claim 1, characterized in that a static analysis target executable program analyzes and optimizes a translated target code according to recorded information to generate a dynamic link library for calling the target program in a dynamic execution process; and collecting relocation information of the function after the static translation, recording names and addresses of the library function and other functions, and generating a relocation information table.
3. The dynamic and static fusion binary translation method based on the dynamic link library according to claim 1 or 2, characterized in that each function name to be positioned and its offset, repositioning type and backfill address in the memory are recorded in the repositioning information table.
4. The dynamic and static fusion binary translation method based on the dynamic link library according to claim 1, wherein in the dynamic translation execution process, when the function is executed internally, if the executed function is already translated and optimized in the static translation stage, the translated and optimized program is preferentially executed according to the relocation information table and the dynamic link library; if the function is not translated in the static phase, the function is directly translated and executed.
5. The dynamic and static fusion binary translation system based on the dynamic link library is characterized by comprising the following components: a processing module, a static analysis module and a dynamic execution module, wherein,
the processing module divides the program by taking the function as a unit and determines a function execution process according to the function characteristics, and the processing module specifically comprises the following steps: judging whether the function is a third-party library function, if so, replacing and executing the function by adopting a local same library function, otherwise, judging whether an indirect jump branch instruction exists in the function, if not, translating a source machine code into a target code by taking a basic block as a unit in a static translation stage, and if so, putting the function in a dynamic translation execution stage for execution;
the static analysis module is used for statically analyzing the target executable program and generating a dynamic link library for calling the target program in the dynamic execution process; collecting relocation information of the function after the static translation, and generating a relocation information table;
and the dynamic execution module is used for dynamically executing the function after the translation optimization in the static translation stage according to the relocation information table and the dynamic link library.
6. A server, comprising: one or more processors; storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to perform the method of any one of claims 1 to 4.
7. A computer-readable medium, on which a computer program for execution by a processor is stored, the computer program being adapted to perform the method of any of claims 1-4.
CN202010345949.0A 2020-04-27 2020-04-27 Dynamic and static fusion binary translation method and system based on dynamic link library Pending CN111625279A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010345949.0A CN111625279A (en) 2020-04-27 2020-04-27 Dynamic and static fusion binary translation method and system based on dynamic link library

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010345949.0A CN111625279A (en) 2020-04-27 2020-04-27 Dynamic and static fusion binary translation method and system based on dynamic link library

Publications (1)

Publication Number Publication Date
CN111625279A true CN111625279A (en) 2020-09-04

Family

ID=72271791

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010345949.0A Pending CN111625279A (en) 2020-04-27 2020-04-27 Dynamic and static fusion binary translation method and system based on dynamic link library

Country Status (1)

Country Link
CN (1) CN111625279A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114461227A (en) * 2022-04-13 2022-05-10 飞腾信息技术有限公司 Method and device for running software and machine-readable storage medium
CN115794123A (en) * 2023-02-13 2023-03-14 湖南大学 Extensible framework for program cross-architecture migration and program cross-architecture migration method
CN116501450A (en) * 2023-06-25 2023-07-28 北京开源芯片研究院 Translation control method, binary translation method, instruction execution method and device
WO2023164897A1 (en) * 2022-03-03 2023-09-07 华为技术有限公司 Optimization method and apparatus for binary program

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1716202A (en) * 2004-06-30 2006-01-04 中国科学院计算技术研究所 Be association of activity and inertia incomplete disposal route of static information and device in the binary translation
CN101452396A (en) * 2008-12-25 2009-06-10 上海交通大学 Binary translation method combining static optimization
CN101488096A (en) * 2009-02-19 2009-07-22 上海交通大学 Method for constructing super block by utilizing subdivision information of access edge relationship
US20160266945A1 (en) * 2006-10-25 2016-09-15 Vmware, Inc. Runtime emulating static thread local storage of portable executable software code
CN109634869A (en) * 2018-12-21 2019-04-16 中国人民解放军战略支援部队信息工程大学 Binary translation intermediate representation correctness test method and device based on semantic equivalence verifying

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1716202A (en) * 2004-06-30 2006-01-04 中国科学院计算技术研究所 Be association of activity and inertia incomplete disposal route of static information and device in the binary translation
US20160266945A1 (en) * 2006-10-25 2016-09-15 Vmware, Inc. Runtime emulating static thread local storage of portable executable software code
CN101452396A (en) * 2008-12-25 2009-06-10 上海交通大学 Binary translation method combining static optimization
CN101488096A (en) * 2009-02-19 2009-07-22 上海交通大学 Method for constructing super block by utilizing subdivision information of access edge relationship
CN109634869A (en) * 2018-12-21 2019-04-16 中国人民解放军战略支援部队信息工程大学 Binary translation intermediate representation correctness test method and device based on semantic equivalence verifying

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
傅立国: "二进制翻译模型构建与优化关键技术研究", 《中国博士学位论文全文数据库 信息科技辑》 *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023164897A1 (en) * 2022-03-03 2023-09-07 华为技术有限公司 Optimization method and apparatus for binary program
CN114461227A (en) * 2022-04-13 2022-05-10 飞腾信息技术有限公司 Method and device for running software and machine-readable storage medium
CN115794123A (en) * 2023-02-13 2023-03-14 湖南大学 Extensible framework for program cross-architecture migration and program cross-architecture migration method
CN116501450A (en) * 2023-06-25 2023-07-28 北京开源芯片研究院 Translation control method, binary translation method, instruction execution method and device
CN116501450B (en) * 2023-06-25 2023-10-17 中国科学院计算技术研究所 Translation control method, binary translation method, instruction execution method and device

Similar Documents

Publication Publication Date Title
CN111625279A (en) Dynamic and static fusion binary translation method and system based on dynamic link library
US7757221B2 (en) Apparatus and method for dynamic binary translator to support precise exceptions with minimal optimization constraints
KR101381274B1 (en) Register mapping techniques for efficient dynamic binary translation
CN101299192B (en) Non-aligning access and storage processing method
US20040255279A1 (en) Block translation optimizations for program code conversation
US8612948B2 (en) Dynamic compiler program, dynamic compiling method and dynamic compiling device
US20030149963A1 (en) Condition code flag emulation for program code conversion
US20120198428A1 (en) Using Aliasing Information for Dynamic Binary Optimization
US20180165079A1 (en) Instruction-set simulator and its simulator generation method
CN114115990A (en) Program migration method, system and storage medium for dynamic and static combined binary translation
Shen et al. An LLVM-based hybrid binary translation system
US20100095102A1 (en) Indirect branch processing program and indirect branch processing method
US20140196019A1 (en) Method and Apparatus for Substituting Compiler Built-in Helper Functions with Machine Instructions
US20170046140A1 (en) State recovery methods and apparatus for computing platforms
US8938728B2 (en) Dynamic compiler program, dynamic compiling method and dynamic compiling device
CN116594622A (en) Python program compiling method and system based on type deduction and data flow analysis
Ung et al. Dynamic binary translation using run-time feedbacks
US7774767B2 (en) System and method for compiler interprocedural optimization having support for object files in libraries
CN115048184A (en) Method and device for optimizing execution of interpreter instruction
CN114816435A (en) Software development method based on reverse technology
CN114443052A (en) Dynamic specialization method and device during IL instruction operation
US9417872B2 (en) Recording medium storing address management program, address management method, and apparatus
Saleil Simple Optimizing JIT Compilation of Higher-Order Dynamic Programming Languages
US11593080B1 (en) Eliminating dead stores
CN116661807A (en) Binary translation code inline optimization method, binary translation code inline optimization device and storage medium

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20200904

RJ01 Rejection of invention patent application after publication