WO2021151350A1 - 一种动态链接库的加载方法及装置 - Google Patents

一种动态链接库的加载方法及装置 Download PDF

Info

Publication number
WO2021151350A1
WO2021151350A1 PCT/CN2020/132417 CN2020132417W WO2021151350A1 WO 2021151350 A1 WO2021151350 A1 WO 2021151350A1 CN 2020132417 W CN2020132417 W CN 2020132417W WO 2021151350 A1 WO2021151350 A1 WO 2021151350A1
Authority
WO
WIPO (PCT)
Prior art keywords
dynamic link
link library
library
integrated
libraries
Prior art date
Application number
PCT/CN2020/132417
Other languages
English (en)
French (fr)
Inventor
王涛
孙文涌
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP20916877.2A priority Critical patent/EP4086761A4/en
Priority to US17/796,454 priority patent/US11886222B1/en
Publication of WO2021151350A1 publication Critical patent/WO2021151350A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading

Definitions

  • This application relates to the field of computer technology, in particular to a method and device for loading a dynamic link library.
  • each dynamic link library includes code segment, data segment and BSS segment. Each segment is aligned with 4KB as an example. If each segment wastes 2KB of memory space on average, 200 dynamic link libraries will waste 1200KB of running. Memory space.
  • the application program runs according to a certain dynamic link library, for the dynamic link library, it needs to be relocated, symbolized and bound before the dynamic link library can be used.
  • the dynamic link library may also depend on other dynamic link libraries. Therefore, the application program not only needs to relocate the dynamic link library, but also needs to relocate other dynamic link libraries that the dynamic link library depends on in order to realize normal operation, which is likely to cause a large time overhead.
  • the present application provides a method and device for loading a dynamic link library, which help reduce the waste of running memory space and save the time and overhead of application program running.
  • the embodiment of the present application provides a method for loading a dynamic link library, which is applied to an electronic device, which specifically includes: in response to a request of an application program to load the first dynamic link library, determining whether the identifier of the first dynamic link library is in In the loaded dynamic link library list; when the identification of the first dynamic link library is not in the loaded dynamic link library list, perform steps A to C, and step A to allocate a handle for the first dynamic link library, and link the first dynamic link library The identifier of the library and the handle allocated for the first dynamic link library are added to the list of loaded dynamic libraries; step B, it is judged whether the first dynamic link library is an integrated dynamic link library; when the first dynamic link library is an integrated dynamic link library , Perform step 1 and step 2, and perform step C after performing step 2.
  • the electronic device can respond to the application's request to load the first dynamic link library, it is determined that when the identifier of the first dynamic link library is not in the loaded dynamic link library list, it can not only allocate a handle to the first dynamic link library , And add the identification of the first dynamic link library and the assigned handle to the list of loaded dynamic link libraries. It can also determine whether the first dynamic link library is an integrated dynamic link library. The source code of the integrated dynamic link library is compiled, which helps to reduce the waste of running memory space.
  • the electronic device when the first dynamic link library is an integrated dynamic link library, the electronic device will also add the identification of the integrated dynamic link library and the handle allocated for the first dynamic link library to the loaded dynamic link library, which helps to avoid The repeated loading of electronic devices also helps to reduce the number of times the application program relocates the dynamic link library, thereby reducing time overhead.
  • the first dynamic link library when the first dynamic link library is an integrated dynamic link library, the first dynamic link library includes a virtual library list segment and N binary segments, where the virtual library list segment includes M integrated dynamics
  • the identification of the link library, any one of the N binary segments includes the content of the corresponding binary segment in the M integrated dynamic link libraries; N is a positive integer greater than or equal to 1.
  • the first dynamic link library is one of the application program's dependent libraries; or, When the application program is running, it responds to a request of the application program to load the first dynamic link library. This helps simplify the implementation.
  • the first dynamic link library can be obtained by compiling the source code of M integrated dynamic link libraries based on the following methods:
  • the first dynamic link library is obtained by integrating M static link libraries; each static link library in the M static link libraries is obtained by compiling a corresponding source code among the source codes of the M integrated dynamic link libraries. So as to facilitate the realization.
  • step D in response to the application's request to load the first dynamic link library, after judging whether the identification of the first dynamic link library is in the list of loaded dynamic link libraries, when the identification of the first dynamic link library is in When the dynamic link library list has been loaded, step D is executed, and step C is executed after step D is executed.
  • Step D Obtain the handle of the first dynamic link library according to the identifier of the first dynamic link library in the list of loaded dynamic link libraries.
  • step B after performing step B to determine whether the first dynamic link library is an integrated dynamic link library, when the first dynamic link library is not an integrated dynamic link library, perform step 3, and after performing step 3 , Go to step C.
  • Step 3 Relocate the first dynamic link library according to the handle allocated for the first dynamic link library, and load the first dynamic link library into the running memory of the electronic device.
  • the electronic device can determine whether the first dynamic link library is an integrated dynamic link library based on the following methods:
  • the first dynamic link library determines whether the first dynamic link library includes a virtual library list section; wherein, when the first dynamic link library includes a virtual list section, the first dynamic link library is an integrated dynamic link library; or, determine whether the identification of the first dynamic link library is A predefined identifier, where, when the identifier of the first dynamic link library is a predefined identifier, the first dynamic link library is an integrated dynamic link library.
  • an embodiment of the present application provides a device that includes a link request module and a link loading module; wherein the link request module is configured to receive a request for an application program to load a first dynamic link library;
  • the link load module is used to:
  • steps A to C are executed.
  • Step A Allocate a handle for the first dynamic link library, and add the identifier of the first dynamic link library and the handle allocated for the first dynamic link library to the list of loaded dynamic libraries;
  • Step B judging whether the first dynamic link library is an integrated dynamic link library
  • step 1 and step 2 are executed, and after step 2 is executed, step C is executed.
  • Step 1 Add the identifier of the integrated dynamic link library and the handle allocated for the first dynamic link library to the list of loaded dynamic link libraries.
  • the first dynamic link library is the compiler to M integrated dynamic link libraries Compiled from the source code;
  • Step 2 Relocate the first dynamic link library according to the handle allocated for the first dynamic link library, and load the first dynamic link library into the running memory of the electronic device;
  • Step C Return the handle allocated for the first dynamic link library to the application.
  • the first dynamic link library includes a virtual library list segment and N binary segments, where the virtual library list segment includes the identifiers of M integrated dynamic link libraries, and any one of the N binary segments is binary.
  • the segment includes the content of the corresponding binary segment in the M integrated dynamic link libraries; N is a positive integer greater than or equal to 1.
  • the first dynamic link library is one of the application's dependent libraries; or, the application is running In response to the application's request to load the first dynamic link library.
  • the first dynamic link library can be obtained by compiling the source code of M integrated dynamic link libraries based on the following methods:
  • the first dynamic link library is obtained by integrating M static link libraries; each static link library in the M static link libraries is obtained by compiling a corresponding source code among the source codes of the M integrated dynamic link libraries. So as to facilitate the realization.
  • the link loading module determines whether the identification of the first dynamic link library is in the list of loaded dynamic link libraries, it is also used when the identification of the first dynamic link library is in the loaded dynamic link library.
  • the link loading module determines whether the identification of the first dynamic link library is in the list of loaded dynamic link libraries.
  • Step D Obtain the handle of the first dynamic link library according to the identifier of the first dynamic link library in the list of loaded dynamic link libraries.
  • the link loading module is also used for: when the first dynamic link library is not an integrated dynamic link library, execute Step 3, and after performing step 3, perform step C.
  • Step 3 Relocate the first dynamic link library according to the handle allocated for the first dynamic link library, and load the first dynamic link library into the running memory of the electronic device.
  • the link loading module can determine whether the first dynamic link library is an integrated dynamic link library in the following manner:
  • the first dynamic link library determines whether the first dynamic link library includes a virtual library list segment, wherein, when the first dynamic link library includes a virtual list segment, the first dynamic link library is an integrated dynamic link library; or,
  • the identifier of the first dynamic link library is a predefined identifier, wherein, when the identifier of the first dynamic link library is a predefined identifier, the first dynamic link library is an integrated dynamic link library.
  • an embodiment of the present application provides an electronic device, including a functional module that executes each of the foregoing aspects and any possible design method provided by each aspect.
  • a chip provided by an embodiment of the present application is coupled with a memory in an electronic device, so that the chip invokes a computer executable program stored in the memory during operation to implement the above-mentioned embodiments of the present application.
  • a computer-readable storage medium stores a computer-executable program, and when the computer-executable program runs on an electronic device, the electronic device executes the above-mentioned first On the one hand and any one of the possible design methods of the first aspect.
  • an embodiment of the present application provides a computer-readable storage medium, the computer-readable storage medium includes an integrated dynamic link library, and when the integrated dynamic link library is loaded on the electronic device, the electronic The device executes the foregoing first aspect and any one of the possible design methods of the first aspect.
  • a computer program product of an embodiment of the present application when the computer program product runs on an electronic device, causes the electronic device to execute the above-mentioned first aspect and any one of the possible design methods of the first aspect .
  • FIG. 1 is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the application.
  • FIG. 2 is a schematic diagram of the software structure of an electronic device according to an embodiment of the application.
  • FIG. 3 is a schematic diagram of an ELF file according to an embodiment of the application.
  • FIG. 4 is a schematic flowchart of a method for loading a dynamic link library according to an embodiment of the application
  • FIG. 5 is a schematic diagram of an integrated dynamic link library according to an embodiment of the application.
  • Fig. 6 is a schematic structural diagram of a device according to an embodiment of the application.
  • FIG. 7 is a schematic structural diagram of another electronic device according to an embodiment of the application.
  • At least one in the embodiments of the present application refers to one or more.
  • “Multiple” means two or more.
  • "The following at least one (item)” or similar expressions refers to any combination of these items, including any combination of a single item (a) or a plurality of items (a).
  • at least one of a, b, or c can represent: a, b, c, a and b, a and c, b and c, or a, b, and c.
  • each of a, b, and c can be an element itself, or a collection containing one or more elements.
  • the character "/" generally indicates that the associated objects before and after are in an "or" relationship.
  • a and/or B can mean that: A alone exists, A and B exist at the same time, and B exists alone. Among them, A and B can be singular or plural.
  • the embodiment of the application introduces the integrated dynamic link library, so that the electronic device can run the application program according to the integrated dynamic link library, and the integrated dynamic link library is the source code of multiple integrated dynamic link libraries through the compiler before the electronic device leaves the factory. Compiled, not only helps to reduce the waste of running memory space, but also helps to reduce the number of times the application relocates the dynamic link library, thereby reducing time overhead.
  • the electronic devices in the embodiments of the present application may be mobile phones, tablet computers, wearable devices, vehicle-mounted devices, augmented reality (AR)/virtual reality (VR) devices, notebook computers, and super mobile personal computers.
  • AR augmented reality
  • VR virtual reality
  • UMPC ultra-mobile personal computer
  • netbook personal digital assistant
  • PDA personal digital assistant
  • the electronic device includes 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, and a battery 142 , Antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, earphone interface 170D, sensor module 180, buttons 190, motor 191, indicator 192, camera 193 , A display screen 194, and a subscriber identification module (SIM) card interface 195, etc.
  • SIM subscriber identification module
  • the sensor module 180 may include a pressure sensor, a gyroscope sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, etc.
  • the processor 110 may include one or more processing units.
  • the processor 110 may include an application processor (AP), a modem (modem), a graphics processing unit (GPU), an image signal processor (ISP), a controller, and a video editor. Decoder, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural network processor (neural-network processing unit, NPU), etc.
  • the different processing units may be independent devices, or two or more different processing units may also be integrated into one device.
  • the controller can be the nerve center and command center of the electronic device.
  • the controller can generate operation control signals according to the instruction operation code and timing signals to complete the control of fetching instructions and executing instructions.
  • a memory may also be provided in the processor 110 to store instructions and data.
  • the memory in the processor 110 is a cache memory.
  • the memory can store instructions or data that have just been used or recycled by the processor 110. If the processor 110 needs to use the instruction or data again, it can be directly called from the memory. Repeated accesses are avoided, the waiting time of the processor 110 is reduced, and the efficiency of the system is improved.
  • the processor 110 may include one or more interfaces.
  • the processor 110 includes a universal serial bus (USB) interface 130 and a subscriber identity module (SIM) interface 195.
  • the processor 110 may also include an integrated circuit (I2C) interface, an integrated circuit audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (PCM) interface, and a universal asynchronous A universal asynchronous receiver/transmitter (UART) interface, a mobile industry processor interface (MIPI), and/or a general-purpose input/output (GPIO) interface, etc.
  • I2C integrated circuit
  • I2S integrated circuit audio
  • PCM pulse code modulation
  • UART universal asynchronous A universal asynchronous receiver/transmitter
  • MIPI mobile industry processor interface
  • GPIO general-purpose input/output
  • the interface connection relationship between the modules illustrated in the embodiments of the present application is merely a schematic description, and does not constitute a structural limitation of the electronic device.
  • the electronic device may also adopt different interface connection modes in the foregoing embodiments, or a combination of multiple interface connection modes.
  • the USB interface 130 is an interface that complies with the USB standard specifications, and specifically may be a Mini USB interface, a Micro USB interface, a USB Type C interface, and the like.
  • the USB interface 130 can be used to connect a charger to charge the electronic device, and can also be used to transfer data between the electronic device and the peripheral device. It can also be used to connect earphones and play audio through earphones. This interface can also be used to connect other electronic devices, such as AR devices.
  • the SIM card interface 195 is used to connect to the SIM card.
  • the SIM card can be inserted into the SIM card interface 195 or pulled out from the SIM card interface 195 to achieve contact and separation with the electronic device.
  • the electronic device can support 1 or N SIM card interfaces, and N is a positive integer greater than 1.
  • the SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, etc.
  • the same SIM card interface 195 can insert multiple cards at the same time. The types of the multiple cards can be the same or different.
  • the SIM card interface 195 can also be compatible with different types of SIM cards.
  • the SIM card interface 195 may also be compatible with external memory cards.
  • the electronic device interacts with the network through the SIM card to realize functions such as call and data communication.
  • the electronic device adopts an eSIM, that is, an embedded SIM card.
  • the eSIM card can be embedded in the electronic device and cannot be separated from the electronic device.
  • the charging management module 140 is used to receive charging input from the charger.
  • the charger can be a wireless charger or a wired charger.
  • the charging management module 140 may receive the charging input of the wired charger through the USB interface 130.
  • the charging management module 140 may receive the wireless charging input through the wireless charging coil of the electronic device. While the charging management module 140 charges the battery 142, it can also supply power to the electronic device through the power management module 141.
  • 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 charge 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 times, and battery health status (leakage, impedance).
  • the power management module 141 may also be provided in the processor 110.
  • the power management module 141 and the charging management module 140 may also be provided in the same device.
  • the wireless communication function of the electronic device can be realized by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem, the baseband processor, and so on.
  • the antenna 1 and the antenna 2 are used to transmit and receive electromagnetic wave signals.
  • Each antenna in an electronic device can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization.
  • Antenna 1 can be multiplexed as a diversity antenna of a wireless local area network.
  • the antenna can be used in combination with a tuning switch.
  • the mobile communication module 150 can provide a wireless communication solution including 2G/3G/4G/5G and other standards applied to electronic devices.
  • the mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), and the like.
  • LNA low noise amplifier
  • the wireless communication module 160 includes wireless local area networks (WLAN) (such as Wi-Fi networks), Bluetooth (BT), and global navigation satellite system (GNSS) that can be applied to electronic devices. ), frequency modulation (FM), near field communication (NFC), infrared technology (infrared, IR) and other wireless communication solutions.
  • WLAN wireless local area networks
  • BT Bluetooth
  • GNSS global navigation satellite system
  • FM frequency modulation
  • NFC near field communication
  • IR infrared technology
  • the antenna 1 of the electronic device is coupled with the mobile communication module 150, and the antenna 2 is coupled with the wireless communication module 160, so that the electronic device can communicate with the network and other devices through wireless communication technology.
  • the wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), broadband Code division multiple access (wideband code division multiple access, WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC , FM and/or IR technology, etc.
  • GSM global system for mobile communications
  • GPRS general packet radio service
  • CDMA code division multiple access
  • WCDMA broadband Code division multiple access
  • TD-SCDMA time-division code division multiple access
  • LTE long term evolution
  • BT GNSS
  • WLAN wireless local area network
  • NFC long term evolution
  • FM and/or IR technology etc.
  • the GNSS may include global positioning system (GPS), global navigation satellite system
  • the electronic device realizes the display function through the GPU, the display screen 194, and the application processor.
  • the display screen 194 is used to display images, videos, and the like.
  • the display screen 194 includes a display panel.
  • the display panel can adopt liquid crystal display (LCD), organic light-emitting diode (OLED), active matrix organic light-emitting diode or active-matrix organic light-emitting diode (active-matrix organic light-emitting diode).
  • LCD liquid crystal display
  • OLED organic light-emitting diode
  • AMOLED flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, quantum dot light-emitting diode (QLED), etc.
  • the electronic device may include one or N display screens 194, and N is a positive integer
  • the electronic device can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194, and application processor.
  • the ISP is used to process the data fed back from the camera 193. For example, when taking a picture, the shutter is opened, the light is transmitted to the photosensitive element of the camera through the lens, the light signal is converted into an electrical signal, and the photosensitive element of the camera transmits the electrical signal to the ISP for processing and is converted into an image visible to the naked eye.
  • ISP can also optimize the image noise, brightness, and skin color. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene.
  • the ISP may be provided in the camera 193.
  • the camera 193 is used to capture still images or videos.
  • the object generates an optical image through the lens and is projected to the photosensitive element.
  • the photosensitive element may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor.
  • CMOS complementary metal-oxide-semiconductor
  • the photosensitive element converts the optical signal into an electrical signal, and then transfers the electrical signal to the ISP to convert it into a digital image signal.
  • ISP outputs digital image signals to DSP for processing.
  • DSP converts digital image signals into standard RGB, YUV and other formats of image signals.
  • the electronic device may include 1 or N cameras 193, and N is a positive integer greater than 1.
  • the external memory interface 120 may be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device.
  • the external memory card communicates with the processor 110 through the external memory interface 120 to realize the data storage function. For example, save music, video and other files in an external memory card.
  • the internal memory 121 includes a running memory (memory) and a built-in memory.
  • the running memory can be used to store computer executable program code or data.
  • the executable program code includes instructions.
  • the processor 110 executes various functional applications and data processing of the electronic device by running instructions stored in the running memory.
  • the running memory may include high-speed random access memory.
  • the built-in memory can also be called a built-in external memory, etc., which can be used to store programs and/or data.
  • the built-in memory can store the operating system, integrated dynamic link library, unintegrated dynamic link library, and so on.
  • the electronic device usually loads the program and/or data in the built-in memory into the running memory, so that the processor 110 runs the corresponding program and/or data to realize the corresponding function.
  • the electronic device may load the integrated dynamic link library in the built-in memory into the running memory, so that the processor 110 can run the corresponding application program.
  • the internal memory 121 may include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, a universal flash storage (UFS), and the like.
  • the electronic device can implement audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the earphone interface 170D, and the application processor. For example, music playback, recording, etc.
  • the button 190 includes a power-on button, a volume button, and the like.
  • the button 190 may be a mechanical button. It can also be a touch button.
  • the electronic device can receive key input, and generate key signal input related to user settings and function control of the electronic device.
  • the motor 191 can generate vibration prompts.
  • the motor 191 can be used for incoming call vibration notification, and can also be used for touch vibration feedback.
  • touch operations that act on different applications can correspond to different vibration feedback effects.
  • Acting on touch operations in different areas of the display screen 194, the motor 191 can also correspond to different vibration feedback effects.
  • Different application scenarios for example: time reminding, receiving information, alarm clock, games, etc.
  • the touch vibration feedback effect can also support customization.
  • the indicator 192 can be an indicator light, which can be used to indicate the charging status, the change of the power level, and can also be used to indicate messages, missed calls, notifications, and the like.
  • the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the electronic device.
  • the electronic device may include more or fewer components than those shown in the figure, or combine certain components, or split certain components, or arrange different components.
  • the illustrated components can be implemented in hardware, software, or a combination of software and hardware.
  • the software system of the electronic device in the embodiment of the present application may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture.
  • the layered architecture (for example, the Android system) divides the software into several layers, each layer has a clear role and division of labor, and the communication between the layers is through the software interface.
  • FIG. 2 shows a block diagram of a software structure of an electronic device according to an embodiment of the present application, which includes an application layer, a system library, a linker, and a kernel layer.
  • the application layer can include applications such as camera, gallery, calendar, call, map, navigation, browser, Bluetooth, music, video, short message, etc.
  • the system library can provide a dynamic link library for applications in the application layer, such as an integrated dynamic link library, or an unintegrated dynamic link library.
  • the integrated dynamic link library in the embodiment of the present application may be obtained by a compiler by compiling the source code of multiple integrated dynamic link libraries.
  • the integrated dynamic link library includes a virtual library list segment and N binary segments. Each binary segment includes the contents of corresponding binary segments in multiple integrated dynamic link libraries.
  • the unintegrated dynamic link library or the integrated dynamic link library in the embodiments of the present application may be a basic dynamic link library or a standard dynamic link library. Taking the Android system as an example, libc, libc++, libpthread, libm, etc. are all standard dynamic link libraries, or basic dynamic link libraries.
  • the compiler can perform all or part of the source code of all standard dynamic link libraries in the Android system. Compile an integrated dynamic link library.
  • 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.
  • the linker is located between the system library and the kernel layer, and can be used to load application dependent libraries, such as integrated dynamic link libraries, or unintegrated dynamic link libraries.
  • application dependent libraries such as integrated dynamic link libraries, or unintegrated dynamic link libraries.
  • the dependent library of the application can be understood as: a dynamic link library that the mobile phone needs to use or rely on to run the application.
  • the integrated dynamic link library in the embodiment of the present application is used to realize the normal operation of the application program installed in the mobile phone, and it may be obtained by compiling the source code of multiple integrated dynamic link libraries by a compiler.
  • a compiler For example, take the compiler to compile the source code of M integrated dynamic link libraries to obtain an integrated dynamic link library as an example.
  • the compiler compiles the source code of each integrated dynamic link library in the M integrated dynamic link libraries to obtain a static link library and a dynamic link library.
  • the binary section included in the static link library obtained by the compiler compiling the source code of the integrated dynamic link library is the binary section needed for the operation of the application program. This helps to save storage space.
  • the compiler integrates the static link library obtained by compiling each integrated dynamic link library to obtain an integrated dynamic link library.
  • the compiler obtains the virtual library list segment according to the identification of each integrated dynamic link library, and integrates the same type of binary segments in the static link library obtained by compiling each integrated dynamic link library to obtain N types Binary segment, and root virtual library list segment and N binary segments to generate integrated dynamic link library.
  • the integrated dynamic link library includes a virtual library list segment and N types of binary segments.
  • Each binary segment includes the contents of the corresponding binary segment in the M integrated dynamic link libraries.
  • the virtual library list segment includes the identifiers of M integrated dynamic link libraries.
  • the identifier of the integrated dynamic link library may be the virtual name (soname) of the integrated dynamic link library, or it may be another identifier indicating the integrated dynamic link library, which is not limited in the embodiment of the present application.
  • the compiler compiles the source code of libc, libc++ and libpthrea to obtain an integrated dynamic link library.
  • the integrated dynamic link library includes a virtual library list section, code section, data section and BSS section.
  • the virtual library list segment includes the identifier of libc, the identifier of libc++, and the identifier of libpthrea.
  • the code segment of the integrated dynamic link library includes the content of the code segment of libc, the code segment of libc++ and the code segment of libpthrea.
  • the data segment of the integrated dynamic link library includes the content of the data segment of libc, the data segment of libc++ and the data segment of libpthrea.
  • the BSS section of the integrated dynamic link library includes the contents of the BSS section of libc, the BSS section of libc++ and the BSS section of libpthrea. It should be noted that the code segment, data segment and BSS segment can all be understood as a binary segment.
  • standard dynamic links such as libc, libc++ or libpthrea usually include not only code segments, data segments, and BSS segments, but also symbol tables, procedure linkage tables (PLT), and global offsets.
  • PLT procedure linkage tables
  • the symbol table, PLT and global offset table may not be used or called during the running of the application. Therefore, when the compiler compiles the source code of multiple integrated dynamic link libraries, The sections that are not used or called during the running of these applications will no longer be compiled into the integrated dynamic link library, which helps to save storage space.
  • the integrated dynamic link library and multiple integrated dynamic link libraries are aligned with pages. Compared with the link library, it is more helpful to reduce the waste of running space memory.
  • the integrated dynamic link library including the virtual library list section, code section, data section and BSS section as an example.
  • the code section, data section and BSS section of the integrated dynamic link library are obtained by integrating the contents of the corresponding binary sections in the M integrated dynamic link libraries.
  • the integrated dynamic link library is obtained by the compiler by compiling the source code of 200 integrated dynamic link libraries such as libc, libc++, libpthread, libm, etc.
  • each segment is aligned in a page (4KB)
  • each segment of the 200 integrated dynamic link libraries is aligned with 4KB. If each page wastes an average of 2KB, 200 will be integrated
  • the integrated dynamic link library includes the virtual library list section, code section, data section and BSS section.
  • the integrated dynamic link library is configured into the built-in memory before the mobile phone leaves the factory.
  • the integrated dynamic link library may be stored in the built-in memory in an executable and linkable format (ELF) file.
  • ELF executable and linkable format
  • the format of the ELF file is shown in Figure 3, including ELF header (ELF header), program header table (program header table), multiple binary sections (section) (for example, section1, section2, ..., sectionn, etc.) and Section header table.
  • the program header table includes multiple program headers, and each program header may include p_type, p_vaddr, p_offset, p_paddr, p_filesz, p_memsz, p_flags, and p_align.
  • the program header table is optional, that is, the program header table may or may not be included in the ELF file.
  • the section header table includes multiple section headers.
  • Each segment header may include sh_name, sh_type, sh_flags, sh_addr, sh_offset, sh_size, sh_link, sh_link, sh_info, sh_addralign, and sh_entsize.
  • relevant introduction about the ELF header, program header table, section and section header table please refer to the relevant introduction about the ELF file in Wikipedia, which will not be repeated here. It is worth noting that for ELF files that integrate dynamic link libraries, multiple segments include a virtual library list segment.
  • these dynamic link libraries can be stored in the built-in memory as ELF files, and the format of the ELF file can also be seen in Figure 3. As shown, but the ELF files of these dynamic link libraries do not include the virtual library list segment.
  • the dynamic link library such as the integrated dynamic link library
  • the binary segments in the ELF file are stored in the running memory.
  • the ELF header, program header, and segment header table in the ELF file are not stored.
  • the integrated dynamic link library may be a dynamic link library with the same name or a dynamic link library with a non-same name.
  • the integrated dynamic link library with the same name can be understood as: the name of the integrated dynamic link library is the same as the standard dynamic link library or the basic dynamic link library in the Android operating system.
  • the integrated dynamic link library including M integrated dynamic link libraries as an example, when the integrated dynamic link library is a dynamic link library with the same name, the name of the integrated dynamic link library is that the application depends on the M integrated dynamic link libraries.
  • the name of the first dynamic link library to be integrated. So that the mobile phone can first load and integrate the dynamic link library for the application.
  • the name of the first integrated dynamic link library that different applications depend on may be the same or different.
  • the M integrated dynamic link libraries are M standard dynamic link libraries in the Android operating system
  • the M standard dynamic link libraries are standard dynamic link library 1 to standard dynamic link library M, respectively.
  • the first dynamic link library that the application 1 depends on is the standard dynamic link library 1 in M standard dynamic link libraries
  • the name of the integrated dynamic link library is the name of the standard dynamic link library 1.
  • the first dynamic link library that the application 1 depends on can be understood as the dynamic link library that is first used or called by the mobile phone running the application 1.
  • the first dynamic link library that the application 2 depends on is the standard dynamic link library M among the M standard dynamic link libraries, and the name of the integrated dynamic link library is the name of the standard dynamic link library M.
  • the first dynamic link library that application 3 depends on is the standard dynamic link library N
  • the standard dynamic link library N is not a dynamic link library among the M standard dynamic link libraries, but it is different from the standard dynamic link library N
  • the name of the integrated dynamic link library may be the name of the standard dynamic link library 3.
  • the dynamic link library that is dependent on the standard dynamic link library N is the standard dynamic link library 3, which can be understood as: the mobile phone runs the application 3 first using the standard dynamic link library N, and then the standard dynamic link library 3.
  • the integrated dynamic link library is a dynamic link library with a non-identical name, which can be understood as: the name of the integrated dynamic link library is different from the name of the standard dynamic link library or the basic dynamic link library in the Android operating system, such as libsystem.
  • the integrated dynamic link library in order to make the integrated dynamic link library exist in the mobile phone, the integrated dynamic link library can be used first, and the mobile phone can preload the integrated dynamic link library.
  • the mobile phone needs to be loaded from the built-in memory into the running memory before it can be called by the caller (for example, an application, etc.) to implement the application
  • the caller for example, an application, etc.
  • the dependent library of the application can be loaded.
  • the mobile phone may load the dependent library of the application in response to the user's operation of opening an application, and then run the application according to the dependent library of the application.
  • the operation of opening an application program may be an operation of clicking the icon of the application program, a voice command, or a shortcut gesture operation, etc., which is not limited.
  • the mobile phone can also load the dependent library of the application before using the dynamic link library during the process of running the application.
  • the specific timing of loading the dependent library of the application can be predefined in the program by the R&D personnel, or it can be determined by the mobile phone based on a predefined algorithm and combined with specific scenarios.
  • the comparison of application examples is not limited.
  • the dependent library of the application program may be one or multiple, which are dynamic link libraries that need to be used or invoked to run the application program in the mobile phone, such as integrated dynamic link libraries, unintegrated dynamic link libraries, and so on.
  • the embodiment of the present application provides a method for loading the dynamic link library in order to enable the mobile phone to run the application program normally so that the caller (such as the application program) can obtain the handle of the dynamic link library.
  • dynamic link library A is loaded.
  • the linker is caused to execute the method of loading the dynamic link library in response to the request to load the dynamic link library A.
  • the application when the application is started, it requests the linker to load the dynamic link library A.
  • the application is running, it requests the linker to load the dynamic link library A.
  • the mobile phone can call a function (for example, the function can be defined by the developer) when the application is started or when the application is running, so that the caller (such as the application) can request the linker Load the dynamic link library A.
  • a function for example, the function can be defined by the developer
  • the method of loading a dynamic link library in the embodiment of the present application, as shown in FIG. 4, specifically includes the following steps.
  • step 401 the mobile phone judges whether the identifier of the dynamic link library A is in the loaded dynamic library list, if not, execute step 402, otherwise, execute step 406.
  • the loaded dynamic library list is used to avoid repeated records, and to record the identification of the loaded dynamic link library and the handle corresponding to the identification of the loaded dynamic link library. That is, the loaded dynamic link library list includes the identification of the loaded dynamic link library and the handle corresponding to the identification of the loaded dynamic link library.
  • step 402 the mobile phone allocates a handle to the dynamic link library A, and adds the identification of the dynamic link library A and the handle allocated to the dynamic link library A to the list of loaded dynamic libraries.
  • step 403 the mobile phone judges whether the dynamic link library A is an integrated dynamic link library, if yes, execute step 404; otherwise, execute step 405.
  • the mobile phone can determine whether the dynamic link library A is an integrated dynamic link library by judging whether the dynamic link library A includes a virtual library list segment. When the dynamic link library A includes the virtual library list section, the dynamic link library A is an integrated dynamic link library, and when the dynamic link library A does not include the virtual library list section, the dynamic link library A is not an integrated dynamic link library.
  • the mobile phone can also determine whether the dependent library is an integrated dynamic link library through the name of the dependent library. This method can be applied to the scenario where the integrated dynamic link library is a dynamic link library with a non-identical name.
  • the mobile phone can also judge whether the dynamic link library A is an integrated dynamic link library through a certain field or identification segment. The embodiment of the present application does not limit the manner in which the mobile phone judges the integrated dynamic link library.
  • the mobile phone adds the identifier of the integrated dynamic link library in the virtual library list section of the dynamic link library A and the handle of the integrated dynamic link library to the loaded dynamic library list.
  • the handle of the integrated dynamic link library is the handle allocated by the mobile phone to the dynamic link library A, that is, the handle of the dynamic link library A. Therefore, when the application program needs to call the integrated dynamic link path in the dynamic link library A, it can relocate the dynamic link library A according to the handle of the dynamic link library A, so as to achieve the purpose of normal operation of the application.
  • the identifiers of the integrated dynamic link library in the virtual list section of the dynamic link library A are the identifier of libc, the identifier of libc++, and the identifier of libpthrea.
  • the handle allocated by the mobile phone to the dynamic link library A is handle A, and the handles of libc, libc++ and libpthrea are also handle A. If the first dependent library called by the application is libc, the application can relocate to the dynamic link library A according to the handle A corresponding to the libc identifier, and run the application according to the dynamic link library A.
  • step 405 the mobile phone performs relocation according to the handle of the dynamic link library A, and loads the dynamic link library A into the running memory.
  • Step 406 The mobile phone returns the handle of column A of the dynamic link library to the caller.
  • steps 401 to 406 may be executed by the linker in the mobile phone, thereby facilitating implementation.
  • step 402 and step 403 precede step 404.
  • the mobile phone can perform step 403 to determine whether the dynamic link library A is an integrated dynamic link library, and then perform step 402 to allocate a handle to the dynamic link library A, and after the handle is allocated, if the dynamic link library A is an integrated dynamic link library, Step 404 is executed, otherwise, step 405 is executed.
  • the mobile phone when there are multiple dependent libraries in the application, the mobile phone can refer to the method of loading dynamic link libraries shown in FIG. 4 for the process of loading each dependent library.
  • the mobile phone loads the dynamic link library according to the dependency order between the dependent libraries of the application.
  • the dependent libraries of application A are dynamic link library 1, dynamic link library 2, and dynamic link library 3.
  • Dynamic link library 1 is the first dynamic link library that application A depends on, and dynamic link library 1 depends on dynamic link.
  • Library 2 dynamic link library 2 depends on dynamic link library 3
  • the mobile phone first loads dynamic link library 1, then dynamic link library 2, and finally dynamic link library 3 for application A.
  • the caller can request the linker to load the dynamic link library in a loop, and the dynamic link library that the caller requests to the linker to load is the dependent library of the application.
  • the caller can request the linker to load the dynamic link library according to the dependency sequence between the dependent libraries of the application, so that the linker can load the dynamic link library in a circular manner in response to the request for circular loading of the dynamic link library.
  • the mobile phone when the mobile phone has finished loading the dynamic link library for a certain application, that is, after the application's dependent library is loaded, the mobile phone can run the application according to the loaded dynamic link library.
  • the dependent library of the application is an integrated dynamic link library
  • the mobile phone runs the application according to the integrated dynamic link library.
  • the application can just relocate the integrated dynamic link library once, and then call the corresponding function or parameter from the integrated dynamic link library.
  • other functions or parameters in the integrated dynamic link library that are dependent on the function or parameter are due to relocation.
  • the address offset between the functions or parameters called by the positioning is fixed, so the application can directly read from the integrated dynamic link library without relocating again, which helps to save time and overhead.
  • the integrated dynamic link library 500 includes a virtual library list section 501, a code section 502, a data section 503, and a BSS section 504.
  • the virtual library list segment 501 includes an identifier of libc and an identifier of libc++.
  • libc includes code segment 1
  • libc++ includes code segment 2.
  • the code segment 502 includes code segment 1 and code segment 2.
  • Code segment 1 includes the function f(y)
  • code segment 2 includes the function y.
  • the application can call the function f(y) according to the handle of the integrated dynamic link library 500 and the symbol of the integrated dynamic link library 500, but the execution of the function f(y) depends on the function y.
  • the functions y and The relative address offset between the functions f(y) is L, which is fixed. Therefore, the application program does not need to relocate again when calling the function y.
  • the method provided in the embodiments of the present application is introduced from the perspective of the mobile phone as the execution subject.
  • the mobile phone may include a hardware structure and/or software module, and the above functions are implemented in the form of a software module or a hardware structure combined with a software module. Whether a certain function among the above-mentioned functions is executed by a hardware structure, a software module, or a hardware structure plus a software module depends on the specific application and design constraint conditions of the technical solution.
  • the device 600 specifically includes a link request module 601 and a link loading module 602.
  • the device 600 includes a link request module 601 and a link loading module 602; wherein, the link request module 601 is configured to receive a request to load the first dynamic link library;
  • the link loading module 602 is used to execute:
  • the identifier of the integrated dynamic link library and the handle allocated for the first dynamic link library are added to the list of loaded dynamic link libraries.
  • the first dynamic link library is compiled Compiled by the source code of M integrated dynamic link libraries;
  • the first dynamic link library is relocated according to the handle allocated for the first dynamic link library, and the first dynamic link library is loaded into the running memory of the electronic device.
  • an embodiment of the present application discloses an electronic device 700.
  • the electronic device 700 may include: one or more processors 701 and a memory 702; and one or more computer executable programs. It can be connected via one or more communication buses.
  • the one or more computer executable programs are stored in the aforementioned memory 702 and configured to be executed by the one or more processors 701 to implement the method for loading the dynamic link library shown in FIG. 7 of the embodiment of the present application.
  • the processors involved in each of the foregoing embodiments may be general-purpose processors, digital signal processors (digital signal processors, DSP), application specific integrated circuits (ASICs), ready-made programmable gate arrays (field programmable gate arrays, FPGAs). ) Or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
  • DSP digital signal processors
  • ASICs application specific integrated circuits
  • FPGAs field programmable gate arrays
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.
  • the steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of hardware and software modules in the decoding processor.
  • the software module can be located in random access memory (RAM), flash memory, read-only memory (read-only memory, ROM), programmable read-only memory or electrically erasable programmable memory, registers, etc. mature in the field Storage medium.
  • the storage medium is located in the memory, and the processor reads the instructions in the memory and completes the steps of the above method in combination with its hardware.
  • the disclosed system, device, and method can be implemented in other ways.
  • the device embodiments described above are merely illustrative, for example, the division of the units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components may be combined or It can be integrated into another system, or some features can be ignored or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • the functional units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium.
  • the technical solution of the present application essentially or the part that contributes to the existing technology or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (processor) execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage media include: U disk, mobile hard disk, ROM, RAM, magnetic disk or optical disk and other media that can store program codes.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

一种动态链接库的加载方法及装置,涉及计算机技术领域。其中,方法应用于电子设备,包括:响应于加载第一动态链接库的请求,判断第一动态链接库的标识是否在已加载动态链接库列表中(401);若不在,则为第一动态链接库分配句柄,并将第一动态链接库的标识以及分配的句柄添加到已加载动态库列表中(402);判断第一动态链接库是否为整合动态链接库(403);若是,则将M个被整合的动态链接库的标识以及分配的句柄添加到已加载动态链接库列表中(404),第一动态链接库是编译器对M个被整合的动态链接库的源码编译得到的;根据为第一动态链接库分配的句柄,将第一动态链接库加载到电子设备的运行内存中(405)。这种技术方案有助于降低运行内存空间的浪费和时间开销。

Description

一种动态链接库的加载方法及装置
相关申请的交叉引用
本申请要求在2020年01月31日提交中国专利局、申请号为202010077751.9、申请名称为“一种动态链接库的加载方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机技术领域,特别涉及一种动态链接库的加载方法及装置。
背景技术
电子设备中,不同应用程序的运行可以通过动态链接库(dynamic link library,DLL)实现代码、或变量等的共享,有助于节省磁盘和运行内存空间的开销。其中,动态静态库是以段(section)进行组织的,每个段以页(例如4KB)对齐。然而,在段的实际大小不足页的大小的情况下,容易造成运行内存空间的浪费。尤其当电子设备中的动态链接库的个数较多时,运行内存空间的浪费可能会越严重。以200个动态链接库,每个动态链接库包括代码段、数据段和BSS段,每个段以4KB对齐为例,如果每个段平均浪费2KB内存空间,200个动态链接库大概浪费1200KB运行内存空间。
此外,应用程序在根据某一动态链接库运行的情况下,针对该动态链接库,需要先重定位,进行符号解析和绑定,才能使用该动态链接库。而且该动态链接库还可能依赖其他动态链接库。因此,应用程序不但需要对该动态链接库重定位,也需要对该动态链接库依赖的其它动态链接库重定位,才能实现正常运行,这样容易导致时间开销较大。
发明内容
本申请提供了一种动态链接库的加载方法及装置,有助于降低运行内存空间的浪费、以及节省应用程序运行的时间开销。
第一方面,本申请实施例提供了一种动态链接库的加载方法,应用于电子设备,具体包括:响应于应用程序加载第一动态链接库的请求,判断第一动态链接库的标识是否在已加载动态链接库列表中;当第一动态链接库的标识不在已加载动态链接库列表中时,执行步骤A~C,步骤A,为第一动态链接库分配句柄,并将第一动态链接库的标识以及为第一动态链接库分配的句柄添加到已加载动态库列表中;步骤B,判断第一动态链接库是否为整合动态链接库;当第一动态链接库为整合动态链接库时,执行步骤1和步骤2,并在执行步骤2之后执行步骤C。步骤2,将M被整合的动态链接库的标识以及为第一动态链接库分配的句柄添加到已加载动态链接库列表中,第一动态链接库是编译器对M个被整合的动态链接库的源码编译得到的;M为大于1的正整数;步骤2,根据为第一动态链接库分配的句柄对第一动态链接库重定位,并将第一动态链接库加载到电子设备的运行内存中。步骤C,向所述应用程序返回为所述第一动态链接库分配的句柄。
本申请实施例中由于电子设备可以响应于应用程序加载第一动态链接库的请求,判断 当第一动态链接库的标识不在已加载动态链接库列表时,不但可以为第一动态链接库分配句柄,并将第一动态链接库的标识以及分配的句柄添加到已加载动态链接库列表中,还可以判断第一动态链接库是否为整合动态链接库,而整合动态链接库是通过对多个被整合的动态链接库的源码编译得到的,因而有助于降低运行内存空间的浪费。此外,当第一动态链接库为整合动态链接库时,电子设备还将被整合的动态链接库的标识以及为第一动态链接库分配的句柄添加到已加载动态链接库中,有助于避免电子设备的重复加载,还有助于减少应用程序对动态链接库重定位的次数,从而降低时间开销。
在一种可能的设计中,第一动态链接库为整合动态链接库时,该第一动态链接库包括虚拟库列表段和N个二进制段,其中,虚拟库列表段包括M个被整合的动态链接库的标识,N个二进制段中的任意一个二进制段包括M个被整合的动态链接库中对应的二进制段的内容;N为大于或等于1的正整数。通过在整合动态链接库中增加虚拟库列表段,可以使得电子设备识别出整合动态链接库是通过对哪些动态链接库的源码编译得到的,有助于便于应用程序的调用。
在一种可能的设计中,在应用程序启动时,响应于应用程序循环加载该应用程序的依赖库的请求,所述第一动态链接库为所述应用程序的依赖库之一;或者,在应用程序运行时,响应于该应用程序加载所述第一动态链接库的请求。从而有助于简化实现方式。
在一种可能的设计中,第一动态链接库可以基于下列方式通过对M个被整合的动态链接库的源码编译得到:
第一动态链接库是通过对M个静态链接库整合得到的;该M个静态链接库中每个静态链接库是通过对M个被整合的动态链接库的源码中对应源码编译得到的。从而便于实现。
在一种可能的设计中,响应于该应用程序加载第一动态链接库的请求,判断第一动态链接库的标识是否在已加载动态链接库列表中之后,当第一动态链接库的标识在已加载动态链接库列表中时,执行步骤D,并在执行步骤D之后执行步骤C。
步骤D,根据已加载动态链接库列表中第一动态链接库的标识,获得第一动态链接库的句柄。
在一种可能的设计中,在执行步骤B判断第一动态链接库是否为整合动态链接库之后,当第一动态链接库不为整合动态链接库时,执行步骤3,并在执行步骤3之后,执行步骤C。
步骤3,根据为第一动态链接库分配的句柄对第一动态链接库重定位,并将第一动态链接库加载到电子设备的运行内存中。
在一种可能的设计中,电子设备可以基于下列方式判断第一动态链接库是否为整合动态链接库:
判断第一动态链接库是否包括虚拟库列表段;其中,当第一动态链接库包括虚拟列表段时,第一动态链接库为整合动态链接库;或者,判断第一动态链接库的标识是否为预定义的标识,其中,当第一动态链接库的标识为预定义的标识时,第一动态链接库为整合动态链接库。
通过上述技术方案,便于电子设备判断第一动态链接库是否为整合动态链接库。
第二方面,本申请实施例提供了一种装置,所述装置包括链接请求模块和链接加载模块;其中,链接请求模块用于接收应用程序加载第一动态链接库的请求;
链接加载模块用于:
响应于加载第一动态链接库的请求,判断第一动态链接库的标识是否在已加载动态链接库列表中;
当第一动态链接库的标识不在已加载动态链接库列表中时,执行步骤A~C。
步骤A,为第一动态链接库分配句柄,并将第一动态链接库的标识以及为第一动态链接库分配的句柄添加到已加载动态库列表中;
步骤B,判断第一动态链接库是否为整合动态链接库;
当第一动态链接库为整合动态链接库时,执行步骤1和步骤2,并在执行步骤2之后,执行步骤C。
步骤1,将M被整合的动态链接库的标识以及为第一动态链接库分配的句柄添加到已加载动态链接库列表中,第一动态链接库是编译器对M个被整合的动态链接库的源码编译得到的;
步骤2,根据为第一动态链接库分配的句柄对第一动态链接库重定位,并将第一动态链接库加载到电子设备的运行内存中;
步骤C,向所述应用程序返回为所述第一动态链接库分配的句柄。
在一种可能设计中,第一动态链接库包括虚拟库列表段和N个二进制段,其中,虚拟库列表段包括M个被整合的动态链接库的标识,N个二进制段中的任意一个二进制段包括M个被整合的动态链接库中对应的二进制段的内容;N为大于或等于1的正整数。
在一种可能设计中,在应用程序启动时,响应于该应用程序循环加载应用程序的依赖库的请求,第一动态链接库为所述应用程序的依赖库之一;或者,在应用程序运行时,响应于该应用程序加载第一动态链接库的请求。
在一种可能的设计中,第一动态链接库可以基于下列方式通过对M个被整合的动态链接库的源码编译得到:
第一动态链接库是通过对M个静态链接库整合得到的;该M个静态链接库中每个静态链接库是通过对M个被整合的动态链接库的源码中对应源码编译得到的。从而便于实现。
在一种可能的设计中,所述链接加载模块在判断第一动态链接库的标识是否在已加载动态链接库列表中之后,还用于当第一动态链接库的标识在已加载动态链接库列表中时,执行步骤D,并在执行步骤D之后执行步骤C。
步骤D,根据已加载动态链接库列表中第一动态链接库的标识,获得第一动态链接库的句柄。
在一种可能的设计中,链接加载模块在执行步骤B判断第一动态链接库是否为整合动态链接库之后,还用于:当所述第一动态链接库不为整合动态链接库时,执行步骤3,并在执行步骤3之后,执行步骤C。
步骤3,根据为第一动态链接库分配的句柄对第一动态链接库重定位,并将第一动态链接库加载到电子设备的运行内存中。
在一种可能的设计中,所述链接加载模块可以通过下列方式判断第一动态链接库是否为整合动态链接库:
判断所述第一动态链接库是否包括虚拟库列表段,其中,当第一动态链接库包括虚拟列表段时,第一动态链接库为整合动态链接库;或者,
判断所述第一动态链接库的标识是否为预定义的标识,其中,当第一动态链接库的标识为预定义的标识时,第一动态链接库为整合动态链接库。
第三方面,本申请实施例提供了一种电子设备,包括执行上述各个方面以及各方面提供的任一可能设计的方法的功能模块。
第四方面,本申请实施例提供的一种芯片,所述芯片与电子设备中的存储器耦合,使得所述芯片在运行时调用所述存储器中存储的计算机可执行程序,实现本申请实施例上述第一方面以及第一方面提供的任一可能设计的方法。
第五方面,本申请实施例的一种计算机可读存储介质,该计算机可读存储介质存储有计算机可执行程序,当所述计算机可执行程序在电子设备上运行时,使得电子设备执行上述第一方面以及第一方面任意一种可能的设计的方法。
第六方面,本申请实施例提供了一种计算机可读存储介质,所述计算机可读存储介质包括整合动态链接库,当所述整合动态链接库在所述电子设备上被加载时,使得电子设备执行上述第一方面以及第一方面任意一种可能的设计的方法。
第七方面,本申请实施例的一种计算机程序产品,当所述计算机程序产品在电子设备上运行时,使得所述电子设备执行上述第一方面以及第一方面任意一种可能的设计的方法。
另外,第二方面至第七方面中任一种可能设计方式所带来的技术效果可参见第一方面中不同设计方式所带来的技术效果,此处不再赘述。
附图说明
图1为本申请实施例的一种电子设备的硬件结构示意图;
图2为本申请实施例的一种电子设备的软件结构示意图;
图3为本申请实施例一种ELF文件的示意图;
图4为本申请实施例的一种动态链接库加载的方法流程示意图;
图5为本申请实施例的一种整合动态链接库的示意图;
图6为本申请实施例的一种装置的结构示意图;
图7为本申请实施例的另一种电子设备的结构示意图。
具体实施方式
应理解,本申请实施例中“至少一个”是指一个或者多个。“多个”是指两个或两个以上。“以下至少一(项)个”或其类似表达,是指的这些项中的任意组合,包括单项(个)或复数项(个)的任意组合。例如,a、b或c中的至少一项(个),可以表示:a,b,c,a和b,a和c,b和c,或a、b和c七种情况。其中a、b、c中的每一个本身可以是元素,也可以是包含一个或多个元素的集合。字符“/”一般表示前后关联对象是一种“或”的关系。“和/或”,描述关联对象的关联关系,表示可以存在三种关系。例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B的三种情况。其中A、B可以是单数或者复数。
在本申请中,“示例的”、“在一些实施例中”、“在另一些实施例中”等用于表示作例子、例证或说明。本申请中被描述为“示例”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用示例的一词旨在以具体方式呈现概念。
需要指出的是,本申请实施例中涉及的“第一”、“第二”等词汇,仅用于区分描述的目的,而不能理解为指示或暗示相对重要性,也不能理解为指示或暗示顺序。
本申请实施例通过引入整合动态链接库,使得电子设备可以根据整合动态链接库运行 应用程序,而整合动态链接库是电子设备在出厂之前,通过编译器对多个被整合的动态链接库的源码编译得到的,不但有助于降低运行内存空间的浪费,还有助于减少应用程序对动态链接库重定位的次数,从而降低时间开销。
示例的,本申请实施例的电子设备可以为手机、平板电脑、可穿戴设备、车载设备、增强现实(augmented reality,AR)/虚拟现实(virtual reality,VR)设备、笔记本电脑、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本、个人数字助理(personal digital assistant,PDA)等,本申请实施例对电子设备的具体类型不作任何限制。电子设备的示例性实施例包括但不限于搭载
Figure PCTCN2020132417-appb-000001
或者其它操作系统。
示例的,如图1所示,为本申请实施例的一种电子设备的结构示意图。具体的,如图所示,电子设备包括处理器110、外部存储器接口120、内部存储器121、通用串行总线(universal serial bus,USB)接口130、充电管理模块140、电源管理模块141、电池142、天线1、天线2、移动通信模块150、无线通信模块160、音频模块170、扬声器170A、受话器170B、麦克风170C、耳机接口170D、传感器模块180、按键190、马达191、指示器192、摄像头193、显示屏194、以及用户标识模块(subscriber identification module,SIM)卡接口195等。其中,传感器模块180可以包括压力传感器、陀螺仪传感器、气压传感器、磁传感器、加速度传感器、距离传感器、接近光传感器、指纹传感器、温度传感器、触摸传感器、环境光传感器、骨传导传感器等。
处理器110可以包括一个或多个处理单元。例如:处理器110可以包括应用处理器(application processor,AP)、调制解调器(modem)、图形处理器(graphics processing unit,GPU)、图像信号处理器(image signal processor,ISP)、控制器、视频编解码器、数字信号处理器(digital signal processor,DSP)、基带处理器、和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,或者,两个或更多个不同的处理单元也可以集成在一个器件中。
控制器可以是电子设备的神经中枢和指挥中心。控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。
在一些实施例中,处理器110可以包括一个或多个接口。例如,处理器110包括通用串行总线(universal serial bus,USB)接口130、用户标识模块(subscriber identity module,SIM)接口195。再例如,处理器110还可以包括集成电路(inter-integrated circuit,I2C)接口、集成电路内置音频(inter-integrated circuit sound,I2S)接口、脉冲编码调制(pulse code modulation,PCM)接口、通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口、移动产业处理器接口(mobile industry processor interface,MIPI)、和/或通用输入输出(general-purpose input/output,GPIO)接口等。
可以理解的是,本申请实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对电子设备的结构限定。在本申请另一些实施例中,电子设备也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。
USB接口130是符合USB标准规范的接口,具体可以是Mini USB接口、Micro USB接口、USB Type C接口等。USB接口130可以用于连接充电器为电子设备充电,也可以用于电子设备与外围设备之间传输数据。也可以用于连接耳机,通过耳机播放音频。该接口还可以用于连接其他电子设备,例如AR设备等。
SIM卡接口195用于连接SIM卡。SIM卡可以通过插入SIM卡接口195,或从SIM卡接口195拔出,实现和电子设备的接触和分离。电子设备可以支持1个或N个SIM卡接口,N为大于1的正整数。SIM卡接口195可以支持Nano SIM卡、Micro SIM卡、SIM卡等。同一个SIM卡接口195可以同时插入多张卡。所述多张卡的类型可以相同,也可以不同。SIM卡接口195也可以兼容不同类型的SIM卡。SIM卡接口195也可以兼容外部存储卡。电子设备通过SIM卡和网络交互,实现通话以及数据通信等功能。在一些实施例中,电子设备采用eSIM,即:嵌入式SIM卡。eSIM卡可以嵌在电子设备中,不能和电子设备分离。
充电管理模块140用于从充电器接收充电输入。其中,充电器可以是无线充电器,也可以是有线充电器。在一些有线充电的实施例中,充电管理模块140可以通过USB接口130接收有线充电器的充电输入。在一些无线充电的实施例中,充电管理模块140可以通过电子设备的无线充电线圈接收无线充电输入。充电管理模块140为电池142充电的同时,还可以通过电源管理模块141为电子设备供电。
电源管理模块141用于连接电池142、充电管理模块140与处理器110。电源管理模块141接收电池142和/或充电管理模块140的输入,为处理器110、内部存储器121、外部存储器、显示屏194、摄像头193和无线通信模块160等供电。电源管理模块141还可以用于监测电池容量、电池循环次数、电池健康状态(漏电、阻抗)等参数。在其他一些实施例中,电源管理模块141也可以设置于处理器110中。在另一些实施例中,电源管理模块141和充电管理模块140也可以设置于同一个器件中。
电子设备的无线通信功能可以通过天线1、天线2、移动通信模块150、无线通信模块160、调制解调器以及基带处理器等实现。
天线1和天线2用于发射和接收电磁波信号。电子设备中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。例如:可以将天线1复用为无线局域网的分集天线。在另外一些实施例中,天线可以和调谐开关结合使用。
移动通信模块150可以提供应用在电子设备上的包括2G/3G/4G/5G等制式的无线通信的解决方案。移动通信模块150可以包括至少一个滤波器、开关、功率放大器、低噪声放大器(low noise amplifier,LNA)等。
无线通信模块160包括可以提供应用在电子设备上的包括无线局域网(wireless local area networks,WLAN)(如Wi-Fi网络)、蓝牙(bluetooth,BT)、全球导航卫星系统(global navigation satellite system,GNSS)、调频(frequency modulation,FM)、近距离无线通信技术(near field communication,NFC)、红外技术(infrared,IR)等无线通信的解决方案。
在一些实施例中,电子设备的天线1和移动通信模块150耦合,天线2和无线通信模块160耦合,使得电子设备可以通过无线通信技术与网络以及其他设备通信。所述无线通信技术可以包括全球移动通讯系统(global system for mobile communications,GSM)、通用分组无线服务(general packet radio service,GPRS)、码分多址接入(code division multiple access,CDMA)、宽带码分多址(wideband code division multiple access,WCDMA)、时分 码分多址(time-division code division multiple access,TD-SCDMA)、长期演进(long term evolution,LTE)、BT、GNSS、WLAN、NFC、FM和/或IR技术等。所述GNSS可以包括全球卫星定位系统(global positioning system,GPS)、全球导航卫星系统(global navigation satellite system,GLONASS)、北斗卫星导航系统(beidou navigation satellite system,BDS)、准天顶卫星系统(quasi-zenith satellite system,QZSS)和/或星基增强系统(satellite based augmentation systems,SBAS)。
电子设备通过GPU、显示屏194以及应用处理器等实现显示功能。显示屏194用于显示图像、视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD)、有机发光二极管(organic light-emitting diode,OLED)、有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting diode的,AMOLED)、柔性发光二极管(flex light-emitting diode,FLED)、Miniled、MicroLed、Micro-oLed、量子点发光二极管(quantum dot light emitting diodes,QLED)等。在一些实施例中,电子设备可以包括1个或N个显示屏194,N为大于1的正整数。
电子设备可以通过ISP、摄像头193、视频编解码器、GPU、显示屏194以及应用处理器等实现拍摄功能。ISP用于处理摄像头193反馈的数据。例如,拍照时,打开快门,光线通过镜头被传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将所述电信号传递给ISP处理,转化为肉眼可见的图像。ISP还可以对图像的噪点,亮度,肤色进行算法优化。ISP还可以对拍摄场景的曝光、色温等参数优化。在一些实施例中,ISP可以设置在摄像头193中。
摄像头193用于捕获静态图像或视频。物体通过镜头生成光学图像投射到感光元件。感光元件可以是电荷耦合器件(charge coupled device,CCD)或互补金属氧化物半导体(complementary metal-oxide-semiconductor,CMOS)光电晶体管。感光元件把光信号转换成电信号,之后将电信号传递给ISP转换成数字图像信号。ISP将数字图像信号输出到DSP加工处理。DSP将数字图像信号转换成标准的RGB,YUV等格式的图像信号。在一些实施例中,电子设备可以包括1个或N个摄像头193,N为大于1的正整数。
外部存储器接口120可以用于连接外部存储卡,例如Micro SD卡,实现扩展电子设备的存储能力。外部存储卡通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐、视频等文件保存在外部存储卡中。
内部存储器121包括运行内存(memory)和内置存储器。其中,运行内存可以用于存储计算机可执行程序代码或数据等。所述可执行程序代码包括指令。处理器110通过运行存储在运行内存的指令,从而执行电子设备的各种功能应用以及数据处理。例如,运行内存可以包括高速随机存取存储器。而内置存储器又可以称之为内置外存等,可以用于存储程序和/或数据。例如,内置存储器可以存储操作系统、整合动态链接库、未被整合的动态链接库等。电子设备通常将内置存储器中的程序和/或数据加载到运行内存后,使得处理器110运行相应的程序和/或数据,实现相应的功能。例如,电子设备可以通过将内置存储器中的整合动态链接库加载到运行内存后,使得处理器110运行相应的应用程序。此外,内部存储器121可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、通用闪存存储器(universal flash storage,UFS)等。
电子设备可以通过音频模块170、扬声器170A、受话器170B、麦克风170C、耳机接口170D、以及应用处理器等实现音频功能。例如音乐播放、录音等。
按键190包括开机键、音量键等。按键190可以是机械按键。也可以是触摸式按键。电子设备可以接收按键输入,产生与电子设备的用户设置以及功能控制有关的键信号输入。
马达191可以产生振动提示。马达191可以用于来电振动提示,也可以用于触摸振动反馈。例如,作用于不同应用(例如拍照、音频播放等)的触摸操作,可以对应不同的振动反馈效果。作用于显示屏194不同区域的触摸操作,马达191也可对应不同的振动反馈效果。不同的应用场景(例如:时间提醒、接收信息、闹钟、游戏等)也可以对应不同的振动反馈效果。触摸振动反馈效果还可以支持自定义。
指示器192可以是指示灯,可以用于指示充电状态、电量变化,也可以用于指示消息、未接来电、通知等。
可以理解的是,本申请实施例示意的结构并不构成对电子设备的具体限定。在本申请另一些实施例中,电子设备可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。
本申请实施例中电子设备的软件系统可以采用分层架构、事件驱动架构、微核架构、微服务架构、或云架构。其中,分层架构(如,安卓(android)系统)将软件分成若干个层,每一层都有清晰的角色和分工,层与层之间通过软件接口通信。
具体的,图2示出本申请实施例的电子设备的一种软件结构框图,包括应用程序层、系统库、链接加载器(linker)和内核层。其中,应用程序层可以包括相机、图库、日历、通话、地图、导航、浏览器、蓝牙、音乐、视频、短信息等应用程序。
系统库可以为应用程序层内的应用程序提供动态链接库,例如整合动态链接库、或未被整合的动态链接库。其中,本申请实施例中整合动态链接库可以是编译器通过对多个被整合的动态链接库的源码编译得到的。具体的,整合动态链接库包括虚拟库列表段和N个二进制段。每个二进制段包括多个被整合的动态链接库中对应的二进制段的内容。此外,本申请实施例中未被整合的动态链接库、或被整合的动态链接库可以为基础动态链接库、或标准动态链接库。以安卓系统为例,libc、libc++、libpthread、libm等均为标准动态链接库、或基础动态链接库,编译器可以对安卓系统中的所有标准动态链接库的部分或者全部标准动态链接库的源码编译得到一个整合动态链接库。
内核层是硬件和软件之间的层。内核层至少包含显示驱动、摄像头驱动、音频驱动、传感器驱动。
linker位于系统库和内核层之间,可以用于加载应用程序的依赖库,例如整合动态链接库、或者未被整合的动态链接库等。其中,应用程序的依赖库可以理解为:手机运行应用程序需要使用或依赖的动态链接库。
以具有图1和图2所示结构的手机为例,结合整合动态链接库对本申请实施例进行详细介绍。
首先,本申请实施例对整合动态链接库进行介绍,以便于本领域技术人员的理解。
本申请实施例中整合动态链接库用于实现手机中安装的应用程序的正常运行,可以是编译器对多个被整合的动态链接库的源码编译得到的。示例的,以编译器对M个被整合的动态链接库的源码编译得到一个整合动态链接库为例。编译器针对M个被整合的动态链接库中每个被整合的动态链接库的源码进行编译得到一个静态链接库和一个动态连接库。进一步的,编译器对被整合的动态链接库的源码进行编译得到的静态链接库中包括的二进制 段为应用程序运行需要使用的二进制段。从而有助于节省存储空间。然后,编译器根据对每个被整合的动态链接库编译得到的静态链接库进行整合,得到一个整合动态链接库。具体的,编译器根据每个被整合的动态链接库的标识,得到虚拟库列表段,以及对每个被整合的动态链接库编译得到的静态链接库中相同类型的二进制段整合,得到N种二进制段,并根虚拟库列表段和N种二进制段生成整合动态链接库。也就是说,整合动态链接库包括虚拟库列表段和N种二进制段。每种二进制段包括M个被整合的动态链接库中对应二进制段中的内容。虚拟库列表段包括M个被整合的动态链接库的标识。例如,被整合的动态链接库的标识可以为被整合的动态链接库的虚拟名称(soname),也可以为其它指示被整合的动态链接库的标识,本申请实施例对此不作限定。
以安卓系统为例,编译器对libc、libc++和libpthrea的源码编译,得到一个整合动态链接库。该整合动态链接库包括虚拟库列表段、代码段、数据段和BSS段。其中,虚拟库列表段包括libc的标识、libc++的标识和libpthrea的标识。整合动态链接库的代码段包括libc的代码段、libc++的代码段和libpthrea的代码段中的内容。整合动态链接库的数据段包括libc的数据段、libc++的数据段和libpthrea的数据段中的内容。整合动态链接库的BSS段包括libc的BSS段、libc++的BSS段和libpthrea的BSS段中的内容。需要说明的是,代码段、数据段和BSS段均可以理解为一种二进制段。
另外,在安卓系统中,通常libc、libc++或者libpthrea等标准动态链接中除了包括代码段、数据段和BSS段以外,还可以包括符号表、过程链接表(procedure linkage table,PLT)和全局偏移量表等,但是由于符号表、PLT和全局偏移量表等在应用程序运行的过程中可能不使用或不调用,因此,编译器在对多个被整合的动态链接库的源码编译时,会将这些应用程序运行过程中不使用或不调用的段(section)不再编译到整合动态链接库中,有助于节省存储空间。
本申请实施例中,由于整合动态链接库的二进制段包括多个被整合的动态链接库的对应二进制段的内容,因此在段以页对齐的情况下,整合动态链接库与多个被整合动态链接库相比,更有助于降低运行空间内存的浪费。以整合动态链接库包括虚拟库列表段、代码段、数据段和BSS段为例。除虚拟库列表段以外,整合动态链接库的代码段、数据段和BSS段是通过对M个被整合的动态链接库中相应的二进制段中的内容整合得到的。例如,整合动态链接库是编译器通过对libc、libc++、libpthread、libm等200个被整合的动态链接库的源码编译得到的,在每个段均以页(4KB)对齐的情况下,当200个被整合的动态链接库未被编译成一个整合动态链接库时,这200个被整合的动态链接库中每个段均是以4KB对齐的,如果每个页平均浪费2KB,200个被整合的动态链接库大概要浪费200×3×4KB/2=1200KB左右。而当将这个200个被整合的动态链接库的源码编译成一个整合动态链接库后,该整合动态链接库包括虚拟库列表段、代码段、数据段和BSS段,在每个段均以页(4KB)对齐的情况下,如果每个页平均浪费2KB,整合动态链接库包括4个段,则整合动态链接库大概要浪费8KB,与200个被整合的动态链接库未被编译成一个整合动态链接库相比,大大降低了内存空间(例如运行内存空间、内置存储器存储空间)的浪费。
具体的,整合动态链接库是在手机出厂之前配置到内置存储器中的。示例的,整合动态链接库可以以可执行和可链接库格式(executable and linkable format,ELF)文件存储到内置存储器中。其中,ELF文件的格式如图3所示,包括ELF头(ELF header)、程序头表(program header table)、多个二进制段(section)(例如,section1、section2、……、sectionn 等)和段头表(section header table)。其中,程序头表中包括多个程序头(program header),每个程序头可以包括p_type、p_vaddr、p_offset、p_paddr、p_filesz、p_memsz、p_flags和p_align。需要说明的是,程序头表是可选的(optional),也就是说,ELF文件中可以包括程序头表,也可以不包括程序头表。段头表中包括多个段头。每个段头可以包括sh_name、sh_type、sh_flags、sh_addr、sh_offset、sh_size、sh_link、sh_link、sh_info、sh_addralign和sh_entsize。具体的,关于ELF头、程序头表、段和段头表的相关介绍可以参见维基百科中关于ELF文件的相关介绍,在此不再赘述。值得注意的是,对于整合动态链接库的ELF文件来说,多个段中包括虚拟库列表段。
此外,本申请实施例中,对于未被整合的标准动态链接库或者基础动态链接库来说,这些动态链接库可以是以ELF文件存储在内置存储器中的,ELF文件的格式也可以参见图3所示,但是这些动态链接库的ELF文件中不包括虚拟库列表段。
当动态链接库(例如整合动态链接库)从内置存储器被加载到运行内存之后,运行内存中存储的为ELF文件中的各二进制段。通常,在运行内存中,不存储ELF文件中的ELF头、程序头和段头表。以整合动态链接库包括虚拟库列表段和N种二进制段为例,当整合动态链接库被加载到运行内存之后,运行内存中存储的为虚拟库列表段和N种二进制段。
应理解,本申请实施例中,整合动态链接库可以为同名动态链接库,也可以为非同名动态链接库。
以安卓操作系统为例,整合动态链接库为同名动态链接库可以理解为:整合动态链接库的名称与安卓操作系统中的标准动态链接库或基础动态链接库同名。以整合动态链接库包括M个被整合的动态链接库为例,在整合动态链接库为同名动态链接库的情况下,整合动态链接库的名称为M个被整合的动态链接库中应用程序依赖的第一个被整合的动态链接库的名称。以使得手机可以针对该应用程序先加载整合动态链接库。
可以理解的是,M个被整合的动态链接库中,不同应用程序依赖的第一个被整合的动态链接库的名称可以相同,也可以不同。例如,M个被整合的动态链接库为安卓操作系统中的M个标准动态链接库,这M个标准动态链接库分别为标准动态链接库1~标准动态链接库M。例如,应用程序1依赖的第一个动态链接库为M个标准动态链接库中的标准动态链接库1,整合动态链接库的名称为标准动态链接库1的名称。需要说明的是,应用程序1依赖的第一个动态链接库,可以理解为,手机运行应用程序1首先使用或调用的动态链接库。再例如,应用程序2依赖的第一个动态链接库为M个标准动态链接库中的标准动态链接库M,则整合动态链接库的名称为标准动态链接库M的名称。此外,又例如,应用程序3依赖的第一个动态链接库为标准动态链接库N,而标准动态链接库N不是M个标准动态链接库中的动态链接库时,但是与标准动态链接库N存在依赖关系的动态链接库为标准动态链接库3时,则整合动态链接库的名称可以为标准动态链接库3的名称。其中,与标准动态链接库N存在依赖关系的动态链接库为标准动态链接库3,可以理解为:手机运行应用程序3先使用标准动态链接库N,再使用标准动态链接库3。
以安卓操作系统为例。本申请实施例中整合动态链接库为非同名动态链接库可以理解为:整合动态链接库的名称不同于安卓操作系统中的标准动态链接库或基础动态链接库的名称,例如libsystem。在这种情况下,为了使得手机中存在整合动态链接库的情况下,可以先使用整合动态链接库,手机可以预先加载整合动态链接库。
本申请实施例中,无论是整合动态链接库,还是未被整合的动态链接库,手机均需要 从内置存储器加载到运行内存中后,才可以被调用者(例如应用程序等)调用,实现应用程序的正常运行。示例的,本申请实施例中,手机可以启动应用程序后,运行应用程序之前,加载该应用程序的依赖库。例如,手机可以响应于用户打开某一应用程序的操作,加载该应用程序的依赖库,然后再根据该应用程序的依赖库,运行该应用程序。比如,打开某一应用程序的操作可以为点击该应用程序图标的操作、语音指令、或者快捷手势操作等,对此不作限定。又示例的,手机也可以在运行应用程序的过程中,使用动态链接库之前,加载该应用程序的依赖库。具体的,手机在运行应用程序的过程中,具体加载应用程序的依赖库的时机可以是研发人员在程序中预定义好的,也可以是手机基于预定义的算法,结合具体场景确定的,本申请实施例对比不作限定。
其中,该应用程序的依赖库可以为一个,也可以为多个,为手机中运行该应用程序需要使用或调用的动态链接库,例如整合动态链接库、未被整合的动态链接库等。
本申请实施例在引入整合动态链接库后,为了使得手机能够正常运行应用程序,使得调用者(如应用程序)能够获的动态链接库的句柄,提供了一种加载动态链接库的方法。以手机针对某一应用程序加载动态链接库A为例,当调用者请求加载动态链接库A时,加载动态链接库A。示例的,当应用程序向linker请求加载动态链接库A时,则使得linker响应于加载动态链接库A的请求执行加载动态链接库的方法。例如,应用程序当启动时,向linker请求加载动态链接库A。或者应用程序当运行时,向linker请求加载动态链接库A。比如,在具体实现时,手机可以在应用程序启动时或者在应用程序运行时,调用某一函数(例如,该函数可以是研发人员定义好的),实现调用者(如应用程序)向linker请求加载动态链接库A。
示例的,本申请实施例中加载动态链接库的方法,如图4所示,具体包括以下步骤。
步骤401,手机判断动态链接库A的标识是否在已加载动态库列表中,若不在,则执行步骤402,否则执行步骤406。其中,已加载动态库列表用于避免重复记载,以及记录已加载的动态链接库的标识以及与已加载的动态链接库的标识对应的句柄。即,已加载的动态链接库列表包括已加载的动态链接库的标识以及与已加载的动态链接库的标识对应的句柄。
步骤402,手机为动态链接库A分配句柄,并将动态链接库A的标识以及为动态链接库A分配的句柄添加到已加载动态库列表中。
步骤403,手机判断动态链接库A是否为整合动态链接库,若是,则执行步骤404,否则执行步骤405。
示例的,手机可以通过判断动态链接库A是否包括虚拟库列表段来判断动态链接库A是否为整合动态链接库。当动态链接库A包括虚拟库列表段时,动态链接库A为整合动态链接库,当动态链接库A不包括虚拟库列表段时,动态链接库A不为整合动态链接库。又示例的,手机还可以通过依赖库的名称判断依赖库是否为整合动态链接库。该种方式可以应用于整合动态链接库为非同名动态链接库的场景。此外,手机还可以通过某一字段或标识段来判断的动态链接库A是否为整合动态链接库,本申请实施例对手机判断整合动态链接库的方式不作限定。
步骤404,手机将动态链接库A的虚拟库列表段中的被整合的动态链接库的标识以及与被整合的动态链接库的句柄增加到已加载动态库列表中。其中,被整合的动态链接库的句柄为手机为动态链接库A分配的句柄,即动态链接库A的句柄。从而使得应用程序在需 要调用动态链接库A中的被整合动态链接路时,可以根据动态链接库A的句柄,实现对动态链接库A的重定位,以达到应用程序正常运行的目的。
例如,动态链接库A的虚拟列表段中的被整合的动态链接库的标识为libc的标识、libc++的标识和libpthrea的标识。手机为动态链接库A分配的句柄为句柄A,则libc、libc++和libpthrea的句柄也均为句柄A。如果应用程序调用的第一个依赖库为libc,则应用程序可以根据libc的标识对应的句柄A,重定位到动态链接库A,并根据动态链接库A运行应用程序。
步骤405,手机根据动态链接库A的句柄进行重定位,将动态链接库A加载到运行内存中。
步骤406,手机给调用者返回动态链接库列A的句柄。
示例的,在手机中的软件架构如图2所示的情况下,步骤401~步骤406可以是手机中的linker执行的,从而便于实现。
需要说明的是,步骤402和步骤403没有必然的先后顺序,但是步骤402和步骤403在步骤404之前。例如,手机可以先执行步骤403判断动态链接库A是否为整合动态链接库,然后执行步骤402,为动态链接库A分配句柄,并在分配句柄后,若动态链接库A为整合动态链接库,则执行步骤404,否则执行步骤405。
值得说明的是,在本申请实施例中,当应用程序存在多个依赖库的情况下,手机针对每个依赖库加载的流程可以参见图4中所示的加载动态链接库的方法。示例的,针对某一应用程序,手机根据该应用程序的依赖库之间的依赖顺序加载动态链接库。例如,应用程序A的依赖库分别为动态链接库1、动态链接库2和动态链接库3,动态链接库1为应用程序A依赖的第一个动态链接库,而动态链接库1依赖动态链接库2,动态链接库2依赖动态链接库3,则手机针对应用程序A先加载动态链接库1,再加载动态链接库2,最后加载动态链接库3。
此外,当应用程序存在多个依赖库的情况下,调用者(如应用程序)可以向linker循环请求加载动态链接库,而调用者向linker请求加载的动态链接库为应用程序的依赖库。示例的,调用者可以根据应用程序的依赖库之间的依赖顺序,向linker请求加载动态链接库,从而使得linker可以响应于循环加载动态链接库的请求,循环加载动态链接库。
进一步的,手机当针对某一应用程序,加载动态链接库完成后,即应用程序的依赖库加载完成后,手机可以根据已加载的动态链接库,运行该应用程序。示例的,应用程序的依赖库为被整合的动态链接库的情况下,手机根据整合动态链接库,运行该应用程序。
在应用程序的依赖库为多个,且这多个动态链接库均为被整合的动态链接库的情况下,由于这多个动态链接库均被整合到一个整合动态链接库中,因此,应用程序可以只需对整合动态链接库重定位一次,就可以从整合动态链接库中调用相应的函数或参数,而整合动态链接库中与该函数或参数存在依赖关系的其它函数或参数由于与重定位调用的函数或参数之间的地址偏移量是固定的,因此应用程序可以直接从整合动态链接库中读取,而无需再次重定位,从而有助于节省时间开销。
例如,如图5所示,整合动态链接库500包括虚拟库列表段501、代码段502、数据段503和BSS段504。其中,虚拟库列表段501包括libc的标识和libc++的标识。libc包括代码段1,libc++包括代码段2。其中代码段502包括代码段1和代码段2。代码段1包括函数f(y),代码段2包括函数y。应用程序可以根据整合动态链接库500的句柄和整合 动态链接库500的符号,调用函数f(y),但是函数f(y)的执行依赖于函数y,在整合动态链接库500中函数y和函数f(y)之间相对地址偏移量为L,是固定的,因此,应用程序可以无需调用函数y时无需再次重定位。
以上个各实施例可以单独使用,也可以相互结合使用,以实现不同的技术效果。
上述本申请提供的实施例中,从手机作为执行主体的角度对本申请实施例提供的方法进行了介绍。为了实现上述本申请实施例提供的方法中的各功能,手机可以包括硬件结构和/或软件模块,以软件模块或者硬件结构结合软件模块的形式来实现上述各功能。上述各功能中的某个功能以硬件结构、软件模块、还是硬件结构加软件模块的方式来执行,取决于技术方案的特定应用和设计约束条件。
如图6所示,为本申请实施例的一种装置的结构示意图。其中,装置600具体包括链接请求模块601和链接加载模块602。示例的,装置600包括链接请求模块601和链接加载模块602;其中,链接请求模块601用于接收加载第一动态链接库的请求;
链接加载模块602用于执行:
响应于加载第一动态链接库的请求,判断第一动态链接库的标识是否在已加载动态链接库列表中;
当第一动态链接库的标识不在已加载动态链接库列表中时,为第一动态链接库分配句柄,并将第一动态链接库的标识以及为第一动态链接库分配的句柄添加到已加载动态库列表中;
判断第一动态链接库是否为整合动态链接库;
当第一动态链接库为整合动态链接库时,将M被整合的动态链接库的标识以及为第一动态链接库分配的句柄添加到已加载动态链接库列表中,第一动态链接库是编译器对M个被整合的动态链接库的源码编译得到的;
根据为第一动态链接库分配的句柄对第一动态链接库重定位,并将第一动态链接库加载到电子设备的运行内存中。
如图7所示,本申请实施例公开了一种电子设备700,该电子设备700可以包括:一个或多个处理器701、和存储器702;以及一个或多个计算机可执行程序,上述各器件可以通过一个或多个通信总线连接。其中该一个或多个计算机可执行程序被存储在上述存储器702中并被配置为被该一个或多个处理器701执行,实现本申请实施例图7所示的动态链接库的加载方法。
上述各个实施例中涉及处理器可以是通用处理器、数字信号处理器(digital signal processor,DSP)、专用集成电路(application specific integrated circuit,ASIC)、现成可编程门阵列(field programmable gate array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存取存储器(random access memory,RAM)、闪存、只读存储器(read-only memory,ROM)、可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器,处理器读取存储器中的指令,结合其硬件完成上述方法的步骤。
具体的,上述装置700和电子设备800的具体实现方式可以参见方法部分的相关介绍, 在此不再赘述。
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器(processor)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到的变化或替换,都应涵盖在本申请的保护范围之内,因此本申请的保护范围应以权利要求的保护范围为准。

Claims (18)

  1. 一种动态链接库的加载方法,其特征在于,应用于电子设备,所述方法包括:
    响应于应用程序加载第一动态链接库的请求,判断所述第一动态链接库的标识是否在已加载动态链接库列表中;
    当所述第一动态链接库的标识不在所述已加载动态链接库列表中时,执行步骤A~C:
    步骤A,为所述第一动态链接库分配句柄,并将所述第一动态链接库的标识以及为所述第一动态链接库分配的句柄添加到已加载动态库列表中;
    步骤B,判断第一动态链接库是否为整合动态链接库;
    当所述第一动态链接库为整合动态链接库时,执行步骤1和步骤2,并在执行步骤2之后,执行步骤C;
    步骤1,将M个被整合的动态链接库的标识以及为所述第一动态链接库分配的句柄添加到所述已加载动态链接库列表中,所述第一动态链接库是通过对所述M个被整合的动态链接库的源码编译得到的,所述M为大于1的正整数;
    步骤2,根据为所述第一动态链接库分配的句柄对所述第一动态链接库重定位,并将所述第一动态链接库加载到所述电子设备的运行内存中;
    步骤C,向所述应用程序返回为所述第一动态链接库分配的句柄。
  2. 如权利要求1所述的方法,其特征在于,所述第一动态链接库包括虚拟库列表段和N个二进制段,其中,虚拟库列表段包括所述M个被整合的动态链接库的标识,N个二进制段中的任意一个二进制段包括所述M个被整合的动态链接库中对应的二进制段的内容;所述N为大于或等于1的正整数。
  3. 如权利要求1或2所述的方法,其特征在于,响应于应用程序加载第一动态链接库的请求,包括:
    在所述应用程序启动时,响应于所述应用程序循环加载所述应用程序的依赖库的请求,所述第一动态链接库为所述应用程序的依赖库之一;或者,
    在所述应用程序运行时,响应于所述应用程序加载所述第一动态链接库的请求。
  4. 如权利要求1至3任一所述的方法,其特征在于,所述第一动态链接库是通过对所述M个被整合的动态链接库的源码编译得到的,包括:
    所述第一动态链接库是通过对M个静态链接库整合得到的;所述M个静态链接库中每个静态链接库是通过对所述M个被整合的动态链接库的源码中对应源码编译得到的。
  5. 如权利要求1至4任一所述的方法,其特征在于,所述响应于应用程序加载第一动态链接库的请求,判断第一动态链接库的标识是否在已加载动态链接库列表中之后,还包括:
    当所述第一动态链接库的标识在所述已加载动态链接库列表中时,执行步骤D,并在执行步骤D之后执行步骤C;
    步骤D,根据所述已加载动态链接库列表中所述第一动态链接库的标识,获得所述第一动态链接库的句柄。
  6. 如权利要求1至4任一所述的方法,其特征在于,在执行步骤B判断第一动态链接库是否为整合动态链接库之后,还包括:
    当所述第一动态链接库不为整合动态链接库时,执行步骤3,并在执行步骤3之 后,执行步骤C;
    步骤3,根据为所述第一动态链接库分配的句柄对所述第一动态链接库重定位,并将所述第一动态链接库加载到所述电子设备的运行内存中。
  7. 如权利要求2至6任一所述的方法,其特征在于,所述判断第一动态链接库是否为整合动态链接库,包括:
    判断所述第一动态链接库是否包括虚拟库列表段;其中,当所述第一动态链接库包括虚拟列表段时,所述第一动态链接库为整合动态链接库;或者,
    判断所述第一动态链接库的标识是否为预定义的标识,其中,当所述第一动态链接库的标识为所述预定义的标识时,所述第一动态链接库为整合动态链接库。
  8. 一种装置,其特征在于,所述装置包括链接请求模块和链接加载模块;
    所述链接请求模块,用于接收应用程序加载第一动态链接库的请求;
    所述链接加载模块,用于:
    响应于加载所述第一动态链接库的请求,判断第一动态链接库的标识是否在已加载动态链接库列表中;
    当所述第一动态链接库的标识不在所述已加载动态链接库列表中时,用于执行步骤A~C;
    步骤A,为所述第一动态链接库分配句柄,并将所述第一动态链接库的标识以及为所述第一动态链接库分配的句柄添加到已加载动态库列表中;
    步骤B,判断第一动态链接库是否为整合动态链接库;
    当所述第一动态链接库为整合动态链接库时,执行步骤1和步骤2,并在执行步骤2之后,执行步骤C;
    步骤1,将M被整合的动态链接库的标识以及为所述第一动态链接库分配的句柄添加到所述已加载动态链接库列表中,所述第一动态链接库是通过对所述M个被整合的动态链接库的源码编译得到的;
    步骤2,根据为所述第一动态链接库分配的句柄对所述第一动态链接库重定位,并将所述第一动态链接库加载到所述电子设备的运行内存中;
    步骤C,向所述应用程序返回为所述第一动态链接库分配的句柄。
  9. 如权利要求8所述的装置,其特征在于,所述第一动态链接库包括虚拟库列表段和N个二进制段,其中,虚拟库列表段包括所述M个被整合的动态链接库的标识,N个二进制段中的任意一个二进制段包括所述M个被整合的动态链接库中对应的二进制段的内容;所述N为大于或等于1的正整数。
  10. 如权利要求7或8所述的装置,其特征在于,响应于应用程序加载第一动态链接库的请求,包括:
    在所述应用程序启动时,响应于所述应用程序循环加载所述应用程序的依赖库的请求,所述第一动态链接库为所述应用程序的依赖库之一;或者,
    在所述应用程序运行时,响应于所述应用程序加载所述第一动态链接库的请求。
  11. 如权利要求8至10任一所述的装置,其特征在于,所述第一动态链接库是通过对所述M个被整合的动态链接库的源码编译得到的,包括:
    所述第一动态链接库是通过对M个静态链接库整合得到的;所述M个静态链接库中每个静态链接库是通过对所述M个被整合的动态链接库的源码中对应源码编译得到的。
  12. 如权利要求8至11任一所述的装置,其特征在于,所述链接加载模块在响应于应用程序加载第一动态链接库的请求,判断第一动态链接库的标识是否在已加载动态链接库列表中之后,还用于:
    当所述第一动态链接库的标识在所述已加载动态链接库列表中时,执行步骤D,并在执行步骤D之后执行步骤C;
    步骤D,根据所述已加载动态链接库列表中所述第一动态链接库的标识,获得所述第一动态链接库的句柄。
  13. 如权利要求8至12任一所述的装置,其特征在于,所述链接加载模块在执行步骤B判断第一动态链接库是否为整合动态链接库之后,还用于:
    当所述第一动态链接库不为整合动态链接库时,执行步骤3,并在执行步骤3之后,执行步骤C;
    步骤3,根据为所述第一动态链接库分配的句柄对所述第一动态链接库重定位,并将所述第一动态链接库加载到所述电子设备的运行内存中。
  14. 如权利要求9至13任一所述的装置,其特征在于,所述判断第一动态链接库是否为整合动态链接库,包括:
    判断所述第一动态链接库是否包括虚拟库列表段;其中,当所述第一动态链接库包括虚拟列表段时,所述第一动态链接库为整合动态链接库;或者,
    判断所述第一动态链接库的标识是否为预定义的标识,其中,当所述第一动态链接库的标识为所述预定义的标识时,所述第一动态链接库为整合动态链接库。
  15. 一种电子设备,其特征在于,所述电子设备包括处理器和存储器,所述存储器存储有计算机可执行程序,所述处理器调用所述计算机可执行程序,使得所述电子设备执行如权利要求1至7任一所述方法。
  16. 一种芯片,其特征在于,所述装置与存储器耦合,使得所述装置在运行时调用所述存储器中存储的计算机可执行程序,实现如权利要求1至7任一所述的方法。
  17. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质包括计算机可执行程序,当计算机可执行程序在所述电子设备上运行时,使得所述电子设备执行如权利要求1至7任一所述的方法。
  18. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质包括整合动态链接库,当所述整合动态链接库在所述电子设备上被加载时,使得所述电子设备执行如权利要求1至7任一所述的方法。
PCT/CN2020/132417 2020-01-31 2020-11-27 一种动态链接库的加载方法及装置 WO2021151350A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP20916877.2A EP4086761A4 (en) 2020-01-31 2020-11-27 METHOD AND APPARATUS FOR LOADING A DYNAMIC LINK LIBRARY
US17/796,454 US11886222B1 (en) 2020-01-31 2020-11-27 Dynamic link library loading method and apparatus

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010077751.9 2020-01-31
CN202010077751.9A CN113204377B (zh) 2020-01-31 2020-01-31 一种动态链接库的加载方法及装置

Publications (1)

Publication Number Publication Date
WO2021151350A1 true WO2021151350A1 (zh) 2021-08-05

Family

ID=77024795

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/132417 WO2021151350A1 (zh) 2020-01-31 2020-11-27 一种动态链接库的加载方法及装置

Country Status (4)

Country Link
US (1) US11886222B1 (zh)
EP (1) EP4086761A4 (zh)
CN (1) CN113204377B (zh)
WO (1) WO2021151350A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114237742A (zh) * 2021-12-10 2022-03-25 北京奇艺世纪科技有限公司 一种动态库的加载编译方法、装置、终端及存储介质
CN117135448A (zh) * 2023-02-24 2023-11-28 荣耀终端有限公司 拍摄的方法和电子设备

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114528037B (zh) * 2021-12-31 2024-03-12 北京达佳互联信息技术有限公司 一种应用启动方法、装置、电子设备及存储介质
CN114564150B (zh) * 2022-02-28 2024-03-22 无锡江南计算技术研究所 动态链接模式片上存储器空间分配方法

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160321089A1 (en) * 2015-04-30 2016-11-03 Microsoft Technology Licensing, Llc Binary file generation
CN106775744A (zh) * 2016-12-28 2017-05-31 北京五八信息技术有限公司 一种生成静态库的方法和装置
CN107291513A (zh) * 2017-07-04 2017-10-24 武汉斗鱼网络科技有限公司 文件加载方法及装置、计算机可读存储介质
CN107391190A (zh) * 2017-07-18 2017-11-24 杭州中天微系统有限公司 一种程序模块动态装载方法
CN109814939A (zh) * 2017-11-20 2019-05-28 华为技术有限公司 一种动态加载方法、目标文件的制作方法及装置

Family Cites Families (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5375241A (en) 1992-12-21 1994-12-20 Microsoft Corporation Method and system for dynamic-link library
US5633654A (en) * 1993-11-12 1997-05-27 Intel Corporation Computer-implemented process and computer system for raster displaying video data using foreground and background commands
CA2143488C (en) 1995-02-27 2000-01-11 Robert Paul Duncan Dynamic link libraries without linker or loader support
US6363436B1 (en) 1997-01-27 2002-03-26 International Business Machines Corporation Method and system for loading libraries into embedded systems
US20060026584A1 (en) * 2004-07-27 2006-02-02 Muratori Richard D Explicit linking of dynamic link libraries
US7735075B2 (en) 2005-12-01 2010-06-08 Samsung Electronics Co., Ltd. System and method for a pseudo dynamic link library (DLL) linker for a monolithic image in a wireless device
US7761591B2 (en) * 2005-12-16 2010-07-20 Jean A. Graham Central work-product management system for coordinated collaboration with remote users
US7886285B2 (en) * 2006-03-14 2011-02-08 International Business Machines Corporation Combining software executable libraries
EP2477110A1 (en) * 2011-01-14 2012-07-18 Wibu-Systems AG Method for protecting an application program against reverse engineering and related computer program product
CN103488466B (zh) 2012-06-11 2017-02-08 联想(北京)有限公司 用于执行应用程序的方法和装置
US10678893B2 (en) * 2015-01-18 2020-06-09 Frederic Scott Deaver Methods and related apparatus for managing access to digital assets
CN106293880B (zh) 2016-08-10 2019-12-13 北京奇虎科技有限公司 在Windows系统上运行Android应用程序的方法及装置
CN109542043A (zh) * 2018-10-31 2019-03-29 武汉华中数控股份有限公司 一种基于插件的数控系统管理方法及装置

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160321089A1 (en) * 2015-04-30 2016-11-03 Microsoft Technology Licensing, Llc Binary file generation
CN106775744A (zh) * 2016-12-28 2017-05-31 北京五八信息技术有限公司 一种生成静态库的方法和装置
CN107291513A (zh) * 2017-07-04 2017-10-24 武汉斗鱼网络科技有限公司 文件加载方法及装置、计算机可读存储介质
CN107391190A (zh) * 2017-07-18 2017-11-24 杭州中天微系统有限公司 一种程序模块动态装载方法
CN109814939A (zh) * 2017-11-20 2019-05-28 华为技术有限公司 一种动态加载方法、目标文件的制作方法及装置

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114237742A (zh) * 2021-12-10 2022-03-25 北京奇艺世纪科技有限公司 一种动态库的加载编译方法、装置、终端及存储介质
CN114237742B (zh) * 2021-12-10 2023-09-01 北京奇艺世纪科技有限公司 一种动态库的加载编译方法、装置、终端及存储介质
CN117135448A (zh) * 2023-02-24 2023-11-28 荣耀终端有限公司 拍摄的方法和电子设备

Also Published As

Publication number Publication date
US20230342164A1 (en) 2023-10-26
CN113204377B (zh) 2022-12-06
US11886222B1 (en) 2024-01-30
CN113204377A (zh) 2021-08-03
EP4086761A1 (en) 2022-11-09
EP4086761A4 (en) 2023-04-19

Similar Documents

Publication Publication Date Title
WO2021151350A1 (zh) 一种动态链接库的加载方法及装置
EP4002108B1 (en) Application start method and electronic device
WO2020108356A1 (zh) 一种应用显示方法及电子设备
WO2021027630A9 (zh) 补丁方法、相关装置及系统
WO2021159746A1 (zh) 文件共享方法、系统及相关设备
WO2021121052A1 (zh) 一种多屏协同方法、系统及电子设备
WO2021052311A1 (zh) 一种根据后壳颜色显示用户界面的方法和电子设备
WO2021218429A1 (zh) 应用窗口的管理方法、终端设备及计算机可读存储介质
WO2021042991A1 (zh) 一种非侵入式交互方法及电子设备
CN114498028B (zh) 数据传输方法、装置、设备及存储介质
CN113656089B (zh) 应用程序中的类验证方法和装置
WO2022228065A1 (zh) 功能跳转方法及电子设备
CN115022982B (zh) 多屏协同无感接入方法、电子设备及存储介质
WO2021238376A1 (zh) 功能包的加载方法、装置、服务器和电子设备
CN115878500A (zh) 内存回收方法、装置、电子设备及可读存储介质
CN114398108A (zh) 电子设备及其驱动加载方法、介质
CN113971034A (zh) 安装应用的方法和电子设备
WO2024131458A1 (zh) 应用下载方法、服务器、电子设备及系统
WO2024083114A1 (zh) 一种软件分发方法、电子设备及系统
CN113760239A (zh) 应用程序开发方法、装置、终端设备及可读存储介质
CN115866668A (zh) 蓝牙空口射频性能测试方法与装置、电子设备
CN117130680A (zh) 一种芯片资源的调用方法及电子设备
CN116699513A (zh) 测距方法、装置、系统及可读存储介质
CN117707662A (zh) 界面显示方法及电子设备
CN114692132A (zh) 应用程序管控方法、装置、电子设备及可读存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20916877

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2020916877

Country of ref document: EP

Effective date: 20220804

NENP Non-entry into the national phase

Ref country code: DE