Dynamic library determination method, electronic equipment, storage medium and program product

By determining and recording the correspondence between external symbols and dynamic libraries before the executable file starts, and using a global symbol hash table to quickly find dynamic libraries, the problem of low startup efficiency caused by searching one by one is solved, and fast loading and startup acceleration are achieved.

CN121979910APending Publication Date: 2026-05-05ZTE CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411536777.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-31
Publication Date
2026-05-05

AI Technical Summary

Technical Problem

During the executable file startup phase, searching for dynamic libraries on the disk one by one takes a long time, resulting in low efficiency in loading dynamic libraries and affecting the startup efficiency of the executable file.

Method used

The correspondence between multiple external symbols and dynamic libraries in the executable file is pre-determined and recorded in a global symbol hash table. During the startup phase, the corresponding dynamic library is directly searched from the hash table, avoiding searching one by one.

Benefits of technology

It shortens the time to find the dynamic library where the external symbols are located, accelerates the symbol search and relocation process, and improves the startup efficiency of executable files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121979910A_ABST
    Figure CN121979910A_ABST
Patent Text Reader

Abstract

The invention provides a dynamic library determination method, electronic equipment, a storage medium and a program product. The method comprises the following steps: 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, the global symbol hash table records a corresponding relationship between a plurality of external symbols of the executable file and a dynamic library where the plurality of external symbols are located. Therefore, 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 external symbol searching and repositioning process can be accelerated, and the efficiency of searching the external symbol is improved. Therefore, the starting efficiency of the executable file is improved, and the starting performance of the network element equipment is accelerated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of document processing technology, and in particular to a method for determining dynamic libraries, electronic devices, storage media, and program products. Background Technology

[0002] During the startup phase of an executable file, it is typically necessary to load the dynamic libraries containing the executable's external symbols to prepare for process startup. In related technologies, when loading dynamic libraries, the disk can be searched one by one to determine if the external symbols for the executable exist. If they do, the dynamic library is loaded; otherwise, the search continues to the next dynamic library. However, in some scenarios, the number of dynamic libraries on the disk may be large. Searching each dynamic library on the disk one by one can be time-consuming, resulting in low search efficiency and hindering fast loading of dynamic libraries, thus impacting the executable's startup efficiency. Summary of the Invention

[0003] This application provides a method for determining dynamic libraries, an electronic device, a storage medium, and a program product to solve the problem of low startup efficiency of executable files.

[0004] To solve the above-mentioned technical problems, this application is implemented as follows: Firstly, a method for determining a dynamic library is provided, including: During the startup phase of the executable file, for the first external symbol of the executable file, the first dynamic library corresponding to the first external symbol is searched in a pre-determined global symbol hash table. The global symbol hash table records the correspondence between multiple external symbols of the executable file and the dynamic libraries in which the multiple external symbols are located.

[0005] Secondly, an electronic device is provided, comprising: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the method as described in the first aspect.

[0006] Thirdly, a computer-readable storage medium is provided, wherein when instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the method described in the first aspect.

[0007] Fourthly, a computer program product is provided, the computer program product including 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 described in the first aspect.

[0008] In this embodiment, the correspondence between multiple external symbols of the executable file and the dynamic libraries containing those external symbols can be predetermined, and this correspondence is recorded in a global symbol hash table. During the executable file's startup phase, for a specific first external symbol of the executable file, the first dynamic library corresponding to that first external symbol can be found from the global symbol hash table. This first dynamic library is the dynamic library containing the first external symbol. Thus, since the dynamic library containing the external symbols of the executable file can be determined based on the correspondence recorded in the global symbol hash table during the executable file's startup phase, there is no need to search each dynamic library individually. Therefore, the time spent searching for the dynamic library containing the external symbols can be shortened, accelerating the external symbol search and relocation process, thereby improving the startup efficiency of the executable file and accelerating the startup performance of network element devices. Attached Figure Description

[0009] To more clearly illustrate the technical solutions in this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0010] Figure 1 This is a diagram illustrating how to locate and load the dynamic library containing the external symbols of an executable file in related technologies. Figure 2 This is a flowchart illustrating a method for determining a dynamic library according to an embodiment of this application; Figure 3 This is a schematic diagram illustrating an embodiment of this application for determining a global symbol hash table; Figure 4 This is a schematic diagram illustrating an embodiment of this application of loading a dynamic library based on a global symbolic hash table; Figure 5 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application; Figure 6 This is a schematic diagram of the structure of a dynamic library determination device according to an embodiment of this application. Detailed Implementation

[0011] During the executable file startup phase, it is typically necessary to map the dynamic libraries containing the external symbols that the executable file depends on into the process's address space and allocate virtual addresses to prepare for process startup. This process is generally called symbol lookup and relocation, and can be performed by the loader. In related technologies, when the loader loads the dynamic library containing the external symbol, it does not know which specific dynamic library on the disk the external symbol is located in. Therefore, the loader's processing logic is usually as follows: Figure 1As shown, the specific steps include: Step 1: Search the dynamic libraries that the executable file depends on in the current runtime environment to see if the external symbol to be found exists. Step 2: For a certain dynamic library in the path, quickly search for the existence of external symbols in the current dynamic library through the .hash section or .gnu.hash section of the dynamic library's ELF file. If they exist, stop the search; if they do not exist, search for the next dynamic library in the path. Step 3: Load the dynamic library containing the first external symbol found from the disk and map it into the process's address space, and assign the external symbol a mapped virtual address. This completes the lookup and relocation process for the external symbol.

[0012] Based on the above processing logic, it can be seen that when the loader loads the dynamic library containing the external symbols, it needs to search for the external symbols of each dynamic library on the disk. As a result, when the number of dynamic libraries that the executable file depends on is large, it will take a long time, resulting in low search efficiency, decreased symbol lookup performance, and inability to load dynamic libraries quickly, which in turn affects the startup efficiency of the executable file and the startup performance of the process.

[0013] This application provides a method, electronic device, storage medium, and program product for determining dynamic libraries. It pre-determines the correspondence between multiple external symbols of an executable file and the dynamic libraries containing those external symbols, and records this correspondence in a global symbol hash table. During the executable file's startup phase, for a specific first external symbol, the corresponding first dynamic library can be found in the global symbol hash table; this first dynamic library is the dynamic library containing the first external symbol. Thus, since the dynamic library containing the external symbols of the executable file can be determined based on the correspondence recorded in the global symbol hash table during the executable file's startup phase, there is no need to search each dynamic library individually. Therefore, the time spent searching for the dynamic library containing the external symbols can be shortened, accelerating the external symbol lookup and relocation process, thereby improving the startup efficiency of the executable file and accelerating the startup performance of network element devices.

[0014] The technical solutions provided in this application can be applied to executable files and dynamic libraries compiled using the GNU compiler in any Linux operating environment.

[0015] It should be noted that the technical solutions of this application embodiment involve the working mode of the Linux system underlying loader, which is unrelated to specific network element devices. Therefore, the system or product supporting the technical solutions of this application embodiment may include, but is not limited to, network element devices, PCs, servers or other embedded devices, as long as the running environment is a Linux system series and the executable files and dynamic libraries are based on the GNU compilation system.

[0016] To enable those skilled in the art to better understand the technical solutions in this application, the technical solutions in this application will be clearly and completely described below with reference to the accompanying drawings of one or more embodiments. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort should fall within the protection scope of this application.

[0017] The terms "first," "second," etc., used in this application and the claims are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that this application can be implemented in orders other than those illustrated or described herein. Furthermore, in this application and the claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0018] The technical solutions provided by the various embodiments of this application are described in detail below with reference to the accompanying drawings.

[0019] Figure 2 This is a flowchart illustrating a method for determining a dynamic library according to an embodiment of this application. Figure 2 The method for determining the dynamic library shown can be executed by the loader, and specifically includes the following steps.

[0020] S202: During the startup phase of the executable file, for the first external symbol of the executable file, the first dynamic library corresponding to the first external symbol is searched in a pre-determined global symbol hash table. The global symbol hash table records the correspondence between multiple external symbols of the executable file and the dynamic libraries in which the multiple external symbols are located.

[0021] The first external symbol can be any external symbol that the executable file depends on. During the executable file's startup phase, for the first external symbol that the executable file depends on, the first dynamic library corresponding to the first external symbol can be found from a pre-defined global symbol hash table. The global symbol hash table records the correspondence between multiple external symbols of the executable file (which can be all external symbols that the executable file depends on) and the dynamic libraries where each external symbol resides. If the first dynamic library is found, it can be determined that the first dynamic library is the dynamic library where the first external symbol resides.

[0022] In this way, since the dynamic library where the external symbols of the executable file are located can be determined according to the correspondence recorded in the global symbol hash table during the startup phase of the executable file, there is no need to search the dynamic library one by one. Therefore, the time to find the dynamic library where the external symbols are located can be shortened, the external symbol search and relocation process can be accelerated, thereby improving the startup efficiency of the executable file and accelerating the startup performance of the network element device.

[0023] In this embodiment, the global symbol hash table can be predetermined, specifically determined before the executable file's startup phase, for example, during the executable file's linking phase. In some implementations, determining the global symbol hash table may include: Obtain each dynamic library that the executable file depends on and the symbol hash table of each dynamic library; A global symbolic hash table is generated based on each dynamic library and its symbolic hash table.

[0024] For an executable file, during its compilation, its dependent dynamic libraries are also compiled. Each dynamic library includes an ELF file, which contains a symbol hash table (i.e., the .gnu.hash or .hash section of the ELF file). The symbol hash table records one or more external symbols. To determine the global symbol hash table, each dynamic library that the executable file depends on, along with its symbol hash table, can be obtained. Then, based on each dynamic library and its symbol hash table, the global symbol hash table is generated.

[0025] In generating a global symbolic hash table based on each dynamic library and its symbolic hash table, some implementations may include the following steps: The symbol hash tables of each dynamic library are parsed to determine the external symbols in each dynamic library; For each external symbol resolved, determine the correspondence between the external symbol and the dynamic library in which the external symbol resides; Store the correspondence in a global symbolic hash table.

[0026] Specifically, for each dynamic library in the executable file, the symbol hash table of the dynamic library can be parsed to obtain the external symbols recorded in the symbol hash table. These external symbols are the external symbols in the dynamic library. After obtaining the external symbols in each dynamic library, for each external symbol, it can be determined which dynamic library the external symbol is located in, thus establishing the correspondence between the external symbols and the dynamic libraries they reside in.

[0027] It should be noted that in practical applications, the number of dynamic libraries containing external symbols may be one or more. When there is only one dynamic library containing an external symbol, the correspondence between the external symbol and its corresponding dynamic library can be determined by specifying the correspondence between the external symbol and that single dynamic library. When there are multiple dynamic libraries containing external symbols, in some implementations, the correspondence between the external symbol and its corresponding dynamic libraries can be determined by specifying the correspondence between the external symbol and all of those libraries. In other implementations, considering that loading only one dynamic library containing a particular external symbol is sufficient, a correspondence between the external symbol and one of its corresponding dynamic libraries can be established. This not only meets the requirements but also simplifies the correspondence and saves storage space in the global symbol hash table.

[0028] In specific implementations, when determining the correspondence between external symbols and the dynamic libraries they reside in, for each resolved external symbol, it is first necessary to determine whether the dynamic library containing the external symbol is unique, i.e., whether the number of dynamic libraries containing the external symbol is one or more. If the dynamic library containing the external symbol is unique, i.e., the number of dynamic libraries containing the external symbol is one, then the correspondence between the external symbol and this single dynamic library can be determined as the correspondence between the external symbol and its dynamic library. If the dynamic libraries containing the external symbol are not unique, i.e., the number of dynamic libraries containing the external symbol is multiple, then in some implementations, a target dynamic library can be determined from the multiple dynamic libraries containing the external symbol, and then the first correspondence between the external symbol and the target dynamic library can be determined as the correspondence between the external symbol and its dynamic library. The target dynamic library can be any one of the multiple dynamic libraries containing the external symbol. In other implementations, the second correspondence between the external symbol and the multiple dynamic libraries containing the external symbol can also be determined as the correspondence between the external symbol and its dynamic library.

[0029] After obtaining the correspondence between external symbols and the dynamic libraries containing those symbols, this correspondence can be stored in a global symbol hash table. In some implementations, when storing the correspondence in the global symbol hash table, it can be stored in the form of a fast-searchable data structure. This improves query efficiency when searching for the dynamic libraries containing the external symbols of an executable file based on the correspondence in the global symbol hash table. The fast-searchable data structure can be a key-value structure, where the key is the name of the external symbol and the value is the name of the dynamic library containing the external symbol.

[0030] After storing the mapping relationships in a global symbol hash table, optionally, in some implementations, the global symbol hash table can also be written as segment data into the executable ELF file. Thus, during the executable's startup phase, the global symbol hash table can be obtained from the executable ELF file, and then the dynamic library containing the executable's external symbols can be determined by searching the global symbol hash table.

[0031] After determining the global symbol hash table based on the method described above, during the startup phase of the executable file, for the first external symbol of the executable file, the first dynamic library corresponding to the first external symbol can be found in the global symbol hash table. This first dynamic library is the dynamic library that needs to be loaded.

[0032] As mentioned earlier, the correspondence stored in the global symbol hash table can be a correspondence between an external symbol and a single dynamic library containing that external symbol, or a correspondence between an external symbol and multiple dynamic libraries containing that external symbol. Thus, when searching for the first dynamic library corresponding to the first external symbol in the global symbol hash table, if only one dynamic library is found, that dynamic library can be identified as the first dynamic library. If multiple dynamic libraries are found, the first dynamic library can be determined from among those multiple dynamic libraries; for example, a dynamic library can be randomly selected from among the multiple dynamic libraries as the first dynamic library.

[0033] In this embodiment, after finding the first dynamic library from the global symbol hash table, the first dynamic library can be loaded. In some implementations, the first dynamic library is located on the disk, and can be loaded from the disk. When loading the first dynamic library from the disk, the first dynamic library can be mapped from the disk to the address space of the process corresponding to the executable file, and the first external symbol is assigned a mapped virtual address. At this point, the lookup and relocation process for the first external symbol is complete.

[0034] It should be noted that when searching for the first dynamic library containing the first external symbol of the executable file in the global symbol hash table, the search result may be empty, meaning the dynamic library containing the first external symbol is not found in the global symbol hash table. In this case, to ensure successful loading of the dynamic library containing the first external symbol, in some implementations, the dynamic library can be determined and loaded based on processing logic in related technologies. That is, the first external symbol can be checked one by one among the multiple dynamic libraries that the executable file depends on on the disk. If the first external symbol is found in a second dynamic library on the disk, the second dynamic library can be loaded. That is, the second dynamic library can be loaded from the disk and mapped into the address space of the process corresponding to the executable file, and the first external symbol is assigned a mapped virtual address. In this way, the successful loading of the dynamic library containing the first external symbol can be guaranteed.

[0035] To facilitate understanding of the method for determining dynamic libraries provided in the embodiments of this application, a more specific implementation method will be described below. Specifically, it may include the following steps.

[0036] Step 1: During the linking stage of the executable file, obtain the names of all external symbols in the executable file and the names of the source dynamic libraries (i.e., the dynamic libraries where these external symbols reside). Combine the correspondence information between the names of external symbols and the names of the source dynamic libraries into a data structure that can be quickly retrieved, and store it as segment data in the executable ELF file.

[0037] Specifically, such as Figure 3 As shown. First, the symbol hash table (which records one or more external symbols of the executable file) in each dynamic library ELF file that the executable file depends on can be parsed to record the correspondence between each external symbol and its source dynamic library. For any given external symbol, if there are multiple source dynamic libraries, in some implementations, deduplication can be performed based on the symbol name to retain the correspondence between the external symbol and one source dynamic library. In other implementations, deduplication can be omitted, and the correspondence between the external symbol and multiple source dynamic libraries can be retained. Second, the correspondence between each external symbol and its source dynamic library is stored in a global symbol hash table, using the symbol name as the key and the name of the symbol's source dynamic library as the value. Finally, the global symbol hash table is written into the executable ELF file and stored as a new data segment.

[0038] Step 2: When the executable file starts running, for a certain external symbol in the executable file, the global symbol hash table can be searched directly to obtain the source dynamic library of the external symbol, without having to search each dynamic library file on the disk. If found, the corresponding dynamic library is loaded.

[0039] Specifically, such as Figure 4As shown. For a specific external symbol in an executable file, the global symbol hash table located in the executable ELF file segment data can be directly retrieved. The corresponding relationship stored in the global symbol hash table is found, and the name of the dynamic library containing the external symbol is obtained based on the corresponding relationship. Then, the dynamic library is directly loaded and mapped into the process's address space from the dynamic library search path of the current runtime environment, completing the relocation of the external symbol's virtual address. This process can save the overhead of searching for external symbols from dynamic libraries one by one on the disk, save disk I / O operations, accelerate the symbol lookup process during the executable file startup phase, and thus improve the startup performance of the executable file. Specifically, when obtaining the name of the dynamic library containing the external symbol based on the corresponding relationship, in some implementations, if the corresponding relationship is between the external symbol and a single source dynamic library, the obtained dynamic library name is the name of that single source dynamic library. If the corresponding relationship is between the external symbol and multiple source dynamic libraries, the obtained dynamic library name is the name of any one of the multiple source dynamic libraries. That is, a dynamic library can be selected from multiple source dynamic libraries, and the name of the selected dynamic library is determined as the dynamic library name obtained based on the corresponding relationship.

[0040] It should be noted that in step 2, if the source dynamic library name of the external symbol is found in the global symbol hash table, the external symbol lookup and relocation process ends. If the source dynamic library name of the external symbol is not found in the global symbol hash table, step 3 can be executed.

[0041] Step 3: Perform the symbol lookup and relocation process in the relevant technology.

[0042] The method for determining dynamic libraries provided in this application can pre-determine the correspondence between multiple external symbols of an executable file and the dynamic libraries containing those external symbols, and record this correspondence in a global symbol hash table. During the startup phase of the executable file, for a certain first external symbol of the executable file, the first dynamic library corresponding to that first external symbol can be found from the global symbol hash table. This first dynamic library is the dynamic library containing the first external symbol. Thus, since the dynamic library containing the external symbols of the executable file can be determined based on the correspondence recorded in the global symbol hash table during the startup phase of the executable file, there is no need to search each dynamic library individually. Therefore, the time for finding the dynamic library containing the external symbols can be shortened, the external symbol lookup and relocation process can be accelerated, thereby improving the startup efficiency of the executable file and accelerating the startup performance of network element devices.

[0043] The foregoing has described specific embodiments of this application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0044] Figure 5 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application. Please refer to it. Figure 5 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and memory. The memory may include main memory, such as high-speed random-access memory (RAM), or non-volatile memory, such as at least one disk drive. Of course, the electronic device may also include other hardware required for other business operations.

[0045] The processor, network interface, and memory can be interconnected via an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. This bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 5 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.

[0046] Memory is used to store programs. Specifically, programs may include program code, which includes computer operation instructions. Memory may include main memory and non-volatile memory, and provides instructions and data to the processor.

[0047] The processor reads the corresponding computer program from non-volatile memory into main memory and then executes it, forming a dynamic library at the logical level. The processor executes the program stored in memory and specifically performs the following operations: During the startup phase of the executable file, for the first external symbol of the executable file, the first dynamic library corresponding to the first external symbol is searched in a pre-determined global symbol hash table. The global symbol hash table records the correspondence between multiple external symbols of the executable file and the dynamic libraries in which the multiple external symbols are located.

[0048] The above is as stated in this application. Figure 5 The method for determining a dynamic library disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by integrated logic circuits in the processor's hardware or by instructions in software form. The processor can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method.

[0049] The electronic device can also perform Figure 2 The method, and the implementation of the dynamic library determination device in Figure 2 The functions described in the illustrated embodiments will not be repeated here.

[0050] Of course, in addition to software implementation, the electronic device of this application does not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. In other words, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0051] This application also discloses a computer-readable storage medium that stores one or more programs, the programs including instructions that, when executed by a portable electronic device including multiple applications, enable the portable electronic device to perform... Figure 2 The method of the illustrated embodiment is specifically used to perform the following operations: During the startup phase of the executable file, for the first external symbol of the executable file, the first dynamic library corresponding to the first external symbol is searched in a pre-determined global symbol hash table. The global symbol hash table records the correspondence between multiple external symbols of the executable file and the dynamic libraries in which the multiple external symbols are located.

[0052] Figure 6 This is a schematic diagram of the structure of a dynamic library determination device 60 according to an embodiment of this application. Please refer to... Figure 6 In one software implementation, the dynamic library determination device 60 may include: a determination module 61, wherein: In the startup phase of the executable file, the determination module 61 searches for the first external symbol of the executable file in a pre-determined global symbol hash table to find the first dynamic library corresponding to the first external symbol. The global symbol hash table records the correspondence between multiple external symbols of the executable file and the dynamic libraries in which the multiple external symbols are located.

[0053] In some implementations, the determining module 61 further includes, prior to the executable file startup phase: Obtain each dynamic library that the executable file depends on and the symbol hash table of each dynamic library; The global symbol hash table is generated based on each of the dynamic libraries and the symbol hash table of each dynamic library.

[0054] In some implementations, the determining module 61 generates the global symbol hash table based on each of the dynamic libraries and the symbol hash table of each of the dynamic libraries, including: The symbol hash tables of each dynamic library are parsed to determine the external symbols in each dynamic library; For each of the resolved external symbols, determine the correspondence between the external symbol and the dynamic library in which the external symbol resides; The correspondence is stored in the global symbol hash table.

[0055] In some implementations, the determining module 61 determines the correspondence between the external symbol and the dynamic library where the external symbol resides, including: When there are multiple dynamic libraries containing the external symbol, the target dynamic library is determined from the multiple dynamic libraries containing the external symbol; The first correspondence between the external symbol and the target dynamic library is determined as the correspondence between the external symbol and the dynamic library in which the external symbol is located.

[0056] In some implementations, the determining module 61, in determining the correspondence between the external symbol and the dynamic library where the external symbol resides, includes: When there are multiple dynamic libraries containing the external symbol, the second correspondence between the external symbol and the multiple dynamic libraries containing the external symbol is determined as the correspondence between the external symbol and the dynamic library containing the external symbol.

[0057] In some implementations, the determining module 61, in the step of searching for the first dynamic library corresponding to the first external symbol in a pre-determined global symbol hash table, includes: Search a pre-determined global symbol hash table for multiple dynamic libraries corresponding to the first external symbol; The first dynamic library is determined from the plurality of dynamic libraries.

[0058] In some implementations, the determining module 61 stores the correspondence in the global symbol hash table, including: The correspondence is stored in the global symbol hash table in the form of a data structure that can be retrieved quickly; The fast-searchable data structure includes a key-value pair, where the key is the name of the external symbol and the value is the name of the dynamic library where the external symbol resides.

[0059] In some implementations, the determining module 61, after storing the correspondence in the global symbol hash table, further includes: Write the global symbol hash table as segment data into the executable ELF file.

[0060] In some embodiments, the dynamic library determining device 60 further includes: Load the module and load the first dynamic library.

[0061] In some implementations, the first dynamic library is located on a disk; the loading module loads the first dynamic library, including: The first dynamic library is loaded from the disk and mapped to the address space of the process corresponding to the executable file, and the first external symbol is assigned a mapped virtual address.

[0062] In some embodiments, the determining module 61 further includes: If the first dynamic library is not found in the global symbol hash table, the first external symbol is checked one by one in the multiple dynamic libraries that the executable file depends on on the disk. If the first external symbol is found in the second dynamic library, the second dynamic library is loaded.

[0063] The dynamic library determination device 60 provided in this application can also execute... Figure 2 The method, and the dynamic library determination device 60 in Figure 2 The functions of the embodiments shown will not be described again in this application.

[0064] This application also proposes 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 in the above-described method embodiment for determining a dynamic library.

[0065] In summary, the above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.

[0066] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.

[0067] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0068] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0069] The various embodiments in this application are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

Claims

1. A method for determining a dynamic library, comprising: During the startup phase of the executable file, for the first external symbol of the executable file, the first dynamic library corresponding to the first external symbol is searched in a pre-determined global symbol hash table. The global symbol hash table records the correspondence between multiple external symbols of the executable file and the dynamic libraries in which the multiple external symbols are located.

2. The method of claim 1, wherein prior to the startup phase of the executable file, the method further comprises: Obtain each dynamic library that the executable file depends on and the symbol hash table of each dynamic library; The global symbol hash table is generated based on each of the dynamic libraries and the symbol hash table of each dynamic library.

3. The method as described in claim 2, wherein generating the global symbol hash table based on each of the dynamic libraries and the symbol hash tables of each of the dynamic libraries comprises: The symbol hash tables of each dynamic library are parsed to determine the external symbols in each dynamic library; For each of the resolved external symbols, determine the correspondence between the external symbol and the dynamic library in which the external symbol resides; The correspondence is stored in the global symbol hash table.

4. The method as described in claim 3, wherein determining the correspondence between the external symbol and the dynamic library where the external symbol resides includes: When there are multiple dynamic libraries containing the external symbol, the target dynamic library is determined from the multiple dynamic libraries containing the external symbol; The first correspondence between the external symbol and the target dynamic library is determined as the correspondence between the external symbol and the dynamic library in which the external symbol is located.

5. The method of claim 3, wherein determining the correspondence between the external symbol and the dynamic library where the external symbol resides includes: When there are multiple dynamic libraries containing the external symbol, the second correspondence between the external symbol and the multiple dynamic libraries containing the external symbol is determined as the correspondence between the external symbol and the dynamic library containing the external symbol.

6. The method of claim 5, wherein searching for the first dynamic library corresponding to the first external symbol in a predetermined global symbol hash table comprises: Search a pre-determined global symbol hash table for multiple dynamic libraries corresponding to the first external symbol; The first dynamic library is determined from the plurality of dynamic libraries.

7. The method of claim 3, wherein storing the correspondence in the global symbol hash table comprises: The correspondence is stored in the global symbol hash table in the form of a data structure that can be retrieved quickly; The fast-searchable data structure includes a key-value pair, where the key is the name of the external symbol and the value is the name of the dynamic library where the external symbol resides.

8. The method of claim 3, further comprising, after storing the correspondence in the global symbol hash table: The global symbol hash table is written as segment data into the executable ELF file.

9. The method of claim 1, further comprising: Load the first dynamic library.

10. The method of claim 9, wherein the first dynamic library is located on a disk; loading the first dynamic library includes: The first dynamic library is loaded from the disk and mapped to the address space of the process corresponding to the executable file, and the first external symbol is assigned a mapped virtual address.

11. The method of claim 1, further comprising: If the first dynamic library is not found in the global symbol hash table, the first external symbol is checked one by one in the multiple dynamic libraries that the executable file depends on on the disk. If the first external symbol is found in the second dynamic library, the second dynamic library is loaded.

12. An electronic device, comprising: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the method as described in any one of claims 1 to 11.

13. A computer-readable storage medium, wherein instructions in the storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the method as described in any one 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 as claimed in any one of claims 1 to 11.