CN114064114A - Dynamic library generation method and device - Google Patents

Dynamic library generation method and device Download PDF

Info

Publication number
CN114064114A
CN114064114A CN202111401467.3A CN202111401467A CN114064114A CN 114064114 A CN114064114 A CN 114064114A CN 202111401467 A CN202111401467 A CN 202111401467A CN 114064114 A CN114064114 A CN 114064114A
Authority
CN
China
Prior art keywords
code
function
dynamic library
modified
target
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
CN202111401467.3A
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.)
Yunkong Zhixing Technology Co Ltd
Original Assignee
Yunkong Zhixing Technology 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 Yunkong Zhixing Technology Co Ltd filed Critical Yunkong Zhixing Technology Co Ltd
Priority to CN202111401467.3A priority Critical patent/CN114064114A/en
Publication of CN114064114A publication Critical patent/CN114064114A/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/72Code refactoring
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/31Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/73Program documentation

Abstract

The embodiment of the specification discloses a dynamic library generation method and a dynamic library generation device. The scheme comprises the following steps: acquiring a target code serving as basic data for generating a dynamic library; analyzing the target code to obtain a code structure of the target code; modifying the target code according to the set format of the dynamic library to obtain a modified target code; and generating a dynamic library by the modified target code according to a preset rule.

Description

Dynamic library generation method and device
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for generating a dynamic library.
Background
In the program, the library represents a preprogrammed reusable compilation function. The reason for using a library in a program is that functions can be conveniently used when repeatedly used, concrete implementation of functions can be hidden when the functions are distributed in the form of a library, and precompiled functions can be used as needed, thereby facilitating maintenance thereof.
Libraries are classified into static libraries, which are contained in an object file of an application program during a program compiling process, and dynamic libraries, which are contained in an object file when a computer program executes the process. The static library is combined with the object of the application program during compilation to form an execution file. Instead, the dynamic library separates a function commonly required by various programs from the application program, and loads the function to memory only when called during runtime. Since the static libraries are integrated with the objects of the application during compilation, the size of the execution file increases due to the large number of static libraries that are contained by the application. When a plurality of applications using the same static library are simultaneously executed, the respective same codes are loaded into the memory, and thus it is difficult to efficiently utilize the memory. However, when using a dynamic library, since a plurality of applications share and use one dynamic library, memory can be efficiently utilized.
Therefore, there is a need to provide a more reliable dynamic library generation scheme.
Disclosure of Invention
The embodiment of the specification provides a dynamic library generation method and a dynamic library generation device, which are used for solving the problems that codes need to be manually modified and the generation efficiency of a dynamic library is low in the conventional dynamic library generation method.
In order to solve the above technical problem, the embodiments of the present specification are implemented as follows:
the dynamic library generation method provided by the embodiment of the present specification is characterized by including:
acquiring a target code serving as basic data for generating a dynamic library;
analyzing the target code to obtain a code structure of the target code;
modifying the target code according to the set format of the dynamic library to obtain a modified target code;
and generating a dynamic library by the modified target code according to a preset rule.
An embodiment of the present specification provides a dynamic library generating apparatus, including:
the target code acquisition module is used for acquiring a target code serving as basic data for generating a dynamic library;
the code structure analysis module is used for analyzing the target code to obtain the code structure of the target code;
the object code modification module is used for modifying the object code according to the set format of the dynamic library to obtain a modified object code;
and the dynamic library generating module is used for generating a dynamic library by the modified target code according to a preset rule.
At least one embodiment of the present description can achieve the following advantageous effects: obtaining an object code serving as basic data for generating a dynamic library; analyzing the target code to obtain a code structure of the target code; modifying the target code according to the set format of the dynamic library to obtain a modified target code; and generating a dynamic library by the modified target code according to a preset rule. The method can automatically modify the target code serving as the basic data for generating the dynamic library into the code meeting the generation format of the dynamic library without manually modifying the target code by a user, thereby quickly generating the corresponding dynamic library and improving the generation efficiency.
Drawings
In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments described in the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without any creative effort.
FIG. 1 is a schematic overall flowchart of a dynamic library generation method in an embodiment of the present disclosure;
fig. 2 is a schematic structural diagram of a dynamic library generating apparatus provided in an embodiment of this specification.
Detailed Description
To make the objects, technical solutions and advantages of one or more embodiments of the present disclosure more apparent, the technical solutions of one or more embodiments of the present disclosure will be described in detail and completely with reference to the specific embodiments of the present disclosure and the accompanying drawings. It is to be understood that the embodiments described are only a few embodiments of the present specification, and not all embodiments. All other embodiments that can be derived by a person skilled in the art from the embodiments given herein without making any creative effort fall within the protection scope of one or more embodiments of the present disclosure.
The technical solutions provided by the embodiments of the present description are described in detail below with reference to the accompanying drawings.
The existing algorithm is manually written C/C + + engineering or C/C + + engineering generated by some tool software, and in practical application, some codes have code forms which do not meet the requirements of a dynamic library and cannot be directly generated. For example, the main function may be a simulation run rather than an algorithm main function, all of the input and output variables of the algorithm are global variables, the state of each calculation is cached through the global variables, and the like. For example: the online automatic driving algorithm is operated on the cloud platform in a dynamic library calling mode, and the method is an advantageous mode. However, there are many platforms for automated driving decision and control algorithm development. When the developed algorithm is generated into a dynamic library, the code of the algorithm does not necessarily accord with the requirements of the dynamic library on the code. For example, the cloud is to be multithreaded, and global variables cannot be used in generating dynamic library code. The algorithms are generated into a dynamic library, and codes are generally required to be modified manually, so that complex algorithms are large in code amount, complex in function calling relation, time-consuming and labor-consuming in manual modification, repeated modification is required each time, errors are extremely easy to make in the modification process, errors are not easy to find out after errors are made, and great adverse effects are caused on the efficiency of development iteration and repeated testing.
In order to solve the defects in the prior art, the scheme provides the following embodiments:
fig. 1 is a schematic overall scheme flow diagram of a dynamic library generation method in an embodiment of the present specification. From the viewpoint of a program, the execution subject of the flow may be a program installed in an application server or an application client. In the embodiment of the present specification, the execution subject may be a program installed in an application server for generating a dynamic library.
As shown in fig. 1, the process may include the following steps:
step 210: object code is obtained as basic data for generating a dynamic library.
Libraries, which are essentially binary forms of executable code, may be loaded into memory for execution by an operating system. Libraries can be divided into two categories: static libraries (. a,. lib) and dynamic libraries (. so,. dll). Static and dynamic refer to linking. When a program needs to run, in addition to the main program itself (EXE file), other files, including some system files of the operating system, need to be called, and the DLL is just used as the called file, i.e. the dynamic link library file. The dynamic library is not linked to the object code at the time of program compilation, but is loaded only when the program is running. If different application programs call the same library, only one instance of the shared library needs to be arranged in the memory, and the problem of space waste is avoided. The dynamic library is loaded only when the program runs, and the problem that the static library brings troubles to the updating, the deployment and the publishing of the program is solved. The user only needs to update the dynamic library. The dynamic library may correspond to a header file that contains definitions of data types and declarations of functions. The source file from which the dynamic library is made is the implementation of the function, i.e., the definition of the function. So, the name of the dynamic link library is in the form of libxxx, lib for prefix, and ". so" for suffix.
The object code needs to generate a corresponding dynamic library so as to be called at any time when a subsequent user uses the object code.
Step 220: and analyzing the target code to obtain the code structure of the target code.
The process of parsing may be understood as a process of identifying individual code structures in the code. The program code comprises a main self-defined function name, a main file name, a self-defined function, a global variable, a global constant and the like. The main self-defined function name is a function used for calling the dynamic library, and needs to be exposed to the outside in a function declaration mode. The variables are divided into local and global variables, and the local variables can also be called internal variables. Variables created by an object or a function are usually local variables, which can only be internally referenced, but cannot be referenced by other objects or functions. The global variable can be created by some object function or created anywhere in the program. The global variable is a variable that can be referenced by all objects or functions of the program.
Step 230: and modifying the target code according to the set format of the dynamic library to obtain the modified target code.
In generating a dynamic library, there are some formats set, for example: the cloud end needs to be used in a multi-thread mode, and global variables cannot be used in codes for generating the dynamic library. Generally, most of generated programs are used for simulation, but when a dynamic library is actually generated, only an algorithm applied to a core is needed, and therefore, some extra functions or other format contents in a code need to be eliminated.
Therefore, the target code can be automatically modified according to the set format of the dynamic library, so that the modified target code meets the code format requirement for generating the dynamic library.
Step 240: and generating a dynamic library by the modified target code according to a preset rule.
The generating a dynamic library according to the modified target code according to a preset rule may specifically include:
and identifying the statement of the dynamic library header file of the system based on the modified object code, adding a link command of the dynamic library of the system, and compiling to generate the dynamic library. Specifically, the method comprises the following steps: all Linked library commands with gcc-shared-fPIC space separation-o target. so generated commands are all linked library commands with gcc-shared-fPIC space separation.
It should be understood that the order of some steps in the method described in one or more embodiments of the present disclosure may be interchanged according to actual needs, or some steps may be omitted or deleted.
The method of FIG. 1, by obtaining object code that is the underlying data for generating a dynamic library; analyzing the target code to obtain a code structure of the target code; modifying the target code according to the set format of the dynamic library to obtain a modified target code; and generating a dynamic library by the modified target code according to a preset rule. The method can automatically modify the target code serving as the basic data for generating the dynamic library into the code meeting the generation format of the dynamic library without manually modifying the target code by a user, thereby quickly generating the corresponding dynamic library and improving the generation efficiency.
Based on the process of fig. 1, some specific embodiments of the process are also provided in the examples of this specification, which are described below.
Optionally, the analyzing the object code to obtain the code structure of the object code may specifically include:
determining a main self-defined function name and a main file name in the target code;
determining a code file corresponding to the target code based on the main custom function name and the main file name;
for any one code file, identifying a global variable and a global constant in the code file, and storing the global variable and the global constant in a database.
The database may be a list of corresponding records or stored code structures for dynamic library generation.
The main custom function name and the main file name in the code are identified, the header files can be read through the main file name, all the cited project header files are identified, the code files corresponding to all the header files are sequentially read, all the cited system header files are further identified, and for the system header files, a corresponding preset command which links the dynamic library of the system header files during compiling is found. Specifically, the content in the include is identified, and the spaces are ignored.
The code files are read, and for each file, the defined global variables are identified and stored in a list. The global variable definition is a variable definition outside the function definition after include, and the variable definition can be judged through a format and variable type key.
Optionally, the analyzing the object code to obtain the code structure of the object code may specifically include:
identifying a function declaration or definition in the code file;
storing the function names used in the function declarations or definitions in the database.
Optionally, the analyzing the object code to obtain the code structure of the object code may specifically include:
identifying a custom function in the code file;
and determining the calling of the custom function in the custom function.
Optionally, after determining the corresponding call function in the custom function, the method may further include:
determining the calling of all corresponding code files to the custom function;
and generating a function call relation diagram based on the custom function call of all the code files, and storing the function call relation diagram in the database.
The call relation graph can comprise call relations among the functions in the target code, and the relevance among the functions is known.
Specifically, code files are read, function statements are identified for each file, function names are stored, calling of custom functions in the codes is identified in function definition, the used custom functions are found according to main function definition, the used custom functions are found in the custom functions, and the like, so that a calling relation graph among the functions is generated.
Optionally, the identification function declaration may be implemented by a format, including a return variable type or a return value-free flag void, a function name, and an input variable type divided by commas in parentheses; the function definition identification finds a brace on the basis of the function declaration so as to determine the calling relationship; the function call is the function name plus parenthesis and its internal input parameters. Optionally, the modifying the object code according to the set format of the dynamic library to obtain a modified object code may specifically include:
modifying the global variable used by the self-defined function into the function input parameter in the function statement and definition, and modifying the calling statement of the original global variable in the function definition according to the input parameter form;
determining a target function for calling the custom function according to the calling relation graph;
modifying the corresponding statement for calling the self-defined function in the target function definition into the function calling statement in the new parameter transfer form to obtain a modified code;
and adding the global constant definition into a self-defined function using the global constant in the modified code to be used as a local constant, and obtaining the modified target code.
Optionally, if a pointer is used to transfer the global variable in the modification process of inputting the global variable as the function parameter and the global variable is a structural body, the function definition is modified from "." - > "when the internal variable of the original global variable structure is called.
Optionally, the modified object code may include a header file reference of the object code as basic data for generating a dynamic library, a variable and structure type definition, a main function declaration of the modified object code, and a calling function declaration.
Reading the code file, identifying the global variable used in the code file in the function definition of each function, rewriting the global variable into the function parameter of the pointer type, and rewriting the global variable in the function definition into the pointer form. And according to the call relation diagram, rewriting a function call statement for other functions calling the function, and adding corresponding pointer type global variable parameter transfer.
The calls of the functions may be nested, i.e., the parameter of one function is the return value of another function, and thus the wrapping needs to be ignored and identified with bracket matching.
For each code file and header file, a new version of the file is created, which can be identified as the modified object code. The new version code file comprises the head file reference of the original version code file, the definition of the global constant and the declaration and definition of the function in the call relation graph after the modification, the new version head file comprises the head file reference of the original version code file, the definition of the variable and the type of the structure body, the main function declaration which accords with the generation requirement of the dynamic library and the other original function declarations. And associating all program files, identifying the statements of the dynamic library head file of the system, adding a link command of the dynamic library of the system, and compiling to generate the dynamic library.
Optionally, for a C + + project written in an object-oriented manner, each function may be a member function, so when writing a new version of a code file, a class definition is retained, and a similar structure automatic adjustment is implemented on the selected function definition in the class.
According to the method, a calling relation graph is established by presetting a main function and recognizing function calling; converting the global variable into modification of pointer parameters; extracting useful codes and generating a dynamic library for the new version file; the code form is standard, no global variable exists, and the method can be used for multithreading; and moreover, variables, functions and calls are automatically identified, the adaptability to code forms is strong, only main self-defined function names are required to be input, one-key operation is realized, the use is easy, and the generation efficiency of the dynamic library is high.
Based on the same idea, the embodiment of the present specification further provides a device corresponding to the above method. Fig. 2 is a schematic structural diagram of a dynamic library generating apparatus provided in an embodiment of this specification. As shown in fig. 2, the apparatus may include:
an object code obtaining module 210 for obtaining an object code as basic data for generating a dynamic library;
a code structure analysis module 220, configured to analyze the target code to obtain a code structure of the target code;
an object code modification module 230, configured to modify the object code according to the set format of the dynamic library, to obtain a modified object code;
and a dynamic library generating module 240, configured to generate a dynamic library according to a preset rule by using the modified target code.
The examples of the present specification also provide some specific embodiments of the apparatus based on the apparatus of fig. 2, which is described below.
Optionally, the code structure may include at least a main custom function name, a main file name, a calling function, a global variable, and a global constant.
Optionally, the code structure parsing module 220 may specifically include:
the main custom function name and main file name determining unit is used for determining a main custom function name and a main file name in the target code;
the code file determining unit is used for determining a code file corresponding to the target code based on the user-defined function name and the main file name;
and the global variable and global constant identification unit is used for identifying the global variable and the global constant in any code file and storing the global variable and the global constant in a database.
Optionally, the code structure parsing module 220 may specifically include:
a function declaration identifying unit for identifying a function declaration or definition in the code file;
a function name storage unit for storing function names used in the function declaration or definition in the database.
Optionally, the code structure parsing module 220 may specifically include:
the self-defined function identification unit is used for identifying the self-defined function in the code file;
and the calling function determining unit is used for determining the calling of the custom function in the custom function.
Optionally, the code structure parsing module 220 may be further configured to:
determining the calling of all corresponding code files to the custom function;
and generating a function call relation diagram based on the custom function call of all the code files, and storing the function call relation diagram in the database.
Optionally, the object code modification module 230 may specifically include:
the global variable modification unit is used for modifying the global variable used by the user-defined function into the function input parameter in the function statement and definition and modifying the calling statement of the original global variable in the function definition according to the input parameter form;
the target function determining unit is used for determining a target function for calling the custom function according to the calling relation graph;
a calling statement modification unit, configured to modify a corresponding statement for calling the custom function in the target function definition into a function calling statement in the new parameter transfer form, so as to obtain a modified code;
and the target code modifying unit is used for adding the global constant definition to a self-defined function using the global constant in the modified code to be used as a local constant to obtain the modified target code.
Optionally, the dynamic library generating module 240 may specifically include:
and the dynamic library generating unit is used for identifying the head file statement of the system dynamic library, adding a link command of the system dynamic library and compiling to generate the dynamic library based on the modified object code.
Optionally, the modified object code may include a header file reference of the object code as basic data for generating a dynamic library, a variable and structure type definition, a main function declaration of the modified object code, and a calling function declaration.
In the embodiment, the target code serving as the basic data for generating the dynamic library is acquired; analyzing the target code to obtain a code structure of the target code; modifying the target code according to the set format of the dynamic library to obtain a modified target code; and generating a dynamic library by the modified target code according to a preset rule. The method can automatically modify the target code serving as the basic data for generating the dynamic library into the code meeting the generation format of the dynamic library without manually modifying the target code by a user, thereby quickly generating the corresponding dynamic library and improving the generation efficiency.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the apparatus embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose Logic functions are determined by programming the Device by a user. A digital character system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate a dedicated integrated circuit chip. Furthermore, nowadays, instead of manually making an Integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development and writing, but the original code before compiling is also written by a specific Programming Language, which is called Hardware Description Language (HDL), and HDL is not only one but many, such as abel (advanced Boolean Expression Language), ahdl (alternate Hardware Description Language), traffic, pl (core universal Programming Language), HDCal (jhdware Description Language), lang, Lola, HDL, laspam, hardward Description Language (vhr Description Language), vhal (Hardware Description Language), and vhigh-Language, which are currently used in most common. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include, but are not limited to, the following microcontrollers: the ARC625D, AtmelAT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic for the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller as pure computer readable program code, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may thus be considered a hardware component, and the means included therein for performing the various functions may also be considered as a structure within the hardware component. Or even means for performing the functions may be regarded as being both a software module for performing the method and a structure within a hardware component.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functionality of the units may be implemented in one or more software and/or hardware when implementing the present application.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention 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 invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. 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.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Disks (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission medium which can be used to store information which can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
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 application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (10)

1. A method for dynamic library generation, comprising:
acquiring a target code serving as basic data for generating a dynamic library;
analyzing the target code to obtain a code structure of the target code;
modifying the target code according to the set format of the dynamic library to obtain a modified target code;
and generating a dynamic library by the modified target code according to a preset rule.
2. The method of claim 1, wherein the code structure comprises at least a primary custom function name, a primary file name, a custom function, a global variable, and a global constant.
3. The method according to claim 2, wherein the analyzing the object code to obtain the code structure of the object code specifically comprises:
determining a main self-defined function name and a main file name in the target code;
determining a code file corresponding to the target code based on the main custom function name and the main file name;
for any one code file, identifying a global variable and a global constant in the code file, and storing the global variable and the global constant in a database.
4. The method according to claim 3, wherein the analyzing the object code to obtain the code structure of the object code specifically comprises:
identifying a function declaration or definition in the code file;
storing the function names used in the function declarations or definitions in the database.
5. The method according to claim 3, wherein the analyzing the object code to obtain the code structure of the object code specifically comprises:
identifying a custom function in the code file;
and determining the calling of the custom function in the custom function.
6. The method of claim 5, wherein after determining the call to the custom function in the custom function, further comprising:
determining the calling of all corresponding code files to the custom function;
and generating a function call relation diagram based on the custom function call of all the code files, and storing the function call relation diagram in the database.
7. The method according to claim 6, wherein the modifying the object code according to the set format of the dynamic library to obtain the modified object code specifically comprises:
modifying the global variable used by the self-defined function into the function input parameter in the function statement and definition, and modifying the calling statement of the original global variable in the function definition according to the input parameter form;
determining a target function for calling the custom function according to the calling relation graph;
modifying the corresponding statement for calling the self-defined function in the target function definition into the function calling statement in the new parameter transfer form to obtain a modified code;
and adding the global constant definition into a self-defined function using the global constant in the modified code to be used as a local constant, and obtaining the modified target code.
8. The method according to claim 1, wherein the generating a dynamic library from the modified object code according to a preset rule specifically comprises:
and identifying the statement of the dynamic library header file of the system based on the modified object code, adding a link command of the dynamic library of the system, and compiling to generate the dynamic library.
9. The method of claim 1, wherein the modified object code comprises a header reference of the object code as basic data for generating a dynamic library, a variable and structure type definition, and all custom function declarations and definitions of the modified object code.
10. A dynamic library generation apparatus, comprising:
the target code acquisition module is used for acquiring a target code serving as basic data for generating a dynamic library;
the code structure analysis module is used for analyzing the target code to obtain the code structure of the target code;
the object code modification module is used for modifying the object code according to the set format of the dynamic library to obtain a modified object code;
and the dynamic library generating module is used for generating a dynamic library by the modified target code according to a preset rule.
CN202111401467.3A 2021-11-19 2021-11-19 Dynamic library generation method and device Pending CN114064114A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111401467.3A CN114064114A (en) 2021-11-19 2021-11-19 Dynamic library generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111401467.3A CN114064114A (en) 2021-11-19 2021-11-19 Dynamic library generation method and device

Publications (1)

Publication Number Publication Date
CN114064114A true CN114064114A (en) 2022-02-18

Family

ID=80275534

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111401467.3A Pending CN114064114A (en) 2021-11-19 2021-11-19 Dynamic library generation method and device

Country Status (1)

Country Link
CN (1) CN114064114A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117009252A (en) * 2023-10-07 2023-11-07 之江实验室 Fault injection testing method and device based on function replacement

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117009252A (en) * 2023-10-07 2023-11-07 之江实验室 Fault injection testing method and device based on function replacement
CN117009252B (en) * 2023-10-07 2024-01-02 之江实验室 Fault injection testing method and device based on function replacement

Similar Documents

Publication Publication Date Title
CN111796831B (en) Compiling method and device for multi-chip compatibility
US6961931B2 (en) Dependency specification using target patterns
US10324712B1 (en) Method and system of migrating legacy code for upgraded systems
CN111399853A (en) Templated deployment method of machine learning model and custom operator
CN108197027B (en) Software performance optimization method, storable medium, computer program
US20110126179A1 (en) Method and System for Dynamic Patching Software Using Source Code
US10248409B1 (en) Limiting the effects of source code patches on corresponding native-code patches
US10289395B2 (en) Performing a compiler optimization pass as a transaction
CN112882718A (en) Compiling processing method, device, equipment and storage medium
CN112527415A (en) Method, device, equipment and medium for migrating applets across platforms
US20180203676A1 (en) Removing library objects from a static library
Favre Preprocessors from an abstract point of view
WO2018161509A1 (en) Conditional compilation preprocessing method, terminal and storage medium
CN114547024A (en) SQL statement risk detection method, device, equipment and medium
CN112860312A (en) Method and device for detecting item dependency relationship change
US10839124B1 (en) Interactive compilation of software to a hardware language to satisfy formal verification constraints
JP4806158B2 (en) System and method for declaratively defining and using subclasses in markup
US20030110468A1 (en) Program code generator and program
CN114064114A (en) Dynamic library generation method and device
US11593076B2 (en) Method for merging architecture data
KR100834676B1 (en) Method for building software project
KR20090011974A (en) Method for extracting the target files of compilation
CN115934161A (en) Code change influence analysis method, device and equipment
CN113608748B (en) Data processing method, device and equipment for converting C language into Java language
CN111176623B (en) C + + abstract information recovery method based on graph convolution neural network

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