BINARY IMPLEMENTATION AT THE LEVEL OF A SHARED USED OBJECT
The binary implementation method optimizes software migration by emulating guest platforms within hosts, using a binary translator to leverage existing shared objects and minimize unnecessary emulation, enhancing efficiency and reducing resource usage.
Patent Information
- Application Number
- DE112015006436
- Authority / Receiving Office
- DE · DE
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2015-04-10
- Publication Date
- 2025-01-30
- Estimated Expiration
- 2035-04-10
AI Technical Summary
Existing binary implementation techniques for software programs face inefficiencies and resource consumption when migrating from a guest platform to a host platform, particularly due to the need to emulate entire guest hardware and operating systems, leading to slow performance and high resource usage.
A binary implementation method that emulates the guest platform within the host platform, using a binary translator to determine if corresponding shared objects or libraries exist, and if not, creates binary implementations of these objects or libraries, while optimizing by only emulating functional calls and avoiding unnecessary code execution.
This approach reduces resource consumption and improves performance by minimizing the need to emulate entire guest systems, allowing software programs to run efficiently on host platforms without full hardware emulation.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
CROSS-REFERENCE TO RELATED APPLICATION
[0001] This application is related to an international patent application filed concurrently herewith, having Agent's Docket No. 096553-0074 and entitled "BINARY TRANSLATION INTO NATIVE CLIENT", the entire disclosure of which is incorporated herein by reference. BACKGROUND
[0002] The field technology generally concerns techniques for binary implementation. A software program is usually compiled for a specified platform, which may include a specified hardware architecture, a specified operating system, and / or specified libraries. A user may wish to run this software program on another platform different from the specified platform, which may have a different hardware architecture, a different operating system, or different libraries. In such a case, the platform for which the program is compiled is referred to as the guest, and a platform on which the code is to be executed is referred to as the host.To configure the program for execution on the host platform, the host platform can be programmed to emulate (in software) the specified guest platform, and a binary conversion can be performed to convert the software program from its original form into a new software program that can run on the host platform with the emulated specified guest platform. In a binary conversion, binary code for the specified guest platform is converted into binary code for the host platform.
[0003] US 6438745 B1 discloses a program conversion device comprising a library call instruction detection unit for detecting each library call instruction included in an input object program, the library call instruction calling a source library that is an external program module; a library correspondence table that provides various information, such as the correspondence between arguments of source libraries and arguments of target libraries that have the same function as the source libraries and are called by an output object program;a library call instruction generation unit for converting the detected library call instruction into an instruction that calls a target library corresponding to the source library, and for converting instructions for setting the arguments of the source library into instructions for setting arguments of the target library by referring to the library correspondence table;
[0004] US 2009 / 094586 A1 discloses a native binding technique for inserting calls to native functions during the translation of subject code into target code, such that function calls in the subject program to subject code functions in the target code are replaced by calls to native equivalents of the same functions. Parameters of native function calls are transformed from target code representations to be consistent with native code representations, native code calling conventions, and native function prototypes.
[0005] US 2003 / 101334 A1 discloses systems and methods for integrating emulated and native code, in particular, a method for emulating code from an original computer system on a host computer system. Briefly described, such a method comprises the steps of: retrieving a programming instruction associated with program code to be emulated on a host computer system; determining whether the programming instruction is to be executed natively on the host computer system or emulated on the host computer system; and, if the programming instruction is to be executed natively on the host computer system, outputting a native code fragment associated with the programming instruction into an interface of a dynamic execution layer for execution. SUMMARY
[0006] In some aspects, the subject technology relates to a method. The method includes receiving, at a host platform, a software program written for a specified guest platform different from the host platform, wherein the software program uses a set of shared objects or dynamically loaded libraries, and wherein the software program is incompatible with the host platform. The method includes emulating the specified guest platform within the host platform. The method includes determining whether the host platform has a corresponding shared object or dynamically loaded library, wherein the corresponding shared object or dynamically loaded library comprises a common orA common external interface is implemented with a specified shared object or a specified dynamically loaded library from within the set of shared objects or dynamically loaded libraries. The method includes, if the host platform has the corresponding shared object or dynamically loaded library, using the corresponding shared object or dynamically loaded library instead of the specified shared object or dynamically loaded library to execute the software program within the host platform.The method includes, if the host platform lacks the corresponding shared object or dynamically loaded library, performing a binary conversion of the specified shared object or dynamically loaded library to execute the software program within the host platform.
[0007] In some aspects, the subject technology relates to a non-transitory computer-readable storage medium that stores instructions and data. The instructions include code for receiving, at a host platform, a software program written for a guest platform specified different from the host platform, wherein the software program uses a set of shared objects or dynamically loaded libraries, and wherein the software program is incompatible with the host platform. The instructions include code for determining whether the host platform has a corresponding shared object or dynamically loaded library, wherein the corresponding shared object or dynamically loaded library comprises a common orImplements a common external interface with a specified shared object or dynamically loaded library from within the set of shared objects or dynamically loaded libraries. The instructions include code for, if the host platform has the corresponding shared object or dynamically loaded library, using the corresponding shared object or dynamically loaded library instead of the specified shared object or dynamically loaded library to execute the software program within the host platform.The instructions contain code for, if the host platform lacks the corresponding shared object or dynamically loaded library, performing a binary conversion of the specified shared object or dynamically loaded library to execute the software program within the host platform.
[0008] In some aspects, the subject technology relates to a system. The system includes one or more processors and memory that stores instructions and data. The instructions include code for receiving, at a host platform, a software program written for a specified guest platform different from the host platform, where the software program uses a set of shared objects or dynamically loaded libraries, and where the software program is incompatible with the host platform. The instructions include code for emulating the specified guest platform within the host platform. The instructions include code for determining whether the host platform has a corresponding shared object or dynamically loaded library, where the corresponding shared object or dynamically loaded library is a common orA common external interface is implemented with a specified shared object or dynamically loaded library from within the set of shared objects or dynamically loaded libraries. The instructions include code for, if the host platform has the corresponding shared object or dynamically loaded library, using the corresponding shared object or dynamically loaded library instead of the specified shared object or dynamically loaded library to execute the software program within the host platform.The instructions contain code for, if the host platform lacks the corresponding shared object or dynamically loaded library, performing a binary conversion of the specified shared object or dynamically loaded library to execute the software program within the host platform.
[0009] It is understood that other configurations of the subject technology will be readily apparent from the following detailed description, in which various configurations of the subject technology are shown and described by way of illustration. As will be realized, the subject technology is capable of other and different configurations, and its several details are capable of modification in various other respects, all without departing from the scope of the subject technology. Accordingly, the drawings and detailed description are to be considered as illustrative and not restrictive in nature. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] Features of the art technology are set forth in the appended claims. However, for purposes of explanation, several aspects of the disclosed subject matter are set forth in the following figures. Fig. Figure 1A illustrates an example guest machine that may participate in a binary conversion at a shared object level. Fig. Figure 1B illustrates an example host machine that may participate in a binary conversion at a shared object level. Fig. Figure 2 illustrates an example process by which a binary implementation can be completed at a shared object level. Fig. Figure 3 conceptually represents an exemplary electronic system that implements some implementations of the domain technology. DETAILED DESCRIPTION
[0011] The detailed description set forth below is intended as a description of various configurations of the subject technology and is not intended to represent the only configurations in which the subject technology may be practiced. The accompanying drawings are incorporated herein and form a part of the detailed description. The detailed description contains specific details for the purpose of providing a thorough understanding of the subject technology. It will be clear and apparent, however, that the subject technology is not limited to the details set forth herein and may be practiced without these specific details. In some cases, certain structures and components are shown in block diagram form to avoid obscuring the concepts of the subject technology.
[0012] As used herein, "platform" can refer to an environment necessary for a piece of software to run. The environment can include a hardware architecture, an operating system, and / or multiple libraries. Example platforms include an Android® operating system on ARM® hardware, a Linux® operating system on x86® hardware, and Native Client running on Chrome OS® on x86® hardware. "Binary conversion" can refer to a process for taking binary code from one platform and converting it into binary code for another platform. "Shared object," "shared library," or "dynamic library" can be a file that is intended to be shared or accessed by one or more executable files."Shared object," "shared library," or "dynamic library" is associated with executable files or other objects / libraries at load time or runtime. "Marshalling" can refer to the process of transforming a memory representation of an object from a data format used on one platform to a data format used on another. Additionally, each of the above terms contains its obvious and normal meaning.
[0013] An application can run on one platform. The application can have a main executable and zero or more dynamic libraries. The dynamic libraries can be application-specific or general-purpose. Application-specific dynamic libraries implement application-specific behavior and may be distributed along with the application by the application vendor. General-purpose dynamic libraries implement behavior that may be required by many different applications (e.g., displaying images on a display device). Such libraries are usually distributed separately by their own vendors (e.g., the operating system developer or the hardware developer). In some cases, a general-purpose dynamic library may have versions for many different operating systems.
[0014] The main executable and the dynamic libraries that coexist on a given operating system can communicate with each other by making function calls. The main executable and the dynamic libraries can communicate with the operating system by making system calls.
[0015] The main executable file, the dynamic libraries, and the operating system run on specific hardware. The main executable file, the dynamic libraries, and the operating system are pieces of software compiled for this specific hardware and represented in binary code using the specific hardware instruction set.
[0016] A binary conversion can refer to a process that takes binary code from one platform (the guest platform) and converts it into binary code for another platform (the host platform or the target platform). One goal of a binary conversion is to run applications originally compiled for the guest platform on the host platform without accessing the application's source code and recompiling the source code.
[0017] In some cases, called full machine emulation, a binary translation is performed by taking a map of the original main executable, dynamic libraries, and operating system, and running all of the above on the host hardware. In these cases, a binary translation is used to emulate the guest hardware's instruction set on the host hardware. The advantage of this approach is very precise guest emulation. The disadvantage is relatively slow performance, since a large amount of guest code, including the guest operating system and libraries, must be binary translated.
[0018] In some cases, called system call emulation, a binary implementation is achieved by taking the original main executable and dynamic libraries from the guest and running them on a different operating system or hardware associated with the host. In these cases, the original guest program and its dynamic libraries are binary implemented down to the guest system calls, and the guest system calls are emulated via host system calls. This approach does not emulate the guest code as precisely as the previous approach, but can be more efficient because the original guest operating system is not binary implemented. Likewise, only system calls required by the application can be emulated in the host, greatly reducing complexity.
[0019] The domain technology may involve going further. Specifically, the domain technology may involve taking the original main executable and application-specific dynamic libraries from the guest and running them with the generic dynamic libraries native to the host. A binary translation is used to emulate function calls to the application-specific dynamic libraries (original to the guest), system calls to the guest operating system, and the guest hardware instruction set. Advantages of this approach include that the guest's generic dynamic libraries do not need to be binary translated. Instead, only the function calls required by the original main executable and application-specific libraries are emulated on the host.This approach results in greater efficiency than full machine emulation or system call emulation.
[0020] A complexity of domain technology is the emulation of function calls. Function call interfaces can vary greatly across platforms. Specifically, different platforms may have different calling conventions, where the phrase "calling convention" can refer to how different platforms pass arguments to functions and receive return values from those functions. Different platforms may have different representations for data objects, including differences in the data model and the sizes and alignments of different data types. Likewise, data objects of the same meaning and function may have different internal representations on different platforms. For example, a FILE object will be different in a GNU C library (glibc) and a Bionic C library, even if the data model is the same in both glibc and bionic.
[0021] This complexity can be addressed by converting calling conventions and marshaling (= ordering) data objects. This can be accomplished based on known prototypes of the functions involved and the binary layout of the data objects involved. However, in some cases, converting calling conventions and marshaling data objects may not be feasible. In such cases, several solutions can be used, which are described below. One solution involves using the same address space and a 1:1 pointer mapping for the guest and the host. This avoids marshaling pointers to data objects. Another solution involves providing proxy functions to convert calling conventions from the guest to the host (e.g., "host function wrappers") and from the host to the guest (e.g., "guest function wrappers").The same address can be used for a host function and its corresponding host function wrapper to avoid marshaling pointers to host functions.
[0022] Current binary translation schemes include full machine emulation or userland emulation. As used herein, the term "userland" may refer to, for example, user-space operating system software, which may not be part of a kernel. In full machine emulation, all guest machine hardware is emulated, including the software program for a guest platform, along with an operating system for the guest system. Alternatively, the guest hardware and the operating system associated with the specified guest platform may be emulated using the host platform and host operating system, and the software program may run at the very beginning of this emulation framework. The binary translation schemes described above consume a large amount of resources, such as processor time and memory. As the foregoing illustrates, a new technique for binary translation may be desirable.
[0023] The domain technology concerns a shared-object level binary implementation of a software program that has migrated from a specified guest platform to a host platform. The software program is originally compiled for the specified guest platform, which is different from the host platform. The software program is incompatible with the host platform. The software program uses a set of shared objects or libraries that contain dependencies on system libraries of the specified guest hardware system and vendor libraries created by the vendor and specific to the software program.
[0024] During binary translation, the specified guest platform is emulated within the host platform. For each object or dynamically loaded library in the group of shared objects or dynamically loaded libraries used by the software program, the binary translator determines whether the host platform has a corresponding shared object or dynamically loaded library that implements a common external interface with the object or dynamically loaded library in the group.If the object is a library, the library can be a system library (which is associated with a corresponding system library / object on the host hardware, where the corresponding library / object has the common external interface with the library) or a vendor library (which may not be associated with a corresponding library / object on the host hardware). An example of a system library can be a library for presenting primitive graphics on a display device, which library is present in almost every platform. An example of a vendor library can be a library created by the vendor of the software program for use exclusively with the software program. The vendor libraries can be made available to the user for download (e.g.via the Internet or via a removable disk, such as a CD or USB stick) when the user purchases or requests the software program for download from a machine implementing the specified guest hardware system.
[0025] As used herein, "a corresponding shared object or dynamically loaded library" exists in a host platform for a native object or dynamically loaded library of the guest platform if the corresponding shared object or dynamically loaded library implements a common external interface with the native object or dynamically loaded library.An original object or dynamically loaded library and a corresponding shared object or dynamically loaded library have a "common external interface" if the original object and the corresponding shared object or dynamically loaded library implement similar or substantially the same function calls and implement similar or substantially the same behavior in response to the function calls.
[0026] If the object or dynamically loaded library (e.g., a system library) corresponds to a corresponding shared object or dynamically loaded library on the host hardware, where the corresponding shared object or dynamically loaded library has the same behavior as the object, the binary translator uses the corresponding shared object or dynamically loaded library instead of the object to execute the software program within the host hardware. The binary translator does not binary translate the specified shared object or dynamically loaded library. The binary translator dynamically resolves dependencies within the first program to link to the corresponding shared object or dynamically loaded library of the host platform instead of the object of the specified guest platform.
[0027] Specifically, the binary translator cooperates with dynamic connector mechanisms that implement late binding and resolves entries for functions in host libraries via specialized trampolines. For example, a trampoline can perform an application binary interface (ABI) translation and performs a semantic translation. The trampoline can replace calls to the guest version of the API with calls to the host version of the API. The trampolines can be implemented using custom Executable and Linkable Format (ELF) connectors. During a load, the ELF connector can insert appropriate trampolines into the import table of the object being transferred from the guest to the host.A semantic translation may include a translation of function pointer APIs by making them suitable for invocation by the host, or a transformation of an object binary layout for cases where the host and the guest have different requirements, such as due to an alignment or a different implementation of system libraries on the guest and host platforms.
[0028] As an example, when guest code calls the qsort() standard library function, the guest code stores 'qsort' as an unresolved entry in the library's import table. During late binding, such an entry is filled with the pointer to machine code that does two things: (1) it reads arguments from emulated guest registers and a stack so that they are visible to the host function; and (2) it converts arguments according to the known signature of the 'qsort' function. In other words, guest pointers are converted to host pointers, integers are passed as is, and the function pointer argument is wrapped in dynamically generated host code so that the function pointer argument can be called by the host 'qsort' emulation as needed. Wrapping guest function pointers may involve the reverse conversion from the host ABI to the guest ABI.
[0029] As a result, the guest program achieves the expected behavior while performing desired operations using optimized host versions of the function. The comparator function on the host is run using a binary conversion, while the sorting algorithm itself runs at its native speed.
[0030] The external reference of the shared object in the guest shared object can be resolved either using a host shared object, as described above, or using other guest shared objects. In the latter case, no trampoline is required because both the caller and callee follow the same ABI. Thus, the custom loader can behave in the same way as the standard loader.
[0031] Some domain-specific approaches ensure that a binary implementation, which can be slower and more resource-intensive than a native implementation, is applied only to vendor-provided shared objects for which there is no native host implementation. These approaches are an improvement over other schemes that include providing binary implementations of both vendor-provided libraries and system libraries.
[0032] The technique described above requires the execution of system libraries of the host platform directly on the host platform's hardware and of vendor libraries on an emulation of the specified guest platform on the host platform. As a result, it may be necessary to synchronize state (e.g., registers, a stack, etc.) of the host platform with the state of the emulated specified guest platform. When a call to a host function is made from the guest, the emulation layer performs all necessary argument translation, which may include moving parameters from the emulated guest state to registers and a stack or the host hardware, so that host code can act as if it were being called normally.
[0033] Fig. 1A illustrates an example guest machine 100A that may participate in binary conversion at a shared object level. Guest machine 100A may be any computing device, such as a laptop computer, a desktop computer, a tablet computer, a mobile phone, a personal digital assistant (PDA), an electronic music player, a smart watch, a television, coupled with one or more processors and memory, etc. In some examples, guest machine 100A has ARM hardware.
[0034] As shown, guest machine 100A includes a processing unit 102A, a network interface 104A, and memory 106A. Processing unit 102A includes one or more processors. Processing unit 102A may include a central processing unit (CPU), a graphics processing unit (GPU), or any other processing unit. Processing unit 102A executes computer instructions stored in a computer-readable medium, such as memory 106A. Network interface 104A allows guest machine 100A to send and receive data on a network, such as the Internet, an intranet, a cellular network, a local area network or wide area network, a wired network, a wireless network, a virtual private network (VPN), etc. Memory 106A stores data and / or instructions.Memory 106A may be one or more of a cache unit, a memory unit, an internal storage unit, or an external storage unit. As illustrated, memory 106A includes guest hardware architecture 108A, a software program 110A, guest system objects 122A and 124A, and provider objects 126A and 128A.
[0035] Guest hardware architecture 108A may include any platform used by guest machine 100A, such as registers or a system stack. Software program 110A uses guest hardware architecture 108A during its execution. Software program 110A is written for guest machine 100A and designed to work with guest hardware architecture 108A present in guest machine 100A. Software program 110A may be any software program, such as a word processor, messaging or email program, an audio or video player, an online or offline game program, etc.
[0036] As shown, the software program 110A includes links 112A, 114A, 116A, and 118A. The links 112A and 114A each interface with guest system objects 122A and 124A. The guest system objects 122A and 124A are objects for which a corresponding shared object or dynamically loaded library exists in a host machine (e.g., host machine 100B used in conjunction with Fig. 1B discussed below) where the corresponding shared object or dynamically loaded library implements a common external interface and behavior with the guest system object 122A or 124A. For example, the guest system object 122A or 124A may correspond to a system library implemented in any or all platforms. Examples of a system library include a graphics library for presenting primitive graphics at a display device or a sound library for playing sound files at an audio output device. The links 116A and 118A each interface with provider objects 126A and 128A.
[0037] The provider objects 126A and 128A are objects for which a corresponding shared object or corresponding dynamically loaded libraries are available in a host machine (e.g., host machine 100B, described below in connection with Fig. 1B) where the corresponding shared object or dynamically loaded library implements a common external interface and behavior with the provider object 126A or 128A. For example, the provider objects 126A and 128A may be made available to the user of the guest machine 100A for download (e.g., over a network or via a removable disk such as a CD or USB stick) when the user purchases or requests the software program from the guest machine 100A.
[0038] As discussed above, the software program 110A is designed to run on the guest machine 100A (or another machine with the same platform). The software program 110A is designed to interface with the guest hardware architecture 108A and with the guest system objects 122A and 124A. However, in some cases, it may be desirable to run the guest software program 110A on a host machine (e.g., the host machine 100B, which will be described below in connection with Fig. 1B) with a platform different from that of guest machine 100A. In some implementations, the art technology provides techniques for permitting software program 110A to execute on such a host machine.
[0039] Fig. 1B illustrates an exemplary host machine 100B that may participate in a binary conversion at a shared object level. Host machine 100B may be any computing device, such as a laptop computer, a desktop computer, a tablet computer, a mobile phone, a personal digital assistant (PDA), an electronic music player, a smart watch, a television, coupled with one or more processors and memory, etc. Host machine 100B has a platform that is different from the platform of guest machine 100A. For example, if the platform of guest machine 100A is ARM hardware, the platform of host machine 100B is not ARM hardware and may be, for example, x86 hardware.
[0040] As shown, host machine 100B includes a processing unit 102B, a network interface 104B, and memory 106B. Processing unit 102B includes one or more processors. Processing unit 102B may include a central processing unit (CPU), a graphics processing unit (GPU), or any other processing unit. Processing unit 102B executes computer instructions stored in a computer-readable medium, such as memory 106B. Network interface 104B allows host machine 100B to send and receive data on a network, such as the Internet, an intranet, a cellular network, a local area network, a wide area network, a wired network, a wireless network, a virtual private network (VPN), etc. Memory 106B stores data and / or instructions.Memory 106B may be one or more of a cache unit, a storage unit, an internal storage unit, or an external storage unit. As illustrated, memory 106B includes host hardware architecture 107B, a software program 110B, host system objects 122B and 124B, and a binary translator 130B containing emulated guest hardware architecture 108B and binary translations (BTs) of provider objects 126B and 128B.
[0041] The host hardware architecture 107B may include any platforms used by the host machine 100B, such as registers or a system stack. Software written for the host machine 100B may utilize the host hardware architecture 107B during its execution. The host hardware architecture 107B may be unaware of the presence of the contents of the binary translator 130B, the emulated guest hardware architecture 108B, and the binary translations of the provider objects 126B and 128B. Thus, the host platform may not provide an interface for the emulated guest hardware architecture 108B and the binary translations of the provider objects 126B and 128B to access the host hardware architecture 107B and may operate in its normal manner.
[0042] Binary translator 130B generates and stores emulated guest hardware architecture 108B, which is implemented in software and corresponds to guest hardware architecture 108A in guest machine 100A. Emulated guest hardware architecture 108B of host machine 100B has the same functionality and behavior as guest hardware architecture 108A of guest machine 100A. For example, if guest hardware architecture 108A of guest machine 100A includes registers and stacks implemented in hardware, emulated guest hardware architecture 108B may include registers and stacks with the same functionality and behavior implemented in software at the very beginning of host machine 100B.
[0043] The software program 110B corresponds to the software program 110A of the guest machine 100A. However, the software program 100B is configured to execute on the host machine 100B. The software program 100B interfaces with the emulated guest hardware architecture 108B of the host machine 100B instead of interfacing with the guest hardware architecture 108A of the guest machine 100A. As illustrated, the software program includes links 112B and 114B to host system objects 122B and 124B, respectively. The links 112B and 114B to the host system objects 122B and 124B replace the links 112A and 114A to the guest system objects 122A and 124A of the Fig. 1A. The software program contains links 116B and 118B to binary conversions of provider objects 126B and 128B, respectively. As will be described in more detail below in connection with Fig. 2, provider objects 126A and 128A have binary conversions performed to obtain the binary conversions of provider objects 126B and 128B because a corresponding shared object or corresponding dynamically loaded library having the same external interface, functionality, and behavior does not exist on host machine 100B. Host system objects 122B and 124B are native to the architecture of host machine 100B. Similarly, guest system objects 122A and 124A are native to the architecture of guest machine 100A.
[0044] The link 112B corresponds to the link 112A, and the host system object 122B corresponds to the guest system object 122A. In other words, the host system object 122B implements a common external interface and has common functionality and behavior with the guest system object 122A. As a result, in the process of porting from the guest machine 100A to the host machine 100B, the software program 110B / 110A can be set to connect (via the link 112B / 112A) to the host system object 122B instead of the guest system object 122A.
[0045] The link 114B corresponds to the link 114A, and the host system object 124B corresponds to the guest system object 124A. In other words, the host system object 124B implements a common external interface and has common functionality and behavior with the guest system object 124A. As a result, in the process of porting from the guest machine 100A to the host machine 100B, the software program 110B / 110A can be set to connect (via the link 114B / 114A) to the host system object 124B instead of the guest system object 124A.
[0046] Link 116B corresponds to link 116A. Object 126B generated by binary translator 130B is a binary conversion of provider object 126A of guest machine 100A. As a result of the binary conversion, object 126B executes on host machine 100B and implements an external interface, functionality, and behavior similar to that of provider object 126A. Thus, software program 110B can connect to object 126B within binary translator 130B, instead of provider object 126A.
[0047] Link 118B corresponds to link 118A. Object 128B generated by binary translator 130B is a binary conversion of provider object 128A of guest machine 100A. As a result of the binary conversion, object 128B executes on host machine 100B and implements an external interface, functionality, and behavior similar to that of provider object 128A. Thus, software program 110B can connect to object 128B within binary translator 130B, instead of provider object 128A.
[0048] Importantly, the host hardware architecture 107B may be unaware of the emulated guest hardware architecture 108B and may operate in its normal manner without providing an interface to the emulated guest hardware architecture 108B. The binary translator 130B hides the emulated guest hardware architecture 108B within itself and performs the binary translations of the provider objects 126B and 128B compatible with the expectations of the host machine 100B, such as the ABI of the host machine 100B.
[0049] In the Fig. 1A and Fig. 1B, the domain technology is described in association with two system objects 122A / 122B and 124A / 124B and two provider objects 126A and 128A. However, the domain technology may be implemented with any number (e.g., zero, one, two, or more than two) of system objects and any number (e.g., zero, one, two, or more than two) of provider objects.
[0050] Fig. 2 illustrates an exemplary process 200 by which a binary translation may be completed at a shared object level.
[0051] Process 200 begins at step 210, where a host platform (e.g., host machine 100B) receives a software program (e.g., software program 110A) written for a specified guest platform (e.g., guest machine 100A) that is different from the host platform. The software program uses a group of shared objects or dynamically loaded libraries (e.g., objects 122A, 124A, 126A, and 128A). The software program is incompatible with the host platform.
[0052] In a step 220, the guest platform emulates the specified guest platform within the host platform. For example, if the guest platform contains registers and a system stack, the host platform can generate software emulations of the guest hardware's registers and system stack. The software program can run on the emulated guest platform instead of the original guest platform.
[0053] In a step 230, the host platform determines whether the host platform has a corresponding shared object or corresponding dynamically loaded libraries, wherein the corresponding shared object or corresponding dynamically loaded library implements a common external interface with a specified shared object or the specified dynamically loaded library from within the group of shared objects or dynamically loaded libraries. The specified shared object or the specified dynamically loaded library may be a guest system object (e.g., guest system object 122A or 124A) that has a corresponding host system object (e.g., host system object 122B or 124B) that implements the common external interface with the guest system object.Alternatively, the specified shared object or dynamically loaded library may be a provider object (e.g., provider object 126A or 128A), which may not be associated with such a corresponding host system object. If the host platform has the corresponding shared object or dynamically loaded library, process 200 proceeds to step 240. If the host platform lacks the corresponding shared object or dynamically loaded library, process 200 proceeds to step 250.
[0054] The group of shared objects or dynamically loaded libraries may include a group of libraries. The group of libraries may include at least one system library associated with the corresponding shared object or dynamically loaded library for the host platform, and at least one vendor library that may not be associated with the corresponding shared object or dynamically loaded library for the host platform.
[0055] In step 240, upon determining that the host platform has the corresponding shared object or dynamically loaded library, the host platform uses the corresponding shared object or dynamically loaded library instead of the specified shared object or dynamically loaded library to execute the software program within the host platform. The host platform may dynamically (e.g., at runtime rather than compile time) modify links in the software program to link to the corresponding shared object or dynamically loaded library instead of the specified shared object or dynamically loaded library. (For example, referring to the Fig. 1A-1B, the connection 112B / 1121A may be dynamically modified to connect to the host system object 122B instead of the guest system object 122A.) The host platform may provide calls to the appropriate shared object or dynamically loaded library. After step 240, the process 200 ends.
[0056] In step 250, upon determining that the host platform lacks the corresponding shared object or dynamically loaded library, the host platform performs a binarization of the specified shared object or dynamically loaded library for execution of the software program within the host platform. Performing the binarization may include creating a binarized object, wherein an external interface of the binarized object includes a function call to other binarized provider objects or system objects of the host platform. In some cases, any instructions in the object that can be executed in the specified guest platform but cannot be executed on the host platform may be converted to instructions that can be executed on the host platform.For example, if the host platform is a 64-register architecture, which requires that no instructions be provided that cross register 32 (as is true for some implementations of the x86 architecture), an instruction to access registers 30-35 can be modified to an instruction to access registers 30-31 and an instruction to access registers 32-35. The code translation can be performed "in time." In other words, the translation can occur when control is transferred from code associated with a system object to code associated with a provider object, and vice versa. In other words, the translation can occur when a system object stops executing and a provider object starts executing, or vice versa.An advantage of the "in-time" approach is that any code in the software program that isn't running on the host platform isn't converted, reducing the time and processing resources consumed by binary conversion. After step 250, process 200 ends.
[0057] In some examples, the software program executing on the host platform may receive a call that requires access to a state of the emulated guest platform (e.g., host hardware architecture 108B) or to a state of the host platform (e.g., host hardware architecture 107B). The host platform may, in response to the call, synchronize the state of the emulated guest platform with the state of the host platform. For example, the host platform may propagate changes made to the stack or registers of the emulated guest platform to the stack or registers of the host platform, and vice versa. As a result of this synchronization, the call may be processed according to a synchronized state of the emulated guest platform and the host platform.During synchronization, the emulation layer can perform any necessary argument translation, which may include moving parameters from the emulated guest state to registers and a stack or the host hardware, so that the host code can act as if it were being called normally.
[0058] As described above, steps 210-250 of the process are implemented according to a specific order and in a sequence. However, steps 210-250 may be implemented in any order. In some examples, two or more of steps 210-250 may be implemented in parallel.
[0059] Fig. 3 conceptually illustrates a system 300 with which some implementations of the subject-matter technology are implemented. For example, one or more of the guest machine 100A or the host machine 100B may be implemented using the arrangement of the electronic system 300. The electronic system 300 may be a computer (e.g., a cellular phone, PDA) or any other type of electronic device. Such an electronic system includes various types of computer-readable media and interfaces for various other types of computer-readable media. The electronic system 300 includes a bus 305, a processor(s) 310, a system memory 315, a read-only memory 320, a persistent storage device 325, an input device interface 330, an output device interface 335, and a network interface 340.
[0060] Bus 305 collectively represents all system, peripheral, and chipset buses that communicatively connect the numerous internal devices of electronic system 300. For example, bus 305 communicatively connects processor(s) 310 to read-only memory 320, system memory 315, and permanent storage device 325.
[0061] From these various units, the processor(s) 310 retrieve instructions to execute and data to process to carry out the processes of the domain technology. The processor(s) may include a single processor or a multi-core processor in different implementations.
[0062] Read-only memory (ROM) 320 stores static data and instructions required by processor(s) 310 and other modules of electronic system 300. Permanent storage device 325, on the other hand, is a read-and-write storage device. The device is a non-volatile memory unit that stores instructions and data even when electronic system 300 is powered off. Some implementations of the art technology use a mass storage device (e.g., a magnetic or optical disk and its corresponding disk drive) as permanent storage device 325.
[0063] Other implementations use a removable storage device (e.g., a floppy disk, a memory stick, and its corresponding drive) as the permanent storage device 325. Like the permanent storage device 325, the system memory 315 is a read-and-write storage device. However, unlike the storage device 325, the system memory 315 is a volatile read-and-write memory, such as random access memory. The system memory 315 stores some of the instructions and data required by the processor at runtime. In some implementations, the domain technology processes are stored in the system memory 315, the permanent storage device 325, or the read-only memory 320. For example, the various memory units include instructions for a binary conversion at a shared object level, according to some implementations.From these various units, the processor(s) 310 retrieve instructions to execute and data to process to perform the processes of some implementations.
[0064] Bus 305 also connects to input and output device interfaces 330 and 335. Input device interface 330 allows the user to communicate information and selection commands to the electronic system. Input devices used with input device interface 330 include, for example, alphanumeric keyboards and pointing devices (also called "cursor control devices"). Output device interfaces 335 enable, for example, the display of images generated by electronic system 300. Output devices used with output device interface 335 include, for example, printers and display devices such as cathode ray tubes (CRTs) or liquid crystal displays (LCDs). Some implementations include devices such as a touch screen that function as both an input and output device.
[0065] Finally, as in Fig. 3, bus 305 also connects electronic system 300 to a network (not shown) through a network interface 340. In this manner, electronic system 300 may be part of a network of computers, such as a local area network (LAN), a wide area network (WAN), an intranet, or a network of networks, such as the Internet. Any or all components of electronic system 300 may be used in conjunction with the subject-matter technology.
[0066] The features and applications described above may be implemented as software processes specified as a group of instructions recorded on a computer-readable storage medium (also called a computer-readable medium). When executed by one or more processors (which may include, for example, one or more processors, processor cores, or other processing units), these instructions cause the processor(s) to perform the instructions indicated in the instructions. Examples of computer-readable media include, but are not limited to, CD-ROMs, memory sticks, RAM chips, hard disks, EPROMs, etc. The computer-readable media does not contain carrier waves and electronic signals that travel wirelessly or over wired connections.
[0067] In this specification, the term "software" means to include firmware residing in read-only memory or applications stored in magnetic storage or flash memory, such as a solid-state drive, which can be read into memory for processing by a processor. Likewise, in some implementations, multiple software technologies may be implemented as sub-parts of a larger program while remaining distinct or separate software technologies. In some implementations, multiple software technologies may also be implemented as separate programs. Finally, any combination of separate programs that together implement a software technology described herein is within the scope of the art technology.In some implementations, the software programs, when installed to operate on one or more electronic systems, define one or more specific machine implementations that execute and perform the operations of the software programs.
[0068] A computer program (also known as a program, software, software application, script, or code) may be written in any form of programming language, including compiled or interpreted languages, declarative or procedural languages, and it may be used in any form, including as a stand-alone program or as a module, component, subroutine, object, or other unit suitable for use in a computing environment. A computer program may, but need not, correspond to a file in a file system. A program may be stored in a subsection of a file containing other programs or data (e.g., one or more scripts stored in a markup language document), in a single file dedicated to the program in question, or in several coordinated files (e.g.,Files that store one or more modules, subroutines, or sections of code. A computer program can be designed to run on one computer or on multiple computers located at one location or distributed across multiple locations and connected by a communications network.
[0069] The functions described above may be implemented in a digital electronic circuit in computer software, firmware, or hardware. The techniques may be implemented using one or more computer program products. Programmable processors and computers may be included in or packaged as mobile devices. The processes and logic operations may be performed by one or more programmable processors and one or more programmable logic circuits. General-purpose and special-purpose computing devices and storage devices may be interconnected by communications networks.
[0070] Some implementations include electronic components, such as microprocessors, hard disk storage, and random access memory, that store computer program instructions in a machine-readable or computer-readable medium (also called computer-readable storage media, machine-readable media, or machine-readable storage media). Some examples of such computer-readable media include RAM, ROM, read-only compact discs (CD-ROM), write-once compact discs (CD-R), rewritable compact discs (CD-RW), read-only digital versatile discs (e.g., DVD-ROM, dual-layer DVD-ROM), a variety of write-once / rewritable DVDs (e.g., DVD-RAM, DVD-RW, DVD+RW, etc.), a memory stick (e.g., SD cards, micro SD cards, etc.).), magnetic or solid-state hard drives, Blu-Ray® read-only / write-once discs, ultra-density optical discs, any other optical or magnetic media and discs. The computer-readable media may store a computer program executable by at least one processor and containing groups of instructions for performing various operations. Examples of computer programs or computer code include machine code generated, for example, by a compiler, and files containing higher-level code executed by a computer, electronic component, or microprocessor using an interpreter.
[0071] While the above discussion primarily refers to a microprocessor or multi-core processor executing software, some implementations are performed by one or more integrated circuits, such as application-specific integrated circuits (ASICs) or field-programmable gate arrays (FPGs). In some implementations, such integrated circuits execute instructions stored on the circuit itself.
[0072] As used in this specification and any claims of this application, the terms "computer," "server," "processor," and "memory" all refer to electronic or other technological devices. These terms exclude people or groups of people. For the purposes of this specification, the terms "display" or "display means" are indicating an electronic device. As used in this specification and any claims of this application, the terms "computer-readable medium" and "computer-readable media" are entirely limited to tangible, physical objects that store information in a form readable by a computer. These terms exclude any wireless signals, wired download signals, and any transient signals.
[0073] To provide interaction with a user, implementations of the subject matter described in this specification may be implemented on a computer having a display device, e.g., a cathode ray tube (CRT) or liquid crystal display (LCD) monitor, for displaying information to the user, and a keyboard and pointing device, e.g., a mouse or trackball, through which the user can provide input to the computer. Other types of devices may equally well be used to provide interaction with a user; for example, feedback provided to the user may be any form of sensory feedback, such as visual feedback, audio feedback, speech, or tactile input.Additionally, a computer may interact with a user by sending documents to and receiving documents from a device used by the user; for example, by sending web pages to a web browser on a user's client device in response to requests received from the web browser.
[0074] The subject matter described in this description may be implemented in a computer system that includes a backend component, e.g., a data server, or that includes a middleware component, e.g., an application server, or that includes a frontend component, e.g., a client computer with a graphical user interface or a web browser through which a user can interact with an implementation of the subject matter described in this description, or any combination of one or more of such backend, middleware, or frontend components. These components of the system may be interconnected by any form or medium of digital data communication, e.g., a communications network. Examples of communications networks include a local area network (LAN) and a wide area network (WAN), an internetwork (e.g., the Internet), and peer-to-peer networks (e.g.,Ad hoc peer-to-peer networks).
[0075] The computer system may include clients and servers. A client and a server are generally remote from each other and typically interact through a communications network. The client and server relationship is established by means of computer programs running on the respective computers that have a client-server relationship with each other. In some aspects of the disclosed subject matter, a server sends data (e.g., an HTML page) to a client device (e.g., for purposes of displaying data to and receiving user input from a user interacting with the client device). Data generated at the client device (e.g., a result of the user interaction) may be received by the client device at the server.
[0076] It is understood that any specific order or hierarchy of steps in the disclosed processes is a representation of exemplary approaches. Based on design preferences, it is understood that the specific order or hierarchy of steps in the processes may be rearranged, or that all of the illustrated steps may be performed. Some of the steps may be performed concurrently. For example, multitasking or parallel processing may be advantageous under certain circumstances. Furthermore, the separation of various system components illustrated above should not be understood to require such separation, and it should be understood that the described program components and systems may generally be integrated together into a single software product or packaged into multiple individual software products.
[0077] Various modifications to these aspects will be readily apparent, and the general principles defined herein may be applied to other aspects. Thus, the claims are not intended to be limited to the aspects shown herein, but are intended to be consistent with the full scope of protection consistent with the language of the claims. Reference to an element in the singular is not intended to mean "one and only one" unless specifically so stated, but rather "one or more." Unless specifically so stated, the term "some" refers to one or more. Masculine pronouns (e.g., "his") include the feminine and neuter genders (e.g., "her" and "its"), and vice versa. Headings and subtitles, if any, are used for convenience only and do not limit the subject technology.
[0078] A phrase such as an "aspect" does not imply that the aspect is essential to the subject matter technology or that the aspect applies to all configurations of the subject matter technology. A disclosure regarding an aspect may apply to all configurations or to one or more configurations. A phrase such as an aspect may refer to one or more aspects, and vice versa. A phrase such as a "configuration" does not imply that such a configuration is essential to the subject matter technology or that such a configuration applies to all configurations of the subject matter technology. A disclosure regarding a configuration may apply to all configurations or to one or more configurations. A phrase such as a configuration may refer to one or more configurations, or vice versa.
Claims
[1] Method comprising: Receiving, at a host platform, a software program written for a specified guest platform that is different from the host platform, wherein the software program uses a set of shared objects or dynamically loaded libraries, and wherein the software program is incompatible with the host platform; Emulating the specified guest platform within the host platform; Determining whether the host platform has a corresponding shared object or dynamically loaded library, wherein the corresponding shared object or dynamically loaded library implements a common external interface with a specified shared object or dynamically loaded library from within the set of shared objects or dynamically loaded libraries; if the host platform has the corresponding shared object or dynamically loaded library, using the corresponding shared object or dynamically loaded library instead of the specified shared object or dynamically loaded library to execute the software program within the host platform; and if the host platform lacks the corresponding shared object or dynamically loaded library, performing a binary conversion of the specified shared object or dynamically loaded library to execute the software program within the host platform. [2] The method of claim 1, wherein performing the binarization of the specified shared object or the specified dynamically loaded library comprises creating a first binarized object, wherein an external interface of the first binarized object comprises a function call to a second binarized object for the host platform or to an object native to the host platform. [3] The method of claim 1, wherein the group of shared objects or dynamically loaded libraries comprises at least one system library associated with the corresponding shared object or dynamically loaded library at the host platform and at least one vendor library not associated with the corresponding shared object or dynamically loaded library at the host platform. [4] The method of claim 1, wherein the specified guest platform comprises ARM hardware and wherein the host platform comprises x86 hardware. [5] The method of claim 1, wherein using the corresponding shared object or dynamically loaded library instead of the specified shared object or dynamically loaded library to execute the software program within the host platform comprises: dynamically modifying connections or links in the software program with the corresponding shared object or dynamically loaded library instead of the specified shared object or dynamically loaded library. [6] The method of claim 1, wherein using the corresponding shared object or dynamically loaded library instead of the specified shared object or dynamically loaded library to execute the software program within the host platform comprises: Providing a bridge so that calls to the specified shared object or dynamically loaded library are converted into calls to the corresponding shared object or dynamically loaded library. [7] The method of claim 1, further comprising: Receiving a call that requires access to a state of the emulated guest platform or to a state of the host platform; and in response to the call, synchronize the state of the emulated guest platform with the state of the host platform. [8] A non-transitory computer-readable medium comprising instructions that, when executed by one or more computers, cause the one or more computers to implement a method, the method comprising: Receiving, at a host platform, a software program written for a specified guest platform that is different from the host platform, wherein the software program uses a set of shared objects or dynamically loaded libraries, and wherein the software program is incompatible with the host platform; Determining whether the host platform has a corresponding shared object or dynamically loaded library, wherein the corresponding shared object or dynamically loaded library implements a common external interface with a specified shared object or dynamically loaded library from within the set of shared objects or dynamically loaded libraries; if the host platform has the corresponding shared object or dynamically loaded library, using the corresponding shared object or dynamically loaded library instead of the specified shared object or dynamically loaded library to execute the software program within the host platform; and if the host platform lacks the corresponding shared object or dynamically loaded library, performing a binary conversion of the specified shared object or dynamically loaded library to execute the software program within the host platform. [9] The non-transitory computer-readable medium of claim 8, wherein performing the binarization of the specified shared object or the specified dynamically loaded library comprises creating a first binarized object, wherein an external interface of the first binarized object comprises a function call to a second binarized object for the host platform or to an object native to the host platform. [10] The non-transitory computer-readable medium of claim 8, wherein the group of shared objects or dynamically loaded libraries comprises at least one system library associated with the corresponding shared object or dynamically loaded library at the host platform and at least one vendor library not associated with the corresponding shared object or dynamically loaded library at the host platform. [11] The non-transitory computer-readable medium of claim 8, wherein the specified guest platform comprises ARM hardware and wherein the host platform comprises x86 hardware. [12] The non-transitory computer-readable medium of claim 8, wherein using the corresponding shared object or dynamically loaded library instead of the specified shared object or dynamically loaded library to execute the software program within the host platform comprises: dynamically modifying connections or links in the software program with the corresponding shared object or dynamically loaded library instead of the specified shared object or dynamically loaded library. [13] The non-transitory computer-readable medium of claim 8, wherein using the corresponding shared object or dynamically loaded library instead of the specified shared object or dynamically loaded library to execute the software program within the host platform comprises: Providing a bridge so that calls to the specified shared object or dynamically loaded library are converted into calls to the corresponding shared object or dynamically loaded library. [14] The non-transitory computer-readable medium of claim 8, wherein the method further comprises: Emulate the specified guest platform within the host platform. [15] The non-transitory computer-readable medium of claim 14, wherein the method further comprises: Receiving a call that requires access to a state of the emulated guest platform or to a state of the host platform; and in response to the call, synchronize the state of the emulated guest platform with the state of the host platform. [16] System comprising: one or more processors; and a memory comprising instructions that, when executed by the one or more processors, cause the one or more processors to implement a method, the method comprising: Receiving, at a host platform, a software program written for a specified guest platform that is different from the host platform, wherein the software program uses a set of shared objects or dynamically loaded libraries, and wherein the software program is incompatible with the host platform; Emulating the specified guest platform within the host platform; Determining whether the host platform has a corresponding shared object or dynamically loaded library, wherein the corresponding shared object or dynamically loaded library implements a common external interface with a specified shared object or dynamically loaded library from within the set of shared objects or dynamically loaded libraries; if the host platform has the corresponding shared object or dynamically loaded library, using the corresponding shared object or dynamically loaded library instead of the specified shared object or dynamically loaded library to execute the software program within the host platform; and if the host platform lacks the corresponding shared object or dynamically loaded library, performing a binary conversion of the specified shared object or dynamically loaded library to execute the software program within the host platform. [17] The system of claim 16, wherein the set of shared objects or dynamically loaded libraries comprises at least one system library associated with the corresponding shared object or dynamically loaded library at the host platform and at least one vendor library not associated with the corresponding shared object or dynamically loaded library at the host platform. [18] The system of claim 16, wherein the specified guest platform comprises ARM hardware and wherein the host platform comprises x86 hardware. [19] The system of claim 16, wherein using the corresponding shared object or dynamically loaded library instead of the specified shared object or dynamically loaded library to execute the software program within the host platform comprises: Providing a bridge so that calls to the specified shared object or dynamically loaded library are converted into calls to the corresponding shared object or dynamically loaded library. [20] The system of claim 16, wherein the method further comprises: Receiving a call that requires access to a state of the emulated guest platform or to a state of the host platform; and in response to the call, synchronize the state of the emulated guest platform with the state of the host platform.
Citation Information
Patent Citations
Systems and methods for integrating emulated and native code
US20030101334A1
Method and apparatus for performing native binding
US20090094586A1
Program conversion apparatus
US6438745B1