Data processing method and related apparatuses

The merged shared library (MSL) addresses inefficiencies in shared library management by combining dependent libraries, reducing memory consumption and improving loading efficiency while maintaining compatibility with existing applications.

WO2026089625A1PCT designated stage Publication Date: 2026-04-30HUAWEI TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
PCT/RU2024/000326
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2024-10-22
Publication Date
2026-04-30

AI Technical Summary

Technical Problem

Existing shared library management systems in Linux-based systems face inefficiencies due to high memory consumption and performance degradation caused by the PLT/GOT mechanism, particularly when dealing with numerous dependencies among shared libraries.

Method used

A merged shared library (MSL) is introduced, which combines multiple shared libraries with dependencies, eliminating the need for PLT/GOT calls and reducing memory consumption by loading only the requested parts, while maintaining compatibility with existing applications without requiring changes.

Benefits of technology

The MSL reduces memory consumption and improves loading efficiency by optimizing shared library interactions, ensuring correct loading without altering user applications, thus enhancing performance in systems with high dependency counts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure IMGF000049_0001
    Figure IMGF000049_0001
  • Figure 00000054_0000
    Figure 00000054_0000
  • Figure 00000054_0001
    Figure 00000054_0001
Patent Text Reader

Abstract

Embodiments of the present disclosure provide a data processing method and related apparatuses. Execution information of a first shared library called by a program is loaded by a device based on a merged shared library (MSL) and in response to an instruction for executing a program, where the MSL includes execution information of each of multiple shared libraries, the multiple shared libraries include the first shared library, and at least two of the multiple shared libraries have a dependency therebetween. In this way, the execution information of the first shared library is loaded based on the MSL obtained by merging the multiple shared libraries, since the MSL records execution information of all the multiple shared libraries, so for any two of them which have a dependency therebetween, they can be loaded simply based on the MSL, so the use of the MSL would facilitate the loading process, in this way, PLT(Procedure Linkage Table) / GOT(Global Offset Table) can be eliminated by calls in the MSL and the memory consumption can be reduced, and only the requested part (that is, part related to the first shared library) in the MSL is loaded, so as to further reduce the memory consumption and improve the loading efficiency; in addition, there is no need to change the program (user side), so as to allow the MSL solution to be applied to the existing program (which is also referred to as processes / application mentioned below) without rebuilding it and get benefits without any additional workload related to the program.
Need to check novelty before this filing date? Find Prior Art

Description

DATA PROCESSING METHOD AND RELATED APPARATUSESTECHNICAL FIELD

[0001] The present disclosure relates to the field of shared library technologies, and in particular, to a data processing method and related apparatuses.BACKGROUND

[0002] Usage of shared libraries (particularly in a Linux-based systems) is a common way to manage application’s dependencies. The shared libraries would be loaded by a dynamic loader at the beginning of the execution of the application, so as to ensure correct running of the application.

[0001] This background information is provided to reveal information believed by the applicant to be of possible relevance to the present disclosure. No admission is necessarily intended, nor should be construed, that any one of the preceding information constitutes prior art against the present disclosure.SUMMARY

[0001] In a first aspect, a data processing method is provided by the embodiment of the present disclosure, and the method includes:loading, by a device based on a merged shared library (MSL) and in response to an instruction for executing a program, execution information of a first shared library called by the program, where the MSL includes execution information of each of multiple shared libraries, the multiple shared libraries include the first shared library, and at least two of the multiple shared libraries have a dependency therebetween.

[0002] In this way, the execution information of the first shared library is loaded based on the MSL obtained by merging the multiple shared libraries, since the MSL records execution information of all the multiple shared libraries, so for any two of them which have a dependencytherebetween, they can be loaded simply based on the MSL, so the use of the MSL would facilitate the loading process, in this way, PLT(Procedure Linkage Table) / GOT(Global Offset Table) can be eliminated by calls in the MSL and the memory consumption can be reduced, and only the requested part (that is, part related to the first shared library) in the MSL is loaded, so as to further reduce the memory consumption and improve the loading efficiency; in addition, there is no need to change the program (user side), so as to allow the MSL solution to be applied to the existing program (which is also referred to as processes / application mentioned below) without rebuilding it and get benefits without any additional workload related to the program.

[0003] In a possible implementation of the first aspect, the first shared library depends on at least one second shared library included the multiple shared libraries, and the method further includes:loading, by the device based on the MSL and a dependency between the first shared library and each of the at least one second shared library in the multiple shared libraries, execution information of each of the at least one second shared library in the multiple shared libraries.

[0004] In the case where the first shared library has a dependency with a shared library in the MSL, there is no need to load the two shared libraries by PLT / GOT mechanism, and only the requested part (that is, part related to the first shared library) in the MSL is loaded, thereby reducing the memory consumption and improving loading efficiency.

[0005] In a possible implementation of the first aspect, for each of the at least one second shared library, the dependency between the first shared library and the second shared library is represented by execution of one or more functions in the second shared library being called by execution of one or more functions in the first shared library.

[0006] The first shared library depending on the at least one second shared library is reflected by the function(s) in the first shared library calling execution of the function(s) in each of the at least one second shared library when the first shared library is being executed.

[0007] In a possible implementation of the first aspect, the loading of the first shared library includes:checking, by the device in response to the instruction for executing the program, whether there is a link between the first shared library and the MSL;loading, by the device, when there is a link between the first shared library and the MSL, the execution information of the first shared library from the MSL based on the link betweenthe first shared library and the MSL, where the link is indicative of the first shared library.

[0008] The multiple shared libraries that are merged into the MSL are replaced with links to MSL, no changes need to be made from user process / application side, and each of the multiple shared libraries can be loaded correctly by its corresponding link, which reducing the memory consumption and improving the preference of calling the shared libraries.

[0009] In a possible implementation of the first aspect, the execution information of each of the multiple shared libraries includes attribute information of each of the multiple shared libraries, first sections parsed from each of the multiple shared libraries and second sections for each of the multiple shared libraries generated based on the first sections, where the attribute information of each of the multiple shared libraries is used for determining metadata of each of the multiple shared libraries.

[0010] The MSL includes all necessary information related to each of the multiple shared libraries, so that the shared library can maintain its original sections for this shared library before the merging, and the original sections which are presented as first sections in the MSL, can be loaded correctly based on the attribute information of the shared library and third section.

[0011] In a possible implementation of the first aspect, where the loading of the first shared library includes:constructing, by the device, a variable of the first shared library when loading the first shared library;where the method further includes:deconstructing, by the device, the variable of the first shared library when the execution of the program is finished.

[0012] In a possible implementation of the first aspect, at least two of the first sections with a same postfix are from a same shared library.

[0013] Each of the first sections can be identified by its postfix to determine to which shared library it belongs, which further facilitates the correct loading of the shared library.

[0014] In a possible implementation of the first aspect, the MSL includes a first part and a second part;where the first part of the MSL includes the first sections parsed from each of the multiple shared libraries, the second sections for each of the multiple shared libraries and a thirdsection; the third section includes the attribute information of each of the multiple shared libraries and is indicative of the first sections, the second sections and information about dependencies among the multiple shared libraries, where each of the dependencies among the multiple shared libraries is represented by execution of one or more functions in one of the multiple shared libraries being called by execution of one or more functions in another one of the multiple shared libraries;where the second part of the MSL is indicative of the third section and the first sections parsed from each of the multiple shared libraries.

[0015] The third section of the MSL can be read based on the second part, and the first sections and the second sections included in the second part can be further read based on the third section, which further facilitates the correct loading of the shared library.

[0016] In a possible implementation of the first aspect, the second part includes a first header and multiple second headers corresponding to the multiple shared libraries one-by-one;where the first header is indicative of a type of the MSL, the third section and a reference to the second header;where for each of the multiple second headers, the second header is indicative of first sections parsed from a shared library corresponding to the second header.

[0017] In a possible implementation of the first aspect, the second sections for each of the multiple shared libraries include at least one fourth section and information of at least one function included in each of the multiple shared libraries, where the at least one fourth section is generated based on the functions included in the multiple shared libraries and the information about the dependencies among the multiple shared libraries.

[0018] Based the generated fourth section and information of at least one function in each of the multiple shared libraries, information about functions included in each of the multiple shared libraries can be maintained, thereby reducing the memory consumption on the premise of maintaining the original sections for realizing the original functions of the multiple shared libraries.

[0019] In a possible implementation of the first aspect, information of at least one function included in a same shared library occupies a block of contiguous memory addresses. In this way, the memory consumption can be reduced.

[0020] In a possible implementation of the first aspect, the third section includes a third header, multiple fifth sections corresponding to the multiple shared libraries one-by-one, and a sixthsection;where the third header is indicative of each of the multiple fifth sections and the sixth section;where each of the multiple fifth sections is used for storing the attribute information of each of the multiple shared libraries;where the sixth section is used for storing data indicated by the attribute information of each of the multiple shared libraries.

[0021] The third section of the MSL can be read based on the third header, and the fifth sections can be further read based on the third section, which further facilitates the correct loading of the shared library.

[0022] In a possible implementation of the first aspect, for each of the multiple shared libraries, the attribute information of the shared library indicated by a corresponding fifth section includes:an original name of the shared library;a reference to a memory address of information of at least one function included in the shared library;a reference to a memory address of a second header corresponding to the shared library, where the memory address of the second header corresponding to the shared library is stored in the sixth section.

[0023] In a possible implementation of the first aspect, the indication of the original name of the shared library includes an indication of a memory address where the original name of the shared library is stored and an indication of a hash value of the original name of the shared library.

[0024] In a possible implementation of the first aspect, for a shared library in the multiple shared libraries which depends on at least one external shared library, the second sections for the shared library further include at least one specific section from the at least one external shared library;the attribute information of the shared library indicated by a corresponding fifth section includes:a reference to a memory address of the at least one specific section from the at least one external shared library, where the memory address of the at least one specific section is stored in the sixth section;a reference to each of the at least one external shared library.

[0025] Since the MSL can also be formed by integrating specific section(s) from external shared library, so when there is a shared library in the MSL which depends on an external shared library, the external shared library can be loaded based on the MSL, thus ensuring the correct loading of the shared library.

[0026] In a possible implementation of the first aspect, for a shared library in the multiple shared libraries, the attribute information of the shared library indicated by a corresponding fifth section includes at least one of:at least one variable related to the shared library;a reference to an index of a fifth section of each of at least one shared library in the multiple shared libraries on which the shared library depends, where the index of the fifth section of each of the at least one shared library is stored in the sixth section.

[0027] Based on items included in the attribute information of the shared library indicated by the corresponding fifth section, the shared library can be loaded correctly and efficiently.

[0028] In a possible implementation of the first aspect, the third header is indicative of:a version of the MSL;a size of the third header;a size of the multiple fifth sections;a hash algorithm for obtaining an original name of each of the multiple shared libraries; a size of a memory reserved for the MSL when memory mapping is performed; a memory address of the sixth section;a memory address of at least one fourth section shared among the multiple shared libraries.

[0029] In a possible implementation of the first aspect, the indication of the size of the multiple fifth sections includes an indication of a size of each of the multiple fifth sections in the third section and an indication of a number of the multiple shared libraries.

[0030] In a possible implementation of the first aspect, the indication of the memory address of the sixth section includes an indication of a start of the memory address of the sixth section and an indication of a size of the sixth section.

[0031] The third section can be read correctly and efficiently based on the above items indicated in the third header, so that the first sections and second sections in the MSL can be further readbased on the third section, thereby improving the preference of calling the shared libraries.

[0032] In a second aspect, a data processing apparatus is provided by the embodiment of the present disclosure, and the apparatus includes:a loading module, configured to load, based on a merged shared library (MSL) in response to an instruction for executing a program, execution information of a first shared library called by the program, where the MSL includes execution information of each of multiple shared libraries, the multiple shared libraries include the first shared library, and at least two of the multiple shared libraries have a dependency therebetween.

[0033] In this way, the execution information of the first shared library is loaded based on the MSL obtained by merging the multiple shared libraries, since the MSL records execution information of all the multiple shared libraries, so for any two of them which have a dependency therebetween, they can be loaded simply based on the MSL, so the use of the MSL would facilitate the loading process, in this way, PLT(Procedure Linkage Table) / GOT(Global Offset Table) can be eliminated by calls in the MSL and the memory consumption can be reduced, and only the requested part (that is, part related to the first shared library) in the MSL is loaded, so as to further reduce the memory consumption and improve the loading efficiency; in addition, there is no need to change the program (user side), so as to allow the MSL solution to be applied to the existing program (which is also referred to as processes / application mentioned below) without rebuilding it and get benefits without any additional workload related to the program.

[0034] In a possible implementation of the second aspect, the first shared library depends on at least one second shared library included the multiple shared libraries, and the loading module is further configured to:load, based on the MSL and a dependency between the first shared library and each of the at least one second shared library in the multiple shared libraries, execution information of each of the at least one second shared library in the multiple shared libraries.

[0035] In the case where the first shared library has a dependency with a shared library in the MSL, there is no need to load the two shared libraries by PLT / GOT mechanism, and only the requested part (that is, part related to the first shared library) in the MSL is loaded, thereby reducing the memory consumption and improving loading efficiency.

[0036] In a possible implementation of the second aspect, for each of the at least one secondshared library, the dependency between the first shared library and the second shared library is represented by execution of one or more functions in the second shared library being called by execution of one or more functions in the first shared library.

[0037] In a possible implementation of the second aspect, the loading module is further configured to:check, in response to the instruction for executing the program, whether there is a link between the first shared library and the MSL;load, when there is a link between the first shared library and the MSL, the execution information of the first shared library from the MSL based on the link between the first shared library and the MSL, where the link is indicative of the first shared library.

[0038] The multiple shared libraries that are merged into the MSL are replaced with links to MSL, no changes need to be made from user process / application side, and each of the multiple shared libraries can be loaded correctly by its corresponding link, which reducing the memory consumption and improving the preference of calling the shared libraries.

[0039] In a possible implementation of the second aspect, the execution information of each of the multiple shared libraries includes attribute information of each of the multiple shared libraries, first sections parsed from each of the multiple shared libraries and second sections for each of the multiple shared libraries generated based on the first sections, the attribute information of each of the multiple shared libraries is used for determining metadata of each of the multiple shared libraries.

[0040] The MSL includes all necessary information related to each of the multiple shared libraries, so that the shared library can maintain its original sections for this shared library before the merging, and the original sections which are presented as first sections in the MSL, can be loaded correctly based on the attribute information of the shared library and third section.

[0041] In a possible implementation of the second aspect, where the loading module is further configured to:construct a variable of the first shared library when loading the first shared library; deconstruct the variable of the first shared library when the execution of the program is finished.

[0042] In a possible implementation of the second aspect, at least two of the first sections with asame postfix are from a same shared library.

[0043] Each of the first sections can be identified by its postfix to determine to which shared library it belongs, which further facilitates the correct loading of the shared library.

[0044] In a possible implementation of the second aspect, the MSL includes a first part and a second part;where the first part of the MSL includes the first sections parsed from each of the multiple shared libraries, the second sections for each of the multiple shared libraries and a third section; the third section includes the attribute information of each of the multiple shared libraries and is indicative of the first sections, the second sections and information about dependencies among the multiple shared libraries, where each of the dependencies among the multiple shared libraries is represented by execution of one or more functions in one of the multiple shared libraries being called by execution of one or more functions in another one of the multiple shared libraries;where the second part of the MSL is indicative of the third section and the first sections parsed from each of the multiple shared libraries.

[0045] The third section of the MSL can be read based on the second part, and the first sections and the second sections included in the second part can be further read based on the third section, which further facilitates the correct loading of the shared library.

[0046] In a possible implementation of the second aspect, the second part includes a first header and multiple second headers corresponding to the multiple shared libraries one-by-one;where the first header is indicative of a type of the MSL, the third section and a reference to the second header;where for each of the multiple second headers, the second header is indicative of first sections parsed from a shared library corresponding to the second header.

[0047] In a possible implementation of the second aspect, the second sections for each of the multiple shared libraries include at least one fourth section and information of at least one function included in each of the multiple shared libraries, where the at least one fourth section is generated based on the functions included in the multiple shared libraries and the information about the dependencies among the multiple shared libraries.

[0048] Based the generated fourth section and information of at least one function in each of the multiple shared libraries, information about functions included in each of the multiple sharedlibraries can be maintained, thereby reducing the memory consumption on the premise of maintaining the original sections for realizing the original functions of the multiple shared libraries.

[0049] In a possible implementation of the second aspect, information of at least one function included in a same shared library occupies a block of contiguous memory addresses. In this way, the memory consumption can be reduced.

[0050] In a possible implementation of the second aspect, the third section includes a third header, multiple fifth sections corresponding to the multiple shared libraries one-by-one, and a sixth section;where the third header is indicative of each of the multiple fifth sections and the sixth section;where each of the multiple fifth sections is used for storing the attribute information of each of the multiple shared libraries;where the sixth section is used for storing data indicated by the attribute information of each of the multiple shared libraries.

[0051] The third section of the MSL can be read based on the third header, and the fifth sections can be further read based on the third section, which further facilitates the correct loading of the shared library.

[0052] In a possible implementation of the second aspect, for each of the multiple shared libraries, the attribute information of the shared library indicated by a corresponding fifth section includes:an original name of the shared library;a reference to a memory address of information of at least one function included in the shared library;a reference to a memory address of a second header corresponding to the shared library, where the memory address of the second header corresponding to the shared library is stored in the sixth section.

[0053] In a possible implementation of the second aspect, the indication of the original name of the shared library includes an indication of a memory address where the original name of the shared library is stored and an indication of a hash value of the original name of the shared library.

[0054] In a possible implementation of the second aspect, for a shared library in the multiple shared libraries which depends on at least one external shared library, the second sections for theshared library further include at least one specific section from the at least one external shared library;the attribute information of the shared library indicated by a corresponding fifth section includes:a reference to a memory address of the at least one specific section from the at least one external shared library, where the memory address of the at least one specific section is stored in the sixth section;a reference to each of the at least one external shared library.

[0055] Since the MSL can also be formed by integrating specific section(s) from external shared library, so when there is a shared library in the MSL which depends on an external shared library, the external shared library can be loaded based on the MSL, thus ensuring the correct loading of the shared library.

[0056] In a possible implementation of the second aspect, for a shared library in the multiple shared libraries, the attribute information of the shared library indicated by a corresponding fifth section includes at least one of:at least one variable related to the shared library;a reference to an index of a fifth section of each of at least one shared library in the multiple shared libraries on which the shared library depends, where the index of the fifth section of each of the at least one shared library is stored in the sixth section.

[0057] Based on items included in the attribute information of the shared library indicated by the corresponding fifth section, the shared library can be loaded correctly and efficiently.

[0058] In a possible implementation of the second aspect, the third header is indicative of:a version of the MSL;a size of the third header;a size of the multiple fifth sections;a hash algorithm for obtaining an original name of each of the multiple shared libraries; a size of a memory reserved for the MSL when memory mapping is performed; a memory address of the sixth section;a memory address of at least one fourth section shared among the multiple shared libraries.

[0059] In a possible implementation of the second aspect, the indication of the size of the multiple fifth sections includes an indication of a size of each of the multiple fifth sections in the third section and an indication of a number of the multiple shared libraries.

[0060] In a possible implementation of the second aspect, the indication of the memory address of the sixth section includes an indication of a start of the memory address of the sixth section and an indication of a size of the sixth section.

[0061] The third section can be read correctly and efficiently based on the above items indicated in the third header, so that the first sections and second sections in the MSL can be further read based on the third section, thereby improving the preference of calling the shared libraries.

[0062] In a third aspect, a computing device cluster is provided by the embodiment of the present disclosure, including a processing circuitry for performing the data processing method according to the first aspect or any possible implementation of the first aspect.

[0063] In a fourth aspect, a computer program product is provided by the embodiment of the present disclosure, and the computer program product includes computer execution instructions which, when executed by a processor, cause the processor to execute the data processing method according to the first aspect or any possible implementation of the first aspect.

[0064] In a fifth aspect, a computer program is provided by the embodiment of the present disclosure, and the computer program includes computer execution instructions which, when executed by a processor, cause the processor to execute the data processing method according to the first aspect or any possible implementation of the first aspect.

[0065] In a sixth aspect, an electronic device is provided by the embodiment of the present disclosure, and the electronic device includes processing circuitry for executing the data processing method according to the first aspect or any possible implementation of the first aspect.

[0066] In a seventh aspect, a computer-readable medium is provided by the embodiment of the present disclosure, and the computer-readable medium includes computer execution instructions which, when executed by a processor, cause the processor to execute the data processing method according to the first aspect or any possible implementation of the first aspect.

[0067] In an eighth aspect, a chip is provided by the embodiment of the present disclosure, and the chip includes an input / output (I / O) interface and a processor, where the processor is configured to call and run computer execution instructions stored in a memory, to enable a device installingwith the chip to execute the data processing method according to the first aspect or any possible implementation of the first aspect.

[0068] Embodiments of the present disclosure provide a data processing method and related apparatuses. In response to an instruction for executing a program, execution information of a first shared library called by the program is loaded by a device based on a merged shared library (MSL), where the MSL includes execution information of each of multiple shared libraries, the multiple shared libraries include the first shared library, and at least two of the multiple shared libraries have a dependency therebetween. In this way, the execution information of the first shared library is loaded based on the MSL obtained by merging the multiple shared libraries, since the MSL records execution information of all the multiple shared libraries, so for any two of them which have a dependency therebetween, they can be loaded simply based on the MSL, so the use of the MSL would facilitate the loading process, in this way, PLT / GOT can be eliminated by calls in the MSL and the memory consumption can be reduced, and only the requested part (that is, part related to the first shared library) in the MSL is loaded, so as to further reduce the memory consumption and improve the loading efficiency; in addition, there is no need to change the program (user side), so as to allow the MSL solution to be applied to the existing program (which is also referred to as processes / application mentioned below) without rebuilding it and get benefits without any additional workload related to the program.BRIEF DESCRIPTION OF DRAWINGS

[0069] FIG. 1A is a schematic diagram of current mechanism of usage shared libraries in the related art.

[0070] FIG. IB and FIG. 1C are schematic diagrams of PLT / GOT mechanism in the related art.

[0071] FIG. 2 is a schematic flowchart of a data processing method according to one or more embodiments of the present disclosure.

[0072] FIG. 3 A is a schematic flowchart of an example merging process of a MSL according to one or more embodiments of the present disclosure.

[0073] FIG. 3B is a schematic diagram of an example structure of an MSL according to one or more embodiments of the present disclosure.

[0074] FIG. 4A is a schematic overview diagram of using a merged shared library according to one or more embodiments of the present disclosure.

[0075] FIG. 4B is a schematic diagram of an example of calling an external function for a shared library according to one or more embodiments of the present disclosure.

[0076] FIG. 5 is a schematic diagram of an example merging process of shared libraries according to one or more embodiments of the present disclosure.

[0077] FIG. 6A and FIG. 6B are schematic structural diagrams of layouts of example MSL according to one or more embodiments of the present disclosure.

[0078] FIG. 6C is an illustrative third section according to one or more embodiments of the present disclosure.

[0079] FIG. 7 is a schematic diagram of an example loading process of shared libraries according to one or more embodiments of the present disclosure.

[0080] FIG. 8 shows a schematic structural diagram of a data processing apparatus according to one or more embodiments of the present disclosure.

[0081] FIG. 9 is a structural diagram of an electronic device according to one or more embodiments of the present disclosure.

[0082] FIG. 10 is a schematic diagram of an architecture of a computing device cluster according to one or more embodiments of the present disclosure.

[0083] FIG. 11 is a schematic diagram of a connection between computing devices over a network according to one or more embodiments of the present disclosure.DESCRIPTION OF EMBODIMENTS

[0084] To describe the technical solutions in embodiments of the present disclosure or in the prior art more clearly, the following briefly introduces the accompanying drawings needed for describing the embodiments or the prior art.

[0085] In the following description, reference is made to the accompanying figures, which form part of the present disclosure, and which show, by way of illustration, specific aspects of embodiments of the present disclosure or specific aspects in which embodiments of the present disclosure may be used. It is understood that embodiments of the present disclosure may be usedin other aspects and include structural or logical changes not depicted in the figures. The following detailed description, therefore, is not to be taken in a limiting sense, and the scope of the present disclosure is defined by the appended claims.

[0086] Before describing the detail contents of the present disclosure, the following terms are explained.

[0087] Object file - a binary file that contains a machine code (also can be termed as “object code”), as well as other data and metadata, generated by a compiler from a source code. Object file is suitable to be an input for a linker.

[0088] Code segment - also known as text segment, or as text, is a part of a binary file that contains executable instructions for a specific CPU (Central processing Unit). For example, the binary file can be in an executable and linkable format (ELF) in linux system, or in a portable execute (PE) format in window system, which is not limited in embodiments of the present disclosure.

[0089] Data section - is a part of a binary file that contains permanent constants and variables used in a computer program.

[0090] Shared library (also can be referred to as “shared lib / shared_lib.so”, and also can be referred to as “Dynamic Shared Object, DSO”) - a binary file in a pre-required format that contains functions designed to be used by multiple applications or contains functions designed to be used by other shared libraries at runtime, which is also referred to as executable file. Throughout the text, a specific shared library may also be referred to as shared_libN.so, e.g., shared_libl.so, shared_lib2.so.

[0091] Linker - a program which takes one or more object files as an input and combines them into a single executable file or shared library, or takes one or more shared libraries as an input and combines them into a merged shared library. The linker can also be implemented as a static linker.

[0092] Loader - is a part of operational system that is responsible for loading programs and shared libraries into a memory for execution by CPU (and for unloading abovementioned programs and libraries from the memory after execution stage). The loader can also be implemented as a dynamic linker or dynamic loader.

[0093] In the related art, usage of shared libraries (particularly in a Linux-based system) is a common way to manage application’s dependencies. The libraries are loaded by a dynamic loaderbefore the application, which has dependencies on them. This approach allows to reduce RAM (Random-Access Memory) consumption because different applications can use same (already loaded) shared libraries. But it has its own cost: all calls between shared libraries above are performed with PLT / GOT (Procedure Linkage Table / Global Offset Table) mechanism usage, which allows to call functions with unknown addresses (at linkage stage), but leads to performance degradation at runtime - it leads to additional overhead (more instructions need to be executed, more jumps, and increased possibility of CPU cache invalidation).

[0094] FIG. 1 A is a schematic diagram of a current mechanism of usage shared libraries in the related art. As shown in FIG. 1 A, there are different applications Appl , App2 and AppN for calling different libraries, the number N of applications is not limited herein. Illustratively, Appl calls all shared libraries (which are shared_libl.so to shared_libN.so) shown in FIG. 1A, for calling a function A in shared_libl.so, PLT / GOT mechanism would be triggered so as to get the address of function A in the memory space, and then if function A needs to call another function B in shared_libN.so (shown by arrow from shared_libl.so to shared_libN.so in FIG. 1A), PLT / GOT mechanism would be used again to get the address of function B in the memory space. Similar situation would happen to App2 which calls shared_lib2.so, and in shared_lib2.so there is a function that needs to call another function in shared_libl.so, shown as the arrow from shared_lib2.so to shared_libl.so in FIG. 1A, so PLT / GOT mechanism would also be used, that is, cross-libraries interaction is realized through PLT / GOT mechanism. It is also possible that some App simply calls one or more shared libraries which rely on no other shared libraries, such as AppN in FIG. 1 A, it calls shared_libN.so, shared_libN.so does not have a function that needs to call another function from other libraries.

[0095] In order to better elaborate the above PLT / GOT mechanism, FIG. IB and FIG. 1C show the case where one shared library (shared_libl.so) calls another shared library (shared_lib2.so). As shown in FIG. IB, there is a function A in shared_libl.so that needs to call another external function B in shared_lib2.so, it is checked in PLT whether an address of this external function B exists in GOT corresponding to the shared_libl.so, if not, PLT calls a resolver to resolve the address of this external function B, and this address is written into the corresponding GOT, so that shared_libl .so can call the external function B by this address written into the corresponding GOT. After the address of this external function was written into the corresponding GOT, next time whenthis external function B is called by function A, the check of the address of this external function B in PLT would lead to the GOT corresponding to the shared_libl .so, the resolver would no longer be triggered, function A in shared_libl.so can directly call the external function B by this address in the corresponding GOT, which is shown in FIG. 1C.

[0096] As described above, the current PLT / GOT mechanism of usage shared libraries is used for many decades already and shows its applicability in complex systems. But systems became more and more complicated, and it leads to more and more dependencies on shared libraries. For example, for an open source operational system, there is a process which is responsible for starting other processes, and this process depends on almost 1000 shared libraries, which is a quite huge number. When all those shared libraries are loaded by a dynamic loader, they consume a lot of memory (said memory is fragmented because all shared libraries are loaded independently for each own memory region, without considering how it will be positioned relative to other shared libraries). And beside inefficient memory consumption, there is a more impactful characteristic: performance degradation - because interaction with all of those 1000 shared libraries is performed using PLT / GOT mechanism, which uses additional code for calling function(s) in a shared library for another shared library, therefore code executes slower and there is higher rate of instruction cache misses during execution.

[0097] In view of the above, the present disclosure proposes a data processing method in which all highly tied (in terms of usage by predefined processes) shared libraries are merged into one merged shared library (MSL, whose exemplary structure is shown in FIGS. 6A and 6B), which optimizes (eliminates) PLT / GOT calls inside MSL, reduces memory consumption, changes the static linker and dynamic loader to handle MSL in a correct way. The proposed mechanism may require changes to static linker and dynamic loader, but any inefficient memory consumptions and any changes in user code are excluded, so from the perspective of a user application, there won’t be any changes at all - MSL is allowed to be used for the user application even without rebuilding the user application.

[0098] The proposed disclosure is applicable to various operational systems to optimize applications / processes with high number of dependencies on shared libraries (e.g., approximately more than 10-20). It is also possible to use the PLT / GOT mechanism and the proposed mechanism when appropriate. For example, based on features of shared libraries, e.g., how big they are interms of instructions, how many PLT calls are there, flexible choice could be made between the PLT / GOT mechanism and the proposed mechanism, since additional section for MSL also costs memory overhead. Therefore, the more shared libraries are merged, the more benefits can be achieved, with the proposed MSL, performance benefit will be bigger for applications / processes which are more often uses functions from MSL on its hot paths.

[0099] It should be noted that the solution of the present disclosure can be applicable for various operational systems, although only the Linux system is illustrated in the description.

[0100] The embodiments of the present disclosure will be elaborated with reference to accompanying figures. The present disclosure provides a data processing method, which is performed by a data processing apparatus mentioned below (e.g., a dynamic loader including a data processing apparatus) or a device in which the data processing apparatus is integrated. Reference may be made to FIG. 2, the data processing method may include the following steps. It should be noted that in FIG. 2, the execution subject of the method is a device, and this is just illustrative rather than restrictive.

[0101] S201, a device loads, based on a merged shared library (MSL) and in response to an instruction for executing a program, execution information of a first shared library called by the program.

[0102] Specifically, the MSL includes execution information of each of multiple shared libraries, the first shared library is one of the multiple shared libraries. The multiple shared libraries are merged to form the MSL, so the MSL includes execution information of all the multiple shared libraries.

[0103] For example, the execution of a program may be related to execution of an application, when a user opens an application on a terminal device, the execution of the program related to the application would be triggered, and the instruction for executing the program would be generated by the terminal device, then the first shared library called by the program would be loaded for execution of the program. It should be noted that the above scenario is illustrative rather than restrictive, the application scenarios of the embodiments of the present disclosure are not limited.

[0104] Upon receiving the instruction for executing the program, execution information of one or more shared libraries would be loaded for ensuring the correct execution of the program. Here the execution information may contain information related to the execution of the shared library.In a possible implementation of the present disclosure, the execution information of each of the multiple shared libraries may include attribute information of each of the multiple shared libraries (the attribute information of each of the multiple shared libraries is used for determining metadata of each of the multiple shared libraries), first sections parsed from each of the multiple shared libraries and second sections for each of the multiple shared libraries generated based on the first sections, sometimes the execution information may include global and / or local variables involved with the shared library if there’s any. In a possible implementation of the present disclosure, for a shared library, the attribute information of the shared library may include an original name of the shared library, memory addresses of the segments / sections (.text, .bss, .data) in the shared library, memory addresses of second sections for the shared library, the dependency for the shared library if it depends on any other shared library (which would be or not be included in the multiple shared libraries), etc., which is not limited herein. The first sections of the shared library may be obtained by parsing first sections in the shared library and renaming the parsed sections, and the second sections would be those necessary for correct execution of the shared library, such as the symbol table which records the names of functions contained in the shared library and other dynamic sections.

[0105] At least two of the multiple shared libraries have a dependency therebetween. In a possible implementation of the present disclosure, in a case where the first shared library depends on at least one second shared library included in the multiple shared libraries, for each of the at least one second shared library, the dependency between the first shared library and the second shared library is represented by execution of one or more functions in the second shared library being called by execution of one or more functions in the first shared library. That is, the execution of one or more functions in the first shared library depends on execution of one or more functions in the second shared library. The dependency between two of the multiple shared libraries can be elaborated in connection with the following example, there is a shared library from the multiple shared libraries in which a function needs to call another function from another shared library, then these two shared libraries have the dependency therebetween.

[0106] Here the multiple shared libraries are merged into one MSL. There is no limitation on the number of the shared libraries, and these multiple shared libraries may be frequently used / called shared libraries, the determination of frequently used shared libraries may be made based on, e.g.,profile data of users. Besides, two or more of the multiple shared libraries are dependent from each other, since the multiple shared libraries have been merged into one MSL, so when one shared library is to be loaded for the execution of a program, if it depends on one or more other shared libraries, they will also be loaded, in this way, the execution of the program would be expedited.

[0107] In a possible implementation of the present disclosure, the first shared library is an executable file, in different operating systems, executable files may have different formats, the format of the first shared library is not limited in the embodiments of the present disclosure.

[0108] In a possible implementation of the present disclosure, the merging process of the multiple shared libraries can be performed by a static linker. Here the static linker may take shared libraries as input, and obtain a MSL as output. The process may include the following the steps, which is showed in FIG. 3 A. The process may be performed by a static linker or a device in which the static linker is integrated.

[0109] S301, input the multiple shared libraries to be merged.

[0110] For example, which shared libraries would be merged can be derived based on profile data, such profile data reflects most frequently called shared libraries.

[0111] S302, parse a header and sections of each of the multiple shared libraries, and add a postfix to each of the sections to generate first sections.

[0112] In a possible implementation, for each of the multiple shared libraries, parsing its header would be useful for getting information for parsing sections in the shared library. Each of the multiple shared libraries may include multiple sections, such as a .text section, a .data section, a .bss section and may also include other sections, all sections of each of the multiple shared libraries are parsed and renamed, and then the first sections are generated, which avoids duplication of section names.

[0113] The renaming may be done in various ways. For example, after parsing all sections of each of the multiple shared libraries, all sections from the same shared library are added with their corresponding postfixes. The addition of postfixes would make it possible to distinguish sections from different shared libraries.

[0114] In a possible implementation, a postfix for a section may be formed by a first segment identifying to which shared library this section belongs and a second segment identifying the type of this section, so postfixes from the same shared library would have the same first segment, andthey can be distinguished by their types which are identified in the second segments of postfixes, and postfixes for sections of the same type but from different shared libraries would be have the same second segment but different first segments. For example, shared_libl .so and shared_lib2.so both include .text sections, .data sections and .bss sections, the .text section, the .data section and the .bss section of shared_libl.so are added with postfixes “.text_000”, “.data OOO” and “.bss_OOO” respectively, where “.text”, “.data” and “.bss” are the second segment of the postfixes, and “_000”, “_000” and “_000” are the first segment of the postfixes. Similarly, the .text section, the .data section and the .bss section of shared_lib2.so are added with postfixes “.text_001”, “,data_001” and “.bss_001” respectively, where “.text”, “.data” and “.bss” are the second segment of the postfixes, and “_001”, “_001 ” and “_001” are the first segment of the postfixes.

[0115] In a possible implementation, original sections from the same shared library are added with the same postfix. The type of the section can be indicated by the section itself, and its postfix is used to identify to which shared library this section belongs. It should be noted that a format of postfix used for describing the above sections are just illustrative, other formats may also be used for realizing the functions defined for these sections, and the specific formats are not limited in the embodiments of the present disclosure.

[0116] S303, generate the MSL.

[0117] A possible structure of MSL is shown in FIG. 3B. The generation of the MSL may include generating a first part and a second part of the MSL, the first part of the MSL includes first sections parsed from each of the multiple shared libraries (as described above with reference to S301 and S302), second sections of each shared library and a third section, where the third section is indicated by the second part, as illustratively shown in FIG. 3B with a dashed line from the first header to the third section. Besides, in a possible implementation, the step S303 of generating the MSL includes performing standard linking and optimization on the MSL, and finally generating the MSL.

[0118] After the parsing and adding processes, the first sections of the multiple shared libraries can be obtained, and based on these first sections, second sections can be generated, these second sections are dynamic sections related to the execution of each of the multiple shared libraries merged into the MSL, for example, the second sections for each of the multiple shared libraries can be same or different, which is not limited in the embodiments of the present disclosure. Foreach shared library, the second sections may include fourth section(s) common to some of the multiple shared libraries, e.g., .got, .pit, etc., which means that the fourth section(s) could be shared among some shared libraries merged into the MSL. Sometimes the second sections may also include specific section(s) for the shared library, if the shared library depend on external shared library / libraries. Besides, in addition to the first sections and the second sections, the MSL may also include a third section which provides indications for the first sections, second headers and the second sections, as shown in FIG. 3B with dashed lines.

[0119] Information contained in the first part and the second part and structures of the two parts will be elaborated hereinafter.

[0120] The first part includes the first sections for each of the multiple shared libraries, the second sections and information about dependencies among the multiple shared libraries, where each of the dependencies among the multiple shared libraries is represented by execution of one or more functions in one of the multiple shared libraries being called by execution of one or more functions in another one of the multiple shared libraries, e.g., for any two shared libraries among the multiple shared libraries which have a dependency therebetween, such dependency means that when one of the two shared libraries is being executed, one or more functions in this shared library call execution of one or more functions in another one of the two shared libraries; the second part of the MSL is indicative of the third section and the first sections parsed from each of the multiple shared libraries. In this way, the third section of the MSL and the first sections parsed from each of the multiple shared libraries can be read based on the second part, and the first sections and the second sections included in the first part can be further read based on the third section. Besides, when loading a shared library from the MSL, if it is determined, based on the indication of the third section, that this shared library depends on one or more other shared libraries (not necessarily to be included in the multiple shared libraries), then these shared libraries would also be loaded, for those included in the multiple shared libraries, their loading would be similar to that of said shared library which depends on them. Based on this design of MSL, the correct loading of the shared library can be ensured. It should be noted that here dependencies among the multiple shared libraries mean that some or all of the multiple shared libraries depend on one or more shared libraries among the multiple shared libraries, e.g., the multiple shared libraries merged into MSL are shared_libl.so, shared_lib2.so, ...shared_libN.so, shared_libl.so depends on shared_lib2.soand shared libN.so, shared_lib2.so does not depend on any other shared libraries merged in the MSL, shared_libN.so depends on shared_lib2.so, all these information would be reflected in the dependencies indicated by the third section. If shared_lib2.so, for example, depends on one or more external shared libraries, this information would also be indicated by the third section.

[0121] In a possible implementation of the present disclosure, the second part includes a first header and multiple second headers corresponding to the multiple shared libraries one-by-one; where the first header is indicative of a type of the MSL, the third section and a reference to the second header; where for each of the multiple second headers, the second header is indicative of first sections parsed from a shared library corresponding to the second header. The type of the MSL would be useful for parsing information in the third section. For example, after reading the first header, it can be determined that the MSL is an executable file of merged.so type, and the first header can store a start address of the third section of the MSL, so that the third section can be located based on the first header, it should be noted that the form of the first header can be implemented in other manners, which is not limited in the embodiments of the present disclosure. The third section can include a reference to a memory address of each of the multiple second headers, so that when reading the third section, a memory address of a second header corresponding to a to-be-loaded shared library can be determined, and first sections of this shared library can be read based on the memory address of the second header. For example, as shown in FIG. 3B, there are N second headers corresponding to N shared libraries merged into the MSL, after reading the third section by the data processing apparatus or the device in which the data processing apparatus is integrated, second header 1 is determined as a second header corresponding to a to-be-loaded shared library, and first sections of this shared library can be read based on the memory address of second header 1 , as indicated by a dashed line between second header 1 and first sections.

[0122] In a possible implementation, the first sections of each of the multiple shared libraries are arranged together by parsing each of the multiple shared libraries based on their original information (e.g., including header section, .text section, .data section and .bss section, etc.), as described above. In addition, at least two of the first sections with a same postfix are from a same shared library, e.g., all first sections in the MSL from a same shared library are renamed with a same postfix, in this way, each of the first sections can be identified by its postfix to determine towhich shared library it belongs, which further facilitates the correct loading of the shared library.

[0123] In a possible implementation of the present disclosure, the second sections for each of the multiple shared libraries includes at least one fourth section and information of at least one function included in each of the multiple shared libraries, where the at least one fourth section is generated based on the functions included in the multiple shared libraries and the information about the dependencies among the multiple shared libraries. As described above, for each of the multiple shared libraries, the fourth section(s) may be the same or different, one shared library may share fourth section(s) with one or more of the multiple shared libraries, these fourth sections may include, e.g., .got section, .pit section, etc., which is not limited in the embodiments of the present disclosure. For example, when shared_libl.so and shared_lib2.so are merged into MSL, then the MSL would contain, e.g., .got which has information from .got sections from both shared_libl.so and shared_lib2.so, as a fourth section. In a possible implementation, the at least one fourth section included in the second sections is newly generated based on all functions included in the multiple shared libraries and the information about the dependencies among the multiple shared libraries. The at least one fourth section can simply include necessary information for the MSL, and is used for storing addresses of various entries, such as .got, .got.plt, .pit and the like. In addition, the at least one fourth section can be loaded simply once when calling a shared library in the MSL. That is, after the MSL is generated, when a shared library of the MSL is called for the first time, the at least one fourth section can be loaded; and after then when a shared library (which can be the previous shared library or other libraries) merged into the MSL is called, the at least one fourth section does not need to be loaded again, thereby improving the loading efficiency.

[0124] In a possible implementation, for each of the multiple shared libraries, the at least one function included in the shared library can be all functions included in the shared library, and the information of all functions included in the shared library (e.g., including global function(s) and local function(s)) can be stored in a symbol table, this symbol table can hold information needed to locate and relocate a program's symbolic definitions and references, e.g., names of all functions related to all the multiple shared libraries. Names of all functions included in the multiple shared libraries can be hold in one symbol table, so that when calling a function in a shared library, only a name of this function needs to be known, thus ensuring that the program runs correctly. Here the global function refers to a function whose definition is effective throughout the whole part of theprogram, so that it can be accessible / callable throughout the program; the local function refers to a function whose definition is only effective within a certain part of the program, so that it can be only accessible / callable during execution of the certain part.

[0125] In a possible implementation, information of at least two functions included in a same shared library occupies a block of contiguous memory addresses. For example, there is a shared library in the MSL, which has function 1, function 2 and function 3, information of all these three functions (e.g., names of these three functions) occupies a block of contiguous memory addresses, so that the memory consumption can be reduced. In a possible implementation, the functions whose names are stored in the symbol table can be sorted in a specific format, for example, functions from the same shared library can be arranged together, and these functions can be ordered sequentially or irregularly. For example, functions from shared_libl.so are arranged together, and these functions can be ordered according to alphabetical orders of their names, which is not limited in the embodiments of the present disclosure. Based on the generated fourth section and information of at least one function in each of the multiple shared libraries, information about functions included in each of the multiple shared libraries can be maintained, thereby reducing the memory consumption on the premise of maintaining the original sections for realizing the original functions of the multiple shared libraries.

[0126] In a possible implementation of the present disclosure, the execution information of each of the multiple shared libraries includes attribute information of each of the multiple shared libraries, first sections parsed from each of the multiple shared libraries and second sections for each of the multiple shared libraries generated based on the first sections, the attribute information of each of the multiple shared libraries is used for determining metadata of each of the multiple shared libraries. The first sections and second sections for each of the multiple shared libraries can be stored in the first part of the MSL, which are already described above, the attribute information for each of the shared libraries is used for determining and loading all information related to this shared library (i.e., metadata of this shared library), such as the original name of this shared library, the first sections and second sections of this shared library. Some of the attribute information for each of the shared libraries can be stored in the second part of the MSL, for example, the second part of the MSL includes information indicating that the MSL includes this shared library. Some of the attribute information for each of the shared libraries can be stored in the third section of theMSL, which will be described in detail below.

[0127] The MSL includes all necessary information related to each of the multiple shared libraries, so that the shared library can maintain its original sections for this shared library before the merging, and the original sections, which are presented as first sections in the MSL, can be loaded correctly based on the attribute information of the shared library and the third section.

[0128] The following will describe the third section of the MSL, as described above, the third section is included in the first part of the MSL, and is used for indicating the first sections parsed from each of the multiple shared libraries, the second sections for each of the multiple shared libraries and the information about dependencies among the multiple shared libraries. In a possible implementation, the third section includes a third header, multiple fifth sections corresponding to the multiple shared libraries one-by-one and a sixth section; the third header is indicative of each of the multiple fifth sections and the sixth section; each of the multiple fifth sections is used for storing the attribute information of each of the multiple shared libraries; and the sixth section is used for storing data indicated by the attribute information of each of the multiple shared libraries. In a possible implementation, the attribute information of the shared library stored by a corresponding fifth section is used for loading the shared library, and data indicated by the attribute information of the fifth section is stored in the sixth section. The third section of the MSL can be read based on the third header, and the fifth sections can be further read based on the third section (e.g., based on the third header of the third section), which further facilitates the correct loading of the shared library.

[0129] In a possible implementation of the present disclosure, the third header is indicative of: a version of the MSL; a size of the third header; a size of the multiple fifth sections; a hash algorithm for obtaining an original name of each of the multiple shared libraries; a size of a memory reserved for the MSL when memory mapping is performed; a memory address of the sixth section; a memory address of at least one fourth section shared among the multiple shared libraries.

[0130] In a possible implementation, the version of the MSL can be used for indicating updates to the MSL, and is related to the multiple fifth sections corresponding to the multiple shared libraries respectively, different versions of the MSL can correspond to different data structures for the fifth sections, and correspondingly, the fifth sections can be read based on the current version of the MSL from the MSL.

[0131] In a possible implementation, the size of the third header is used for indicating a size of the third header, so that the third header can be read based on the size of the third header and the start address of the third section of the MSL stored in the second part of the MSL (e.g., indicated by the first header of the second part of the MSL).J0132] In a possible implementation, the indication of the size of the multiple fifth sections includes an indication of a size of each of the multiple fifth sections in the third section and an indication of the number of the multiple shared libraries. In a possible implementation, for the same version of MSL, the multiple fifth sections corresponding to the multiple shared libraries have the same size, so that the size of the multiple fifth sections can be determined based on the size of each of the multiple fifth sections and the number of the multiple shared libraries, and each fifth section can be read based on the size of the multiple fifth sections.

[0133] In a possible implementation, the hash algorithm for obtaining the original name of each of the multiple shared libraries can be used to perform has calculation on the original name of each of the multiple shared libraries, and the hash calculation result (which is referred to as original name of the shared library below) can be stored in the corresponding fifth section. In this way, when reading the attribution information corresponding to the fifth section, the original name of each of the multiple shared libraries can be determined based the hash algorithm and the hash calculation result.

[0134] In a possible implementation, the size of the memory reserved for the MSL when memory mapping is performed is also indicated by the third header. When the dynamic loader loads a shared library, it performs memory mapping (from disk memory to RAM) based on the size of the memory reserved for the MSL.

[0135] In a possible implementation, each of the multiple shared libraries includes multiple sections, and there is at least fourth section among the multiple shared libraries, in this case, address / addresses of the at least fourth section is / are stored in the third header. For example, when shared_libl.so and shared_lib2.so are merged into MSL, then the MSL would contain, e.g., .got which has information from .got sections from both shared_libl.so and shared_lib2.so, as a fourth section, then the address of the fourth section can be stored in the third header.

[0136] In a possible implementation of the present disclosure, the indication of the memory address of the sixth section includes an indication of a start of the memory address of the sixthsection and an indication of a size of the sixth section. In a possible implementation, the sixth section can be read based on the start of the memory address of the sixth section and the size of the sixth section.

[0137] The third section can be read correctly and efficiently by the above items indicated in the third header, so that the first sections and second sections in the MSL can be further read based on the third section, thereby improving the preference of calling the shared libraries.

[0138] In a possible implementation of the present disclosure, for each of the multiple shared libraries, the attribute information of the shared library indicated by a corresponding fifth section includes at least one of: an original name of the shared library; a reference to a memory address of information of at least one function included in the shared library; a reference to a memory address of a second header corresponding to the shared library, where the memory address of the second header corresponding to the shared library is stored in the sixth section.

[0139] In a possible implementation, the indication of the original name of the shared library includes an indication of a memory address where the original name of the shared library is stored and an indication of a hash value of the original name of the shared library. In a possible implementation, the original name of the shared library can be verified based on the hash algorithm in the third header and the hash value of the original name of the shared library.

[0140] In a possible implementation, in the case where there is a shared library in the multiple shared libraries which depends on at least one external shared library (not merged into the MSL), the second sections for the shared library include at least one specific section from the at least one external shared library; and correspondingly, the attribute information of the at least one external shared library included in the third section includes: a reference to a memory address of the at least one specific section from the at least one external shared library, where the memory address of the at least one specific section is stored in the sixth section; a reference to each of the at least one external shared library.

[0141] Here the number of shared libraries in the multiple shared libraries which depend on external shared library / libraries is not limited, there could be one or more, for the plural case, the related description applies to each such shared library. The external shared library can be a shared library that is not merged into the MSL. For example, there is shared_lib3.so in the MSL which depends on external shared_lib4.so, specific section(s) for shared_lib3.so is generated based onexternal shared_lib4.so, the specific section can include, for example, .rela.dyn, .rela.plt, etc. In this case, the third section of the MSL can include attribute information of external shared_lib4.so, the attribute information can include a reference to a memory address of the specific section of external shared_lib4.so, and include a reference to external shared_lib4.so (which refers to the dependency between shared_lib3.so and external shared_lib4.so, as one example, it could be indicated by the dt-needed field in FIG. 6C). Since the MSL can also be formed by integrating specific section(s) from external shared library, so when there is a shared library in the MSL which depends on an external shared library, the external shared library can be loaded based on the MSL, thus ensuring the correct loading of the shared library.

[0142] In a possible implementation of the present disclosure, the step 201 of loading the first shared library includes constructing, by the device, a variable of the first shared library when loading the first shared library; and the method further includes: deconstructing, by the device, the variable of the first shared library when the execution of the program is finished.

[0143] In a possible implementation of the present disclosure, for a shared library in the multiple shared libraries, the attribute information of the shared library indicated by a corresponding fifth section includes at least one of:at least one variable related to the shared library, e.g., there would be one or more variables that need to be loaded when loading the shared library merged into the MSL, so based on this indication, these variables would be constructed when the execution information of the shared library is loaded and would be deconstructed when the execution of the program is finished;a reference to an index of a fifth section of each of at least one shared library in the multiple shared libraries on which the shared library depends, where the index of the fifth section of each of the at least one shared library is stored in the sixth section.

[0144] In a possible implementation, in a case where there is a shared library (merged into the MSL) which does not have a dependency with at least one shared library which has been merged into the MSL, the attribute information of this shared library may skip including a reference to an index of a fifth section, the loading of such shared library may not trigger loading of other shared library / libraries; in a case where there is a shared library (merged into the MSL) which depends on at least one shared library, if the at least one shared library has been merged into the MSL, the attribute information of this shared library can include a reference to an index of a fifth section ofeach of the at least one shared library, if there is one or more shared libraries among the at least one shared library that have not been merged into the MSL, that is, the one or more shared libraries are external shared libraries, then the attribute information of this shared library can include a reference to each of the external shared libraries, as well as a reference to a memory address of specific section(s) from the external shared libraries.

[0145] Based on items included in the attribute information of the shared library indicated by the corresponding fifth section, the shared library can be loaded correctly and efficiently.

[0146] In a possible implementation, the fifth section of each of at least one shared library in the multiple shared libraries on which the shared library depends can include information related to the dependency between the shared library and the at least one shared library on which the shared library depends. For example, the information about / related to the dependency could be indicated by the dt-needed field in FIG. 6C of the MSL. Besides, in addition to the information related to the dependency between the shared library and the at least one shared library on which the shared library depends, the dependency between the shared library merged into the MSL and external shared library (not merged into the MSL) may also be indicated by the fifth section of the shared library merged into the MSL.

[0147] In a possible implementation of the present disclosure, the method can be performed by a dynamic loader, in a possible implementation, the program to be executed can be an application or a part of an application, and when executing the program, the dynamic loader will load the shared library used for executing the program.

[0148] In a possible implementation of the present disclosure, the first shared library depends on at least one second shared library included the multiple shared libraries, and the method further includes: loading, based on the MSL and a dependency between the first shared library and each of the at least one second shared library in the multiple shared libraries, execution information of each of the at least one second shared library in the multiple shared libraries. That is, for each of the at least one second shared library, execution of one or more functions in the first shared library depends on execution of one or more functions in the second shared library. In a possible implementation, the dependency between the first shared library and each of the at least one second shared library in the multiple shared libraries can be obtained based on its corresponding fifth section and the sixth section of the first shared library as described above. It should be understoodthat if the at least one second shared library on which the first shared library still depends on other shared library / libraries, a process similar to the loading of the first shared library would be performed to load each of the other shared library / libraries. Since the at least one second shared library on which the first shared library is loaded when loading the first shared library, correct loading of the first shared library is ensured, and the loading efficiency is also improved. In a possible implementation of the present disclosure, the step S201 of loading the first shared library includes: checking, in response to the instruction for executing the program, whether there is a link between the first shared library and the MSL; when there is a link between the first shared library and the MSL, loading the execution information of the first shared library from the MSL based on the link between the first shared library and the MSL, where the link is indicative of the first shared library. For example, when executing the program that needs to call the first shared library, the dynamic loader checks if the program tries to load the MSL, the check could be done by checking whether there is a link between the first shared library and the MSL, and if there is a link between the first shared library and the MSL, the check result would be that the program tries to load the MSL, then the dynamic loader loads the execution information of the first shared library from the MSL, the link between the first shared library and the MSL can be implemented as a flag / reference used for linking / directing the first shared library to the MSL when the first shared library is loaded. In a possible implementation, each of the multiple shared libraries in the MSL has it corresponding link. The multiple shared libraries that are merged into the MSL are replaced with links to MSL, no changes need to be made from user process / application side, and each of the multiple shared libraries can be loaded correctly by its corresponding link, which reducing the memory consumption and improving the preference of calling the shared libraries.

[0149] FIG. 4A is a schematic overview diagram of using a MSL according to one or more embodiments of the present disclosure. As shown in FIG. 4A, APP1 is similar to that shown in FIG. 1A, it needs to call all shared libraries (which are shared_libl.so to shared_libN.so), and all the shared libraries are merged into a MSL (MSL, which is shown as merged.so in FIG. 4A), the MSL includes all information related to all the shared libraries, and memory address used to store each shared library in related art may be now used to store a link to the MSL including all information related to all shared libraries. That is, all shared libraries that have been merged into the MSL have their respective links to the MSL. The call process of shared libraries by applicationsis realized by means of a dynamic loader, specifically, when running an application, the dynamic loader checks if this application tries to load the MSL, and if so, the dynamic loader simply loads necessary part (necessary information) of this application in the MSL. For example, when running Appl that needs to call all shared libraries shared_libl.so to shared_libN.so, the dynamic loader checks if Appl tries to load the MSL, the check could be done by checking whether there is a link between a certain shared_lib.so (which could be any of shared library depended by Appl) and the MSL, and if there is a link between the shared_lib.so and the MSL, the check result would be that Appl tries to load the MSL, then the dynamic loader loads necessary part of Appl in the MSL, take the calling of shared_libl.so by Appl as an example, the dynamic loader in this case would load not only parts related to shared_libl.so (e.g., parts related to address information of all functions in shared_libl.so), but also parts related to other shared library / libraries who have function(s) to be called by shared_libl.so (e.g., parts related to address information of all functions to be called by functions in shared_libl.so), and if one or more functions called by shared_libl .so still call other function(s), then parts related to other shared libraries which have address information of these other function(s) would also be loaded, until all shared libraries serve as dependencies of Appl are loaded to ensure correct running. For another example, when running App2 which needs to call shared_lib2.so as shown in FIG. 1 A, the dynamic loader checks if the loading of shared_lib2.so by App2 directs App2 to load the MSL, and the check result is that App2 tries to load the MSL since shared_lib2.so is linked to the MSL, then the dynamic loader loads necessary part of App2 in the MSL, i.e., parts related to shared_lib2.so and shared_libl.so in the MSL, because there is a function in the shared_lib2.so that needs to call another function in shared libl.so.

[0150] FIG. 4B is a schematic diagram of an example of calling an external function for a shared library according to one or more embodiments of the present disclosure. Continue to refer to the above example in which APP1 needs to call shared_libl.so, and there is a function in shared_libl.so that needs to call another external function ( func in shared_lib2.so as shown in FIG. 4B), in this case, the dynamic loader checks that Appl tries to load the MSL, and jumps to the MSL by a link corresponding to shared_libl .so, and then the dynamic loader calls the so-called external function in shared_lib2.so by means of a third section in the MSL (which will be described in detail below), without performing PLT / GOT mechanism.

[0151] The usage of MSL by a user (or system) process / application is illustrated above. In this way, all nested shared libraries (which refer to the above shared libraries providing dependency basis for applications) are replaced with links to MSL, no changes need to be made from user process / application side. The dynamic loader is responsible for determining of nested shared libraries, and handling loading / unloading process of the nested shared libraries correctly.

[0152] FIG. 5 is a schematic diagram of an example merging process of shared libraries according to one or more embodiments of the present disclosure, which would be a specific example of the process shown in FIG. 3A. In a possible implementation, the merging process can be performed by a static linker, in another possible implementation, which is shown in FIG. 5. The merging process includes the following steps: all shared libraries to be merged are input into a static linker, here the input shared libraries could be derived based on profile data, which reflects most frequently called shared libraries; the static linker parses headers of shared libraries to be merged, and a special header can be generated for indication of the type of the MSL, such special header is a specific example of the above mentioned first header of the MSL, for example, PT ADLT header shown in FIG. 6B. The static linker also parses all sections (e.g., .text section, .data section, .bss section and possibly other sections) in each of the shared libraries, in order to arrange sections which are of the same type but from different shared libraries together, a postfix would be added to each section for identifying from which shared library the section comes and a type of the section. In a possible implementation, a postfix for a section may be formed by a first segment identifying to which shared library this section belongs and a second segment identifying the type of this section, so postfixes from the same shared library would have the same first segment, and they can be distinguished by their types which are identified in the second segments of postfixes, and postfixes for sections of the same type but from different shared libraries would be have the same second segment but different first segments. For example, all sections such as a .text section, a .data section and a .bss section in shared_libl.so are added with the same postfix “_000”, the corresponding sections of shared_libl.so in the MSL are .text_OOO, . data OOO and .bss_OOO respectively; all sections such as a .text section, a .data section and a .bss section in shared_lib2.so are added the same postfix “_001”, the corresponding sections of shared_lib2.so in the MSL are .text_001, data_001 and .bss_001 respectively. It should be noted that a format of postfix used for describing the above sections are just illustrative, other formats may also be used for realizingthe functions defined for these sections, and the specific formats are not limited in the embodiments of the present disclosure. A postfix added to a header of a shared library would correspond to a postfix added to section(s) from this shared library, so that when loading of this shared library is linked to loading of the MSL, the header and section(s) in this shared library can be loaded correctly.

[0153] In a possible implementation of the present disclosure, after the parsing and adding processes, the static linker holds the postfix-added .text sections, .data sections, .bss sections and other sections as first sections, and the same type of sections from different shared libraries are arranged together, for example, sections that belongs to the text type are arranged together, and these functions can be ordered sequentially or irregularly, in the former case, the same type of sections can be ordered according to values of their postfixes, for example, for the text type of sections, the ordered .text sections are text_000, text_001, ..., which is not limited in the embodiments of the present disclosure.

[0154] After the parsing and adding processes, the static linker generates a symbol table (which includes information of at least one function included in each of the multiple shared libraries mentioned above), one or more common dynamic sections (which is a specific example of fourth section mentioned above, and is also referred to as dynamic linking section(s) herein) and a third section, the symbol table holds information needed to locate and relocate a program's symbolic definitions and references, e.g., the symbol table stores names of all functions related to the shared libraries to be merged, so that when calling a function in a shared library, only a name of this function needs to be known, thus ensuring that the program runs correctly. In addition, in the symbol table, functions can be sorted in a specific format, for example, functions from the same shared library can be arranged together, and these functions can be ordered sequentially or irregularly. For example, functions from shared_libl.so (e.g., shared libl.so mentioned above) are arranged together, and these functions can be ordered according to the first letter of their name, which is not limited in the embodiments of the present disclosure.

[0155] The common dynamic section is used for storing addresses of various entries, such as .got, .got.plt, .pit and the like. The common dynamic section would include merged dynamic section(s) from the shared libraries that to be merged, so it is the same for the shared libraries, for example, when shared_libl.so and shared_lib2.so are merged into MSL, then the MSL wouldcontain, e.g., .got which has information from .got sections from both shared_libl.so and shared_lib2.so, as a common dynamic section.

[0156] The third section includes auxiliary information (which could be information included in fifth section and sixth section mentioned above) used for correct usage of the MSL by the dynamic loader, for example, dependencies between different shared libraries, so-names for shared libraries, etc.

[0157] Then, the static linker performs standard linking and optimization on the MSL, and finally generates a MSL in ELF format.

[0158] The generated MSL contains all necessary data for code execution from the shared libraries, for example: code of functions from the first sections (which are specific examples of first sections of a shared library mentioned above), array of pointers to constructors from the third section, the common dynamic section with entries including variables, etc., so as to optimize MSL by eliminating PLT / GOT calls inside MSL.

[0159] FIG. 6A and FIG. 6B show a layout of an examplary MSL generated in the above described merging process. The MSL includes an ELF header, program headers (which is a specific example of the second part of MSL mentioned above), original renamed sections (which are specific examples of first sections mentioned above), a symbol table, a dynamic linking section (part of which is a specific example of fourth section of the second section mentioned above) and a merged section (which is a specific example of third section mentioned above).

[0160] The ELF header may be in a standard format or may be modified based on the standard format to further indicate a type of the MSL. Normally, a loader should understand a type of the shared library to be loaded at the stage of parsing a header of the shared library, so for the case of MSL loading, one way is to add a special header for indicating a type of the MSL, alternative is to add a special flag to the Elf header, where standard binary tools modification may be required. For example, the ELF header contains auxiliary information (e.g., the special flag mentioned above, etc.) for the dynamic loader to load the MSL correctly (e.g., so as to later invoke only corresponding constructors for loaded shared library during execution of a program).

[0161] The program headers, which is a specific example of the second part of MSL mentioned above, are used for indicating attribute information of the MSL and all sections included in the MSL. The program headers may include a merged program header, such as PT ADLT headershown in FIG. 6B (which is a specific example of the first header of the second part of MSL mentioned above), a dynamic header (for compatibility concern) and special headers corresponding to the shared libraries one-by-one, the special headers would be, e.g., PT_LOAD headers (which are specific examples of second headers of the second part of MSL mentioned above). Among them, the merged program header records an offset to a merged section in the generated section, so that the merged section can be loaded based on the offset in the merged program header.

[0162] The original renamed sections include a .text section, a .data section, a .bss section and possibly other sections in each of the shared libraries.

[0163] The merged section includes a header (which is a specific example of the third header mentioned above), PSODs (which are specific examples of fifth sections of multiple shared libraries mentioned above) corresponding to the shared libraries respectively and a binary blob (which is a specific example of the sixth section mentioned above). The binary blob is used for storing arrays of different values (e.g., dt-needed values), the size of such arrays may vary depending on specific shared libraries (e.g., for one shared library it can be 10, for other shared library it can be 20). So if the size of some array can be varied for different shared libraries, it would be beneficial for storing this array and its size in blob.

[0164] The header (which is a specific example of third header mentioned above) of the merged section records offsets to texts of different shared libraries, for example, includes following information:a version field (which is a specific example of version of the MSL mentioned above) for reflecting updates to the MSL;a header size filed (which is a specific example of size of the third header mentioned above) for indicating a size of this header;a PSOD (pre-shared object data) size field (which is a specific example of size of each of the multiple fifth sections in the merged section mentioned above) for indicating a size of PSOD in a merged section included in the generated section;a field (which is a specific example of the number of the multiple shared libraries mentioned above) of shared library number for indicating the number of all shared libraries merged;a string-hash-type (which is a specific example of hash algorithm for obtaining anoriginal name of each of the multiple shared libraries mentioned above) for indicating which hash calculation algorithm to use to search for the corresponding information in the symbol table;a field of overall map size (which is a specific example of size of a memory reserved for the MSL when memory mapping is performed mentioned above) for indicating a size of a memory reserved for this MSL when the dynamic loader performs memory mapping, for example, when the dynamic loader loads a shared library, it performs memory mapping (from disk memory to RAM), such memory mapping is a part of process of loading shared library;a blob-start filed (which is a specific example of indication of a start of the memory address of sixth section mentioned above);a blob size for indicating a size of blob (which is a specific example of indication of a size of sixth section mentioned above); anda field of program-header-indexes (which is a specific example of memory address of at least one fourth section shared among the multiple shared libraries mentioned above), this field indicates how to find indexes of program headers.

[0165] The illustrative merged section is shown in FIG. 6C. With reference to FIG. 6C, the PSOD includes the following information (which is a specific example of attribute information of a shared library mentioned above):an original name of the shared library, the indication of the original name of the shared library includes an indication of a memory address (e.g., “so-name: strtab-offset Elf64_0ff’ shown in FIG. 6C) where the original name of the shared library is stored and an indication of a hash value (e.g., “so-name-hash: Elf64_Xword” shown in FIG. 6C) of the original name of the shared library;a reference to a memory address of information of at least one function included in the shared library, e.g., “shared-local-symbol-index : cross-section-ref’ and “shared-global-symbolindex : cross-section-ref’ shown in FIG. 6C;a reference to a memory address of a second header corresponding to the shared library, the second header is indicative of original renamed sections parsed from the corresponding shared library, a reference to a memory address of the second header can be e.g., “program-header-indexes : blob-array <ul6>” shown in FIG. 6C, where the memory address of the second header corresponding to the shared library is stored in the sixth section;at least one variable related to the shared library, e.g., “init-array : cross-section-array” and “fini-array : cross-section-array” shown in FIG. 6C;a reference to a memory address of at least one specific section from at least one external shared library on which the shared library depends, e.g., “rela-dyn-index: blob-array<u32>” and “rela-plt-index: blob-array <u32>” shown in FIG. 6C; where the memory address of the at least one specific section is stored in the sixth section;a reference to an index of a fifth section of each of at least one shared library in the multiple shared libraries on which the shared library depends, e.g., “dt-needed : blob-array <u64>” shown in FIG. 6C, where the index of the fifth section of each of the at least one shared library is stored in the sixth section.

[0166] The PSOD contains necessary information for loading sections of shared library corresponding to this PSOD, such as dependencies between the corresponding shared library and other shared libraries associated with the corresponding shared library.

[0167] In the MSL structure, beside information from the shared libraries, for example, information in the original renamed section, the symbol table and the dynamic linking section, the MSL also contains auxiliary information, for example, dependencies between different shared libraries, so-names for nested libraries, etc., so that when loading one or more shared libraries for an application, the dynamic loader can realize correct usage of this merged MSL based on the auxiliary information, so that only the necessary part of this application is loaded.

[0168] As described above, in the merging process, different shared libraries (nested shared libraries) are merged into one MSL by the static linker, in a possible implementation of the present disclosure, after the MSL is obtained, a program which calls the MSL may be executed. When executing a program, a dynamic loader would load the program into a memory, and checks if there is a shared library that has dependencies with other shared library(s), for example, checks if there is a shared library whose functions need to call function(s) from other shared library(s), if so, loads this shared library and the other shared library (s). Then the dynamic loader executes constructors from this shared library and the other shared library(s), and starts the program (e.g., execute main function in the program), after the program finished, the dynamic loader executes all destructors corresponding to the constructors, and cleans up the memory.

[0169] The loading process of shared libraries will be described in detail below. FIG. 7 is aschematic diagram of an example loading process of shared libraries according to one or more embodiments of the present disclosure. As shown in FIG. 7, the loading process is performed by a dynamic loader, and starts when an application needs to call a shared library (shared_libl.so) that has been merged into the MSL. As described above with respect to FIG. 4A and FIG. 4B, multiple shared libraries that have been merged into the MSL correspond to multiple links respectively, and each of multiple links is linked to the MSL. In the loading process, in response to a request from the application, the dynamic loader checks if the requested shared library is linked to the MSL, if so, the dynamic loader first reads the second part of the MSL to find the merged section, and then read a PSOD corresponding to the requested shared library in the merged section of the MSL, the PSOD includes necessary information for loading sections of the requested shared library, if the requested shared library is associated with another shared library, then reads PSOD corresponding to the another shared library until all associated shared libraries are read. Taking the requested shared library as shared libl .so shown in FIG. 1 A and FIG. 4A as an example, the dynamic loader first reads PSOD1 corresponding to shared_libl.so, and PSOD1 includes dependencies between shared_libl.so and shared_libN.so, then the dynamic loader reads PSODN corresponding to shared_libN.so. After reading the PSOD(s), addresses of all functions in the requested shared library or in the requested shared library and the associated shared libraries are obtained, then the dynamic loader maps the addresses of all functions to addresses in a process space corresponding to the application. After mapping, shared_libl.so symbols are added to the dynamic loader from the MSL, only symbols from shared_libl .so are loaded (if an application uses only shared_libl .so), other symbols from other shared_lib.so are not loaded.

[0170] In a possible implementation of the present disclosure, if the requested shared library has constructors, the chain of constructor would be prepared and the constructors would be run before the application starts.

[0171] In a possible implementation of the present disclosure, if the requested shared library depends on a shared library that is not merged into the MSL (which is also referred to as extemal / default shared library throughout the text), the dynamic loader relocates address of the external shared library. When relocating the external shared library, the default mechanism of resolving dependencies (PLT calls) could be used. That is, if NDSO depends on some default shared library (the external shared library), then it is handled in the same way as when one defaultshared library depends on another default shared library.

[0172] The above loading process of shared library can be executed during process start (i.e., at the beginning of process corresponding to the application), or when the application is executed (in the case where the requested shared library is loaded with using mechanism like dlopen). In this case dynamic loader will load only corresponding dependencies of the requested shared library, and execute only corresponding constructors when the requested shared library includes the constructors.

[0173] After the execution of the application is finished, the dynamic loader only executes corresponding destructors during process exit (or a mechanism like diclose).

[0174] In this way, by merging several shared libraries into one MSL, PLT / GOT calls can be eliminated; and by changing the dynamic loader, the shared libraries in MSL can be loaded / unloaded correctly, memory map system calls (mmap syscall for short) can be reduced, in fact, for MSL, it can be used only one mmap syscall, without actual loading elf sections and executing constructors, and only corresponding constructors / destructors are invoked, thereby improving performance of all processes / application which uses MSL and its memory consumption. In addition, there is no need to change user code, so as to allow MSL solution to be applied to the existing processes / application without rebuilding it and get benefits without any additional workload related to user side.

[0175] It should be understood by a person skilled in the art that, the relevant description of the above modules in the possible implementations of the present disclosure may be understood with reference to the relevant description of the data processing methods in the possible implementations of the present disclosure. The technical effects achieved by the above apparatuses are similar as those achieved by the above corresponding method embodiments, which is not repeated herein. FIG. 8 shows a schematic structural diagram of a data processing apparatus according to one or more embodiments of the present disclosure. As shown in FIG. 8, the data processing apparatus 800 may include:a loading module 801, configured to load, based on a merged shared library (MSL) in response to an instruction for executing a program, execution information of a first shared library called by the program, where the MSL includes execution information of each of multiple shared libraries, the multiple shared libraries include the first shared library, and at least two of themultiple shared libraries have a dependency therebetween.

[0176] In a possible implementation, the first shared library depends on at least one second shared library included the multiple shared libraries, and the loading module 801 is further configured to:load, based on the MSL and a dependency between the first shared library and each of the at least one second shared library in the multiple shared libraries, execution information of each of the at least one second shared library in the multiple shared libraries.

[0177] In a possible implementation, for each of the at least one second shared library, the dependency between the first shared library and the second shared library is represented by execution of one or more functions in the second shared library being called by execution of one or more functions in the first shared library.

[0178] In a possible implementation, the loading module 801 is further configured to:check, in response to the instruction for executing the program, whether there is a link between the first shared library and the MSL;load, when there is a link between the first shared library and the MSL, the execution information of the first shared library from the MSL based on the link between the first shared library and the MSL, where the link is indicative of the first shared library.

[0179] In a possible implementation, the execution information of each of the multiple shared libraries includes attribute information of each of the multiple shared libraries, first sections parsed from each of the multiple shared libraries and second sections for each of the multiple shared libraries generated based on the first sections, the attribute information of each of the multiple shared libraries is used for determining metadata of each of the multiple shared libraries.

[0180] In a possible implementation, where the loading module 801 is further configured to:construct a variable of the first shared library when loading the first shared library; deconstruct the variable of the first shared library when the execution of the program is finished.

[0181] In a possible implementation, at least two of the first sections with a same postfix are from a same shared library.

[0182] In a possible implementation, the MSL includes a first part and a second part;where the first part of the MSL includes the first sections parsed from each of the multiple shared libraries, the second sections for each of the multiple shared libraries and a thirdsection; the third section includes the attribute information of each of the multiple shared libraries and is indicative of the first sections, the second sections and information about dependencies among the multiple shared libraries, where each of the dependencies among the multiple shared libraries is represented by execution of one or more functions in one of the multiple shared libraries being called by execution of one or more functions in another one of the multiple shared libraries;where the second part of the MSL is indicative of the third section and the first sections parsed from each of the multiple shared libraries.

[0183] In a possible implementation, the second part includes a first header and multiple second headers corresponding to the multiple shared libraries one-by-one;where the first header is indicative of a type of the MSL, the third section and a reference to the second header;where for each of the multiple second headers, the second header is indicative of first sections parsed from a shared library corresponding to the second header.

[0184] In a possible implementation, the second sections for each of the multiple shared libraries include at least one fourth section and information of at least one function included in each of the multiple shared libraries, where the at least one fourth section is generated based on the functions included in the multiple shared libraries and the information about the dependencies among the multiple shared libraries.

[0185] In a possible implementation, information of at least one function included in a same shared library occupies a block of contiguous memory addresses. In this way, the memory consumption can be reduced.

[0186] In a possible implementation, the third section includes a third header, multiple fifth sections corresponding to the multiple shared libraries one-by-one, and a sixth section;where the third header is indicative of each of the multiple fifth sections and the sixth section;where each of the multiple fifth sections is used for storing the attribute information of each of the multiple shared libraries;where the sixth section is used for storing data indicated by the attribute information of each of the multiple shared libraries.

[0187] In a possible implementation, for each of the multiple shared libraries, the attributeinformation of the shared library indicated by a corresponding fifth section includes: an original name of the shared library;a reference to a memory address of information of at least one function included in the shared library;a reference to a memory address of a second header corresponding to the shared library, where the memory address of the second header corresponding to the shared library is stored in the sixth section.

[0188] In a possible implementation, the indication of the original name of the shared library includes an indication of a memory address where the original name of the shared library is stored and an indication of a hash value of the original name of the shared library.

[0189] In a possible implementation, for a shared library in the multiple shared libraries which depends on at least one external shared library, the second sections for the shared library further include at least one specific section from the at least one external shared library;the attribute information of the shared library indicated by a corresponding fifth section includes:a reference to a memory address of the at least one specific section from the at least one external shared library, where the memory address of the at least one specific section is stored in the sixth section;a reference to each of the at least one external shared library.

[0190] In a possible implementation, for a shared library in the multiple shared libraries, the attribute information of the shared library indicated by a corresponding fifth section includes at least one of:at least one variable related to the shared library;a reference to an index of a fifth section of each of at least one shared library in the multiple shared libraries on which the shared library depends, where the index of the fifth section of each of the at least one shared library is stored in the sixth section.

[0191] In a possible implementation, the third header is indicative of:a version of the MSL;a size of the third header;a size of the multiple fifth sections;a hash algorithm for obtaining an original name of each of the multiple shared libraries; a size of a memory reserved for the MSL when memory mapping is performed;a memory address of the sixth section;a memory address of at least one fourth section shared among the multiple shared libraries.

[0192] In a possible implementation, the indication of the size of the multiple fifth sections includes an indication of a size of each of the multiple fifth sections in the third section and an indication of a number of the multiple shared libraries.

[0193] In a possible implementation, the indication of the memory address of the sixth section includes an indication of a start of the memory address of the sixth section and an indication of a size of the sixth section.

[0194] FIG. 9 is a structural diagram of an electronic device according to one or more embodiments of the present disclosure, the electronic device may be a first end or a second end. As shown in FIG. 9, the electronic device 900 may include: a processor 901 coupled to a memory 902 in a communicative way via an interface 903; where the memory 902 stores a computer executable instruction; the processor 901 executes the computer executable instruction stored in the memory 902 for executing any of the above data processing methods. It should be noted that, the memory 902 may be included or excluded from the electronic device, depending on actual needs.

[0195] In a possible implementation, the electronic device may include a transceiver, a processor, and a memory. The memory may be configured to store code, instructions, and the like executed by the processor.

[0196] FIG. 10 is a schematic diagram of an architecture of a computing device cluster according to one or more embodiments of the present disclosure. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smartphone.

[0197] As shown in FIG. 10, the cluster of computing devices described includes at least one computing device 1000. The memory 1006 in one or more of the computing devices 1000 in the cluster of computing devices can hold the same instructions for performing the method describedin the above embodiments.

[0198] In some possible implementations, some of the instructions for performing the method described in the above embodiments can also be separately held in the memory 1006 of the one or more computing devices 1000 in the cluster of computing devices. In other words, a combination of the one or more computing devices 1000 can jointly execute instructions for performing the method described in the above embodiments.

[0199] It is noted that the memories 1006 in the different computing devices 1000 in the cluster of computing devices can store different instructions for performing some of the functions of the computing devices 1000, respectively.

[0200] In some possible implementations, one or more computing devices in a cluster of computing devices can be connected via a network. Among other things, the network can be a wide area network or a local area network, etc. FIG. 11 illustrates one possible implementation. FIG. 11 is a schematic diagram of a connection between computing devices 1100 A and 1100B over a network according to one or more embodiments of the present disclosure. The two computing devices 1100A and 1100B are connected to each other via a network. Specifically, the connection to said network is made through a communication interface in each computing device. In this class of possible implementations, the memory 1006A in the computing device 1000A holds instructions for performing a part of the method described in the above embodiments. At the same time, the memory 1006B in the computing device 1000B holds instructions for performing other part(s) of the method described in the above embodiments.

[0201] The functions of computing device 1100A illustrated in FIG. 11 can also be accomplished by multiple computing devices. Similarly, the functions of computing device 1100B can be accomplished by multiple computing devices.

[0202] It should be understood that the processor may be an integrated circuit chip and has a data processing capability. In an implementation process, steps of the foregoing method embodiments may be completed by using a hardware integrated logic circuit in the processor, or by using instructions in a form of software. The processor may be a general-purpose processor, a central processing unit (CPU), a graphics processing unit (GPU), a neural processing unit (NPU), a system on chip (SoC) or another programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. The processor may implement or perform the methods, the steps,and the logical block diagrams that are disclosed in the embodiments of the present disclosure. The general-purpose processor may be a microprocessor, or the processor may be any conventional processor or the like. The steps of the methods disclosed with reference to the embodiments of the present disclosure may be directly performed and completed by a hardware decoding processor, or may be performed and completed by using a combination of hardware in the decoding processor and a software module. 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 readonly memory, an electrically erasable programmable memory, or a register. The storage medium is located in the memory, and the processor reads information in the memory and completes the steps of the foregoing methods in combination with hardware in the processor.

[0203] It may be understood that the memory in the embodiments of the present disclosure may be a volatile memory or a non-volatile memory, or may include both a volatile memory and a non¬ volatile memory. The non-volatile memory may be a read-only memory (Read-Only Memory, ROM), a programmable read-only memory (Programmable ROM, PROM), an erasable programmable read-only memory (Erasable PROM, EPROM), an electrically erasable programmable read-only memory (Electrically EPROM, EEPROM), or a flash memory. The volatile memory may be a random-access memory (Random Access Memory, RAM) and is used as an external cache. By way of example rather than limitation, many forms of RAMs may be used, and are, for example, a static random access memory (Static RAM, SRAM), a dynamic random access memory (Dynamic RAM, DRAM), a synchronous dynamic random access memory (Synchronous DRAM, SDRAM), a double data rate synchronous dynamic random access memory (Double Data Rate SDRAM, DDR SDRAM), an enhanced synchronous dynamic random access memory (Enhanced SDRAM, ESDRAM), a synchronous link dynamic random access memory (Synchronous link DRAM, SLDRAM), and a direct rambus random access memory (Direct Rambus RAM, DR RAM).

[0204] It should be noted that the memory described in this specification includes but is not limited to these memories and could be a memory of any other appropriate type.

[0205] An embodiment of the present disclosure provides a computing device cluster, including a processing circuitry for performing any of the above data processing methods.

[0206] An embodiment of the present disclosure provides a chip, including an input / output (I / O)interface and a processor, where the processor is configured to call and run a computer program stored in a memory, to enable a device installing with the chip to perform any of the above data processing methods.

[0207] An embodiment of the present disclosure provides a computer-readable medium storing computer execution instructions which, when executed by a processor, causes the processor to execute any of the above data processing methods. Optionally, the storage medium may be specifically a memory.

[0208] An embodiment of the present disclosure provides a computer program product including computer execution instructions which, when executed by a processor, causes the processor to execute any of the above data processing methods.

[0209] An embodiment of the present disclosure provides a computer program including computer execution instructions which, when executed by a processor, causes the processor to execute any of the above data processing methods.

[0210] A person of ordinary skill in the art may be aware that, in combination with the examples described in the embodiments disclosed in this specification, units and algorithm steps can be implemented by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are performed by hardware or software depends on particular applications and design constraints of the technical solutions. A person skilled in the art may use different methods to implement the described functions for each particular application, but it should not be considered that the implementation goes beyond the scope of this disclosure.

[0211] In the several embodiments provided in this disclosure, it should be understood that the disclosed system, apparatus, and method may be implemented in other manners. For example, the described apparatus embodiment is merely an example. For example, the unit division is merely logical function division and may be other division in actual implementation. For example, a plurality of units or components may be combined or integrated into another system, or some features may be ignored or not performed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections may be implemented through some interfaces. The indirect couplings or communication connections between the apparatuses or units may be implemented in electronic, mechanical, or other forms.

[0212] The units described as separate parts may be or may not be physically separate, and partsdisplayed as units may be or may not be physical units, may be located in one position, or may be distributed on a plurality of network units. Some or all of the units may be selected based on actual requirements to achieve the objectives of the solutions of the embodiments.

[0213] In addition, functional units in the embodiments of this disclosure may be integrated into one processing unit, or each of the units may exist alone physically, or two or more units are integrated into one unit.

[0214] When the functions are implemented in a form of a software functional unit and sold or used as an independent product, the functions may be stored in a computer readable storage medium. Based on such an understanding, the technical solutions in this disclosure essentially, or the part contributing to the prior art, or some of the technical solutions may be implemented in a form of a software product. The computer software product is stored in a storage medium, and includes several instructions for instructing a computer device (which may be a personal computer, a server, a network device, or the like) to perform all or some of the steps of the methods described in the embodiments of this disclosure. The foregoing storage medium includes: any medium that can store program code, such as a USB flash drive, a removable hard disk, a read-only memory (Read-Only Memory, ROM), a random-access memory (Random Access Memory, RAM), a magnetic disk, or an optical disc.

[0215] Although the present disclosure describes methods and processes with steps in a certain order, one or more steps of the methods and processes may be omitted or altered as appropriate. One or more steps may take place in an order other than that in which they are described, as appropriate.

[0216] In this disclosure, “at least one” means one or more, and “a plurality of’ means two or more, “and / or” describes an association relationship of associated objects, and indicates that there may be three relationships. For example, A and / or B may indicate cases includes “only A”, “both A and B”, and “only B”, where A and B may be singular or plural. The charactergenerally indicates that the associated objects are in an OR relationship. “At least one of the following items” or a similar expression thereof refers to any combination of these items, including any combination of a single item or a plurality of items. For example, “at least one of a, b, or c” may represent a, b, c, “a and b”, “a and c”, “b and c”, or “a, b and c”, where a, b, and c may be a single or multiple form.

[0217] Although the present disclosure is described, at least in part, in terms of methods, a person of ordinary skill in the art will understand that the present disclosure is also directed to the various components for performing at least some of the aspects and features of the described methods, be it by way of hardware components, software or any combination of the two. Accordingly, the technical solution of the present disclosure may be embodied in the form of a software product. A suitable software product may be stored in a pre-recorded storage device or other similar nonvolatile or non-transitory computer readable medium, including DVDs, CD-ROMs, USB flash disk, a removable hard disk, or other storage media, for example. The software product includes instructions tangibly stored thereon that enable a processing device (e.g., a personal computer, a server, or a network device) to execute examples of the methods disclosed herein. The machineexecutable instructions may be in the form of code sequences, configuration information, or other data, which, when executed, cause a machine (e.g., a processor or other processing device) to perform steps in a method according to examples of the present disclosure.

[0218] The present disclosure may be embodied in other specific forms without departing from the subject matter of the claims. The described example embodiments are to be considered in all respects as being only illustrative and not restrictive. Selected features from one or more of the above-described embodiments may be combined to create alternative embodiments not explicitly described, features suitable for such combinations being understood within the scope of this disclosure.

Claims

1. CLAIMS1. A data processing method, comprising:3.loading, by a device based on a merged shared library (MSL) and in response to an instruction for executing a program, execution information of a first shared library called by the program, wherein the MSL comprises execution information of each of multiple shared libraries, the multiple shared libraries comprise the first shared library, and at least two of the multiple shared libraries have a dependency therebetween.

2. The method according to claim 1, wherein the first shared library depends on at least one second shared library comprised in the multiple shared libraries, and the method further comprises:5.loading, by the device based on the MSL and a dependency between the first shared library and each of the at least one second shared library in the multiple shared libraries, execution information of each of the at least one second shared library in the multiple shared libraries.

3. The method according to claim 2, wherein for each of the at least one second shared library, the dependency between the first shared library and the second shared library is represented by execution of one or more functions in the second shared library being called by execution of one or more functions in the first shared library.

4. The method according to any one of claims 1 to 3, wherein the loading of the first shared library comprises:8.checking, by the device in response to the instruction for executing the program, whether there is a link between the first shared library and the MSL;9.loading, by the device, when there is a link between the first shared library and the MSL, the execution information of the first shared library from the MSL based on the link between the first shared library and the MSL, wherein the link is indicative of the first shared library.

5. The method according to any one of claims 1 to 4, wherein the execution information of each of the multiple shared libraries comprises attribute information of each of the multiple shared libraries, first sections parsed from each of the multiple shared libraries and second sections for each of the multiple shared libraries generated based on the first sections, wherein the attribute information of each of the multiple shared libraries is used for determining metadata of each of the multiple shared libraries.

6. The method according to claim 5, wherein the loading of the first shared library comprises: constructing, by the device, a variable of the first shared library when loading the first shared library;wherein the method further comprises:12.deconstructing, by the device, the variable of the first shared library when the execution of the program is finished.

7. The method according to claim 5 or 6, wherein at least two of the first sections with a same postfix are from a same shared library.

8. The method according to any one of claims 5 to 7, wherein the MSL comprises a first part and a second part;15.wherein the first part of the MSL comprises the first sections parsed from each of the multiple shared libraries, the second sections for each of the multiple shared libraries and a third section; the third section comprises the attribute information of each of the multiple shared libraries and is indicative of the first sections, the second sections and information about dependencies among the multiple shared libraries, wherein each of the dependencies among the multiple shared libraries is represented by execution of one or more functions in one of the multiple shared libraries being called by execution of one or more functions in another one of the multiple shared libraries; wherein the second part of the MSL is indicative of the third section and the first sections parsed from each of the multiple shared libraries.

9. The method according to claim 8, wherein the second part comprises a first header and multiple second headers corresponding to the multiple shared libraries one-by-one;17.wherein the first header is indicative of a type of the MSL, the third section and a reference to the second header;18.wherein for each of the multiple second headers, the second header is indicative of first sections parsed from a shared library corresponding to the second header.

10. The method according to claim 8 or 9, wherein the second sections for each of the multiple shared libraries comprise at least one fourth section and information of at least one function comprised in each of the multiple shared libraries, wherein the at least one fourth section is generated based on the functions comprised in the multiple shared libraries and the information about the dependencies among the multiple shared libraries.

11. The method according to any one of claims 8 to 10, wherein the third section comprises a third header, multiple fifth sections corresponding to the multiple shared libraries one-by-one, and a sixth section;21.wherein the third header is indicative of each of the multiple fifth sections and the sixth section;22.wherein each of the multiple fifth sections is used for storing the attribute information of each of the multiple shared libraries; wherein the sixth section is used for storing data indicated by the attribute information of each of the multiple shared libraries.

12. A data processing apparatus, comprising:24.a loading module, configured to load, based on a merged shared library (MSL) and in response to an instruction for executing a program, execution information of a first shared library called by the program, wherein the MSL comprises execution information of each of multiple shared libraries, the multiple shared libraries comprise the first shared library, and at least two of the multiple shared libraries have a dependency therebetween.

13. The apparatus according to apparatus 12, wherein the first shared library depends on at least one second shared library comprised in the multiple shared libraries, and the loading module is further configured to:26.load, based on the MSL and a dependency between the first shared library and each of the at least one second shared library in the multiple shared libraries, execution information of each of the at least one second shared library in the multiple shared libraries.

14. The apparatus according to claim 13, wherein for each of the at least one second shared library, the dependency between the first shared library and the second shared library is represented by execution of one or more functions in the second shared library being called by execution of one or more functions in the first shared library.

15. The apparatus according to any one of claims 12 to 14, wherein the loading module is further configured to:29.check, in response to the instruction for executing the program, whether there is a link between the first shared library and the MSL;30.load, when there is a link between the first shared library and the MSL, the execution information of the first shared library from the MSL based on the link between the first shared library and the MSL, wherein the link is indicative of the first shared library.

16. The apparatus according to any one of claims 12 to 15, wherein the execution information of each of the multiple shared libraries comprises attribute information of each of the multiple shared libraries, first sections parsed from each of the multiple shared libraries and second sections for each of the multiple shared libraries generated based on the first sections, wherein the attribute information of each of the multiple shared libraries is used for determining metadata of each of the multiple shared libraries.

17. The apparatus according to claim 16, wherein the loading module is further configured to: construct a variable of the first shared library when loading the first shared library; deconstruct the variable of the first shared library when the execution of the program isfinished.

18. A computing device cluster, comprising a processing circuitry for performing the method according to any one of claims 1 to 11.

19. A computer program product comprising program code for performing the method according to any one of claims 1 to 11.

20. A computer-readable medium storing computer execution instructions which, when executed by a processor, causes the processor to execute the method according to any one of claims 1 to 11.

Citation Information

Patent Citations

  • Systems And Methods For Embedded Shared Libraries In An Executable Image

    US20140282457A1

  • Shared library optimization for heterogeneous programs

    US6460178B1