Dynamic loading method and electronic equipment

By pre-parsing and sharing the parsing results of the files to be loaded, the parallel loading of dynamic libraries is achieved, solving the startup speed and resource waste of dynamic loading technology in multi-process scenarios, and improving the performance and user experience of the application.

CN119225840APending Publication Date: 2024-12-31HUAWEI TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202310808428.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-30
Publication Date
2024-12-31

AI Technical Summary

Technical Problem

The existing dynamic loading technology requires a complete dynamic library loading when starting a new process in a multi-process scenario, resulting in low startup speed and redundant calculations, and wasting computing resources.

Method used

By pre-parsing the files in the list of files to be loaded, saving the parsed results and sharing them among multiple processes, the decoupling and parallel loading of dynamic libraries can be achieved, redundant calculations can be reduced, and application startup speed can be improved.

Benefits of technology

Optimize the startup speed of the application, save computing resources and memory space, and improve user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119225840A_ABST
    Figure CN119225840A_ABST
Patent Text Reader

Abstract

The invention provides a dynamic loading method and electronic device.The method comprises the steps that one or more target files are analyzed, one or more first analysis results are stored, the one or more first analysis results correspond to the one or more target files in a one-to-one mode, the one or more target files comprise first target files, and the first target files comprise second target files; the first target file is an executable file or a dynamic library file; searching a first analysis result of a dynamic library file on which the first executable file depends in the one or more first analysis results; and according to the first analysis result of the dynamic library file on which the first executable file depends, mapping the dynamic library file on which the first executable file depends to a process address space where the first executable file is located. Based on the scheme, sharing of one or more analysis results can be achieved, optimization of the starting speed of the application program is facilitated, calculation resources are saved, memory space is saved, performance of the electronic equipment is improved, and therefore the use experience of a user is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and more specifically, to a dynamic loading method and electronic device. Background Art

[0002] Dynamic loading technology refers to dynamically loading one or more library files into the memory when the program is running, and mapping the functions and variables in them to the process address space of the program for the program to call. Dynamic loading technology allows the program to load the required library files as needed when running, without the need to link all library files to the program during compilation, thereby saving memory space and improving the flexibility of the application.

[0003] However, dynamic library loading of different applications is independent of each other. Each time a new application is started, a complete dynamic loading may be required, which results in a low startup speed and a lot of redundant calculations. Summary of the invention

[0004] The present application provides a dynamic loading method and electronic device, which can realize the sharing of one or more analysis results, which is conducive to optimizing the application startup speed, saving computing resources, saving memory space, and improving the performance of the electronic device, thereby improving the user experience.

[0005] In a first aspect, a dynamic loading method is provided, the method comprising: parsing one or more target files and saving one or more first parsing results, the one or more first parsing results corresponding one to one with the one or more target files, the one or more target files comprising a first target file, the first target file being an executable file or a dynamic library file; searching for a first parsing result of a dynamic library file that the first executable file depends on among the one or more first parsing results; and mapping the dynamic library file that the first executable file depends on to a process address space where the first executable file is located according to the first parsing result of the dynamic library file that the first executable file depends on.

[0006] It should be understood that the one or more target files may include a first target file, and the first target file may be an executable file or a dynamic library file.

[0007] It should be understood that there may or may not be a dependency relationship between one or more target files, and the embodiments of the present application are not limited to this.

[0008] It should be noted that the first executable file may be, for example, an executable file of an application loaded in a user process, and the process address space is a memory space allocated by the system to the user process.

[0009] It should be noted that the first analysis result may be, for example, Figure 4 In the illustrated embodiment, one or more first parsing results may be formatted as follows: Figure 4 The global target file list in the illustrated embodiment is saved.

[0010] In an embodiment of the present application, when the target file is parsed, the first parsing result of the target file can be saved. These first parsing results will be used in the loading process of the dynamic library, so as to realize the decoupling of the parsing process and the loading process of the target file, which is conducive to optimizing the application startup speed and improving the user experience. On the other hand, the first parsing result of a target file can be used in the loading process of multiple different executable files, so as to realize the sharing of the one or more first parsing results, which is conducive to saving computing resources and saving memory space. In addition, the user can perform operations such as adding, deleting, and modifying the one or more first parsing results saved, so as to improve the flexibility of dynamic loading.

[0011] In combination with the first aspect, in some implementations of the first aspect, the one or more target files include a first dynamic library file, and the first parsing result includes a path, a mapping interval, and dependency information of the first dynamic library file.

[0012] It should be understood that the first parsing result of the first dynamic library file may include the name, path, mapping interval and dependency information of the first dynamic library file. Among them, the path of the first dynamic library file may indicate the location where the first dynamic library file is stored in the disk; the dependency information of the first dynamic library file may indicate the dynamic library files that the first dynamic library file depends on, including the dynamic library files that the first dynamic library file directly depends on and the dynamic library files that it indirectly depends on; the mapping interval of the first dynamic library file may indicate the file range that the first dynamic library file needs to map to the process address space, that is, the content that the first dynamic library file needs to load.

[0013] In an embodiment of the present application, one or more first parsing results may include the path, mapping interval and dependency information of one or more target files, so that the dynamic library files and the dynamic library files that the dynamic library files depend on can be quickly found, and the mapping intervals of these dynamic library files can be determined, which is conducive to improving the startup speed of the application. In addition, since the one or more first parsing results can be shared, it is conducive to saving computing resources.

[0014] In combination with the first aspect, in some implementations of the first aspect, the dynamic library file that the first executable file depends on includes the first dynamic library file, wherein, based on the first parsing result of the dynamic library file that the first executable file depends on, mapping the dynamic library file that the first executable file depends on to the process address space where the first executable file is located includes: obtaining the first dynamic library file based on the path of the first dynamic library file; and mapping the first dynamic library file to the process address space based on the mapping interval of the first dynamic library file.

[0015] In combination with the first aspect, in certain implementations of the first aspect, the first target file is a file in a list of files to be parsed, and the files in the list of files to be parsed are files that need to be parsed before the first executable file is loaded into the process address space.

[0016] It should be noted that the files in the to-be-parsed file list may be files configured by the user, or may be default files that need to be pre-parsed.

[0017] It should be noted that one or more target files may be files in the list of files to be parsed, or may not be files in the list of files to be parsed. For example, when the second executable file is started, the dynamic loader may need to parse the second executable file and the dynamic library file that the second executable file depends on. At this time, the first parsing result of the second executable file and the first parsing result of the dynamic library file that the second executable file depends on can be saved, so that other executable files can find the first parsing result of the dynamic library file they need when loading.

[0018] In an embodiment of the present application, by pre-parsing the files in the list of files to be parsed, the first parsing results of the files in the list of files to be parsed and the first parsing results of the dynamic libraries on which these files depend can be obtained and saved. These first parsing results will be used in the loading process of the dynamic library, thereby realizing the decoupling of the parsing process and the loading process of the target file, which is conducive to optimizing the startup speed of the application and improving the user experience. On the other hand, the first parsing result of a target file can be used in the loading process of multiple different executable files, thereby realizing the sharing of the one or more first parsing results, which is conducive to saving computing resources and saving memory space.

[0019] In combination with the first aspect, in certain implementations of the first aspect, the first parsing result of the second dynamic library file and the dynamic library file on which the second dynamic library file depends is searched among the one or more first parsing results, and the second dynamic library file is the designated dynamic library file requested to be loaded by the process where the first executable file is located; based on the first parsing result of the second dynamic library file and the dynamic library file on which the second dynamic library file depends, the second dynamic library file and the dynamic library file on which the second dynamic library file depends are mapped to the process address space.

[0020] In an embodiment of the present application, the loading of the specified dynamic library file can be achieved based on the first parsing result of the specified dynamic library file and the dynamic library file on which the specified dynamic library file depends, which is beneficial to optimizing the application startup speed and improving the user experience.

[0021] In combination with the first aspect, in some implementations of the first aspect, if the first parsing result of the dynamic library file that the first executable file depends on is not found, the first executable file is parsed, and the first parsing result of the first executable file and the first parsing result of the dynamic library file that the first executable file depends on are saved; and / or,

[0022] If the parsing result of the second dynamic library file is not found, the second dynamic library file is parsed, and the first parsing result of the second dynamic library file and the first parsing result of the dynamic library file on which the second dynamic library file depends are saved.

[0023] It should be understood that the dynamic library file that the first executable file depends on and the specified dynamic library are both dynamic libraries required when the first executable file is running.

[0024] In an embodiment of the present application, if the dynamic library required for the runtime of the first executable file has not been parsed, the dynamic library required for the runtime of the first executable file can be parsed according to a traditional method, and the corresponding first parsing result can be saved, thereby optimizing the startup speed of subsequent applications that rely on these dynamic library files, which is beneficial to improving the user experience.

[0025] In combination with the first aspect, in certain implementations of the first aspect, parsing one or more target files and saving one or more first parsing results includes: using multiple threads to parallel parse the one or more target files and saving the one or more first parsing results.

[0026] In the embodiment of the present application, by parsing one or more target files in parallel through multi-threading, the parsing speed can be accelerated, which is conducive to fully utilizing computing resources.

[0027] In combination with the first aspect, in some implementations of the first aspect, the dynamic library files that the first executable file depends on include a third dynamic library file and a fourth dynamic library file, wherein, according to a first parsing result of the dynamic library files that the first executable file depends on, mapping the dynamic library files that the first executable file depends on to the process address space where the first executable file is located comprises: the first thread maps the third dynamic library file to the process address space where the first executable file is located according to the first parsing result of the third dynamic library file;

[0028] The second thread maps the fourth dynamic library file to the process address space according to the first parsing result of the fourth dynamic library file, and the first thread and the second thread are different.

[0029] In the embodiment of the present application, multiple dynamic library files can also be loaded in parallel through multi-threading, thereby speeding up the loading speed, which is beneficial to optimizing the startup speed of the application and improving the user experience.

[0030] In combination with the first aspect, in some implementations of the first aspect, the method further includes:

[0031] The one or more target files are parsed and information of one or more symbols is saved, wherein the one or more symbols are symbols defined in the one or more target files, and the one or more symbols include a first symbol, and the information of the first symbol includes the name of the target file to which the first symbol belongs and the position information of the first symbol in the target file to which the first symbol belongs.

[0032] In the present application embodiment, when the target file is parsed, the information of the symbol defined in the target file can be stored. When the symbol to be relocated is relocated, the position of the symbol to be relocated in the process address space can be quickly found, thereby accelerating the relocation process, helping to optimize the application startup speed, and helping to improve the user experience. On the other hand, the information of one or more symbols can be used in the relocation process of a plurality of different executable files, thereby realizing the sharing of the information of the one or more symbols, helping to save computing resources, and helping to save memory space.

[0033] In combination with the first aspect, in certain implementations of the first aspect, the dynamic library file that the first executable file depends on includes a fifth dynamic library file, and the relocation table of the fifth dynamic library file includes a second symbol. The method also includes: after mapping the dynamic library file that the first executable file depends on to the process address space where the first executable file is located, searching for information of the second symbol in the information of the one or more symbols, and the information of the second symbol is used to relocate the second symbol.

[0034] In combination with the first aspect, in certain implementations of the first aspect, the method further includes: obtaining an address of the second symbol in the process address space based on information of the second symbol; and relocating the second symbol based on the address of the second symbol in the process address space.

[0035] In combination with the first aspect, in certain implementations of the first aspect, the method further includes: when the first executable file and the dynamic library file on which the first executable file depends are not in the resolved file list, parsing the first executable file and the dynamic library file on which the first executable file depends, and saving information about symbols defined in the first executable file and the dynamic library file on which the first executable file depends, and the resolved file list is used to store the names of the resolved executable files or dynamic library files.

[0036] In combination with the first aspect, in certain implementations of the first aspect, parsing the one or more target files and saving information of one or more symbols includes: using multiple threads to parse the one or more target files in parallel and saving information of the one or more symbols.

[0037] In a second aspect, a dynamic loading method is provided, the method comprising: parsing one or more target files and saving information of one or more symbols, the one or more symbols being symbols defined in the one or more target files, the one or more symbols comprising a first symbol, the information of the first symbol comprising the name of the target file to which the first symbol belongs and the position information of the first symbol in the target file to which the first symbol belongs, the one or more target files comprising the first target file, the first target file being an executable file or a dynamic library file; searching for information of a second symbol in the information of the one or more symbols, the second symbol being a symbol in a relocation table of a dynamic library file on which the first executable file depends, the information of the second symbol being used to relocate the second symbol.

[0038] It should be understood that the one or more target files may include a first target file, and the first target file may be an executable file or a dynamic library file.

[0039] It should be understood that there may or may not be a dependency relationship between one or more target files, and the embodiments of the present application are not limited to this.

[0040] In an embodiment of the present application, one or more symbols are symbols defined in one or more target files, including all symbols defined in each target file.

[0041] It should be noted that the first executable file may be, for example, an executable file of a program loaded in a user process, and the process address space is a memory space allocated by the system to the user process.

[0042] It should be noted that the information of each symbol can be, for example, Figure 4 In the symbol parsing result of the embodiment shown, the information of one or more symbols can be, for example, Figure 4 The global symbol table in the illustrated embodiment is saved in the form of a global symbol table.

[0043] In the present application embodiment, when the target file is parsed, the information of the symbol defined in the target file can be stored. When the symbol to be relocated is relocated, the position of the symbol to be relocated in the process address space can be quickly found, thereby accelerating the relocation process, helping to optimize the application startup speed, and helping to improve the user experience. On the other hand, the information of one or more symbols can be used in the relocation process of a plurality of different executable files, thereby realizing the sharing of the information of the one or more symbols, helping to save computing resources, and helping to save memory space.

[0044] In conjunction with the second aspect, in some implementations of the first aspect, the method further includes:

[0045] According to the information of the second symbol, an address of the second symbol in the process address space where the first executable file is located is obtained; and according to the address of the second symbol in the process address space, the second symbol is relocated.

[0046] In combination with the second aspect, in some implementations of the first aspect, the first target file is a file in a list of files to be parsed, and the files in the list of files to be parsed are files that need to be parsed before the first executable file is loaded into the process address space.

[0047] It should be noted that the files in the to-be-parsed file list may be files configured by the user, or may be default files that need to be pre-parsed.

[0048] It should be noted that the one or more target files may be files in the list of files to be parsed, or may not be files in the list of files to be parsed.

[0049] In combination with the second aspect, in certain implementations of the first aspect, the method further includes: when the first executable file or the dynamic library file that the first executable file depends on is not in the resolved file list, parsing the first executable file and the dynamic library file that the first executable file depends on, and saving information about symbols defined in the first executable file and the dynamic library file that the first executable file depends on, and the resolved file list is used to store the names of the resolved executable files or dynamic library files.

[0050] In combination with the second aspect, in certain implementations of the first aspect, parsing the one or more target files and saving information of one or more symbols includes: using multiple threads to parse the one or more target files in parallel and saving information of the one or more symbols.

[0051] The third aspect is an electronic device of an embodiment of the present application, which includes one or more processors; one or more memories; the one or more memories store one or more computer programs, and the one or more computer programs include instructions. When the instructions are executed by the one or more processors, the above aspects or any possible implementation of the above aspects are executed.

[0052] In a fourth aspect, a chip is provided, comprising a processor and a communication interface, wherein the communication interface is used to receive a signal and transmit the signal to the processor, and the processor processes the signal so that the method described in the first aspect and any possible implementation of the first aspect is executed, or the method described in the second aspect and any possible implementation of the second aspect is executed.

[0053] In a fifth aspect, a computer-readable storage medium is provided, characterized in that it includes computer instructions, which, when executed on an electronic device, enable the electronic device to execute the method described in the first aspect and any possible implementation of the first aspect, or execute the method described in the second aspect and any possible implementation of the second aspect.

[0054] In the sixth aspect, a computer program product is provided, characterized in that the computer program product includes: a computer program code, which, when executed, implements the method described in the first aspect and any possible implementation manner of the first aspect, or implements the method described in the second aspect and any possible implementation manner of the second aspect.

[0055] The seventh aspect is an electronic device of an embodiment of the present application, which includes modules / units for executing the above aspects or any possible design method of the above aspects; these modules / units can be implemented by hardware, or the corresponding software can be implemented by hardware. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] Figure 1 It is a structural schematic diagram of an electronic device provided by this embodiment.

[0057] Figure 2 It is a software structure block diagram of the electronic device according to an embodiment of the present application.

[0058] Figure 3 It is a schematic diagram of a dynamically loaded system architecture provided in an embodiment of the present application.

[0059] Figure 4 It is a schematic flow chart of a dynamic loading method provided in an embodiment of the present application.

[0060] Figure 5 It is a schematic flow chart of a dynamic loading method provided in an embodiment of the present application.

[0061] Figure 6 It is a schematic flow chart of a dynamic loading method provided in an embodiment of the present application.

[0062] Figure 7 It is a schematic flow chart of a dynamic loading method provided in an embodiment of the present application.

[0063] Figure 8 It is a schematic diagram of the hardware structure of the device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0064] The terms used in the following embodiments are only for the purpose of describing specific embodiments, and are not intended to be used as limitations on the present application. As used in the specification and the appended claims of the present application, the singular expressions "one", "a kind of", "said", "above", "the" and "this" are intended to also include expressions such as "one or more", unless there is a clear contrary indication in the context. It should also be understood that in the following embodiments of the present application, "at least one", "one or more" refer to one, two or more. The term "and / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist; for example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship.

[0065] References to "one embodiment" or "some embodiments" etc. described in this specification mean that a particular feature, structure or characteristic described in conjunction with the embodiment is included in one or more embodiments of the present application. Thus, the phrases "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear at different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0066] The technical solution in this application will be described below in conjunction with the accompanying drawings.

[0067] The following describes electronic devices and embodiments for using such electronic devices. In some embodiments, the electronic device may be a portable electronic device that also includes other functions such as a personal digital assistant and / or a music player, such as a mobile phone, a tablet computer, a wearable electronic device with wireless communication functions (such as a smart watch), etc. Exemplary embodiments of portable electronic devices include but are not limited to devices equipped with The portable electronic device may be a portable electronic device running OpenHarmony or other operating systems. The portable electronic device may also be other portable electronic devices, such as a laptop computer, etc. It should also be understood that in some other embodiments, the electronic device may not be a portable electronic device, but a desktop computer.

[0068] For example, Figure 1 1 shows a schematic diagram of the structure of the electronic device 100. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a compass 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.

[0069] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0070] The processor 110 may include one or more processing units, for example: the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and / or a neural-network processing unit (neural-network processing unit, NPU), etc. Among them, different processing units may be independent components or integrated into one or more processors. In some embodiments, the electronic device 100 may also include one or more processors 110. Among them, the controller may generate an operation control signal according to the instruction opcode and the timing signal to complete the control of fetching and executing instructions. In some other embodiments, a memory may also be set in the processor 110 for storing instructions and data. Exemplarily, the memory in the processor 110 may be a high-speed cache memory. The memory may store instructions or data that the processor 110 has just used or circulated. If the processor 110 needs to use the instruction or data again, it can be directly called from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the electronic device 100 in processing data or executing instructions.

[0071] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a SIM card interface, and / or a USB interface, etc. Among them, the USB interface 130 is an interface that complies with the USB standard specification, and can specifically be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transmit data between the electronic device 100 and a peripheral device. The USB interface 130 can also be used to connect headphones to play audio through the headphones.

[0072] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0073] The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100. While the charging management module 140 is charging the battery 142, it may also power the electronic device through the power management module 141.

[0074] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.

[0075] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0076] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.

[0077] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.

[0078] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (WiFi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0079] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.

[0080] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. In some embodiments of the present application, when the display panel is made of materials such as OLED, AMOLED, FLED, etc., the above Figure 1 The display screen 194 in the embodiment can be bent. Here, the display screen 194 can be bent, which means that the display screen can be bent to any angle at any position and can be kept at the angle. For example, the display screen 194 can be folded in half from the middle to the left or right. It can also be folded in half from the middle to the top or bottom.

[0081] The electronic device 100 can realize the shooting function through the ISP, the camera 193, the video codec, the GPU, the display screen 194 and the application processor.

[0082] The ISP is used to process the data fed back by the camera 193. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. The ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. The ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP can be set in the camera 193.

[0083] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include one or more cameras 193.

[0084] The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 100 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.

[0085] Video codecs are used to compress or decompress digital videos. The electronic device 100 may support one or more video codecs. Thus, the electronic device 100 may play or record videos in a variety of coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0086] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.

[0087] The external memory interface 120 can be used to connect an external memory, such as a Micro SD card, a hard disk, to expand the storage capacity of the electronic device 100. The external memory communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, files such as music and videos are stored in an external memory card. In the embodiment of the present application, the external memory connected to the external memory interface 120 can be referred to as an external memory.

[0088] The internal memory 121 can be used to store one or more computer programs, which include instructions. The processor 110 can enable the electronic device 100 to perform the methods provided in some embodiments of the present application, as well as various applications and data processing, etc. by running the above instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system; the program storage area can also store one or more applications (such as a gallery, contacts, etc.). The data storage area can store data (such as photos, contacts, etc.) created during the use of the electronic device 100. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more disk storage components, a flash memory component, a universal flash storage (UFS), etc. In some embodiments, the processor 110 can enable the electronic device 100 to perform the methods provided in the embodiments of the present application, as well as other applications and data processing by running instructions stored in the internal memory 121, and / or instructions stored in a memory provided in the processor 110. The electronic device 100 can implement audio functions such as music playback, weather, etc. through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor, etc. In the embodiment of the present application, the internal memory 121 can be referred to as a memory.

[0089] The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, and the like.

[0090] Among them, the pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be set on the display screen 194. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. The capacitive pressure sensor can be a parallel plate including at least two conductive materials. When a force acts on the pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the intensity of the pressure according to the change in capacitance. When a touch operation acts on the display screen 194, the electronic device 100 detects the touch operation intensity according to the pressure sensor 180A. The electronic device 100 can also calculate the touch position according to the detection signal of the pressure sensor 180A. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities can correspond to different operation instructions. For example: when a touch operation with a touch operation intensity less than the first pressure threshold acts on the short message application icon, an instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the short message application icon, an instruction to create a new short message is executed.

[0091] The gyro sensor 180B can be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., X, Y, and Z axes) can be determined by the gyro sensor 180B. The gyro sensor 180B can be used for anti-shake shooting. For example, when the shutter is pressed, the gyro sensor 180B detects the angle of the electronic device 100 shaking, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to offset the shaking of the electronic device 100 through reverse movement to achieve anti-shake. The gyro sensor 180B can also be used for navigation and somatosensory game scenes.

[0092] The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in all directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of the electronic device and is applied to applications such as horizontal and vertical screen switching and pedometers.

[0093] The ambient light sensor 180L is used to sense the ambient light brightness. The electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in a pocket to prevent accidental touches.

[0094] The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to implement fingerprint unlocking, access application locks, fingerprint photography, fingerprint call answering, etc.

[0095] The temperature sensor 180J is used to detect temperature. In some embodiments, the electronic device 100 uses the temperature detected by the temperature sensor 180J to execute a temperature processing strategy. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold, the electronic device 100 reduces the performance of a processor located near the temperature sensor 180J to reduce power consumption and implement thermal protection. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to avoid abnormal shutdown of the electronic device 100 due to low temperature. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 performs a boost on the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.

[0096] The touch sensor 180K is also called a "touch panel". The touch sensor 180K can be set on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a "touch screen". The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 194.

[0097] Figure 2 1 is a software structure diagram of the electronic device 100 of the embodiment of the present application. The layered architecture divides the software into several layers, each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely, the application layer, the application framework layer, the Android runtime (Android runtime) and the system library, and the kernel layer. The application layer can include a series of application packages.

[0098] like Figure 2 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, etc.

[0099] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.

[0100] like Figure 2 As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.

[0101] The window manager is used to manage window programs. The window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc.

[0102] Content providers are used to store and retrieve data and make it accessible to applications. This data can include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.

[0103] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.

[0104] The phone manager is used to provide communication functions of the electronic device 100, such as management of call status (including connecting, hanging up, etc.).

[0105] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.

[0106] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the display in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.

[0107] The system library may include multiple functional modules, such as surface manager, media libraries, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.

[0108] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.

[0109] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG and PNG, etc.

[0110] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis and layer processing.

[0111] A 2D graphics engine is a drawing engine for 2D drawings.

[0112] The kernel layer is the layer between hardware and software. The kernel layer includes at least display driver, camera driver, audio driver, and sensor driver.

[0113] Before introducing the embodiments of the present application, concepts related to the embodiments of the present application are first introduced.

[0114] Process: A program in a computer runs on a certain data set. It is the basic unit for resource allocation and scheduling in the system and the foundation of the operating system structure. In the early computer structure designed for processes, processes are the basic execution entities of programs; in the contemporary computer structure designed for threads, processes are the containers of threads. A program is a description of instructions, data and their organizational forms, and a process is the entity of a program.

[0115] Thread: Sometimes called lightweight process (LWP), it is the smallest unit of program execution flow. A standard thread consists of a thread ID, current instruction pointer, register set and stack. In addition, a thread is an entity in a process and is a basic unit that is independently scheduled and dispatched by the system. A thread does not own system resources, but only has a few resources that are essential for operation. However, it can share all the resources owned by the process with other threads belonging to the same process. A thread can create and cancel another thread, and multiple threads in the same process can execute concurrently.

[0116] Library file: A type of file on a computer that provides users with some out-of-the-box variables, functions or classes. Library files are divided into static library files and dynamic library files, or simply called static libraries and dynamic libraries. The difference between static libraries and dynamic libraries is reflected in the linking stage of the program. Static libraries are copied to the program during the linking stage of the program; dynamic libraries are not copied to the program during the linking stage, but are dynamically loaded into the memory by the system when the program is running for the program to call.

[0117] Executable file: A binary file that contains program code that can be directly executed. When the executable file is run, the system will create a process and load the executable file into the process address space for execution, thereby realizing the program's functions.

[0118] Symbol: The symbols of a library file usually refer to the function and variable names in the library file.

[0119] Symbol table: Usually a data structure used to store symbols (such as functions, variables, etc.) defined and referenced in a dynamic library and their related information, such as name, type, size, etc.

[0120] Relocation table: used to store symbols that need to be relocated in dynamic libraries. Usually, if a symbol is defined in other dynamic libraries, the symbol needs to be relocated.

[0121] Handle: A way to reference or identify an object, which can be used to access or manipulate underlying system resources.

[0122] When a program is started in the system, the system will create a process for the program. A process is a basic concept in the system, representing a running program instance. When creating a process, the system will allocate memory space (i.e., process address space) for the process to store information such as program code, data, and stack. The system will then load the program's executable file into the process address space and start executing the executable file.

[0123] Dynamic loading technology refers to dynamically loading one or more dynamic libraries into memory when the program is running, and mapping the functions and variables in them to the process address space of the program for the program to call. Dynamic loading technology allows the program to load the required library files as needed during runtime, without having to link all library files to the program during compilation, thereby saving memory space and improving program flexibility. The component that completes the above dynamic loading process is the dynamic loader.

[0124] The dynamic loading process of the program at startup mainly includes the following steps:

[0125] (1) The kernel initializes the process address space and maps the code segment, data segment and other contents that need to be loaded into the process address space.

[0126] (2) Perform dependency parsing on the executable file of the program, that is, obtaining the dynamic libraries that the executable file depends on. For example, the dynamic libraries that the executable file depends on can be viewed based on the content of type DT_DEEDED in the .dynamic segment of the executable file. If this dynamic library also depends on other dynamic libraries, then the names of the dynamic libraries that the dynamic library depends on are also added to the load set, and this cycle continues until all dynamic libraries are loaded. If the dependency relationship between executable files and dynamic libraries is viewed as a tree diagram, then the process of parsing the dynamic libraries that the executable file depends on is a process of traversing the tree diagram. For example, depth-first, breadth-first, or other orders can be used to traverse the entire tree diagram.

[0127] (3) Search for the dynamic library that the executable file depends on. For example, you can search for the dynamic library in multiple paths such as LD_LIBRARY_PATH, / lib, / usr / lib, and system directories.

[0128] (4) Open the found dynamic library, read the elf_header information of the dynamic library, and obtain the file range that needs to be mapped into the memory, that is, the mapping interval.

[0129] (5) Map the content that needs to be loaded by the dynamic library to the process address space and add it to the dynamic library list. The dynamic library list is maintained by the dynamic loader and contains all the library files that need to be dynamically loaded when the application is running. Each node in the dynamic library list represents a dynamic library and contains some meta information of the dynamic library, such as the dynamic library name, the list of other dynamic libraries that the current dynamic library depends on, the address of the data and code of the dynamic library, the address of the symbol table, etc.

[0130] (6) Traverse the dynamic library linked list to find the address of the symbol to be relocated. Before the dynamic library is loaded into the process address space, the address of the dynamic library in the process address space cannot be confirmed, nor can the address of the symbol defined in the dynamic library in the process address space be confirmed. If other dynamic libraries depend on this dynamic library and reference the symbol defined by this dynamic library, the program will not be able to determine the address of the symbol and will not be able to complete the symbol reference. Therefore, after all dynamic libraries are loaded, it is necessary to obtain the virtual address of the symbol definition in the process address space and update it to the location where the symbol is referenced, i.e., relocation.

[0131] Each dynamic library can contain a relocation table, and each item in the relocation table represents a symbol to be relocated. The dynamic loader can traverse the relocation table to find the symbol to be relocated, and determine the virtual address of the symbol to be relocated in the process address space based on the address of the dynamic library mapped in the process address space, thereby completing the relocation.

[0132] (7) Complete relocation based on the virtual address of the symbol to be relocated.

[0133] (8) Execute the main function of the process to complete the startup of the process.

[0134] The advantages of dynamic library loading technology include:

[0135] (1) Save memory space: Dynamic libraries can be loaded only when needed. There is no need to link all library files into the program at once, which can save memory space.

[0136] (2) Flexibility: Dynamic libraries can be loaded dynamically at runtime, and the required library files can be loaded as needed, making the program more flexible.

[0137] (3) Maintainability: Dynamic libraries can be updated and maintained independently without recompiling the entire program.

[0138] (4) Reusability: Multiple programs can share the same dynamic library, improving code reusability.

[0139] In short, dynamic library loading technology is a very important technology that can make the program more flexible, save memory space, and improve the maintainability and reusability of the code.

[0140] However, in a multi-process scenario, when a new process is started, a separate and complete dynamic loading may be required, which involves a lot of redundant computing processing and greatly wastes computing resources.

[0141] An embodiment of the present application provides a dynamic loading method, based on which multiple processes can reuse the parsing results of a dynamic library, thereby saving computing resources, and helping to reduce the time required for dynamic loading and improve the startup performance of the program.

[0142] Combine the following Figure 3 and Figure 4 The following describes a method for dynamic loading provided in an embodiment of the present application.

[0143] Figure 3 It is a schematic diagram of a dynamically loaded system architecture provided in an embodiment of the present application. Figure 4 It is a schematic diagram of a dynamic loading method provided in an embodiment of the present application. Figure 4 The dynamic loading method shown can be applied to Figure 3 The system architecture is shown.

[0144] refer to Figure 3 The dynamic loading tool provided in the embodiment of the present application may include two parts, one is the preloading process, and the other is the dynamic loader. The preloading process mainly provides a list of files to be parsed for the user to configure which files need to be preloaded; it completes the startup before all user processes are started, and stores the parsing results of the files in the list of files to be parsed into shared data; when the user process is started, the shared data is shared with the user process. It mainly includes the following modules:

[0145] Parsing module: reads and parses the file to be parsed and the dynamic library that the file to be parsed depends on, and passes the parsing results to the data management module for storage.

[0146] Thread management module: creates and maintains multiple threads, and parses the files to be parsed in parallel based on the parsing module. Since shared data can only be increased but not decreased, and can only be read but not written, the thread management module can support parallel parsing of executable files and dynamic library files.

[0147] Storage management module: responsible for the abstract management, maintenance and update of storage hardware resources.

[0148] Data management module: provides a unified interface for accessing executable files and dynamic libraries, uses a unified data structure to organize shared data, and provides shared data management capabilities based on the storage management module.

[0149] Communication module: realizes data communication and interaction with the dynamic loader.

[0150] The dynamic loader is mainly responsible for mapping the dynamic library to the process address space and relocating the dynamic library symbols. It mainly includes the following modules:

[0151] Communication module: realizes data communication and interaction with the preloading process.

[0152] Multithreading management module: provides the ability to load dynamic library files in parallel and to perform parallel symbol resolution.

[0153] Data management module: provides data structure representation and access interface for shared data obtained from the preloading process.

[0154] File loading module: According to the shared data, obtain the dynamic library that the process depends on, eliminating the dependency resolution; according to the shared data, obtain the path of the dynamic library, eliminating the multi-path search for the dynamic library; according to the shared data, obtain the dynamic library file format information, including the mapping interval, eliminating the parsing of the file format.

[0155] Symbol resolution module: implements symbol lookup and relocation based on shared data.

[0156] refer to Figure 4 , the steps performed on the preloading process side include:

[0157] S401, the kernel starts the preloading process.

[0158] Before any user process is started, the system kernel starts the preloading process.

[0159] S402, open up a shared memory, and initialize a global dynamic library list and a global symbol table on the shared memory.

[0160] Shared memory is used to store shared data, that is, data obtained by the preload process from parsing the target file. Shared data can be stored in the form of a global target file list and a global symbol table. Each item in the global target file list can store the parsing result of a target file (executable file, dynamic library file); each item in the global symbol table can store a symbol and its related information.

[0161] S403: Parse the files to be parsed in the list of files to be parsed.

[0162] Specifically, the preloading process reads the list of files to be parsed, creates a parsing task for the files to be parsed on the list of files to be parsed, and adds the parsing task to the thread task queue. The idle thread obtains the parsing task from the thread task queue, obtains the files to be parsed through the parsing module interface, and parses the files to be parsed. If the files to be parsed also depend on other dynamic library files, parsing tasks must also be created for these dynamic library files and added to the thread task queue.

[0163] In some embodiments, multiple threads can parse these dynamic library files in parallel. For example, the first thread parses dynamic library 1, and the second thread parses dynamic library 2. The first thread and the second thread are two different threads in the process.

[0164] The list of files to be parsed can be configured by the user, that is, the user can select which files to be parsed need to be preloaded, or the list of files to be parsed can also be configured with some default files that need to be parsed. Each element in the list of files to be parsed can represent the name and / or path of a file to be parsed. The preloading process can find the file to be parsed on the disk according to the name and / or path of the file to be parsed.

[0165] The files to be parsed may include executable files and dynamic library files. Take the case where the files to be parsed are executable files as an example. The preloading process requires the executable files to be parsed. Specifically, the following steps may be included:

[0166] (1) Obtain the dynamic libraries that the executable file depends on. The dynamic libraries that the executable file depends on here should include the dynamic libraries that the executable file directly depends on and the dynamic libraries that the executable file indirectly depends on, that is, all the dynamic libraries that the executable file depends on when running.

[0167] (2) According to the name of the dynamic library, the dynamic library that the executable file depends on is searched in some specified paths or default paths on the disk. For example, the dynamic library is searched in multiple paths such as LD_LIBRARY_PATH, / lib, / usr / lib, and system directories.

[0168] (3) Parse the found dynamic library to obtain the path, mapping interval, dependency information, symbol information and other information of the dynamic library. Among them, the path of the dynamic library can indicate the location of the dynamic library file on the disk, so that the dynamic loader can find the dynamic library. The mapping interval indicates the content that the dynamic library needs to load into the memory, so that the dynamic loader can load the dynamic library into the memory. The dependency information indicates which dynamic libraries the dynamic library depends on (including directly dependent dynamic libraries and indirectly dependent dynamic libraries). The symbol information can include, for example, the name, type, size and other basic information of the symbols (such as functions, variables, etc.) defined in the dynamic library, as well as the name of the dynamic library where the symbol is located and the index of the symbol table where the symbol is located.

[0169] It should be noted that the dynamic library where the symbol is located refers to the dynamic library where the symbol is located and defined. The symbol table where the symbol is located refers to the symbol table of the dynamic library where the symbol is located. The index of the symbol table where the symbol is located can indicate the position of the symbol in the symbol table or the position of the symbol in the dynamic library where the symbol is located.

[0170] For ease of explanation, the embodiments of the present application may refer to the parsing of the path, mapping interval, and dependency information of a dynamic library (or executable file) as format parsing, and refer to the parsing of the symbol information of a dynamic library (or executable file) as symbol parsing.

[0171] It should be understood that format parsing and symbol parsing can be performed simultaneously or separately, and the embodiments of the present application do not limit this. The path, mapping interval, dependency information, etc. of the dynamic library (or executable file) can be called the format parsing result, and the symbol information of the dynamic library can be called the symbol parsing result.

[0172] In some embodiments, all the dynamic libraries that the executable file depends on may be obtained first, and then these dynamic libraries may be uniformly parsed. Alternatively, the dynamic libraries that a part of the executable file depends on may be obtained first, and after the parsing of the dynamic libraries that the part of the executable file depends on is completed, the dynamic libraries that another part of the executable file depends on may be obtained and parsed, until the parsing of the dynamic libraries that all the executable files depend on is completed.

[0173] If the file to be parsed is a dynamic library file, the preloading process also needs to parse the dynamic library file to obtain the path, mapping interval, dependency information, symbol information, etc. of the dynamic library file. For other dynamic libraries that the dynamic library depends on, these dynamic libraries can be parsed with reference to the steps described above, which will not be repeated here.

[0174] It should be noted that an executable file can also be understood as a dynamic library file. When parsing an executable file, the name, path, dependency information, symbol information and other information of the executable file can also be obtained.

[0175] It should be understood that parsing the file to be parsed includes parsing the file to be parsed and parsing the dynamic library that the file to be parsed depends on.

[0176] In an embodiment of the present application, the parsing results can be divided into two parts for storage. One part of the parsing results is stored in the form of a global target file list, that is, the format parsing results are stored in the form of a global target file list; the other part of the parsing results is stored in the form of a global symbol table, that is, the symbol information (symbol parsing results) is stored in the form of a global symbol table.

[0177] Exemplarily, each item in the global target file list may represent a format parsing result of a target file, such as the path, mapping interval, dependency information, etc. of the target file. For example, the global target file list may include the names of one or more target files and one or more format parsing results, and the names of the one or more target files correspond to the one or more format parsing results. That is, in the global target file list, the format parsing result of the target file can be found according to the name of the target file.

[0178] Exemplarily, the global target file list may be a structure as shown in Table 1. It should be understood that Table 1 is not filled with values ​​corresponding to executable file 1, dynamic library 2, dynamic library 3, dynamic library 4, and dynamic library 5. In the actual parsing process, Table 1 may be filled with values ​​corresponding to executable file 1, dynamic library 2, dynamic library 3, dynamic library 4, and dynamic library 5, respectively.

[0179] Table 1 Structure of a global target file list

[0180] Target file name path Mapping interval Reliance on Information Executable file 1 Dynamic library 2 Dynamic library 3 Dynamic Library 4 Dynamic Library 5

[0181] It should be understood that the global target file list may also be other types of data structures, which is not limited in the embodiments of the present application. The above examples of the global target file list should not constitute any limitation on the embodiments of the present application.

[0182] In some embodiments, when a request message for obtaining a format parsing result is received, the corresponding format parsing result can be found according to the file name (or file path) carried by the request message. Then, according to the dependency information of the file, the format parsing results of all dynamic libraries that the file depends on are obtained. For example, when a request message containing executable file 1 is received, the dependency information of executable file 1 is found in the global target file list. If executable file 1 depends on dynamic library 2 and dynamic library 3, dynamic library 2 and dynamic library 3 are found in the global target file list; if dynamic library 2 also depends on dynamic library 4, dynamic library 4 also needs to be found in the global target file list; finally, the format parsing results of dynamic library 2, dynamic library 3 and dynamic library 4 are packaged and sent to the requesting party.

[0183] It should be understood that in the above example, the dependency information of executable file 1 can record information such as the name or path of dynamic library 2, dynamic library 3, and dynamic library 4, or can also record the index of dynamic library 2, dynamic library 3, and dynamic library 4 in the global target file list, so that the format parsing results of the dynamic library that executable file 1 depends on can be quickly found.

[0184] The global symbol table can be used to store the symbol information of all resolved dynamic libraries. Each item in the global symbol table can represent a symbol and related information of the symbol, such as the name of the symbol, the name of the dynamic library to which the symbol belongs, the index of the symbol table where the symbol is located, and other information. In other words, in the global symbol table, the name of the dynamic library where the symbol is located and the index of the symbol table where the symbol is located can be found according to the name of the symbol.

[0185] It should be understood that the symbols in the global symbol table are information about symbols defined in the resolved dynamic library.

[0186] Exemplarily, the global symbol table may be a structure as shown in Table 2. It should be understood that Table 2 does not contain the numerical values ​​corresponding to symbol 1, symbol 2, and symbol 2. In the actual parsing process, Table 2 may be filled with the numerical values ​​corresponding to symbol 1, symbol 2, and symbol 2, respectively.

[0187] Table 1 Structure of a global symbol table

[0188] Symbolic Name The name of the target file The index of the symbol table. Symbol 1 Symbol 2 Symbol 3

[0189] In some embodiments, the index of the symbol table where the symbol is located may also be the position information of the symbol in the target file to which it belongs, or may also be the offset of the symbol in the target file to which it belongs.

[0190] It should be understood that the global symbol table may also be other types of data structures. For example, the global symbol table may also be a hash table or a linked list. The embodiments of the present application are not limited to this, and the above examples of the global symbol table should not constitute any limitation on the embodiments of the present application.

[0191] It should be noted that the name of the target file, the name of the executable file, the name of the dynamic library file, the name of the symbol, etc. in the embodiments of the present application can be an identifier or ID, which is used to uniquely identify the file or the symbol. The identifier or ID can, for example, be composed of a series of numbers or letters.

[0192] S404, creating a communication server for monitoring the connection and request of the communication client.

[0193] For each request message received, a request task is created and placed in the thread task queue. The idle thread can obtain the request task from the thread task queue and process the request task.

[0194] S405, receiving a request message sent by the dynamic loader, and determining the type of the request message.

[0195] In an embodiment of the present application, the request message may have two types, one is a target file list request, and the other is a global symbol table request. The target file list request or the global symbol table request can carry the name or path of the executable file loaded by the user process. Wherein, the target file list request is used to request the format parsing result of the executable file, and the global symbol table request is used to request to obtain the global symbol table.

[0196] For the convenience of explanation, the target file list request is referred to as the first request message, and the global symbol table request is referred to as the second request message.

[0197] S406: If the first request message is received, return the first target file list.

[0198] If the first request message is received, the format parsing result of the dynamic library that the executable file depends on is searched in the global target file list according to the name (or path) of the executable file loaded in the user process.

[0199] If the corresponding format parsing results are found, a first target file list is generated based on these format parsing results and returned to the dynamic loader. The first target file list is a target file list exclusive to the executable file. The structure of the first target file list is similar to that of the global target file list. Each item in the first target file list represents a format parsing result of a dynamic library that the executable file depends on. The first target file list does not include the format parsing results of the dynamic library that the executable file does not depend on.

[0200] Exemplarily, when a first request message containing executable file 1 is received, dependency information of executable file 1 is found in the global target file list; if executable file 1 depends on dynamic library 2 and dynamic library 3, dynamic library 2 and dynamic library 3 are found in the global target file list; if dynamic library 2 also depends on dynamic library 4, dynamic library 4 also needs to be found in the global target file list; finally, the format parsing results of dynamic library 2, dynamic library 3 and dynamic library 4 are packaged in the first target file list and sent to the dynamic loader or user process.

[0201] It should be understood that in the above example, the dependency information of executable file 1 can record information such as the name or path of dynamic library 2, dynamic library 3, and dynamic library 4, or can also record the index of dynamic library 2, dynamic library 3, and dynamic library 4 in the global target file list, so that the format parsing results of the dynamic library that executable file 1 depends on can be quickly found.

[0202] It should be noted that different executable files have different exclusive target file lists. Exemplarily, the preloading process may receive multiple first request messages, for example, one first request message carries the path of executable file 1, and another first request message carries the path of executable file 2. The exclusive target file list of executable file 1 includes the format parsing result of the dynamic library that executable file 1 depends on, and the exclusive target file list of executable file 2 includes the format parsing result of the dynamic library that executable file 2 depends on.

[0203] If the format parsing result of the dynamic library that the executable file depends on does not exist, a format parsing task is created for the executable file and added to the thread task queue. The idle thread obtains the format parsing task, performs format parsing on the executable file, thereby obtaining the format parsing result of the executable file and the format parsing result of the dynamic library that the executable file depends on, and returns these format parsing results to the dynamic loader.

[0204] In some embodiments, after the executable file format is parsed, the format parsing result of the executable file and the format parsing result of the dynamic library that the executable file depends on are saved, and these format parsing results are saved in the global target file list.

[0205] In some embodiments, format parsing tasks are created for the executable file and the dynamic library files that the executable file depends on, and added to the thread task queue. Multiple idle threads can obtain format parsing tasks respectively, and perform format parsing on the executable file and the dynamic library files that the executable file depends on in parallel.

[0206] It should be understood that the multiple idle threads are multiple different threads in the process address space.

[0207] S407: If the second request message is received, return the global symbol table.

[0208] If the second request message is received, then according to the name (or path) of the executable file loaded in the user process, it is determined whether the executable file has been subjected to symbol resolution. If the executable file has been subjected to symbol resolution, the global symbol table is returned to the dynamic loader.

[0209] Optionally, if the second request message is received, the handle, address or pointer information of the global symbol table is returned. The dynamic loader can access or read the global symbol table according to the handle, address or pointer information of the global symbol table.

[0210] If the executable file has not been symbolically resolved, a symbol resolution task is created for the executable file and added to the thread task queue. The idle thread obtains the symbol resolution task, performs symbol resolution on the executable file, obtains the symbol information of the executable file and the dynamic library that the executable file depends on, and saves the symbol information to the global symbol table, and then returns the global symbol table to the dynamic loader.

[0211] In some embodiments, symbol resolution tasks are created for the executable file and the dynamic library files that the executable file depends on, and added to the thread task queue. Multiple idle threads can obtain symbol resolution tasks respectively, and perform symbol resolution on the executable file and the dynamic library files that the executable file depends on in parallel.

[0212] In some embodiments, the preloading process may maintain a parsed file list for storing the names or paths of executable files (or dynamic library files) that have been parsed. Thus, when a request message is received, it may be determined whether the executable file (or dynamic library file) has been parsed based on the parsed file list, the name or path of the executable file (or dynamic library file).

[0213] In some embodiments, since the global target file list records information of all resolved files, the global target file list can be used as the resolved file list.

[0214] refer to Figure 3 and Figure 4 , the steps performed on the dynamic loader side may include:

[0215] S408, the kernel starts the user process.

[0216] Specifically, the process address space and stack are initialized, and the code of the executable file and other information are loaded, and the dynamic loader completes the dynamic loading.

[0217] S409, create a communication client and establish a connection with the communication server.

[0218] It should be understood that the communication server and the communication client are a means of inter-process communication. In addition, other methods can also be used to achieve inter-process communication, which is not limited in the embodiments of the present application.

[0219] S410, sending a first request message and / or a second request message, and correspondingly receiving a first target file list and / or a global symbol table.

[0220] The first request message or the second request message may include the name or path of the executable file loaded by the user process. The first request message is used to request to obtain the format parsing result of the executable file, and the first request message is used to request to obtain the global symbol table.

[0221] It should be noted that the first target file list is a target file list exclusive to the executable file. The structure of the first target file list is similar to that of the global target file list, and each item in the first target file list represents the format parsing result of a dynamic library that the executable file depends on. The first target file list does not include the format parsing result of the dynamic library that the executable file does not depend on.

[0222] It should be noted that, usually, the dynamic loader may send a first request message first, and then send a second request message after all dynamic libraries that the executable file depends on are mapped into the process address space.

[0223] S411, traverse the first target file list, and map the dynamic library that the executable file depends on to the process address space.

[0224] Specifically, a loading task is created for each dynamic library in the first target file list, and the loading task is added to the thread task queue. The idle thread executes the loading task, and maps the dynamic library to the process address space according to the format parsing result corresponding to the dynamic library. For example, the dynamic library file is first searched according to the path of the dynamic library, and then the content to be loaded is mapped to the process address space according to the mapping interval of the dynamic library.

[0225] In some embodiments, multiple idle processes can respectively perform loading tasks and simultaneously map multiple dynamic libraries to the process address space, thereby reducing the loading time of the dynamic libraries.

[0226] S412, after mapping the dynamic library that the executable file depends on to the process address space, relocation is performed.

[0227] Specifically, a relocation task is created for each dynamic library in the first target file list, and the relocation task is added to the thread task queue. The idle thread executes the relocation task, obtains the relocation table of the dynamic library, traverses the relocation table, and obtains the symbol to be relocated. Then, the name of the dynamic library where the symbol to be relocated is located and the index of the symbol table where the symbol to be relocated is located are searched in the global symbol table. Then, according to the index of the symbol table where the symbol to be relocated is located, the symbol to be relocated is found in the symbol table where the symbol to be relocated is located, thereby obtaining the address of the symbol to be relocated in the process address space to complete the relocation.

[0228] In some embodiments, multiple idle processes can respectively execute relocation tasks and simultaneously relocate symbols to be relocated of multiple dynamic libraries.

[0229] It should be noted that, during the relocation process, the address of the symbol to be relocated in the process address space can usually be updated to the position that references the relocation symbol.

[0230] It should be noted that the relocation table of a dynamic library records all symbols of the dynamic library that need to be relocated; the symbol table of a dynamic library records information such as the symbols defined in the dynamic library, the names of the symbols, the types of the symbols, and the locations of the symbols in the dynamic library.

[0231] In some embodiments, the symbol to be relocated is found in the symbol table where the symbol to be relocated is located, and the relative position of the symbol to be relocated in the dynamic library to which it belongs can be obtained. Combined with the address of the dynamic library to which the symbol belongs in the process address space, the address of the symbol in the process address space can be determined.

[0232] Optionally, if multiple duplicate dynamic libraries are found in the global symbol table according to the name of the symbol to be relocated, the process returns to the traditional process to search for the symbol to be relocated to complete the relocation.

[0233] S413, execute the main function of the user process to complete the startup of the user process.

[0234] Figure 5 is a schematic flow chart of a dynamic loading method provided in an embodiment of the present application. Figure 5 As shown, the method includes:

[0235] S510: The user process requests to load a specified dynamic library.

[0236] During the startup of a user process, the user process may request to load a specified dynamic library. For example, the user process may use the dlopen function to load a dynamic library with a specified file name or a specified file path.

[0237] S520: The dynamic loader sends a third request message to the preloading process.

[0238] The third request message may carry the name or path of a specified dynamic library, and is used to request to obtain the format parsing result or the global symbol table of the specified dynamic library.

[0239] S530: The preloading process searches for a corresponding format parsing result according to the name of the specified dynamic library.

[0240] According to the name or path of the specified dynamic library, search the global target file list for the format parsing results of the specified dynamic library and the dynamic libraries that the specified dynamic library depends on.

[0241] Optionally, if the corresponding format parsing result is not found, a loading task and a symbol parsing task for the specified dynamic library are created to obtain the format parsing results and symbol information of the specified dynamic library and the dynamic libraries on which the specified dynamic library depends, and the format parsing results of the specified dynamic library are stored in the global target file list, and the symbol information of the specified dynamic library is stored in the global symbol table.

[0242] In some embodiments, the third request message may be included in the first request message, that is, the first request message may carry the name (or path) of the executable file loaded by the user process and the name (or path) of the specified dynamic library. The preloading process finds all format parsing results related to the executable file and the specified dynamic library in the global target file list according to the name (or path) of the executable file and the name (or path) of the specified dynamic library, and packages them and sends them to the dynamic loader.

[0243] In some embodiments, after symbol resolution is performed on the specified dynamic library and the dynamic libraries on which the specified dynamic library depends, the updated global symbol table is returned to the dynamic loader.

[0244] Optionally, the dynamic loader sends a second request message to the preloading process to request a global symbol table.

[0245] S540: The dynamic loader maps the specified dynamic library and the dynamic libraries that the specified dynamic library depends on to the process address space according to the format parsing result of the specified dynamic library and the dynamic libraries that the specified dynamic library depends on.

[0246] Optionally, based on the global symbol table and the relocation table of the specified dynamic library, the relocation of the to-be-relocated symbol of the specified dynamic library is completed.

[0247] Figure 6 is a schematic flow chart of a dynamic loading method provided in an embodiment of the present application. Figure 6 As shown, the method includes:

[0248] S610: parse one or more target files and save one or more first parsing results.

[0249] It should be understood that the one or more target files may include a first target file, and the first target file may be an executable file or a dynamic library file.

[0250] It should be understood that there may or may not be a dependency relationship between one or more target files, and the embodiments of the present application are not limited to this.

[0251] In an embodiment of the present application, one or more first parsing results correspond to one or more target files. The first parsing result of the first target file (for example, the first dynamic library file) may include the name, path, mapping interval and dependency information of the first target file. Among them, the path of the first target file may indicate the location where the first target file is stored on the disk; the dependency information of the first target file may indicate the dynamic library files that the first target file depends on, including the dynamic library files that the first target file directly depends on and the dynamic library files that it indirectly depends on; the mapping interval of the first target file may indicate the file range that the first target file needs to map to the process address space, that is, the content that the first target file needs to load.

[0252] Optionally, the first target file is a file in a list of files to be parsed, and the files in the list of files to be parsed are files that need to be parsed before the first executable file is loaded into the process address space where the first executable file is located. In other words, the files in the list of files to be parsed are files that need to be pre-parsed.

[0253] It should be noted that the first executable file may be, for example, an executable file of a program loaded in a user process, and the process address space is a memory space allocated by the system to the user process.

[0254] It should be noted that the files in the to-be-parsed file list may be files configured by the user, or may be default files that need to be pre-parsed.

[0255] It should be noted that one or more target files may be files in the list of files to be parsed, or may not be files in the list of files to be parsed. For example, when the second executable file is started, the dynamic loader may need to parse the second executable file and the dynamic library file that the second executable file depends on. At this time, the first parsing result of the second executable file and the first parsing result of the dynamic library file that the second executable file depends on can be saved, so that other executable files can find the first parsing result of the dynamic library file they need when loading.

[0256] It should be noted that the first analysis result may be, for example, Figure 4 In the illustrated embodiment, one or more first parsing results may be formatted as follows: Figure 4 The global target file list in the illustrated embodiment is saved.

[0257] Optionally, the one or more target files are parsed in parallel using multiple threads, and one or more first parsing results are saved.

[0258] S620: Search, from among the one or more first parsing results, a first parsing result of a dynamic library file that the first executable file depends on.

[0259] Optionally, in one or more first parsing results, the parsing results of the second dynamic library file and the dynamic library file on which the second dynamic library file depends are searched, the second dynamic library file being the designated dynamic library file requested to be loaded by the process where the first executable file is located; based on the parsing results of the second dynamic library file and the dynamic library file on which the second dynamic library file depends, the second dynamic library file and the dynamic library file on which the second dynamic library file depends are mapped to the process address space.

[0260] Optionally, if the first parsing result of the dynamic library file that the first executable file depends on does not exist, the first executable file is parsed, and the first parsing result of the first executable file and the first parsing result of the dynamic library file that the first executable file depends on are saved; and / or, if the parsing result of the second dynamic library file does not exist, the second dynamic library file is parsed, and the first parsing result of the second dynamic library file and the first parsing result of the dynamic library file that the second dynamic library file depends on are saved.

[0261] S630: Map the dynamic library file that the first executable file depends on to the process address space where the first executable file is located according to a first parsing result of the dynamic library file that the first executable file depends on.

[0262] Optionally, the one or more target files may include a first dynamic library file, and the first executable file depends on the first dynamic library file. The first dynamic library file is obtained according to the path of the first dynamic library file; and the first dynamic library file is mapped to the process address space according to the mapping interval of the first dynamic library file.

[0263] Optionally, the dynamic library files that the first executable file depends on include a third dynamic library file and a fourth dynamic library file, wherein the first thread maps the third dynamic library file to the process address space where the first executable file is located according to the first parsing result of the third dynamic library file; the second thread maps the fourth dynamic library file to the process address space according to the first parsing result of the fourth dynamic library file, and the first thread and the second thread are different.

[0264] Optionally, one or more target files are parsed and information of one or more symbols is saved, where the one or more symbols are symbols defined in the one or more target files, and the one or more symbols include a first symbol, and the information of the first symbol includes the name of the target file to which the first symbol belongs and the position information of the first symbol in the target file to which the first symbol belongs.

[0265] Optionally, after mapping the dynamic library file that the first executable file depends on to the process address space where the first executable file is located, information of the second symbol is searched in information of one or more symbols, and the information of the second symbol is used to relocate the second symbol.

[0266] Optionally, based on the information of the second symbol, an address of the second symbol in the process address space is obtained; and based on the address of the second symbol in the process address space, the second symbol is relocated.

[0267] Optionally, when the first executable file and the dynamic library file that the first executable file depends on are not in the resolved file list, the first executable file and the dynamic library file that the first executable file depends on are parsed, and information about symbols defined in the first executable file and the dynamic library file that the first executable file depends on is saved. The resolved file list is used to store the names of the resolved executable files or dynamic library files.

[0268] Optionally, use multiple threads to parse one or more object files in parallel and save information about one or more symbols.

[0269] In an embodiment of the present application, when parsing a target file, a first parsing result of the target file can be saved. These first parsing results will be used in the loading process of the dynamic library, thereby realizing the decoupling of the parsing process and the loading process of the target file, which is conducive to optimizing the application startup speed and improving the user experience. On the other hand, the first parsing result of a target file can be used in the loading process of multiple different executable files, thereby realizing the sharing of the one or more first parsing results, which is conducive to saving computing resources and saving memory space.

[0270] Figure 7 is a schematic flow chart of a dynamic loading method provided in an embodiment of the present application. Figure 7 As shown, the method includes:

[0271] S710, parsing one or more target files and saving information of one or more symbols.

[0272] It should be understood that the one or more target files may include a first target file, and the first target file may be an executable file or a dynamic library file.

[0273] It should be understood that there may or may not be a dependency relationship between one or more target files, and the embodiments of the present application are not limited to this.

[0274] In an embodiment of the present application, one or more symbols are symbols defined in one or more target files, including all symbols defined in each target file.

[0275] It should be noted that the first executable file may be, for example, an executable file of a program loaded in a user process, and the process address space is a memory space allocated by the system to the user process.

[0276] It should be noted that the information of each symbol can be, for example, Figure 4 In the symbol parsing result of the embodiment shown, the information of one or more symbols can be, for example, Figure 4 The global symbol table in the illustrated embodiment is saved in the form of a global symbol table.

[0277] Optionally, the first target file is a file in a list of files to be parsed, and the files in the list of files to be parsed are files that need to be parsed before the first executable file is loaded into the process address space where the first executable file is located. In other words, the files in the list of files to be parsed are files that need to be pre-parsed.

[0278] It should be noted that the files in the to-be-parsed file list may be files configured by the user, or may be default files that need to be pre-parsed.

[0279] It should be noted that the one or more target files may be files in the list of files to be parsed, or may not be files in the list of files to be parsed.

[0280] Optionally, use multiple threads to parse one or more object files in parallel and save information about one or more symbols.

[0281] S720, searching for information of a second symbol in the information of the one or more symbols, where the information of the second symbol is used to relocate the second symbol.

[0282] It should be noted that the second symbol is a symbol in the relocation table of the dynamic library file that the first executable file depends on. The relocation table records the symbols that need to be relocated in the dynamic library file that the first executable file depends on.

[0283] Optionally, based on the information of the second symbol, an address of the second symbol in the process address space where the first executable file is located is obtained; and based on the address of the second symbol in the process address space, the second symbol is relocated.

[0284] Optionally, when the first executable file or the dynamic library file that the first executable file depends on is not in the resolved file list, the first executable file and the dynamic library file that the first executable file depends on are parsed, and information about symbols defined in the first executable file and the dynamic library file that the first executable file depends on is saved. The resolved file list is used to store the names of the resolved executable files or dynamic library files.

[0285] In some embodiments, since the global target file list records information of all resolved files, the global target file list can be used as the resolved file list.

[0286] In an embodiment of the present application, when the target file is parsed, the information of the symbol defined in the target file can be saved. In an embodiment of the present application, when the target file is parsed, the information of the symbol defined in the target file can be saved. When the symbol to be relocated is relocated, the position of the symbol to be relocated in the process address space can be quickly found, thereby accelerating the relocation process, helping to optimize the application startup speed, and helping to enhance the user experience. On the other hand, the information of one or more symbols can be used in the relocation process of multiple different executable files, thereby realizing the sharing of the information of the one or more symbols, helping to save computing resources, and helping to save memory space.

[0287] Figure 8 It is a schematic diagram of the hardware structure of the device 800 provided in an embodiment of the present application. Figure 8 The device 800 shown (the device 800 may be an electronic device) includes a memory 810, a processor 820, a communication interface 830 and a bus 840. The memory 810, the processor 820 and the communication interface 830 are connected to each other through the bus 840.

[0288] The memory 810 may be a ROM, a static storage device, a dynamic storage device or a RAM. The memory 810 may store a program. When the program stored in the memory 810 is executed by the processor 820, the processor 820 is used to execute each step of the dynamic loading method of the embodiment of the present application.

[0289] The processor 820 can adopt a general-purpose CPU, microprocessor, ASIC, GPU or one or more integrated circuits to execute relevant programs to implement the functions required to be performed by the units in the device 800 of the embodiment of the present application, or to execute the dynamic loading method of the method embodiment of the present application.

[0290] The processor 820 may also be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the dynamic loading method of the present application may be completed by an integrated logic circuit of hardware or software instructions in the processor 820. The above-mentioned processor 820 may also be a general-purpose processor, DSP, ASIC, FPGA or other programmable logic device, discrete gate or transistor logic device, discrete hardware component. The methods, steps and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed by a hardware decoding processor, or may be executed by a combination of hardware and software modules in a decoding processor. The software module may be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 810, and the processor 820 reads the information in the memory 810, and completes the functions required to be performed by the units included in the device 800 of the embodiment of the present application in combination with its hardware, or executes the dynamic loading method of the method embodiment of the present application.

[0291] The communication interface 830 uses a transceiver device such as, but not limited to, a transceiver to implement communication between the apparatus 800 and other devices or a communication network.

[0292] The bus 840 may include a path for transmitting information between the various components of the device 800 (eg, the memory 810 , the processor 820 , and the communication interface 830 ).

[0293] It should be noted that although Figure 8 The device 800 shown only shows a memory, a processor, and a communication interface, but in the specific implementation process, those skilled in the art should understand that the device 800 also includes other devices necessary for normal operation. At the same time, according to specific needs, those skilled in the art should understand that the device 800 may also include hardware devices for implementing other additional functions. In addition, those skilled in the art should understand that the device 800 may also only include the devices necessary to implement the embodiments of the present application, and does not necessarily include Figure 8 All devices shown in .

[0294] An embodiment of the present application also provides a chip, which includes a processor and a communication interface, wherein the communication interface is used to receive a signal and transmit the signal to the processor, and the processor processes the signal so that the dynamic loading method described in any possible implementation method in the foregoing text is executed.

[0295] This embodiment further provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions are run on a computer, the dynamic loading method in the above embodiment is executed.

[0296] This embodiment also provides a computer program product. When the computer program product runs on a computer, it enables the computer to execute the above-mentioned related steps, so that the dynamic loading method in the above embodiment is executed.

[0297] The above embodiments may be used alone or in combination with each other to achieve different technical effects.

[0298] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0299] In this embodiment, the electronic device can be divided into functional modules according to the above method example. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is schematic and is only a logical function division. There may be other division methods in actual implementation.

[0300] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0301] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0302] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0303] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0304] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage media include: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), magnetic disks or optical disks.

[0305] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A method for dynamic loading, characterized in that: include: Parsing one or more target files and saving one or more first parsing results, wherein the one or more first parsing results correspond to the one or more target files one by one, the one or more target files include a first target file, and the first target file is an executable file or a dynamic library file; Searching the one or more first parsing results for a first parsing result of a dynamic library file that the first executable file depends on; According to a first parsing result of the dynamic library file that the first executable file depends on, the dynamic library file that the first executable file depends on is mapped to a process address space where the first executable file is located.

2. The method according to claim 1, characterized in that The one or more target files include a first dynamic library file, and the first parsing result includes a path, a mapping interval, and dependency information of the first dynamic library file.

3. The method according to claim 2, characterized in that The dynamic library file that the first executable file depends on includes the first dynamic library file, The mapping of the dynamic library file that the first executable file depends on to the process address space where the first executable file is located according to the first parsing result of the dynamic library file that the first executable file depends on includes: According to the path of the first dynamic library file, obtaining the first dynamic library file; Map the first dynamic library file to the process address space according to the mapping interval of the first dynamic library file.

4. The method according to any one of claims 1 to 3, characterized in that The first target file is a file in a list of files to be parsed, and the files in the list of files to be parsed are files that need to be parsed before the first executable file is loaded into the process address space.

5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: Searching for a first parsing result of a second dynamic library file and a dynamic library file on which the second dynamic library file depends from among the one or more first parsing results, wherein the second dynamic library file is a designated dynamic library file requested to be loaded by the process where the first executable file is located; According to the first parsing result of the second dynamic library file and the dynamic library file on which the second dynamic library file depends, the second dynamic library file and the dynamic library file on which the second dynamic library file depends are mapped to the process address space.

6. The method according to claim 5, characterized in that The method further comprises: If the first parsing result of the dynamic library file that the first executable file depends on is not found, the first executable file is parsed, and the first parsing result of the first executable file and the first parsing result of the dynamic library file that the first executable file depends on are saved; and / or, If the first parsing result of the second dynamic library file is not found, the second dynamic library file is parsed, and the first parsing result of the second dynamic library file and the first parsing result of the dynamic library file on which the second dynamic library file depends are saved.

7. The method according to any one of claims 1 to 6, characterized in that The step of parsing one or more target files and saving one or more first parsing results includes: The one or more target files are parsed in parallel using multiple threads, and the one or more first parsing results are saved.

8. The method according to claim 1, characterized in that The dynamic library files that the first executable file depends on include a third dynamic library file and a fourth dynamic library file, The mapping of the dynamic library file that the first executable file depends on to the process address space where the first executable file is located according to the first parsing result of the dynamic library file that the first executable file depends on includes: The first thread maps the third dynamic library file to the process address space where the first executable file is located according to the first parsing result of the third dynamic library file; The second thread maps the fourth dynamic library file to the process address space according to the first parsing result of the fourth dynamic library file, and the first thread and the second thread are different.

9. The method according to any one of claims 1 to 8, characterized in that The method further comprises: The one or more target files are parsed and information of one or more symbols is saved, wherein the one or more symbols are symbols defined in the one or more target files, and the one or more symbols include a first symbol, and the information of the first symbol includes the name of the target file to which the first symbol belongs and the position information of the first symbol in the target file to which the first symbol belongs.

10. The method according to claim 9, characterized in that The dynamic library file that the first executable file depends on includes a fifth dynamic library file, and the relocation table of the fifth dynamic library file includes a second symbol. The method further includes: After mapping the dynamic library file that the first executable file depends on to the process address space where the first executable file is located, searching for information of the second symbol in the information of the one or more symbols, the information of the second symbol is used to relocate the second symbol.

11. The method according to claim 10, characterized in that The method further comprises: According to the information of the second symbol, acquiring the address of the second symbol in the process address space; Relocate the second symbol according to the address of the second symbol in the process address space.

12. The method according to any one of claims 9 to 11, characterized in that: The method further comprises: When the first executable file and the dynamic library file on which the first executable file depends are not in the resolved file list, the first executable file and the dynamic library file on which the first executable file depends are resolved, and information about symbols defined in the first executable file and the dynamic library file on which the first executable file depends is saved. The resolved file list is used to store the names of the resolved executable files or dynamic library files.

13. The method according to any one of claims 9 to 12, characterized in that: The parsing of the one or more target files and saving information of one or more symbols includes: The one or more object files are parsed in parallel using multiple threads, and information of the one or more symbols is saved.

14. A method for dynamic loading, characterized in that: include: Parsing one or more target files and saving information of one or more symbols, wherein the one or more symbols are symbols defined in the one or more target files, the one or more symbols include a first symbol, the information of the first symbol includes a name of the target file to which the first symbol belongs and position information of the first symbol in the target file to which the first symbol belongs, the one or more target files include the first target file, and the first target file is an executable file or a dynamic library file; The information of the second symbol is searched in the information of the one or more symbols, where the second symbol is a symbol in a relocation table of a dynamic library file that the first executable file depends on, and the information of the second symbol is used to relocate the second symbol.

15. The method according to claim 14, characterized in that The method further comprises: According to the information of the second symbol, acquiring the address of the second symbol in the process address space where the first executable file is located; Relocate the second symbol according to the address of the second symbol in the process address space.

16. The method according to claim 14 or 15, characterized in that The first target file is a file in a list of files to be parsed, and the files in the list of files to be parsed are files that need to be parsed before the first executable file is loaded into the process address space.

17. The method according to any one of claims 14 to 16, characterized in that: The method further comprises: When the first executable file or the dynamic library file on which the first executable file depends is not in the resolved file list, the first executable file and the dynamic library file on which the first executable file depends are parsed, and information about symbols defined in the first executable file and the dynamic library file on which the first executable file depends is saved. The resolved file list is used to store the names of the resolved executable files or dynamic library files.

18. The method according to any one of claims 14 to 17, characterized in that: The parsing of the one or more target files and saving information of one or more symbols includes: The one or more object files are parsed in parallel using multiple threads, and information of the one or more symbols is saved.

19. An electronic device, characterized in that: The method comprises one or more processors; one or more memories; the one or more memories store one or more computer programs, the one or more computer programs include instructions, and when the instructions are executed by the one or more processors, the method as claimed in any one of claims 1 to 13 is executed, or the method as claimed in any one of claims 14 to 18 is executed.

20. A chip, characterized in that: The chip includes a processor and a communication interface, wherein the communication interface is used to receive a signal and transmit the signal to the processor, and the processor processes the signal so that the method as described in any one of claims 1 to 13 is executed, or the method as described in any one of claims 14 to 18 is executed.

21. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed on a computer, the method according to any one of claims 1 to 13 is executed, or the method according to any one of claims 14 to 18 is executed.

22. A computer program product comprising instructions, characterized in that When the computer program product is executed on a computer, the computer is enabled to execute the method according to any one of claims 1 to 13, or execute the method according to any one of claims 14 to 18.

Citation Information

Cited By

  • Dynamic loading method and electronic device

    EP4715584A1

  • Dynamic loading method and electronic device

    WO2025001245A1