CN-121979910-A - Dynamic library determination method, electronic device, storage medium, and program product
Abstract
The application provides a method for determining a dynamic library, an electronic device, a storage medium and a program product. In a starting stage of an executable file, for a first external symbol of the executable file, searching a first dynamic library corresponding to the first external symbol in a predetermined global symbol hash table, wherein the global symbol hash table records the corresponding relation between a plurality of external symbols of the executable file and the dynamic library where the plurality of external symbols are located. In this way, in the starting stage of the executable file, the dynamic library where the external symbol of the executable file is located can be determined according to the corresponding relation recorded in the global symbol hash table, and the dynamic library does not need to be searched one by one, so that the time for searching the dynamic library where the external symbol is located can be shortened, the searching and repositioning processes of the external symbol are accelerated, the starting efficiency of the executable file is further improved, and the starting performance of the network element equipment is accelerated.
Inventors
- JIANG ZHANG
Assignees
- 中兴通讯股份有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20241031
Claims (14)
- 1. A method of determining a dynamic library, comprising: and in the starting stage of the executable file, for a first external symbol of the executable file, searching a first dynamic library corresponding to the first external symbol in a predetermined global symbol hash table, wherein the global symbol hash table records the corresponding relation between a plurality of external symbols of the executable file and the dynamic library where the plurality of external symbols are located.
- 2. The method of claim 1, the method further comprising, prior to the startup phase of the executable file: Acquiring each dynamic library on which the executable file depends and a symbol hash table of each dynamic library; And generating the global symbol hash table based on each dynamic library and the symbol hash table of each dynamic library.
- 3. The method of claim 2, the generating the global symbol hash table based on each of the dynamic libraries and the symbol hash table for each of the dynamic libraries, comprising: Analyzing the symbol hash table of each dynamic library to determine external symbols in each dynamic library; for each parsed external symbol, determining a corresponding relation between the external symbol and a dynamic library in which the external symbol is located; And storing the corresponding relation to the global symbol hash table.
- 4. The method of claim 3, wherein the determining the correspondence between the external symbol and the dynamic library in which the external symbol is located comprises: determining a target dynamic library from the plurality of dynamic libraries in which the external symbols are located under the condition that the number of the dynamic libraries in which the external symbols are located is a plurality of; and determining a first corresponding relation between the external symbol and the target dynamic library as a corresponding relation between the external symbol and the dynamic library where the external symbol is located.
- 5. The method of claim 3, wherein the determining the correspondence between the external symbol and the dynamic library in which the external symbol is located comprises: And under the condition that the number of the dynamic libraries where the external symbols are located is a plurality of, determining a second corresponding relation between the external symbols and the plurality of the dynamic libraries where the external symbols are located as a corresponding relation between the external symbols and the dynamic libraries where the external symbols are located.
- 6. The method of claim 5, wherein the looking up the first dynamic library corresponding to the first external symbol in the predetermined global symbol hash table comprises: Searching a plurality of dynamic libraries corresponding to the first external symbols in a predetermined global symbol hash table; The first dynamic library is determined from the plurality of dynamic libraries.
- 7. The method of claim 3, the storing the correspondence to the global symbol hash table comprising: storing the corresponding relation to the global symbol hash table in the form of a data structure capable of being quickly searched; the data structure capable of being quickly searched comprises a key-value, wherein the key is the name of the external symbol, and the value is the name of a dynamic library where the external symbol is located.
- 8. The method of claim 3, after storing the correspondence to the global symbol hash table, the method further comprising: And writing the global symbol hash table into an executable ELF file as segment data.
- 9. The method of claim 1, the method further comprising: Loading the first dynamic library.
- 10. The method of claim 9, wherein the first dynamic library is located on a disk, and wherein loading the first dynamic library comprises: and loading and mapping the first dynamic library to an address space of a process corresponding to the executable file by the disk, and endowing the mapping virtual address with the first external symbol.
- 11. The method of claim 1, the method further comprising: Under the condition that the first dynamic library is not found in the global symbol hash table, searching whether the first external symbols exist in a plurality of dynamic libraries on which the executable file in the disk depends one by one; the second dynamic library is loaded upon determining that the first external symbol is present in the second dynamic library.
- 12. An electronic device, comprising: A processor; A memory for storing the processor-executable instructions; wherein the processor is configured to execute the instructions to implement the method of any one of claims 1to 11.
- 13. A computer readable storage medium, which when executed by a processor of an electronic device, causes the electronic device to perform the method of any of claims 1 to 11.
- 14. A computer program product comprising a non-transitory computer readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps of the method of any of claims 1 to 11.
Description
Dynamic library determination method, electronic device, storage medium, and program product Technical Field The present application relates to the field of file processing technologies, and in particular, to a method for determining a dynamic library, an electronic device, a storage medium, and a program product. Background During the startup phase of an executable, it is often necessary to load a dynamic library of external symbols of the executable in order to prepare for the process startup. In the related art, when loading a dynamic library, the dynamic library on the disk can be searched one by one, whether the external symbol of the executable file exists in the dynamic library is judged, if so, the dynamic library is loaded, and if not, the next dynamic library is continuously searched. However, in some scenarios, the number of dynamic libraries on the disk may be relatively large, which may take a long time to search the dynamic libraries on the disk one by one, resulting in a low searching efficiency, failing to quickly load the dynamic libraries, and further affecting the startup efficiency of the executable file. Disclosure of Invention The application provides a method for determining a dynamic library, electronic equipment, a storage medium and a program product, which are used for solving the problem of low starting efficiency of executable files. In order to solve the technical problems, the application is realized as follows: In a first aspect, a method for determining a dynamic library is provided, including: and in the starting stage of the executable file, for a first external symbol of the executable file, searching a first dynamic library corresponding to the first external symbol in a predetermined global symbol hash table, wherein the global symbol hash table records the corresponding relation between a plurality of external symbols of the executable file and the dynamic library where the plurality of external symbols are located. In a second aspect, there is provided an electronic device comprising: A processor; A memory for storing the processor-executable instructions; Wherein the processor is configured to execute the instructions to implement the method according to the first aspect. In a third aspect, there is provided a computer readable storage medium, which when executed by a processor of an electronic device, enables the electronic device to perform the method of the first aspect. In a fourth aspect, there is provided a computer program product comprising a non-transitory computer readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps of the method according to the first aspect. In the embodiment of the application, the corresponding relation between a plurality of external symbols of the executable file and the dynamic library where the plurality of external symbols are located can be predetermined, and the corresponding relation is recorded in the global symbol hash table, and in the starting stage of the executable file, for a certain first external symbol of the executable file, a first dynamic library corresponding to the first external symbol can be searched from the global symbol hash table, wherein the first dynamic library is the dynamic library where the first external symbol is located. In this way, in the starting stage of the executable file, the dynamic library where the external symbol of the executable file is located can be determined according to the corresponding relation recorded in the global symbol hash table, and the dynamic library does not need to be searched one by one, so that the time for searching the dynamic library where the external symbol is located can be shortened, the searching and repositioning processes of the external symbol are accelerated, the starting efficiency of the executable file is further improved, and the starting performance of the network element equipment is accelerated. Drawings In order to more clearly illustrate the application or the technical solutions of the prior art, the drawings that are used in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some embodiments described in the present application, and that other drawings can be obtained according to these drawings without inventive faculty for a person skilled in the art. FIG. 1 is a schematic diagram of a related art method for searching a dynamic library where an external symbol of an executable file is located and loading the dynamic library; FIG. 2 is a flow diagram of a method of determining a dynamic library according to one embodiment of the application; FIG. 3 is a schematic diagram of determining a global symbol hash table in accordance with an embodiment of the present application; FIG. 4 is a schematic diagram of loading a dynamic library according to a global symbol hash table in acco