Detailed Description
Reference will now be made in detail to embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the drawings are illustrative only and should not be construed as limiting the invention.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may also be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. As used herein, the term "and/or" includes all or any element and all combinations of one or more of the associated listed items.
It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
As will be appreciated by those skilled in the art, a "terminal" as used herein includes both devices having a wireless signal receiver, which are devices having only a wireless signal receiver without transmit capability, and devices having receive and transmit hardware, which have devices having receive and transmit hardware capable of two-way communication over a two-way communication link. Such a device may include: a cellular or other communication device having a single line display or a multi-line display or a cellular or other communication device without a multi-line display; PCS (Personal Communications Service), which may combine voice, data processing, facsimile and/or data communication capabilities; a PDA (Personal Digital Assistant), which may include a radio frequency receiver, a pager, internet/intranet access, a web browser, a notepad, a calendar and/or a GPS (Global Positioning System) receiver; a conventional laptop and/or palmtop computer or other device having and/or including a radio frequency receiver. As used herein, a "terminal" or "terminal device" may be portable, transportable, installed in a vehicle (aeronautical, maritime, and/or land-based), or situated and/or configured to operate locally and/or in a distributed fashion at any other location(s) on earth and/or in space. As used herein, a "terminal Device" may also be a communication terminal, a web terminal, a music/video playing terminal, such as a PDA, an MID (Mobile Internet Device) and/or a Mobile phone with music/video playing function, or a smart tv, a set-top box, etc.
The inventor of the present invention has found through research that different operating systems have different ABIs (Application binary interfaces), that is, different basic data structures are required for running applications in different operating systems, and files related to the basic data structures include executable programs and (dynamic) basic library files. The application of different operating systems has different calling modes for calling the basic library file through the system; specifically, the operating systems and the loaders generally correspond one to one, and each application of the operating system generally designates the loader of the operating system to load the base library file on which the application depends during compilation; applications of different operating systems therefore specify different loaders during compilation, and different loaders typically correspond to different base library files and search paths of the base library. The loader of one operating system is typically unable to acquire and load the base library file corresponding to another loader.
The embodiment of the invention supports at least two operating systems, and for convenience of expression and understanding, the operating system to which an application sending an operation request belongs is selected as a first operating system; the operating systems of the at least two operating systems other than the first operating system are other operating systems. And each operating system corresponds to a loader and a base library file respectively.
When the kernel receives an operation request of an application, a first improved basic library file loader of a first operating system to which the application belongs and a basic library file which is depended by the application to be loaded by the first improved basic library file loader are determined; determining an operating system to which a basic library file depended by the application belongs according to information contained in the executable file of the application; and when the operating system to which the basic library file depended by the application belongs is other operating systems, calling other basic library file loaders of other operating systems in the first improved basic library file loader, and acquiring the basic library file depended by the application from the public library for loading so as to supply the application call. Therefore, in the embodiment of the present invention, the public library includes most of the basic library files on which the application in each operating system depends, and the application is started and run by identifying the operating system to which the basic library file on which the application depends belongs, and then calling the loader corresponding to the identified operating system, and obtaining and loading the basic library file on which the application depends from the public library. Compared with the sum of the traditional basic libraries allocated for each operating system, the public library reduces a large number of same basic library files, namely reduces a large number of redundant basic library files, reduces the storage space occupied by the basic libraries and improves the utilization rate of storage resources.
The technical solution of the embodiments of the present invention is specifically described below with reference to the accompanying drawings.
A frame schematic diagram of an internal structure of a terminal device according to an embodiment of the present invention is shown in fig. 1, and includes: a kernel and at least two operating systems.
The at least two operating systems include a first operating system, a second operating system, … …, and an Nth operating system. N is a positive integer of 2 or more.
The operating system of an embodiment of the present invention includes a container system.
The operating system in the embodiment of the present invention may be an operating system disposed in a container created by L inux container virtualization technology, such as a L inux operating system or a Unix operating system in the conventional sense, an Android system or an Ubuntu system derived from a L inux operating system, or a Windows system based on a Windows platform.
The kernel in the embodiment of the invention is improved on the basis of the traditional L inux kernel, the added main functions comprise that when an operation request of an application is received, an operating system to which a basic library file depended by the application belongs is determined, and a basic library file loader of the operating system is called to load the basic library file depended by the application, and the specific functions are described in detail in the following, and are not described again.
For ease of understanding, one of the at least two operating systems is taken as the first operating system, and the other of the at least two operating systems except the first operating system is taken as the other operating system. Each operating system corresponds to a respective base library file loader; each base library file loader corresponds to a respective base library file; all or most of the base library files are stored in a common library. Preferably, the public library comprises base library files other than base C (C language) library files.
Preferably, the base library file is a dynamic base library file.
The following develops and introduces a multisystem basic library file loading method according to an embodiment of the present invention, and a flow diagram of the method is shown in fig. 2, and includes the following steps:
s201: when the kernel receives an operation request of the application, a first improved basic library file loader of a first operating system to which the application belongs and a basic library file which is depended by the application to be loaded are determined.
And after receiving the instruction for starting operation, the application in the first operating system sends an operation request to the kernel.
When the kernel receives the running request of the application of the first operating system and the basic library file which is depended by the application of the first operating system is loaded in a dlopen mode, the first improved basic library file loader and the basic library file which is depended by the application to be loaded by the first improved basic library file loader are determined.
Preferably, the kernel determines the first modified base library file loader and the base library file, to which the application is to be loaded by the first modified base library file loader, according to an instruction for loading the base library file in a dlopen manner in the operation request of the application of the first operating system.
The standard usage is exemplified by: when the kernel receives a void handle (xxx) instruction of an application of the first operating system, determining that a base library file depended on by the application to be loaded is xxx. In the above instruction, handle represents a handle; dlopen represents a system call that is used primarily to open a dynamically linked base library file and return a handle.
The first improved base library file loader comprises: a base library file loader of the first operating system, and other base library file loaders. Further, the first modified base library loader comprises: the base library file loader of the first operating system, and the portion of the other base library file loaders used to load base library files specific to the other operating systems as compared to the first operating system.
It can be seen that, in the embodiment of the present invention, an application default of an operating system specifies that a base library file loader of the operating system loads a base library file on which the application depends; the embodiment of the invention can be implemented without changing the existing application; that is to say, the embodiment of the present invention has strong compatibility with a large number of existing applications.
S202: the kernel suspends the loading of the basic library file which is depended on by the application by the first improved basic library file loader, and judges whether the basic library file which is depended on by the application is a basic C library file or not; if not, executing step S203; if yes, go to step S207.
The inventor notices that in the conventional method for loading a base library file by using a dlopen mode, a dynamic base library is opened by using a dlopen function for a kernel, and the dlopen function directly triggers a loading process of a first L inker (base library file loader) of a first operating system, namely, the first L inker is called to load xxx.
In this embodiment of the present invention, steps S201 and S202 may be executed synchronously. In the embodiment of the invention, the function of the kernel is improved; in the process that the kernel loads the basic library file which is depended on by the application of the first operating system in a dlopen mode, determining the basic library file which is depended on by the application to be loaded by the first improved basic library file loader, and simultaneously suspending the loading of the basic library file which is depended on by the application by the first improved basic library file loader; judging whether a basic library file depended on by the application is a basic C library file or not; if not, executing step S203; if yes, go to step S207.
S203: and the kernel determines an operating system to which the basic library file depended by the application belongs according to the information contained in the executable file of the application.
And the kernel determines an operating system to which the basic library file depended by the application belongs according to the header information of the executable file of the application.
Preferably, the executable program of the application is loaded; analyzing header information of an executable program of the application; and determining a first improved type basic library file loader of a first operating system to which the application belongs according to the header information.
Preferably, the present inventors have noted that the compilation process may be divided into two steps, where the first step compiles the source code of the application into linkable intermediate files, for example, the linkable intermediate files may be files with the suffix name of.o, the second step compiles all linkable intermediate files corresponding to the application (for example, files with the name of. o, wildcard, representing several characters) into Executable files, during the linking process, the compiler fills in the header of the Executable program files with E L F (Executable and L in linkable Format) information, and in the E L F header information, a field called Interpreter is included, which specifies which L inker (basic library file loader) is used to load the dynamic basic library files.
Preferably, the kernel analyzes the E L F information in the header information of the executable program of the application after loading the executable program of the application into the memory, reads the content of the Interpreter field from the E L F information, and determines the operating system to which the basic library file depended by the application belongs according to the content of the Interpreter field.
S204: the kernel judges whether an operating system to which the basic library file depended by the application belongs is a first operating system; if not, go to step S205; if yes, go to step S206.
And the kernel judges whether the operating system to which the basic library file depended by the application belongs is the first operating system to which the application belongs according to the preset corresponding relation between the operating systems and the basic library files.
Wherein, one operating system can correspond to a plurality of basic library files; the same base library file may correspond to multiple operating systems.
Preferably, one operating system may correspond to multiple base library files in a common library; one base library file in the common library may correspond to multiple operating systems.
The corresponding relation between the operating systems and the base library files can also be preset in each L inker or operating system, and is transferred to the kernel when the base library file needs to be called (i.e. the base library file on which the application depends is determined).
S205: and the kernel calls other basic library file loaders of other operating systems in the first improved basic library file loader, acquires the basic library file depended by the application from the public library and loads the basic library file to be called by the application.
When the operating system to which the base library file depended by the application belongs is other operating systems (referring to operating systems other than the first operating system), the kernel calls other base library file loaders of other operating systems in the first improved base library file loader, and acquires the base library file depended by the application from the public library to load so as to supply the application call.
Preferably, the basic library file loaders of a plurality of operating systems in the terminal equipment can be detachably combined together to form a modified basic library file loader; the first, second and N operating systems correspond to the first, second and N modified base library file loaders, respectively. The first modified base library file loader, the second modified base library file loader, …, and the nth modified base library file loader are all the same. For the first modified base library file loader, the second, …, N modified base library file loader is the other modified base library file loader for the other operating systems.
When the operating system to which the basic library file depended by the application belongs is other operating systems, the kernel calls other basic library file loaders of other operating systems in the first improved basic library file loader from the comprehensive basic library file loader, and obtains the basic library file depended by the application from the public library to load so as to supply for calling.
It can be understood that in this step, the base library file on which the application depends in the public library is actually called by other base library file loaders; in the embodiment of the invention, the corresponding (loading) relationship between the basic library file and the basic library file loader is reserved; but the basic library file loader of each operating system is expanded, so that each operating system can call basic library files which belong to other operating systems in the public library according to the expanded basic library file loader. Not only can the sharing of the basic library files among different operating systems be realized; and the same (redundant) basic library files in the public library can be reduced, and the storage space occupied by the basic library files is saved.
Preferably, the inventor of the present invention considers that, in a plurality of base library files corresponding to base library file loaders of different operating systems in a terminal device, there exist both the same base library file and different base library files.
For each operating system, determining, for each other operating system except for the operating system, a base library file unique to the other operating system as compared to the operating system; further using the part of other base library file loader for loading the special base library file as the sub loader of other base library file of other operating system compared with the operating system; and then, combining the basic library file loader of the operating system and at least one other basic library file sub-loader to obtain the improved basic library file loader of the operating system.
It will be appreciated that the base library file loader of each operating system, and each other operating system, is different than the other base library file child loaders of that operating system.
And regarding the first operating system, using the part of the other base library file loader used for loading the base library file which is unique to the other operating system compared with the first operating system as the other base library file child loader of the other operating system. Therefore, the base library files corresponding to the other base library file sub-loaders are base library files specific to the other operating systems compared to the first operating system.
The kernel pre-combines the (first) base library file loader of the first operating system with other base library file child loaders into a first improved base library file loader. That is, the first modified base library file loader comprises: a (first) base library file loader of the first operating system, and other base library file child loaders other than the first operating system.
Further, a second modified base library file loader for a second operating system is similarly obtained, the second modified base library file loader comprising: a (second) base library file loader of the second operating system, and other base library file child loaders of other operating systems other than the second operating system. Similarly, a third modified base library file loader, … and an Nth modified base library file loader can be obtained. Preferably, the first modified base library file loader, the second modified base library file loader, the … and the nth modified base library file loader are the same.
And the kernel calls other preset basic library file sub-loaders of other operating systems from the first improved basic library file loader, and the other basic library file sub-loaders acquire basic library files depended by the application from the public library for loading.
It can be understood that in this step, the basic library file on which the application depends in the public library is actually called by other basic library file child loaders; in the embodiment of the invention, the corresponding (loading) relationship between the basic library file and the basic library file sub-loader is reserved; and according to the other basic library file sub-loaders, the basic library file loader of one operating system is expanded, so that the operating system can call the basic library files which belong to other operating systems in the public library according to the expanded basic library file loader. The method can further reduce the content expanded by the basic library file loader and reduce the storage space occupied by the expanded basic library file loader under the condition of sharing the basic library files of different operating systems and reducing the same (redundant) basic library files in the public library.
Furthermore, the inventor of the present invention found that different L inkers perform the loading process of the dynamic basic library files, then different L inkers have different dynamic basic library search path sequences, because the dynamic basic library files are placed in different positions, a configuration file is correspondingly arranged for each L inker to indicate L inkers need to search those paths to find the corresponding dynamic basic library files, for example, the search path of the dynamic basic library of one operating system includes (/ lib,/usr/lib), while the search path of the dynamic basic library of another operating system is (/ system/lib)
In the embodiment of the invention, the kernel calls other basic library file sub-loaders, and obtains the basic library file depended by the application from the public library to load according to the preset basic library file search path corresponding to the other basic library file sub-loaders.
And after loading the basic library file which the application depends on, calling the basic library file by the application.
For example, the kernel specifies a specific function XYZ in a base library file (xxx.so file pointed to by a handle) required by an application, based on a funcPtr (handle "XYZ") instruction, and assigns the address of this function to funcPtr. The application accesses this function address, i.e., the substantive call to the XYZ function, using the funcPtr () instruction. In the instruction, dlsym represents a system call, and is mainly used for returning an address corresponding to a symbol according to an operation handle and the symbol of the dynamic link basic library file. Not only the function address but also the variable address can be obtained using this function.
S206: and the kernel calls a first improved basic library file loader to acquire a basic library file depended by the application from the public library for loading.
And when the operating system to which the basic library file depended by the application belongs is the first operating system, calling a (first) basic library file loader of the first operating system in the first improved basic library file loader, and acquiring the basic library file depended by the application from the public library for loading.
Preferably, the first modified base library file loader is configured to resume from a suspended state, in which the (first) base library file loader of the first operating system loads the base library file that the application depends on, to a loaded state, that is, obtain the base library file that the application depends on from the common library to load.
S207: and the kernel calls the first improved basic library file loader to acquire the basic C library file depended by the application for loading.
Preferably, the base library files in the public library in the embodiment of the present invention are all dynamic base library files except the base c library file.
In the embodiment of the invention, different operating systems are correspondingly preset with different libc base libraries, for example, one operating system depends on a glibc base c library, and the other operating system depends on bionic L ibc, glibc and bionic and is a file name obtained by compiling an open source library.
The kernel calls a (first) basic library file loader of a first operating system in the first improved basic library file loader, acquires a basic C library file on which the application depends through a traditional path, and loads the acquired basic C library file.
A specific example of the multi-system base library file loading method according to the embodiment of the present invention is described below, and a schematic diagram of the specific example is shown in fig. 3a, applications 1 and 2 are applications of a first operating system and a second operating system, respectively, L inker1 and 2 are a base library file loader of the first operating system and a base library file loader of the second operating system, respectively, base C libraries 1 and 2 are base C library files of the first operating system and base C library files of the second operating system, respectively, other base library files of the first operating system and the second operating system except the base C library files are all preset in a common library, and L inker1 and 2 acquire and load the base C library 1 and the base C library 2 through respective conventional paths.
When it is determined that the base library file on which the application 1 depends is not the base C library file and the base library file belongs to the second operating system, L inker2 is called from L inker1 or a second base library file sub-loader (not shown) acquires the base library file from the common library and loads the base library file.
Fig. 3b is a partially detailed schematic diagram of a specific example of a multi-system base library file loading method according to an embodiment of the present invention, in fig. 3b, L inker1 except L inker2.a and L0 inker2 except L inker1.a represent a base library file loader of a first operating system and a base library file loader of a second operating system, respectively, a dynamic library of system 2 represents a base library file specific to the second operating system as compared to the first operating system, L inker2.a represents L inker2 a portion for loading a base library file specific to the second operating system as compared to the first operating system, a dynamic library of system 1 represents a library base file specific to the first operating system as compared to the second operating system, L inker1.a represents L inker1 for loading a base library file specific to the first operating system as compared to the second operating system, and a base library file loader of the second operating system is represented by a base library base file loader of the first operating system, a base library base file loader of the second operating system, and a base library file loader of the second operating system, and the base library file loader of the first operating system, the second operating system, the base loader, the base library file loader of the second operating system, the base library file loader of the type 395968, the second operating system, the base library file loader, the base library file of the second operating system, the base file type L, the base file of the second operating system.
When it is determined that the base library file on which application 1 depends is not the base C library file and that the base library file belongs to the second operating system, L inker2.a is called from L inker1 to obtain the base library file from the public library and load the same.
Based on the above multi-system basic library file loading method, an embodiment of the present invention further provides a multi-system basic library file loading apparatus, where the apparatus is disposed in a terminal device, and a frame diagram of an internal structure of the apparatus is shown in fig. 4, and the method includes: a base library file determination module 401 and a base library file loading module 402.
The basic library file determining module 401 is configured to determine, when receiving an operation request of an application, a first improved basic library file loader of a first operating system to which the application belongs and a basic library file on which the application to be loaded depends.
The base library file loading module 402 is configured to determine, according to information included in the executable file of the application, an operating system to which the base library file dependent on the application belongs; and when the operating system to which the basic library file depended by the application belongs is other operating systems, calling other basic library file loaders of other operating systems in the first improved basic library file loader, and acquiring the basic library file depended by the application from the public library for loading so as to supply the application call.
Preferably, the basic library file determining module 401 is further configured to suspend loading of the basic library file depended on by the application by the first modified basic library file loader when determining the basic library file depended on by the application to be loaded by the first modified basic library file loader, and determine whether the basic library file depended on by the application is the basic library C file.
The base library file loading module 402 is further configured to call the first improved base library file loader to acquire the base C library file on which the application depends for loading when the base library file determination module determines that the base library file on which the application depends is the base C library file; when the basic library file determining module judges that the basic library file on which the application depends is not the basic C library file, determining an operating system to which the basic library file on which the application depends belongs according to information contained in the executable file of the application; wherein the public library comprises base library files other than the base C library file.
Preferably, the basic library file loading module 402 is specifically configured to invoke other basic library file child loaders of other preset operating systems from the first improved basic library file loader, and obtain a basic library file depended by the application from the public library for loading; and the base library files corresponding to the other base library file sub-loaders are base library files which are unique to other operating systems compared with the first operating system.
Preferably, the basic library file loading module 402 is specifically configured to invoke other basic library file sub-loaders, and obtain a basic library file depended by the application from the public library for loading according to a preset basic library file search path corresponding to the basic library file sub-loader.
Preferably, the base library file loading module 402 is specifically configured to determine, according to header information of an executable file of the application, an operating system to which the base library file depended by the application belongs.
Preferably, the base library file loading module 402 is further configured to, after determining, according to information included in the executable file of the application, an operating system to which the base library file depended by the application belongs, and when the operating system to which the base library file depended by the application belongs is the first operating system, call the first improved base library file loader to obtain, from the public library, the base library file depended by the application for loading.
The method for implementing the functions of the basic library file determining module 401 and the basic library file loading module 402 may be configured to parameter the contents of the specific process and steps of the multi-system basic library file loading method, which is not described herein again.
In the embodiment of the invention, the corresponding loading relation between the base library file and the base library file loader is reserved, and the base library file loader of each operating system is expanded into an improved base library file loader. When the operating system to which the basic library file depended by the application sending the operation request belongs is other operating systems, other basic library file loaders of other operating systems in the first improved basic library file loader can be called to acquire and load the basic library file depended by the application and originally belonging to other operating systems in the public library; not only can the sharing of the basic library files among different operating systems be realized; and the same (redundant) basic library files in the public library can be reduced, and the storage space occupied by the basic library files is saved.
Moreover, in the embodiment of the invention, the corresponding loading relation between the basic library file and the basic library file sub-loader is reserved; and for each operating system, expanding the basic library file loader of the operating system into an improved basic library file loader according to other basic library file sub-loaders. When the operating system to which the basic library file depended by the application sending the operation request belongs is other operating systems, other basic library file sub-loaders of other operating systems in the first improved basic library file loader can be called to acquire and load the basic library file depended by the application and originally belonging to other operating systems in the public library; the method can further reduce the content expanded by the basic library file loader and reduce the storage space occupied by the expanded basic library file loader under the condition of sharing the basic library files of different operating systems and reducing the same (redundant) basic library files in the public library.
In addition, in the embodiment of the invention, the well is mainly carried out on the loader of the kernel and the basic library file, the application itself does not need to be improved, and the method has good compatibility for a large number of applications.
Those skilled in the art will appreciate that the present invention includes apparatus directed to performing one or more of the operations described in the present application. These devices may be specially designed and manufactured for the required purposes, or they may comprise known devices in general-purpose computers. These devices have stored therein computer programs that are selectively activated or reconfigured. Such a computer program may be stored in a device (e.g., computer) readable medium, including, but not limited to, any type of disk including floppy disks, hard disks, optical disks, CD-ROMs, and magnetic-optical disks, ROMs (Read-Only memories), RAMs (Random Access memories), EPROMs (Erasable programmable Read-Only memories), EEPROMs (Electrically Erasable programmable Read-Only memories), flash memories, magnetic cards, or optical cards, or any type of media suitable for storing electronic instructions, and each coupled to a bus. That is, a readable medium includes any medium that stores or transmits information in a form readable by a device (e.g., a computer).
It will be understood by those within the art that each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations, can be implemented by computer program instructions. Those skilled in the art will appreciate that the computer program instructions may be implemented by a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, implement the features specified in the block or blocks of the block diagrams and/or flowchart illustrations of the present disclosure.
Those of skill in the art will appreciate that various operations, methods, steps in the processes, acts, or solutions discussed in the present application may be alternated, modified, combined, or deleted. Further, various operations, methods, steps in the flows, which have been discussed in the present application, may be interchanged, modified, rearranged, decomposed, combined, or eliminated. Further, steps, measures, schemes in the various operations, methods, procedures disclosed in the prior art and the present invention can also be alternated, changed, rearranged, decomposed, combined, or deleted.
The foregoing is only a partial embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.