CN111771187B - Method and device for eliminating code construction difference - Google Patents

Method and device for eliminating code construction difference Download PDF

Info

Publication number
CN111771187B
CN111771187B CN201980003006.5A CN201980003006A CN111771187B CN 111771187 B CN111771187 B CN 111771187B CN 201980003006 A CN201980003006 A CN 201980003006A CN 111771187 B CN111771187 B CN 111771187B
Authority
CN
China
Prior art keywords
binary file
program
function
construction
information
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.)
Active
Application number
CN201980003006.5A
Other languages
Chinese (zh)
Other versions
CN111771187A (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.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Publication of CN111771187A publication Critical patent/CN111771187A/en
Application granted granted Critical
Publication of CN111771187B publication Critical patent/CN111771187B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/72Code refactoring

Abstract

The application provides a method and a device for eliminating code construction difference, wherein the method comprises the following steps: recording construction information when constructing the first binary file when the binary file is constructed for the first time and the first binary file is generated; when the binary file is reconstructed later, the function of the constructed information is generated by intercepting, and the function calls the recorded constructed information; and when the second binary file is generated, constructing the second binary file based on the called construction information. The same construction information is adopted when the binary file is constructed by the source code, so that the difference of the binary file generated by the same source code under different construction environments is improved, and the consistency of the constructed binary file is improved.

Description

Method and device for eliminating code construction difference
Technical Field
The present application relates to the field of information technology, and in particular, to a method and an apparatus for eliminating a code construction difference.
Background
With the increasing demand for information security, the industry has put forward a demand for consistent delivery of source code and binary files, and the consistency of construction is also referred to in the industry as repeatable construction, i.e., to confirm that an executable binary version of the delivery is generated by compiling the delivered source code. However, due to the fact that construction environments are different, source codes and tools for archiving are inaccurate, timestamps are different, and the like, a binary file recompiled through the source codes is inconsistent with a delivered binary file, and if inconsistent places are not interpretable or inconsistent places are too many and are difficult to verify manually, construction consistency requirements are not met, but the source codes and tools are not accurate in industry.
Content of application
The application provides a method and a device for eliminating code construction difference, which are used for reducing the elimination of the code construction difference and improving the consistency of binary file construction.
In a first aspect, a method for eliminating code construction differences is provided, the method comprising the following steps: recording construction information when constructing the first binary file when the binary file is constructed for the first time and the first binary file is generated; when the binary file is reconstructed later, the function of the constructed information is generated by intercepting, and the function calls the recorded constructed information; and when the second binary file is generated, constructing the second binary file based on the called construction information. The same construction information is adopted when the binary file is constructed by the source code, so that the difference of the binary file generated by the same source code under different construction environments is improved, and the consistency of the constructed binary file is improved.
When a first binary file component is specifically carried out and construction information is recorded, when the first binary file is constructed for the first time to generate the first binary file, a function for generating the construction information is intercepted, the function calls the set construction information, and the first binary file is generated based on the set construction information; and recording the set construction information. By adopting the unified construction information when constructing the first binary file, the subsequent construction environment is facilitated.
The setting construction information may be construction information when the collected source code constructs the first binary file when the first binary file is constructed.
The function may be different function functions, for example, the function call function is: and writing a function of the constructed information in the constructed binary file based on the construction tool in the process of calling the source code to construct the binary file. I.e. a function in the building tool.
The building tool described above may be a different tool, such as one of a compiler, a linker, or a compact packaging tool. The building tool may include only a compiler, may also include a compiler, a linker, or may include a compiler, a linker, a compressed package, and the like.
In a particular embodiment, the build information may be information related to building a binary file, such as where the build information includes one of a timestamp, a random number, or environmental information. When specifically included, the timestamp may be included only, the timestamp and the random number may be included at the same time, and different cases such as the timestamp, the random number, and the environment information may be included.
In a particular embodiment, the method further comprises: establishing a white list; adding a program which influences the compiling failure into a white list; when the binary file is reconstructed, whether the processed program is on a white list or not is judged, and if yes, the call of the function in the program in the white list is not intercepted. When intercepting the function, firstly judging whether the program where the function is located is on the white list, if so, not intercepting, and if not, intercepting.
In a particular embodiment, the method further comprises establishing a blacklist; adding a program which generates random numbers and influences binary file sequencing into a blacklist; and intercepting a functional function for generating construction information in the program in the blacklist when the binary file is reconstructed. I.e. intercepting the programs that affect the ordering of the binary file.
In a second aspect, an apparatus for eliminating a code construction difference is provided, the apparatus including a plurality of units, such as a recording unit, for recording construction information for constructing a first binary file when the binary file is generated by first constructing the binary file; the system comprises a reconstruction unit and a processing unit, wherein the reconstruction unit comprises a first interception module and a first generation module, and the first interception module is used for intercepting a function generating construction information and calling the recorded construction information by the function when the binary file is reconstructed; the first generation module is used for reconstructing the binary file and constructing the second binary file based on the construction information called by the interception module. The recording unit and the reconstruction unit record the construction information and perform subsequent reconstruction of the binary file according to the construction information, so that the consistency of the generated binary file is improved during repeated reconstruction.
In a specific possible embodiment, the recording unit includes: the second interception module and the recording module;
the second interception module is used for intercepting the function generating the construction information when the binary file is constructed for the first time to generate the first binary file, so that the function calls the set construction information;
and the recording module is used for recording the set construction information of the function call. And intercepting the function through a second interception module, using the set construction information, and recording the set construction information through a recording module so as to adopt the same information when reconstructing.
In a specific possible embodiment, the rebuilding unit further includes a first selection module, and the first selection module is used for building a white list and adding a program which affects compiling failure to the white list; the first intercepting module is further used for judging whether the program is on the white list or not when the binary file is reconstructed, and if so, not intercepting the call of the function in the program in the white list. When intercepting a function, firstly judging whether a program of the function is on a white list, if so, not intercepting, and if not, intercepting.
In a particular possible embodiment, the reconstruction unit further comprises a second selection module; the second selection module is used for constructing a blacklist and adding a program for generating random numbers and influencing binary file sequencing into the blacklist; the first intercepting module is also used for intercepting a functional function generating construction information in a program in a blacklist when the binary file is reconstructed. I.e. intercepting the programs that affect the ordering of the binary file.
In a third aspect, an apparatus for eliminating code construction differences is provided, the apparatus comprising a processor and a memory, the memory storing a computer program, the processor calling the computer program to perform any of the above methods. The same construction information is adopted when the binary file is constructed by the source code, so that the difference of the binary file generated by the same source code under different construction environments is improved, and the consistency of the constructed binary file is improved.
In a fourth aspect, a computer-readable storage medium is provided, in which a software program is stored, which when read and executed by one or more processors, may implement the method of any of the above. The same construction information is adopted when the binary file is constructed by the source code, so that the difference of the binary file generated by the same source code under different construction environments is improved, and the consistency of the constructed binary file is improved.
In a fifth aspect, there is provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the method of any of the above. The same construction information is adopted when the binary file is constructed by the source code, so that the difference of the binary file generated by the same source code under different construction environments is improved, and the consistency of the constructed binary file is improved.
Drawings
FIG. 1 is a flow chart of source code in generating a binary file;
FIG. 2 is a flow chart of a method provided by an embodiment of the present application;
fig. 3 is a functional function call flow diagram provided in an embodiment of the present application;
fig. 4 is a flowchart of a function interception call and return record construction environment provided in the embodiment of the present application;
FIG. 5 is a flow chart of a method provided in an embodiment of the present application during two build operations;
FIG. 6 is a flow chart of a method provided in an embodiment of the present application during two build operations;
FIG. 7 is a flowchart of a method provided by an embodiment of the present application when a linux system is constructed twice;
FIG. 8 is a flowchart illustrating a method according to an embodiment of the present disclosure when a Windows system is constructed twice;
FIG. 9 is a block diagram of an apparatus provided by an embodiment of the present application;
FIG. 10 is a block diagram of a recording unit provided in an embodiment of the present application;
FIG. 11 is a block diagram of a reconstruction unit provided in an embodiment of the present application;
fig. 12 is a schematic structural diagram of an apparatus according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more clear, the present application will be further described in detail with reference to the accompanying drawings.
For the convenience of understanding the method provided in the embodiments of the present application, a scenario of application of the method applied to a process of generating a binary file by source code is described first. When the binary file is generated by the source code, due to different environments, the same source code may have a difference in the generated binary file, resulting in a poor consistency of the binary file, such as a difference between the binary file generated in a chinese environment and the binary file generated in an english environment, or a difference between the binary files generated at different times. For convenience of understanding, as described below in conjunction with fig. 1, as shown in fig. 1, in the process of compiling the source code into the binary executable program, there are a plurality of links that introduce building information such as time stamps, random numbers, checksums, etc., which may cause the finally generated binary files to be very different.
When the binary is generated by the source code, the __ DATE __, __ TIME __ and __ FILE __ macros used in the C language can cause the difference of binary FILEs generated by two TIMEs of constructing the same set of code; there is also ar tool, which is often used to pack intermediate files in the compilation process, and which writes the modification time of the intermediate file into the binary file, resulting in a difference. There are also linkers: when the linker links the intermediate file into an executable program or a dynamic library, the information such as crc is written into the binary file to cause difference; the order of the intermediate files at the time of linking may also result in binary differences. In addition, there are packaging tools, which are commonly self-developed by manufacturers in telecommunication devices, and which write time stamps and crc information into binary files resulting in differences.
In order to improve the difference between binary files generated by the same source code, the consistency of the generated binary files is improved. The embodiment of the application provides a method for eliminating code construction difference. The method is described in detail below with reference to the accompanying drawings.
As shown in fig. 2, a method for eliminating a code construction difference provided by an embodiment of the present application includes the following steps:
step 001: recording construction information when constructing the first binary file when the binary file is constructed for the first time and the first binary file is generated;
step 002: when the binary file is reconstructed, intercepting a function generating the constructed information, and calling the recorded constructed information by the function; and constructing a second binary file based on the called construction information.
Taking the example of constructing a binary file under the Linux system, LD _ load is an environment variable of the Linux system, which can affect the links at the run time of a program, and which allows you to define a dynamic link library that is loaded preferentially before the program runs. This function is mainly used to selectively load the same function in different dynamically linked libraries. By the environment variable, other dynamic link libraries can be loaded between the main program and the dynamic link library, and even the normal function library is covered, so that the function can be used for using the function of the function or better. As shown in fig. 3, fig. 3 shows a flow in which normal code directly calls the ftime () function; in the normal state, the ftime () function is called, and the value of the call to the function is written into the test.c file. And after intercepting the normal call of the ftime () through the ld _ preload mechanism, controlling the return value of the ftime () to the test.c, and the flow is shown in fig. 4. It can be seen from the above description that the function of intercepting the generated construction information is adopted, and the same construction information is adopted when the binary file is constructed by the source code, so that the difference of the generated binary file of the same source code in different construction environments is improved, and the consistency of the constructed binary file is improved.
Referring also to fig. 5, fig. 5 shows a flow of the two building processes. When the construction is carried out twice, the source codes in the same code library are adopted. When the first build is performed, the build is performed at a build center, which includes a build tool for building binary files, and the build tool may include a plurality of types, such as a build tool including one of a compiler, a linker, or a compact packaging tool, and refer to fig. 6 and 7 together. The building tool may include only a compiler, or may also include a compiler, a linker, or both a compiler, a linker, and a compression package, or both a compiler, a linker, a compression packaging tool, and the like. In the first construction, when the above-described construction tool of the construction center constructs the binary file for the first time and generates the first binary file (Build a), the construction information at the time of constructing the first binary file is recorded, and as shown in fig. 5, the environment information at the time of construction and the time stamp are saved. When the second construction is carried out, the same source code is called in the code base, and when the second construction (reconstruction) is carried out in the construction center, the function generating the construction information is intercepted, so that the function calls the recorded construction information; and constructs a second binary file (Build B) based on the called Build information. The intercepted function is a function for writing construction information in the constructed binary file based on a construction tool in the process of calling the source code to construct the binary file. And after interception, acquiring the construction information (environment information and timestamp) stored during construction, and setting the environment information and the timestamp to be completely consistent with those during first construction, so that the generated second binary file is the same as the first binary file generated during first construction, and the consistency of the generated binary file is improved. Fig. 5 illustrates an example of the first construction and the second construction. However, it should be understood that the above-mentioned manner can be adopted in different reconstruction processes such as the third construction, the fourth construction, and the like, so that binary files constructed at different times can ensure higher consistency.
It should be understood that the above environment information and the timestamp are only exemplary building information, and the building information provided in the embodiments of the present application may include different information, for example, the building information may be information related to building a binary file, such as one of a timestamp, a random number, or environment information. That is, the construction information may include only the time stamp, may include both the time stamp and the random number, and may include different cases such as the time stamp, the random number, and the environment information.
Specifically, in the case of eliminating the difference, taking the TIME stamp as an example, __ DATE __ and __ TIME __ macros are directly used for the source code, and the source code is subjected to macro expansion at the TIME of pre-compilation. Timestamps are typically used to record version information, product commissioning, etc. Such as the following: 1) and (3) using the time stamp as version information: 2) record version compile time: before the programmer submits the code to a formal code base, the programmer can perform personal debugging, and the time for compiling the code can be accurately known by using the time stamp in the code. When a binary file is generated, the time stamp has three display forms in the binary file. 1) Time stamp of the direct display character string: compiling the software codes step by step, compiling the source codes c into intermediate files o (or obj), and then directly linking part of the intermediate files to generate a dynamic library and an executable program; wherein, part of the intermediate files are compressed by ar to generate the a file, and the ar writes the creation time of the intermediate files into the a file. 2) The packaging tool introduces differences, and the structure of the header defined by the self-development packaging tool contains timestamp information, so that the files generated by packaging each time are different. 3) The open source tool introduces the difference, and according to the regulation of the open source uboot header protocol, the time stamp for creating the zlmage is required to be recorded and the CRC value is calculated. When the uboot header is added to the zmage using mkimage, the ih _ time field is filled with the current time, and the CRC value of the reformed uboot header is calculated from the ih _ time field value to fill the ih _ hCRC. Thereby creating a difference. Therefore, in order to ensure the consistency of the generated binary file, it is necessary to intercept the function generating the timestamp, and referring to fig. 6 together, when the program runs, the call of the function generating the timestamp is intercepted, so as to avoid the above difference and ensure the consistency of the generated binary file.
In addition, not all programs need to be masked during the build process, and sometimes the judgment needs to be made based on a time stamp at the time of compilation. Therefore, in the method of the embodiment of the present application, a white list is also established, and the white list is used for adding the program which affects the compiling failure to the white list; when the binary file is reconstructed, whether the processed program is on a white list or not is judged, and if yes, the call of the function in the program in the white list is not intercepted. When intercepting the function, firstly judging whether the program where the function is located is on the white list, if so, not intercepting, and if not, intercepting. For example, the command ("ls-t") requires ordering the files by their creation time stamps. Therefore, in the build phase, there is no way to block the generation of these timestamps. In use, program bep _ env checks if the currently running program is in the white list and if so, bep _ env returns real time information generated by the function in these programs to the caller. If the currently running program is not in the white list, the function in the program is intercepted, and the construction information recorded when the first binary file is constructed for the first time is returned, so that the consistency of the generated binary file is ensured.
In addition, when binary file differences are generated, the order of the files is disordered, so that the order of intermediate files is changed in the process of compiling codes, and the binary file differences are caused. Therefore, the compiler calls the readdir function to read the compiled link file according to the disk index sequence (d _ off) that varies with the file system. By shielding readdir function and adding a statement ordered according to file name, files are ensured to be read according to a fixed sequence, and sequence difference is eliminated. Not all processes will generate random differences during the construction process. Performance is reduced and compilation time is increased after file reordering. Therefore, at build time, a blacklist is set; a program for generating random numbers and influencing binary file sorting is added into a blacklist; and intercepting a functional function for generating construction information in the program in the blacklist when the binary file is reconstructed. Namely, the programs which influence the binary file sequencing are intercepted, so that the consistency of the files is improved. If the first binary file is built for the first time, the file ordering a, b, c, d and the file ordering are included: A. b, C, D, when the program is run in the building, the function contained in the program is called to generate the sequence of a, A, B, B, C, C, D and D, then the program is written into the black list, and the calling of the program is prohibited.
In the above embodiment, a linux system is taken as an example for explanation, but the method provided in the embodiment of the present application may also be applied to a Windows system, as shown in fig. 8, a linux-like ld _ preload mechanism is absent on a Windows platform, and the method of the present application injects Bep _ env.dll into an executable program or a dynamic library of a compiler and a building tool in a DLL injection manner, and in a Windows building environment, it is necessary to identify in advance which compiling tools write difference information when generating binary files. Then Bep _ env.dll is injected into the program, as in the visual studio compiler, which requires Bep _ env.dll to be injected into the compiler cl.exe program. When the compiler and the construction tool acquire the system time stamp, the compiler and the construction tool are intercepted by Bep _ env.dll, the construction time is recorded during the first construction, and the time acquired by the compiler and the construction tool is set as the time of the last construction during the second construction, so that binary systems generated by the two constructions are completely consistent. Specifically, the method comprises the following steps:
when the building is carried out for the first time, a timestamp file is created at the beginning of a compiling script by using-c, and hook time is set at-s before compiling.
During reconstruction, a timestamp file constructed for the first time is checked by using-rb at the beginning of a compiling script, and hook time is set at-s before compiling.
In addition, with the present method, the effect of construction is improved. When the 001 step is specifically carried out, when the binary file is constructed for the first time to generate the first binary file, the function generating the construction information is intercepted, the function calls the set construction information, and the first binary file is generated based on the set construction information; and recording the set construction information. Therefore, when the first binary file is constructed, the unified construction information is adopted, and the subsequent constructed construction environment is facilitated. The set construction information may be a first time stamp generated when the interception function call is made. Such as: when the first binary file is constructed, the construction time may need a period of time, so that a plurality of different timestamps may be generated, and in order to ensure the consistency of the binary file, the timestamps need to be recorded, which results in that the recorded data is huge. However, if the build time is relatively short, such as with a supercomputer, then the timestamps generated may be the same. Therefore, in order to simplify the recorded content, the different timestamps can be recorded statistically as one same timestamp, so that the one timestamp can be called directly when the recording is constructed. The complexity of construction is simplified.
In specific implementation of the foregoing method, an embodiment of the present application further provides an apparatus for eliminating a code construction difference, as shown in fig. 9, where the apparatus includes a plurality of units, such as a recording unit 100, and the recording unit 100 is configured to record construction information for constructing a first binary file when the binary file is generated by constructing the binary file for the first time; reference may be made specifically to the detailed description of the above method. The reconstruction unit 200 further comprises a first interception module 201 and a first generation module 202, wherein the first interception module 201 is configured to intercept a function generating the construction information and enable the function to call the recorded construction information when reconstructing the binary file; the first generating module 202 is configured to reconstruct the binary file, and construct the second binary file based on the construction information called by the intercepting module, which may specifically refer to the specific description in the foregoing method. The recording unit 100 and the reconstruction unit 200 record the construction information and perform subsequent reconstruction of the binary file according to the construction information, so that the consistency of the generated binary file is improved during multiple reconstructions.
As shown in fig. 10, for the recording unit 100, it includes a second intercepting module 101 and a recording module 102; the second intercepting module 101 is configured to intercept a function that generates the construction information when the binary file is constructed for the first time to generate the first binary file, so that the function calls the set construction information; in particular, reference may be made to the detailed description of the above method. And the recording module 102 records the set construction information of the function call. The function is intercepted by the second intercepting module 101, the set construction information is used, and the set construction information is recorded by the recording module 102 so as to use the same information when reconstructing, which can be referred to the detailed description in the above method.
As shown in fig. 11, the reconstructing unit 200 further includes a first selecting module 203, where the first selecting module 203 is configured to construct a white list and add a program that affects the compiling failure to the white list; the first intercepting module 201 is further configured to, when reconstructing the binary file, determine whether the performed program is on a white list, and if so, not intercept the call of the function in the program in the white list. That is, when a function is intercepted, it is first determined whether a program in which the function is located is on a white list, if so, the function is not intercepted, and if not, the function is intercepted, which may specifically refer to the specific description in the foregoing method. Furthermore, the reconstruction unit 200 further comprises a second selection module 204; the second selection module 204 is configured to construct a blacklist, and add a program that generates a random number and affects binary file ordering to the blacklist; the first intercepting module 201 is further configured to intercept a functional function that generates construction information in a program in a blacklist when the binary file is reconstructed and when the binary file is reconstructed. Namely, intercepting the program which has an influence on the binary file ordering, and specifically, referring to the detailed description in the above method.
As shown in fig. 12, the present application further provides an apparatus 300 for eliminating a code construction difference, the apparatus 300 includes a processor 301 and a memory 303, wherein the memory 303 stores a computer program, and the processor 301 calls the computer program to perform any one of the methods described above, and when the call is specifically implemented, as shown in fig. 12, the processor 301 calls the computer program stored in the memory 303 through the bus 303. When the above method is executed, specific reference may be made to the description in the above method steps, which is not described herein again. In the device, the same construction information is adopted when the binary file is constructed by the source code, so that the difference of the binary files generated by the same source code under different construction environments is improved, and the consistency of the constructed binary files is improved.
In addition, an embodiment of the present application further provides a computer-readable storage medium, where a software program is stored, and when the software program is read and executed by one or more processors, the method may implement any one of the methods described above, and the method may specifically refer to the description in the above method steps, which is not described herein again. The same construction information is adopted when the binary file is constructed by the source code, so that the difference of the binary file generated by the same source code under different construction environments is improved, and the consistency of the constructed binary file is improved.
An embodiment of the present application further provides a computer program product including instructions, which when run on a computer, causes the computer to execute any one of the methods described above, and the method may specifically refer to the description in the above method steps, which is not described herein again. In the program product, the same construction information is adopted when the binary file is constructed by the source code, so that the difference of the binary files generated by the same source code under different construction environments is improved, and the consistency of the constructed binary files is improved.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.

Claims (15)

1. A method for eliminating code construction differences, comprising the steps of:
recording construction information for constructing the first binary file when the first binary file is generated by constructing the binary file for the first time;
when the binary file is reconstructed, intercepting a function generating the constructed information, and calling the recorded constructed information by the function; constructing a second binary file based on the called construction information;
when the first binary file is generated by building the binary file for the first time, the method for recording the building information for building the first binary file comprises the following steps:
intercepting a function generating construction information when a first binary file is generated by constructing the binary file for the first time, enabling the function to call the set construction information, and generating the first binary file based on the set construction information; and recording the set construction information.
2. The method of eliminating code build differences according to claim 1, wherein the function call function is:
and calling the function of generating the construction information in the constructed binary file based on the construction tool in the process of constructing the binary file by the source code.
3. The method of eliminating code build discrepancies as in claim 2, wherein the build tool comprises one of a compiler, a linker, or a compact packaging tool.
4. A method of eliminating code build variation as claimed in any one of claims 1 to 3, wherein the build information comprises one of a timestamp, a random number or environmental information.
5. A method for eliminating code build differences according to any of claims 1 to 3, characterized in that the method further comprises: establishing a white list; adding a program which influences the compiling failure into a white list;
when the binary file is reconstructed, whether the processed program is on a white list or not is judged, and if yes, the call of the function in the program in the white list is not intercepted.
6. The method of eliminating code build variation as recited in claim 4, wherein the method further comprises: establishing a white list; adding a program which influences the compiling failure into a white list;
when the binary file is reconstructed, whether the processed program is on a white list or not is judged, and if yes, the call of the function in the program in the white list is not intercepted.
7. The method of eliminating code build variation as recited in claim 4, wherein the method further comprises: establishing a blacklist; adding a program which generates random numbers and influences binary file sequencing into a blacklist;
and intercepting a functional function for generating construction information in the program in the blacklist when the binary file is reconstructed.
8. The method of eliminating code build variation as recited in claim 5, wherein the method further comprises: establishing a blacklist; adding a program which generates random numbers and influences binary file sequencing into a blacklist;
and intercepting a functional function for generating construction information in the program in the blacklist when the binary file is reconstructed.
9. The method of eliminating code build variation as recited in claim 6, wherein the method further comprises: establishing a blacklist; adding a program which generates random numbers and influences binary file sequencing into a blacklist;
and intercepting a functional function for generating construction information in the program in the blacklist when the binary file is reconstructed.
10. An apparatus for eliminating code construction differences, comprising:
the recording unit is used for recording construction information for constructing the first binary file when the binary file is constructed for the first time to generate the binary file;
the reconstruction unit comprises a first interception module and a first generation module, wherein the first interception module is used for intercepting a function generating construction information and enabling the function to call the recorded construction information when the binary file is reconstructed; the first generation module is used for reconstructing the binary file and constructing the second binary file based on the construction information called by the interception module;
the recording unit includes: the second interception module and the recording module;
the second interception module is used for intercepting the function generating the construction information when the binary file is constructed for the first time to generate the first binary file, so that the function calls the set construction information;
and the recording module is used for recording the set construction information of the function call.
11. The apparatus for eliminating code building difference according to claim 10, wherein the rebuilding unit further includes a first selecting module, the first selecting module is used for building a white list and adding a program affecting compiling failure to the white list;
the first intercepting module is further used for judging whether the program is on the white list or not when the binary file is reconstructed, and if so, not intercepting the call of the function in the program in the white list.
12. The apparatus for eliminating code construction difference according to any one of claims 10 to 11, wherein the reconstruction unit further comprises a second selection module; the second selection module is used for constructing a blacklist and adding a program for generating random numbers and influencing binary file sequencing into the blacklist;
the first intercepting module is further configured to, while proceeding with reconstructing the binary file,
and intercepting a functional function for generating construction information in the program in the blacklist when the binary file is reconstructed.
13. An apparatus for eliminating code construction differences, comprising a processor and a memory, wherein the memory stores a computer program, and the processor calls the computer program to execute the method of any one of claims 1 to 9.
14. A computer-readable storage medium, having stored thereon a software program which, when read and executed by one or more processors, is operable to carry out the method of any one of claims 1 to 9.
15. A computer program product comprising instructions which, when run on a computer, cause the computer to perform the method of any one of claims 1 to 9.
CN201980003006.5A 2019-01-31 2019-01-31 Method and device for eliminating code construction difference Active CN111771187B (en)

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2019/074261 WO2020155050A1 (en) 2019-01-31 2019-01-31 Method and device for eliminating code construction difference

Publications (2)

Publication Number Publication Date
CN111771187A CN111771187A (en) 2020-10-13
CN111771187B true CN111771187B (en) 2021-12-10

Family

ID=71839964

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201980003006.5A Active CN111771187B (en) 2019-01-31 2019-01-31 Method and device for eliminating code construction difference

Country Status (2)

Country Link
CN (1) CN111771187B (en)
WO (1) WO2020155050A1 (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101071385A (en) * 2006-05-11 2007-11-14 松下电器产业株式会社 Compile method, debug method, compile program and debug program
CN101470620A (en) * 2007-12-29 2009-07-01 珠海金山软件股份有限公司 Method and apparatus for judging PE file source code consistency

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7937620B2 (en) * 2007-05-07 2011-05-03 Intel Corporation Transient fault detection by integrating an SRMT code and a non SRMT code in a single application
US10037333B2 (en) * 2015-08-05 2018-07-31 Facebook, Inc. Systems and methods for determining content similarity

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101071385A (en) * 2006-05-11 2007-11-14 松下电器产业株式会社 Compile method, debug method, compile program and debug program
CN101470620A (en) * 2007-12-29 2009-07-01 珠海金山软件股份有限公司 Method and apparatus for judging PE file source code consistency

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
"一点运维经验,以及运维眼中的发行版";zhuang;《https://www.v2ex.com/t/208790》;20150728;全文 *

Also Published As

Publication number Publication date
CN111771187A (en) 2020-10-13
WO2020155050A1 (en) 2020-08-06

Similar Documents

Publication Publication Date Title
CN107291480B (en) Function calling method and device
US10331425B2 (en) Automated source code adaption to inject features between platform versions
CN110554965B (en) Automated fuzz testing method, related equipment and computer readable storage medium
JP2000181725A (en) Method and system for altering executable code and giving addition function
US10949332B2 (en) Data race analysis based on altering function internal loads during time-travel debugging
CN109032631B (en) Application program patch package obtaining method and device, computer equipment and storage medium
CN107015841B (en) Preprocessing method for program compiling and program compiling device
CN110737589A (en) automatic point burying method, device, medium and electronic equipment
CN110673837B (en) Code repairing method and device, electronic equipment and computer readable storage medium
CN115629971A (en) Application development system and method
CN111985055A (en) Model packaging method and device and electronic equipment
CN113568839A (en) Method, device, equipment and medium for software testing and statistical test coverage rate
CN112631618A (en) Application program packaging method, application program testing method, terminal and storage medium
US20200301808A1 (en) Determining effects of a function's change on a client function
EP3942418A1 (en) Emulating non-traced code with a recorded execution of traced code
US20200301813A1 (en) Using synthetic inputs during emulation of an executable entity from a recorded execution
US20140229915A1 (en) Debugger with previous version feature
CN111771187B (en) Method and device for eliminating code construction difference
CN111625225A (en) Program specified data output method and device
US11593078B2 (en) Reload ordering for executable code modules
CN115456628A (en) Intelligent contract viewing method and device based on block chain, storage medium and equipment
US6163881A (en) Method of monitoring the operation of a computer
CN114840822A (en) Code protection method, device, equipment and storage medium
US10956304B2 (en) Dynamic diagnostic code instrumentation over a historic program execution
CN112052007A (en) Source code debugging method, device, server 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
GR01 Patent grant
GR01 Patent grant