Data processing method and device, electronic equipment and readable medium

By generating name modification files for open source libraries and generating symbol intercept files for closed source libraries, the symbol conflict problem between library files is solved to ensure that the software is running normally.

CN120276726APending Publication Date: 2025-07-08LOONGSON TECH CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510346366.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-21
Publication Date
2025-07-08

AI Technical Summary

Technical Problem

In software development, symbol conflicts caused by duplicate symbols between library files affect the normal operation of the software.

Method used

By selecting m-1 library files as the pending library, if it is an open source library, generate a name modification file to modify the symbol name, and if it is a closed source library, generate a symbol intercept file for symbol isolation to ensure that the symbol name is unique.

Benefits of technology

It effectively avoids symbolic conflicts between library files, ensures that the software is running normally, and is suitable for open source and closed source library files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120276726A_ABST
    Figure CN120276726A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a data processing method and device, electronic equipment and a readable medium, and relates to the technical field of computers, in the method, m-1 library files are selected as libraries to be processed from m library files on which a target module in software to be processed depends. If the current to-be-processed library is an open source library, generating a name modification file for the current to-be-processed library, and modifying symbol names in the current to-be-processed library into specified names based on the name modification file; the specified name is different from symbol names in other library files. And if the current to-be-processed library is a closed source library, generating a symbol interception file based on a target module corresponding to the current to-be-processed library, and when the target module calls symbols in the current to-be-processed library, loading the to-be-processed library according to the symbol interception file, so that the target module calls the symbols in the current to-be-processed library. In this way, the symbol conflict problem can be avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular, to a data processing method, apparatus, electronic device, and readable medium. Background Art

[0002] Currently, in modern software development, software is designed in a modular manner, that is, software can include multiple modules, and modules can rely on some reusable code blocks to improve execution efficiency. These code blocks are called library files. Library files will include some externally visible, accessible, and callable symbols for modules to access and link. In the case where there are duplicate symbols in the library files relied on by multiple modules, symbol conflict problems often occur, which in turn affects the normal operation of the software.

[0003] Therefore, there is an urgent need for a data processing method to solve the symbol conflict problem. Summary of the Invention

[0004] Embodiments of the present invention provide a data processing method, apparatus, electronic device, and readable medium, which can solve the symbol conflict problem.

[0005] To solve the above problems, embodiments of the present invention disclose a data processing method, which includes:

[0006] Select m - 1 library files from the m library files relied on by a target module in a software to be processed as library files to be processed; there are duplicate symbols among the m library files; m is an integer not less than 2;

[0007] If the current library file to be processed is an open - source library, generate a name modification file for the current library file to be processed, and modify the symbol names in the current library file to specified names based on the name modification file; the specified names are all different from the symbol names in other library files;

[0008] If the current library file to be processed is a closed - source library, generate a symbol interception file based on the target module corresponding to the current library file to be processed, and when the target module calls the symbols in the current library file to be processed, load the current library file to be processed according to the symbol interception file for the target module to call the symbols in the current library file to be processed.

[0009] On the other hand, embodiments of the present invention disclose a data processing apparatus, which includes:

[0010] A selection module, configured to select m - 1 library files from the m library files relied on by a target module in a software to be processed as library files to be processed; there are duplicate symbols among the m library files; m is an integer not less than 2;

[0011] The first processing module is configured to, if the current library to be processed is an open-source library, generate a name modification file for the current library to be processed, and modify the symbol names in the current library to be processed to specified names respectively based on the name modification file; the specified names are different from the symbol names in other library files.

[0012] The second processing module is configured to, if the current library to be processed is a closed-source library, generate a symbol interception file based on the target module corresponding to the current library to be processed, and when the target module calls the symbols in the current library to be processed, load the current library to be processed according to the symbol interception file, so that the target module can call the symbols in the current library to be processed.

[0013] In another aspect, an embodiment of the present invention discloses an electronic device, including: a processor, a memory, a communication interface, and a communication bus. The processor, the memory, and the communication interface complete communication with each other through the communication bus; the memory is used to store at least one executable instruction, and the executable instruction causes the processor to execute the foregoing method.

[0014] An embodiment of the present invention also discloses a machine-readable medium, on which instructions are stored, and when executed by one or more processors, cause the processors to execute the method as described above.

[0015] The embodiments of the present invention include the following advantages: In the data processing method provided by the embodiments of the present invention, m - 1 library files are selected from the m library files on which the target module in the software to be processed depends as the libraries to be processed; there are duplicate symbol names among the m library files. If the current library to be processed is an open-source library, a name modification file is generated for the current library to be processed, and the symbol names in the current library to be processed are modified to specified names respectively based on the name modification file; the specified names are different from the symbol names in other library files. In this way, by modifying the names, it is possible to avoid duplicate symbol names between the library to be processed and other libraries, and thus avoid symbol conflict problems. If the current library to be processed is a closed-source library, a symbol interception file is generated based on the target module corresponding to the current library to be processed, and when the target module calls the symbols in the current library to be processed, the library to be processed is loaded according to the symbol interception file, so that the target module can call the symbols in the current library to be processed, realizing symbol isolation, thereby ensuring that the symbol names in the current library to be processed are not repeated, and thus avoiding symbol conflict problems. Description of the Drawings

[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required to be used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0017] Figure 1 is a flowchart of steps of a data processing method provided by an embodiment of the present invention;

[0018] Figure 2 is a block diagram of a data processing device provided by an embodiment of the present invention;

[0019] Figure 3 is a schematic structural diagram of an electronic device provided by an embodiment of the present invention. Detailed implementation manners

[0020] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present invention.

[0021] Figure 1 is a flowchart of steps of a data processing method provided by an embodiment of the present invention. As Figure 1 shown, the data processing method may include the following steps:

[0022] Step 101: Select m - 1 library files from the m library files on which a target module in the software to be processed depends as the library files to be processed; there are duplicate symbols among the m library files; m is an integer not less than 2.

[0023] Step 102: If the current library file to be processed is an open-source library, generate a name modification file for the current library file to be processed, and based on the name modification file, modify the symbol names in the current library file to specified names respectively; the specified names are different from the symbol names in other library files.

[0024] Step 103: If the current library file to be processed is a closed-source library, generate a symbol interception file based on the target module corresponding to the current library file to be processed, and when the target module calls the symbols in the current library file to be processed, load the library file to be processed according to the symbol interception file for the target module to call the symbols in the current library file to be processed.

[0025] The execution subject of the data processing method provided by the embodiments of the present invention can be an electronic device, which can adopt the Linux system. The software to be processed is software that can be compiled and run on the electronic device. The module can also be in the form of a library file. For example, the module can be a static library. Among them, the library file can also be called a library or a link library. Correspondingly, the embodiments of the present invention can be directed to a complex environment where multiple library files are interdependent, that is, the software depends on modules in the form of multiple library files, and these modules secondarily depend on other library files.

[0026] Compilation and build is the process of converting source code into an executable file, including two main stages: compilation and linking. Compilation converts the source code file written in a high-level language into an intermediate code file, and linking integrates the intermediate code file and the library into the final executable file. During the linking process, the symbol table is used to record all symbols in the program and resolve the definition and reference of each symbol. Among them, symbols can include functions and variables. Libraries can be divided into static libraries and dynamic libraries. Static libraries are directly loaded into the executable file during compilation, and dynamic libraries are loaded during runtime.

[0027] Static libraries and dynamic libraries can be open-source libraries or closed-source libraries. Among them, an open-source library refers to a library whose source code can be obtained, and a closed-source library refers to a library whose source code cannot be obtained. For a closed-source library, only the compiled binary library can be obtained. That is to say, the closed-source libraries relied on by the software to be processed do not need to be compiled. Correspondingly, by generating a symbol interception file, symbol conflicts can be avoided through interception during the runtime. Symbol conflict means that multiple different library files define symbols with the same name, that is, functions or variables with the same name are defined, which may cause runtime errors. During the runtime, if multiple symbols with the same name exist in the library files, the symbol in the first-loaded library file will overwrite the symbols with the same name in other library files, thus bringing potential hazards to the program operation.

[0028] Module dependency on library files means that the module includes functions that call symbols in the library file. In actual application scenarios, a module can depend on multiple library files. The target module can be part or all of the modules in the software to be processed, where m is a positive integer not less than 2. The above m library files are the library files with the same name symbols among the multiple library files on which the modules in the software to be processed depend. The m library files can also be called conflicting libraries. The target module refers to the module whose dependent library files include conflicting libraries.

[0029] In the embodiments of the present invention, a conflicting library can be depended on by different target modules. Exemplarily, the software to be processed includes Module 1, Module 2, and Module 3. Among them, the library files on which Module 1, Module 2, and Module 3 depend respectively are: Library A, Library B, and Library C. There are the same name symbols among Library A, Library B, and Library C. Then m = 3, and Library A and Library B can be determined as the libraries to be processed.

[0030] Further, m - 1 library files can be randomly selected from the m library files as the library to be processed, and the library to be processed is processed to ensure that the names of the libraries among the m library files are not the same, thereby avoiding the symbol conflict problem. Exemplarily, assuming m is 2, then one of the library files can be selected as the library to be processed. Assuming m is 3, then two of the library files can be selected as the library to be processed. Assuming the m library files include: Library A, Library B, and Library C. Select Library A and Library B as the libraries to be processed. By controlling that the symbol names in Library A are different from those in other library files (Library B and Library C), or by loading Library A through a symbol interception file and calling the symbols in Library A when calling the symbols in Library A, the symbol isolation between Library A and other library files (Library B and Library C) is achieved. By controlling that the symbol names in Library B are different from those in other library files (Library A and Library C), or by loading Library B through a symbol interception file and calling the symbols in Library B when calling the symbols in Library B, the symbol isolation between Library B and other library files (Library A and Library C) is achieved. In this way, for the library file that is not selected as the library to be processed (i.e., the above-mentioned Library C), Library C is also prevented from conflicting with Library A and Library B.

[0031] In the embodiments of the present invention, the name modification file can also be referred to as a symbol name modification macro file, and the target module can also be referred to as an intermediate build target. The currently processed library is any one of the m - 1 libraries to be processed. For any library to be processed, the above step 102 or step 103 is respectively adopted based on whether the library to be processed is an open-source library or a closed-source library. If all of the m - 1 libraries to be processed are open-source libraries, then the above step 102 can be used to process each of the m - 1 libraries to be processed. If all of the m - 1 libraries to be processed are closed-source libraries, then the above step 103 can be used to process each of the m - 1 libraries to be processed. If a part of the m - 1 libraries to be processed is open-source libraries and the other part is closed-source libraries, then the above step 102 and step 103 can be used to process these two parts of the libraries to be processed respectively.

[0032] In summary, in the data processing method provided by the embodiments of the present invention, from the m library files on which the target module in the software to be processed depends, m - 1 library files are respectively selected as the libraries to be processed; there are duplicate symbols among the m library files. If the current library to be processed is an open-source library, a name modification file is generated for the current library to be processed, and based on the name modification file, the symbol names in the current library to be processed are respectively modified to specified names; the specified names are different from the symbol names in other library files. In this way, by modifying the names, it is possible to avoid duplicate symbols between the library to be processed and other libraries, thereby avoiding symbol conflict problems. If the current library to be processed is a closed-source library, a symbol interception file is generated based on the target module corresponding to the current library to be processed, and when the target module calls the symbols in the current library to be processed, the library to be processed is loaded according to the symbol interception file, so that the target module can call the symbols in the current library to be processed, achieving symbol isolation, thereby ensuring that the symbol names in the current library to be processed are not repeated, and thus avoiding symbol conflict problems.

[0033] Optionally, the step of generating a name modification file for the current library to be processed may specifically include:

[0034] Step 1021: Compile the current library to be processed to obtain the symbol table of the current library to be processed as the first symbol table.

[0035] Step 1022: According to a preset generation command and each symbol name in the first symbol table, batch generate macro statements for each symbol in the first symbol table; the macro statements include the symbol name and the specified name generated for the symbol.

[0036] Step 1023: Use the macro file generated based on the macro statements as the name modification file.

[0037] In the embodiments of the present invention, the current library to be processed can be first compiled by a compiler to obtain the compiled current library to be processed. Then, based on a preset symbol table acquisition tool, the symbol table of the current library to be processed is obtained as the first symbol table. Among them, the compiler constructs a symbol table during the compilation process to record the symbols that appear in the source code of the current library to be processed. Therefore, the current library to be processed can be first compiled, and then based on the symbol table acquisition tool, the symbol table is obtained from the compiled current library to be processed to obtain the first symbol table. Among them, the symbol table can adopt a data structure of a multi-dimensional array. For example, one row in the multi-dimensional array corresponds to representing a symbol, and one column in the multi-dimensional array corresponds to representing an item of information of the symbol. The information of the symbol can include symbol address, symbol type, symbol name, etc. Exemplarily, the preset symbol table acquisition tool can be the nm tool or the readelf tool, and the nm tool or the readelf tool can list the symbol table in the current library to be processed.

[0038] Furthermore, since the first symbol table obtained by extraction may also include other information besides the name. Therefore, based on a preset extraction tool, the symbol name can be automatically detected and extracted from the first symbol table, that is, other content except the symbol name is removed, and finally a symbol table containing only the name is obtained.

[0039] Exemplarily, the preset extraction tool can be a text processing tool: the awk tool. For example, the information format in the first symbol table obtained by the nm tool is: symbol address, symbol type, symbol name. Exemplarily, this information format can be expressed as: 0000000000001010T func_example. The information format in the first symbol table obtained by the readelf tool is: symbol address, symbol size, symbol type, symbol visibility, section where the symbol is located, symbol name. Exemplarily, this information format can be expressed as: 0000000000000000 0NOTYPE LOCAL DEFAULT ABS_DYNAMIC. Accordingly, the last required field, that is, the symbol name, can be intercepted based on the preset extraction tool. In this way, through automatic extraction, manual extraction is not required, reducing the manual burden, reducing the complexity of manual operations and errors caused by manual operations. At the same time, the speed of problem-solving is improved.

[0040] Exemplarily, taking the software to be processed written in C++ language as an example, the first symbol table containing only the symbol name can be obtained through the following name extraction commands for the corresponding symbol table acquisition tool and the preset extraction tool. The first symbol table containing only the symbol name is the symbol name list. Among them, the name extraction command can be:

[0041] nm your_library.so-with-symbol-version|c++filt|awk '{print$NF}'.

[0042] Among them, nm your_library.so-with-symbol-version means listing the symbol table in the library to be processed and displaying the version information of the symbol when extracting the name; c++filt means removing C++ name decoration when extracting the name; awk '{print$NF}' means outputting the last field ($NF) of each line in the first symbol table to obtain a symbol name list containing only each symbol name, that is, the first symbol table containing only the symbol name.

[0043] It should be noted that when obtaining the symbol table of the current library to be processed, filtering conditions can also be preset according to actual application requirements and scenarios, and the symbol range to be processed when generating macro statements can be narrowed by presetting the filtering conditions. For example, the preset filtering conditions can be that there are symbols with the same name in other library files, the name uses a specific namespace, has a specific version suffix, etc., and the embodiments of the present invention do not limit this. Before generating the macro statement, filtering is performed based on the preset filtering conditions, and the symbol names that do not meet the preset filtering conditions are excluded, and only the remaining symbol names that meet the preset filtering conditions are processed subsequently to obtain the macro statements of the symbols whose symbol names meet the preset filtering conditions, and the embodiments of the present invention do not limit this.

[0044] When batch generating macro statements, the preset generation command can be a command supported by the preset generation tool, and the preset generation command can be used to generate macro statements based on each symbol name in the first symbol table, as well as the macro definition identifier and macro definition text defined in the command. Among them, one macro statement corresponds to one symbol, and the macro statement can include the symbol name (i.e., the original name) and the specified name (i.e., the new name) generated for the symbol. Among them, the specified name of the symbol is globally unique, that is, the specified name of the symbol does not repeat with the symbol names in other library files to ensure the uniqueness of the name. Specifically, the macro definition identifier can make the macro statement conform to the macro definition format, and the macro definition text can be combined with the symbol name as a prefix or suffix to obtain a new name. Exemplarily, the macro definition identifier can be the default identifier: #define, and the macro definition text can be set as needed, and the macro definition texts of different libraries to be processed are different, and the embodiments of the present invention do not limit this.

[0045] Exemplarily, the preset generation tool can be the awk tool or the sed tool. Among them, the sed tool is a stream editor that can filter and transform text data. In the embodiments of the present invention, only the macro definition text needs to be formulated in advance, and batch generation of macro statements can be achieved through the preset generation command, and the degree of automation is relatively high, so the symbol processing is more efficient. Among them, the preset generation command can be a generation command pre-inserted in the implementation code of this data processing method. Or, it can also be a generation command pre-entered by the user in the electronic device, for example, entered after determining the library to be processed. The preset generation command includes a macro definition identifier and a macro definition text. When the electronic device executes the preset generation command, it can call the preset generation tool for processing to batch generate macro statements.

[0046] Taking the sed tool as an example, assuming the macro definition text is: your_prefix_, the preset generation command can be:

[0047] sed's / ^\(.*\) / #define\1your_prefix_\1 / '

[0048] Among them, "sed's / ^\(.*\) / #define\1your_prefix_\1 / " means searching each line of the input text, adding "#define" to the beginning of each line, capturing the content of each line (i.e., the original name) in the first symbol table, and adding the "your_prefix_" prefix to the content of each line. The input text is the first symbol table that only includes symbol names. In this way, by batch-inputting the symbol names in the first symbol table, macro statements for each symbol can be obtained in batch.

[0049] Suppose the input text (i.e., the symbol names in the input first symbol table) is:

[0050] foo

[0051] read

[0052] write

[0053] By executing the preset to generate names, the macro statements generated for each name can be obtained:

[0054] #define foo your_prefix_foo

[0055] #define read your_prefix_read

[0056] #define write your_prefix_write

[0057] Then the format of the macro statement can be expressed as: #define conflicting_symbol renamed_symbol. Among them, conflicting_symbol represents the original name, and renamed_symbol represents the specified name. Macro statements can be generated for each symbol name in the symbol name list respectively. Correspondingly, by storing all the macro statements in the macro definition header file, the macro file can be obtained, that is, the name modification file can be obtained. Among them, this name modification file can be named redefine-exported-symbols.h to show that it is a header file used to update symbol names. In the case of multiple open-source libraries to be processed, for the first symbol table corresponding to each library to be processed, the above steps 1021 to 1023 can be reused for operation to generate name modification files for batch name modification for multiple libraries to be processed.

[0058] In an embodiment of the present invention, the current library to be processed is compiled to obtain a symbol table of the current library to be processed, which is used as the first symbol table. According to a preset generation command and each symbol name in the first symbol table, macro statements are generated in batches for each symbol in the first symbol table; the macro statements include the symbol name and a specified name generated for the symbol. The macro file generated based on the macro statements is used as a name modification file, and a specific operation method for automatically generating a name modification file is given. Moreover, according to the preset generation command, macro statements can be conveniently generated in batches, and a name modification file can be obtained by generating a macro file based on the macro statements, with high generation efficiency. Furthermore, the first compiler option can be quickly generated in response to the first compiler, so as to modify the names of multiple open-source libraries to be processed respectively, avoiding symbol conflicts.

[0059] Optionally, the step of modifying the symbol names in the current library to be processed to the specified names based on the name modification file may specifically include:

[0060] Step 1024: Store the name modification file in a specified path corresponding to the software to be processed.

[0061] Step 1025: Generate a first compilation option for the first compiler based on the specified path, and re-compile the current library to be processed to modify the symbol names in the current library to be processed to the specified names.

[0062] In an embodiment of the present invention, the macro definition file may include the original names and specified names of each symbol in the first symbol table. The macro definition file can be regarded as a symbol renaming rule. When the macro definition file is written to a specified path, it is convenient for subsequent updates, maintenance, or adjustments according to requirements, and can be flexibly used, reducing the cost of subsequent long-term maintenance and having good maintainability.

[0063] The specified path can be the project library file path of the software to be processed. Exemplarily, the specified path can be expressed as / path / to / redefine-exported-symbols.h. After placing the name modification file under the specified path, a first compilation option can be generated for the first compiler based on the specified path. Herein, the first compiler can be the compiler used to compile the current library to be processed. Specifically, the specified path can be written into a preset compilation option template to obtain the first compilation option. Then, the first compilation option is set for the first compiler. For example, the first compilation option can be added to the compiler options of the first compiler. In this way, the name modification file can be passed to the first compiler through the first compilation option. Subsequently, the current library to be processed can be recompiled. Specifically, the first compiler can be started to compile the current library to be processed. In the embodiment of the present invention, during compilation, the conflicting_symbol of the original symbol can be replaced with the new name renamed_symbol in the preprocessing stage based on the name modification file. By placing the name modification file under the preset specified path, it can be ensured that the name modification file can be successfully loaded according to the specified path during the secondary compilation, thereby realizing name modification.

[0064] Exemplarily, the compilation option template can be -Wp, -imacros, the specified path. Correspondingly, the compilation option template can be: -Wp, -imacros, / path / to / redefine-exported-symbols.h. Among them, -Wp indicates that the subsequent content in the first compilation option is passed to the preprocessor, and -imacros indicates that a macro definition file named redefine-exported-symbols.h is specified. By setting the first compilation option and starting the first compiler to compile the current library to be processed, it can be made such that when the first compiler formally compiles the current library to be processed, all macro statements of the macro definition file are inserted at the beginning of the source file of the current library to be processed. Then, during the preprocessing stage, the preprocessor is called to first execute the macro definition file for name modification, and then the formal compilation of the current library to be processed begins.

[0065] In the embodiment of the present invention, the name modification file field is stored under the specified path to pass the name modification file to the first compiler. Specifically, a first compilation option is generated for the first compiler based on the specified path, and the first compilation option is set for the first compiler, so that the first compiler can execute the name modification file according to the first compilation option to modify the symbol name in the current library to be processed to the specified name. In this way, the burden caused by manual modification can be avoided, and the problem of errors caused by the overly long command line when implementing name modification using the name modification file in a command-line manner can be avoided, thereby making the name modification method more reliable.

[0066] In an embodiment of the present invention, during the preprocessing stage of the secondary compilation process, unified renaming can be performed based on the name modification file, and each symbol name is replaced with a unique specified name. Specifically, during the preprocessing stage, according to the first compilation option, the name modification file under the specified path can be obtained, and then the name modification file is executed to modify the symbol name in the current library to be processed to the specified name. In this way, during the secondary compilation process, all symbols that may cause symbol conflicts are renamed to unique names based on the name modification file, thereby ensuring that the symbols in the symbol table after the secondary compilation no longer conflict with the symbols of other library files.

[0067] In an embodiment of the present invention, the name modification file is stored in the specified path corresponding to the software to be processed. Based on the specified path, a first compilation option is generated for the first compiler, and the current library to be processed is recompiled to modify the symbol names in the current library to be processed to the specified names respectively. In this way, batch modification of each symbol name in the first symbol table is achieved through the name modification file, providing a clear and feasible name modification method. And by generating the name modification file, during the preprocessing stage, the name modification file is executed according to the first compilation option first, and the symbol names in the library to be processed are uniformly modified to the specified names that conform to the macro definition according to the name modification file. In this way, it is possible to avoid compilation errors of the first compiler caused by subsequent symbol conflicts, thereby ensuring that the final compilation and construction can be correctly completed and ensuring that the software to be processed can run stably subsequently.

[0068] For the scenario where the library to be processed is an open-source library, that is, the source code of the library to be processed can be modified, in an embodiment of the present invention, the first symbol table is obtained through the first compilation, and then after generating the name modification file, the name modification file is called according to the specified path for the second compilation. During the second compilation process, the symbol renaming rule represented by the name modification file is applied by the first compiler to the project code, that is, the symbol names in the library to be processed are modified to the specified names by the name modification file. Through the two compilation processes, the dual compilation mechanism ensures that all symbols that may cause conflicts are uniquely identified (that is, all symbol names in the library to be processed are modified), ensuring that there are no duplicate names in the symbol table obtained after the final compilation that will cause conflicts, ensuring that symbol conflicts are resolved, and thus avoiding the problem of preferential selection of static library symbols caused by symbol conflicts, providing a complete and effective fallback solution. At the same time, the specified names automatically modified by the name modification file avoid the cumbersome and error-prone manual operations.

[0069] Optionally, the embodiment of the present invention may further include the following steps:

[0070] Step S21: Generate second compilation options for the second compiler based on the specified path, and compile the target module corresponding to the current library to be processed, so as to modify the symbol names belonging to the current library to be processed in the target module to the specified names respectively.

[0071] Since the target module corresponding to the current library to be processed depends on this library to be processed, there are references to the symbols in this current library to be processed in the target module, that is, there are symbol names belonging to the symbol names in this current library to be processed among the symbol names defined in the target module. After the above operations, the symbol names in this current library to be processed have been modified by the name modification file. Therefore, the compilation options can be modified synchronously. Through the above step S21, adaptively modify the symbol names in the target module based on the name modification file read from the specified path to ensure that the target module uses the modified names.

[0072] Specifically, the second compiler and the above first compiler can be the same compiler. Since the previous compilation options will not be retained when compiling the target module, the compilation options can be added again. Or they can also be different compilers. The generation method of the second compilation options can be the same as the generation method of the first compilation options, that is, the second compilation options are the same as the first compilation options. Then, the second compilation options can be added to the compiler options of the second compiler. In this way, the name modification file can be passed to the second compiler through the second compilation options. Then start the second compiler to compile the target module corresponding to the current library to be processed. In the preprocessing stage, the name modification file under the specified path can be obtained according to the second compilation options, and then the name modification file is executed to modify the original names of the symbols in the target module that appear in the name modification file to the specified names. In this way, it is equivalent to uniformly modifying all the symbol names belonging to the current library to be processed in the target module to the specified names that conform to the macro definition during the secondary compilation process, thereby ensuring that the target module can subsequently use the symbols in the current library to be processed normally.

[0073] Optionally, the step of generating a symbol interception file based on the target module corresponding to the current library to be processed may specifically include:

[0074] Step 1031: Obtain the target functions in the target module corresponding to the current library to be processed; the target functions are used to call the symbols in the current library to be processed.

[0075] Step 1032: Generate corresponding interception functions for the target functions based on the function names of the target functions and the library information of the current library to be processed.

[0076] Step 1033: Generate a dynamic library based on the interception functions as the symbol interception file.

[0077] The target module corresponding to the currently to-be-processed library is a target module that depends on the currently to-be-processed library, and the target module includes references to symbols in the currently to-be-processed library. The references to symbols in the currently to-be-processed library in the target module can be that functions in the target module include calls to symbols in the currently to-be-processed library. Correspondingly, each function in the target module can be detected to determine the function that includes a call to a symbol in the currently to-be-processed library as the target function. For example, functions that include calls to symbols in the currently to-be-processed library can be identified through character matching, or it can also be detected whether there is a pre-set marker, and if so, the function is determined to be a function that includes a call to a symbol in the currently to-be-processed library. Among them, the marker can be set for the function when it is manually recognized that there is a call to a symbol in the currently to-be-processed library in the function.

[0078] Exemplarily, assume that the target module includes function 1, function 2, and function 3. Among them, function 2 and function 3 include calls to symbols in the currently to-be-processed library. Then, function 2 and function 3 can be determined as the target functions in the target module. Or, it can also be determined that a function in the target module includes a call to a symbol in the currently to-be-processed library, and then when the symbol in the currently to-be-processed library called in this function has the same name as a symbol in other library files, this function is determined as the target function. In this way, for functions that include calls to symbols in the currently to-be-processed library, further screening is performed, and when the symbol in the currently to-be-processed library called by this function has the same name as a symbol in other library files, this function is determined as the target function. Therefore, through this screening mechanism, the number of target functions to be processed can be reduced to a certain extent, thereby saving processing resources.

[0079] The intercept function corresponding to the target function has the same name as the target function. In the embodiments of the present invention, the target function is a symbol in the target module. The symbol table of the target module can be directly obtained as the second symbol table based on a preset symbol table acquisition tool, and then the function name of the target function can be obtained from it. The library information of the currently to-be-processed library can be information that can locate the library file. Exemplarily, the library information of the currently to-be-processed library can be the library name, library address, etc. Specifically, the function name of the target function and the library information of the currently to-be-processed library can be written into a preset intercept function template to obtain the intercept function corresponding to the target function. In this way, based on the function name of the target function and the library information of the currently to-be-processed library, intercept functions can be generated in batches, which is more convenient and fast to implement and can ensure the processing speed.

[0080] Exemplarily, the function names of multiple target functions and the library information of the current library to be processed can be batch-written into a preset interception function template through a preset text processing tool, and then interception functions corresponding to each of the multiple target functions can be batch-generated. Among them, for different closed-source libraries to be processed, an independent namespace identifier is preset in the used interception function template. The namespace identifiers in the interception function templates of different libraries to be processed can be predefined by developers. The namespace identifier can be a string, and different namespace identifiers are different specified namespaces, thereby ensuring that the specified namespace corresponding to the symbol interception file of each library to be processed is globally unique.

[0081] Specifically, the dlmopen function and the dlsym function can be defined in the interception function template. Among them, the dlmopen function is a Linux system call used to load the current library to be processed represented by the written library information in a specified namespace. The preset namespace identifier is defined in the dlmopen function. The current library to be processed represented by the written library information can be loaded through the dlmopen function, and a namespace identifier is added to the symbol name in the current library to be processed, so as to realize loading the current library to be processed in the specified namespace. Since the namespace identifiers corresponding to the symbol interception files of different libraries to be processed are different, symbol isolation can be realized without modifying the source code of the current library to be processed in advance. It can be applied to the scenario where the current library to be processed is a closed-source library. The dlsym function in the interception function can be used to find and execute the real target function. Since the real target function includes calls to symbols in the current library to be processed, when the real target function is executed, the called symbols can be found in the specified namespace.

[0082] Exemplarily, the interception function template can be:

[0083]

[0084]

[0085] Among them, XX represents the function name of the target function, YY represents the namespace identifier, and ZZ represents the library information of the current library to be processed. Taking the function name bar, the namespace identifier LM_ID_NEWLM, and the library information. / libb.so as an example, the interception function corresponding to bar can be expressed as:

[0086]

[0087] Among them, RTLD_NOW means that all symbol references are resolved immediately when loading the library to be processed. That is, each time the interception function is executed, the library to be processed can be loaded, and a prefix "LM_ID_NEWLM-" is added to the symbol names in the library to be processed to distinguish them from the original symbol names. By adding a prefix to the symbol names in the library to be processed when loading it, it is possible to avoid symbol name conflicts between the loaded library to be processed and the symbols in other previously loaded library files, thereby preventing symbol conflict problems and achieving symbol isolation.

[0088] Furthermore, the interception functions corresponding to all target functions can be written into a specified file, and then the specified file can be compiled into a dynamic library to obtain a symbol interception file.

[0089] Exemplarily, the interception function can be in the form of code, the specified file can be the interposition.c file, and the compiled dynamic library can be named libinterpostion.so. Correspondingly, interposition.c can be compiled into a new dynamic library to obtain libinterposition.so. Specifically, the generation of the dynamic library can be achieved through the following dynamic library compilation command:

[0090] gcc - shared - fPIC - o libinterpostion.so hijack.c - ldl

[0091] Among them, gcc represents the compiler used, the - shared flag is used to instruct the compiler to generate a dynamic library, - fPIC is used to instruct the compiler to generate position - independent code to ensure that the code of the finally generated dynamic library can be loaded into any position in memory, - o libinterposition.so indicates that the output file name is libinterposition.so, hijack.c is used to specify the source code file to be compiled (i.e., the above - mentioned interposition.c file), and ldl represents the linked dynamic loading library, which provides the functions of dynamic loading and symbol searching.

[0092] In the embodiments of the present invention, the target functions in the target module corresponding to the library to be processed are obtained. Then, based on the function names of the target functions and the library information of the current library to be processed, the corresponding interception functions are generated for the target functions. Since in the embodiments of the present invention, a dynamic library is generated through the generated interception functions, the symbol interception file can be obtained, so the acquisition efficiency of the symbol interception file is relatively high.

[0093] Optionally, the step of loading the current library to be processed according to the symbol interception file may specifically include:

[0094] Step 1034: In response to an execution request for a target function in the target module, execute the intercept function corresponding to the target function in the symbol intercept file to load the current library to be processed in the specified namespace corresponding to the symbol intercept file, so that the target module can call the symbols of the current library to be processed included in the target function in the specified namespace; the specified namespace corresponding to the symbol intercept file is globally unique.

[0095] Specifically, in response to a running command for the software to be processed, the symbol intercept file can be first loaded into the memory, and then the software to be processed can be started, that is, the main function (main function) in the software to be processed is executed. During the execution process, if the next function to be executed is a target function, an execution request for the target function will be generated. Correspondingly, since the symbol intercept file will be loaded into the memory first, in response to the execution request for the target function, the intercept function corresponding to the target function in the symbol intercept file will be executed correspondingly, that is, the execution request will be intercepted and overwritten by the code of the intercept function with the same function name, and enter the intercept function. The intercept function will first load the current library to be processed in the specified namespace based on the dlmopen function.

[0096] Then, the intercept function searches for the address of the real target function requested to be executed by the execution request based on the dlsym function, that is, searches for the real target function. After loading the current library to be processed using the dlmopen function, a handle representing the current library to be processed loaded in the specified namespace can be obtained. The handle can be passed as a parameter to the dlsym function.

[0097] Furthermore, the real target function can be executed. The real target function can search for the symbols called in the target function in the specified namespace based on the passed handle to achieve the call, thereby avoiding the symbol overwrite phenomenon caused by symbol name duplication. In this way, even if the symbol name in the real target function has no prefix, through handle lookup, it can be ensured that when the real target function is executed, the symbols with prefixes can be accurately called to avoid symbol conflicts. Since the handle points to the current library to be processed loaded in the specified namespace, based on the handle lookup, it is equivalent to searching for the symbols with namespace prefixes in the current library to be processed, so as to ensure that when the symbol name in the current library to be processed has been modified to a name with a namespace prefix, the real target function can correctly call the symbols in the current library to be processed through the name with a namespace prefix.

[0098] Taking the target function as the bar function and the library to be processed as libb.so, where the bar function includes a call to the foo function in libb.so as an example, the function name of the bar function, "bar", can be obtained from the second symbol table. Since the symbol interception file is loaded into memory first, in response to an execution request for the target function, the interception function corresponding to the target function in the symbol interception file will be executed accordingly. That is, the execution request is intercepted and overwritten by the code of the corresponding interception function, and then enters the corresponding interception function. The interception function will first load the library to be processed, libb.so, in the specified namespace based on the dlmopen function. Then, the interception function searches for the address of the real target function, the bar function, based on the dlsym function, that is, searches for the real bar function. Then, the real bar function is executed. The real bar function can search for and call the foo function with a prefix in the specified namespace based on the passed handle, thus avoiding the symbol overwrite phenomenon caused by symbol name duplication. Specifically, the symbol interception file corresponding to the library to be processed on which the target module to which the target function belongs depends can be executed. Of course, when the conflicting library on which the target module to which the target function belongs depends is not the library to be processed, the target function can be directly executed.

[0099] In the embodiments of the present invention, during the running of the software to be processed, through the loaded symbol interception file, the library to be processed can be opened in the specified namespace, and the symbols of the library to be processed can be called in the specified namespace. Since opening the library to be processed in the specified namespace is equivalent to adding the namespace identifier corresponding to the specified namespace to the symbol name of the library to be processed, symbol isolation can be achieved, avoiding name duplication with other library files linked to the process of the software to be processed, and thus avoiding the problem of symbol conflicts when multiple library files are linked in the process.

[0100] It should be noted that if a target module depends on multiple conflicting libraries, then when the symbol names in the conflicting libraries are modified based on the name modification file, when modifying the symbol names corresponding to those belonging to the multiple conflicting libraries in the target module, it is impossible to identify which conflicting library the symbols in the target module specifically belong to, thus resulting in the inability to modify the symbol names in the target module correspondingly. In the case of symbol interception, it is impossible to determine which symbol interception file corresponding to the library to be processed to use, thus resulting in the inability to execute.

[0101] Exemplarily, assume that the target module is Module 1. If Module 1 depends on two conflicting library files, i.e., m = 2: Library A and Library B. Module 1 includes the symbol print(). Library A and Library B respectively include the symbol print() with the same name. The symbol print() in Library A is used to print A, and the symbol print() in Library B is used to print B. If the symbol print() in the currently to-be-processed Library B is modified to the specified name B_print() through a name modification file to distinguish it from the symbol print() in Library A. Correspondingly, when modifying the name of the symbol print() in Module 1, it is impossible to determine whether the symbol print() is from Library A or Library B, and thus it cannot be modified. Or, when executing the target function including print() in Module 1, when reaching the symbol print() in the target function, it is impossible to determine whether to use the intercept function corresponding to the symbol print() in the symbol intercept file corresponding to Library A or the intercept function corresponding to the symbol print() in the symbol intercept file corresponding to Library B. Therefore, in the embodiments of the present invention, only one conflicting library is included in the library files on which a target module depends, that is, m = 2 is not greater than the total number 1 of the target modules.

[0102] Furthermore, there may be upper-layer dependencies for the target module in the embodiments of the present invention. For example, the target module is depended on by the main function in the to-be-processed software, that is, a three-layer dependency structure is formed: the main function depends on multiple target modules, and these multiple target modules respectively depend on m library files. Exemplarily, assume that the target module includes two target modules, i.e., Module 1 and Module 2, and the main function depends on Module 1 and Module 2. Module 1 and Module 2 respectively depend on Library A and Library B. Specifically, the main function includes the symbols: foo() in Module 1 and bar() in Module 2. The foo() in Module 1 references the established function in Library A, i.e., the symbol print(), and this symbol is used to print A. The bar() in Module 2 references the established function in Library B, i.e., the symbol print(), and this symbol print() is used to print B. Since the symbol print() with the same name exists in both Library A and Library B. Therefore, finally when running the program compiled from the main function, when running to bar(), the implementation of bar() will be searched for in Module 2. When executing bar(), the loaded print() will be searched for in the memory. Actually, at this time, the print() in Library B is to be found. However, since Library A has been pre-loaded into the memory during the prior execution, the print() in Library A will be called and thus A will be printed, resulting in an error.

[0103] In an embodiment of the present invention, the symbol name print() in library B can be modified to B_print() through a name modification file, and the print() in module 1 can be modified to B_print(). Therefore, without modifying the main function, library conflicts can be avoided. Since the code volume of the main function is often large, not modifying the main function can reduce the modification cost.

[0104] Optionally, the embodiment of the present invention may further include the following steps: Step S31, adding a specified environment variable to the software to be processed to control the earliest loading of the symbol interception file. Specifically, the specified environment variable can be set before the main function of the software to be processed to ensure that when the main program is called, all symbol interception files are loaded into the memory before the main program through the specified environment variable.

[0105] The specified environment variable can be the LD_PRELOAD command. Exemplarily, the specified environment variable can be expressed as: LD_PRELOAD =. / libhijack.so. / main. Here, / libhijack.so is used to indicate the dynamic library in the current directory to be loaded first. It should be noted that in the case of multiple libinterpostion.so of libraries to be processed, the libinterpostion.so of multiple libraries to be processed can be written into a specified file respectively, for example, the libinterposition.cpp file, to load the libinterpostion.so of these multiple libraries to be processed simultaneously. Or, the libinterpostion.so of each library to be processed can also be loaded separately. Since the namespace identifiers corresponding to each symbol interception file (i.e., libinterpostion.so) are different, in this way, it is equivalent that the libinterpostion.so of each library to be processed adopts an isolated namespace and there will be no overwriting between the libinterpostion.so of each library to be processed. Therefore, as long as it is ensured that the libinterpostion.so of each library to be processed is loaded before the upper-layer dependent module.

[0106] For the scenario where the library to be processed is a closed-source library, that is, the source code of the library to be processed cannot be modified, in the embodiments of the present invention, dynamic interception and redirection of functions are achieved by intercepting target functions through symbol hijacking technology. Specifically, the library to be processed is loaded in a specified namespace by intercepting functions, and then symbols of the library to be processed included in the target function are called in the specified namespace. This is equivalent to intercepting the call to the symbols of the library to be processed, ensuring that symbols are resolved in the specified namespace corresponding to the library to be processed, avoiding symbol conflicts with other library files, and thus avoiding the symbol overwrite problem caused by symbol conflicts. Accordingly, only at runtime, it is only necessary to first load the symbol interception file based on LD_PRELOAD, which is more convenient and fast to apply, and has lower development costs and maintenance complexity.

[0107] In the embodiments of the present invention, two solution strategies are correspondingly provided according to whether the source code of the library can be modified. Specifically, when the library to be processed is an open-source library, by directly modifying the symbol names in the library to be processed, the efficiency is relatively high. And it will not affect the running process of the software to be processed, and can avoid affecting the program running speed. When the library to be processed is a closed-source library, only an interception function needs to be generated, and the dynamic library compiled as the symbol interception file is loaded first at runtime to run the software normally, and the software development and maintenance are more convenient. And there is no need to recompile the software to be processed, and the operation is simpler.

[0108] Optionally, before step 101 in the embodiments of the present invention, it may further include: if the software to be processed only includes code written in the first language, modify the namespace of the m library files; the first language is a language that supports namespace modification. If the software to be processed further includes code written in the second language, and the m library files are all open-source dynamic libraries, add a version control script to the software to be processed; the version control script is used to isolate the symbols in the m library files. Otherwise, execute the step of selecting m - 1 library files from the m library files on which the target module in the software to be processed depends as the libraries to be processed.

[0109] Among them, namespace modification refers to renaming the namespace name. The first language can be the C++ language, that is, the software to be processed is a program written in pure C++. The second language can be the C language, because the way of namespace modification does not support C language projects. Accordingly, in the case of mixing C and C++ and the libraries to be processed are all dynamic libraries, add a version control script to the source code of the libraries to be processed. Through the version control script, ensure that the code of different libraries is isolated into different namespaces.

[0110] Specifically, the function can be modified based on the namespace name provided by the build tool to specify different namespaces for the symbols in the source code of the above m library files, thereby achieving the modification of the namespace name and eliminating symbol conflicts. Exemplarily, the namespace name modification function can be a command provided by the cmake tool: add_definitions(-D original_namespace = new_namespace). It should be noted that when modifying the namespace, a namespace compilation option can be added for the second compiler (i.e., the compiler used to compile the target module corresponding to the library), and the namespace compilation option includes the original namespace and its corresponding modified namespace.

[0111] Exemplarily, the namespace compilation option can be: -D original_namespace1 = current_namespace1 -D original_namespace2 = current_namespace2 ...... Since the namespace of the symbol names in the library to be processed has been modified after the namespace modification, the compilation option can be synchronously modified to adaptively modify the namespace of the symbols in the target module during compilation to ensure that the target module uses the modified namespace.

[0112] Furthermore, a version control script can be used to control the external visibility of symbols and allocate different version spaces for symbols. The version control script can assign version information to the symbols in the library, so that the symbols in different libraries are in different version spaces, thereby avoiding symbol conflicts. Both the GNU linker (ld) and the LLVM linker (lld) support version control scripts.

[0113] Exemplarily, part of the content of this version control script can be: LIBRARY_1.0{global:*;}. Among them, LIBRARY_1.0 represents the library version information defined for the library file in the version script. {global:*;} means that all symbols in this library file are assigned to the LIBRARY_1.0 version space and are globally visible in the symbol table of the dynamic library.

[0114] In a related technology, symbol conflicts are avoided by adding a link option that controls the external invisibility of symbols in the library file. However, this method is for static libraries. Therefore, there are application limitations, and it may be necessary to modify the library file to a static library, and the operation is rather cumbersome. In another related technology, the symbol table entries in the.o file corresponding to the dependent library are modified by objcopy to rename them. In this method, since the.o file of the dynamic library cannot be obtained, the application scope is limited.

[0115] In the embodiments of the present invention, by integrating two methods of namespace modification and version control script, for the software to be processed that only includes code written in the first language, and for the software to be processed that includes code written in the first language and the second language, but the m library files are all dynamic libraries, these two scenarios with fewer restrictions and greater simplicity can conveniently avoid symbol conflicts by integrating namespace modification and version control script. In scenarios that are not these two simple scenarios, that is, more complex and more restricted scenarios, step 101 above is entered to start execution, ensuring that the symbol conflict problem can ultimately be avoided. The solution has high flexibility and is more complete. According to the complexity of the scenarios faced from easy to difficult and the number of restrictions from few to many, corresponding solutions are given for different scenarios, which can adapt to different types of symbol conflict scenarios and have strong versatility.

[0116] Specifically, in the embodiments of the present invention, when the library to be processed is an open-source library, it means that the source code of the library to be processed can be modified. Correspondingly, a name modification file can be generated, and based on the name modification file, the symbol names in the library to be processed can be modified to specified names to avoid symbol conflict problems. When the library to be processed is a closed-source library, it means that the source code of the library to be processed cannot be modified. Correspondingly, a symbol interception file can be generated, and based on the symbol interception file, the library to be processed can be opened in the corresponding specified namespace, and the symbols in the library to be processed can be called in the specified namespace, thereby avoiding symbol conflict problems and effectively isolating symbol conflicts. Whether the software to be processed is written in a single language or a mixture of multiple languages, and whether the libraries relied on by the software to be processed are static libraries or dynamic libraries. Distinguishing from the two dimensions of whether the relied-on libraries are open-source or closed-source, the situation where the software to be processed uses multiple programming languages and multiple linking methods (for example, the relied-on libraries include static libraries and dynamic libraries) can be covered. In the embodiments of the present invention, for the two situations of whether the relied-on library files are open-source or closed-source, symbol conflicts can be correspondingly avoided, and the problem of symbol conflicts can be effectively and thoroughly solved, with a wide range of applicability, a wide application range, and strong universality. And there is no need to modify the library to a static library, avoiding the problem of cumbersome operations.

[0117] Referring to Figure 2 , a block diagram of a data processing device provided by an embodiment of the present invention is shown. As Figure 2 shown, the data processing device may specifically include:

[0118] A selection module 201, configured to select m - 1 library files from the m library files relied on by the target module in the software to be processed as the libraries to be processed; there are duplicate symbols among the m library files; m is an integer not less than 2;

[0119] The first processing module 202 is configured to, if the currently to-be-processed library is an open-source library, generate a name modification file for the currently to-be-processed library, and modify the symbol names in the currently to-be-processed library to specified names respectively based on the name modification file; the specified names are different from the symbol names in other library files;

[0120] The second processing module 203 is configured to, if the currently to-be-processed library is a closed-source library, generate a symbol interception file based on the target module corresponding to the currently to-be-processed library, and when the target module calls the symbols in the currently to-be-processed library, load the currently to-be-processed library according to the symbol interception file for the target module to call the symbols in the currently to-be-processed library.

[0121] In summary, in the data processing device provided by the embodiments of the present invention, m - 1 library files are selected from the m library files on which the target module in the to-be-processed software depends as the currently to-be-processed libraries; there are duplicate symbol names among the m library files. If the currently to-be-processed library is an open-source library, a name modification file is generated for the currently to-be-processed library, and the symbol names in the currently to-be-processed library are modified to specified names respectively based on the name modification file; the specified names are different from the symbol names in other library files. In this way, by modifying the names, it is possible to avoid duplicate symbol names between the currently to-be-processed library and other libraries, thereby avoiding symbol conflict problems. If the currently to-be-processed library is a closed-source library, a symbol interception file is generated based on the target module corresponding to the currently to-be-processed library, and when the target module calls the symbols in the currently to-be-processed library, the currently to-be-processed library is loaded according to the symbol interception file for the target module to call the symbols in the currently to-be-processed library, achieving symbol isolation, so as to ensure that the symbol names in the currently to-be-processed library are not repeated, thereby avoiding symbol conflict problems.

[0122] Optionally, the first processing module 202 is specifically configured to:

[0123] Compile the currently to-be-processed library to obtain the symbol table of the currently to-be-processed library as the first symbol table;

[0124] According to a preset generation command and each symbol name in the first symbol table, batch generate macro statements for each symbol in the first symbol table; the macro statements include the symbol name and the specified name generated for the symbol;

[0125] Use the macro file generated based on the macro statements as the name modification file.

[0126] Optionally, the first processing module 202 is specifically configured to:

[0127] Store the name modification file to the specified path corresponding to the to-be-processed software;

[0128] Generate first compilation options for a first compiler based on the specified path, and re-compile the currently to-be-processed library to modify the symbol names in the currently to-be-processed library to the specified names respectively.

[0129] Optionally, the apparatus further includes:

[0130] A generation module, configured to generate second compilation options for a second compiler based on the specified path, and compile a target module corresponding to the currently to-be-processed library to modify the symbol names belonging to the currently to-be-processed library in the target module to the specified names respectively.

[0131] Optionally, the second processing module 203 is specifically configured to:

[0132] Obtain a target function in a target module corresponding to the currently to-be-processed library; the target function is used to call symbols in the currently to-be-processed library;

[0133] Generate a corresponding interception function for the target function based on the function name of the target function and the library information of the currently to-be-processed library;

[0134] Generate a dynamic library based on the interception function as the symbol interception file.

[0135] Optionally, the second processing module 203 is specifically configured to:

[0136] In response to an execution request for a target function in the target module, execute the interception function corresponding to the target function in the symbol interception file to load the currently to-be-processed library in a specified namespace corresponding to the symbol interception file, so that the target module can call the symbols of the currently to-be-processed library included in the target function in the specified namespace; the specified namespace corresponding to the symbol interception file is globally unique.

[0137] Optionally, the apparatus further includes:

[0138] An addition module, configured to add a specified environment variable to the to-be-processed software to control the symbol interception file to be loaded first.

[0139] Refer to Figure 3 , which is a schematic structural diagram of an electronic device provided by an embodiment of the present invention. As Figure 3 shown, the electronic device includes: a processor, a memory, a communication interface, and a communication bus.

[0140] The processor, the memory, and the communication interface communicate with each other through the communication bus; the memory is used to store at least one executable instruction, and the executable instruction causes the processor to execute the data processing method of the foregoing embodiment. The executable instructions can form a program.

[0141] An embodiment of the present invention provides a machine-readable medium, on which instructions are stored, and when executed by one or more processors, cause the processor to be able to execute the data processing method of the foregoing embodiment.

[0142] Each embodiment in this specification is described in a progressive manner. The key point of each embodiment is the difference from other embodiments. For the same or similar parts among the embodiments, reference can be made to each other.

[0143] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a device, or a computer program product. Therefore, the embodiments of the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0144] It should be noted that all actions of obtaining signals, information, or data in this application are carried out on the premise of complying with the corresponding data protection regulations and policies of the country where it is located and obtaining authorization from the owner of the corresponding device.

[0145] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, and the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal devices generate a device for realizing the function specified in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.

[0146] These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing terminal device to work in a predictive manner, so that the instructions stored in the computer-readable memory generate a manufactured product including an instruction device, and the instruction device realizes the function in the process Figure 1one process or multiple processes and / or blocks Figure 1 the functions specified in one block or multiple blocks.

[0147] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal devices, so that a series of operation steps are executed on the computer or other programmable terminal devices to generate a computer-implemented process. Thus, the instructions executed on the computer or other programmable terminal devices provide steps for implementing the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 the functions specified in one block or multiple blocks.

[0148] Although the preferred embodiments of the embodiments of the present invention have been described, those skilled in the art can make additional changes and modifications once they learn the basic creative concepts. Therefore, the appended claims are intended to be construed to include the preferred embodiments and all changes and modifications falling within the scope of the embodiments of the present invention.

[0149] Finally, it should also be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations.

[0150] Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or terminal device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or terminal device. Without further limitation, an element defined by the statement "comprising one..." does not exclude the presence of additional identical elements in the process, method, article or terminal device comprising the element.

[0151] The above has introduced in detail a data processing method, a data processing device, an electronic device and one or more readable media provided by the present invention. Specific examples are used in this article to elaborate on the principles and implementation manners of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention; at the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to the present invention.

Claims

1. A data processing method, characterized in that, The method includes: Select m - 1 library files from the m library files on which the target module in the software to be processed depends as the library files to be processed; there are duplicate symbols among the m library files; m is an integer not less than 2; If the current library file to be processed is an open-source library, generate a name modification file for the current library file to be processed, and modify the symbol names in the current library file to specified names based on the name modification file; the specified names are different from the symbol names in other library files; If the current library file to be processed is a closed-source library, generate a symbol interception file based on the target module corresponding to the current library file to be processed, and when the target module calls the symbols in the current library file to be processed, load the current library file to be processed according to the symbol interception file for the target module to call the symbols in the current library file to be processed.

2. The method according to claim 1, wherein The generating a name modification file for the current library file to be processed includes: Compile the current library file to be processed to obtain the symbol table of the current library file to be processed as the first symbol table; Generate macro statements for each symbol in the first symbol table in batches according to a preset generation command and each symbol name in the first symbol table; the macro statements include the symbol name and the specified name generated for the symbol; Use the macro file generated based on the macro statements as the name modification file.

3. The method according to claim 1 or 2, characterized in that, The modifying the symbol names in the current library file to be processed to specified names based on the name modification file includes: Store the name modification file to the specified path corresponding to the software to be processed; Generate a first compilation option for the first compiler based on the specified path, and recompile the current library file to be processed to modify the symbol names in the current library file to be processed to the specified names.

4. The method according to claim 3, characterized in that, The method further includes: Generate a second compilation option for the second compiler based on the specified path, and compile the target module corresponding to the current library file to be processed to modify the symbol names in the target module that belong to the current library file to be processed to the specified names.

5. The method according to claim 1, wherein The generating a symbol interception file based on the target module corresponding to the current library file to be processed includes: Obtain the target function in the target module corresponding to the current library file to be processed; the target function is used to call the symbols in the current library file to be processed; Generate a corresponding interception function for the target function based on the function name of the target function and the library information of the current library file to be processed; Generate a dynamic library based on the interception function as the symbol interception file.

6. The method according to claim 1 or 5, characterized in that The loading the current library file to be processed according to the symbol interception file includes: In response to an execution request for the target function in the target module, execute the interception function corresponding to the target function in the symbol interception file to load the current library file to be processed in the specified namespace corresponding to the symbol interception file for the target module to call the symbols of the current library file to be processed included in the target function in the specified namespace; the specified namespace corresponding to the symbol interception file is globally unique.

7. The method according to claim 6, characterized in that, The method further includes: Add a specified environment variable to the software to be processed to control the earliest loading of the symbol interception file.

8. A data processing device, characterized in that, The device includes: A selection module, configured to select m - 1 library files from m library files on which a target module in the software to be processed depends as library files to be processed; there are duplicate symbols among the m library files; m is an integer not less than 2; A first processing module, configured to, if the current library file to be processed is an open-source library, generate a name modification file for the current library file to be processed, and modify the symbol names in the current library file to specified names respectively based on the name modification file; the specified names are different from the symbol names in other library files; A second processing module, configured to, if the current library file to be processed is a closed-source library, generate a symbol interception file based on the target module corresponding to the current library file to be processed, and when the target module calls a symbol in the current library file to be processed, load the current library file according to the symbol interception file for the target module to call the symbol in the current library file to be processed.

9. An electronic device, characterized in that, It includes: A processor, a memory, a communication interface, and a communication bus, and the processor, the memory, and the communication interface complete communication with each other through the communication bus; The memory is used to store executable instructions, and the executable instructions cause the processor to execute the method according to any one of claims 1 to 7.

10. A machine-readable medium, characterized in that, Instructions are stored thereon, which, when executed by one or more processors, cause the processor to execute the method according to any one of claims 1 - 7.