Method, apparatus, and machine readable storage medium for running software

By directly loading the main program on the target machine and translating and calling the proprietary dynamic libraries, the problem of dynamic libraries being unusable during cross-instruction set architecture migration is solved, achieving efficient software migration and performance improvement.

CN114461306BActive Publication Date: 2026-03-17PHYTIUM TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-13
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

In existing technologies, when software is migrated across instruction set architectures, especially from x86 instruction set architecture to ARM instruction set architecture, dynamic libraries cannot be used normally, causing the software to be unable to run on the new platform and resulting in wasted resources.

Method used

The main program is loaded directly on the target machine, and the proprietary dynamic library is translated and called. The translation engine dynamic library is used to perform binary translation of the proprietary dynamic library, redirect the addresses of import and export functions, and combine ABI conversion to directly use the target machine's native public dynamic library.

Benefits of technology

It improves the software's execution performance on the target machine, effectively utilizes dynamic libraries of different instruction set architectures, avoids resource waste, and enhances the software's functional richness on the new instruction platform.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114461306B_ABST
    Figure CN114461306B_ABST
Patent Text Reader

Abstract

Provided are a method, device and machine readable storage medium for running software. The method can be used to transplant target software from a source machine to a target machine. The target software is language virtual machine based software. The processor of the source machine is based on a first instruction set architecture, the processor of the target machine is based on a second instruction set architecture, and the first instruction set architecture is different from the second instruction set architecture. The method comprises: loading a main program of the target software on the target machine; in response to the main program calling a proprietary dynamic library of the target software, calling a translation code of the proprietary dynamic library; wherein the main program of the target software is based on the second instruction set architecture, and the proprietary dynamic library is based on the first instruction set architecture. Embodiments of the present application directly load the main program of the target software on the target machine (based on the same instruction set architecture as the target machine), without the need to translate the main program, thereby improving the execution performance of the software on the target machine.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of software processing, and more specifically to a method, apparatus, and machine-readable storage medium for running software. Background Technology

[0002] Many software programs consist of multiple components, including the main program, proprietary dynamic libraries, and public dynamic libraries. Many dynamic libraries are released as closed-source third-party libraries. When these closed-source libraries are used with processors of different instruction set architectures, their functions become unusable. Furthermore, some dynamic libraries may be too complex to be ported, or they may be outdated, missing, or no longer maintained. As a result, these dynamic libraries will no longer function in new programs with new instruction set platforms, leading to waste. Summary of the Invention

[0003] This application provides a method, apparatus, and machine-readable storage medium for running software.

[0004] In a first aspect, a method for running software is provided, the method being used to port target software from a source machine to a target machine, wherein the processor of the source machine is based on a first instruction set architecture, and the processor of the target machine is based on a second instruction set architecture, wherein the first instruction set architecture and the second instruction set architecture are different, the method comprising: loading the main program of the target software on the target machine; and, in response to the main program calling a proprietary dynamic library of the target software, calling the translation code of the proprietary dynamic library; wherein the main program of the target software is based on the second instruction set architecture, and the proprietary dynamic library is based on the first instruction set architecture.

[0005] As one possible implementation, the method further includes: in response to the proprietary dynamic library calling the public dynamic library of the target software, calling the native public dynamic library of the target machine.

[0006] As one possible implementation, the method further includes: redirecting the address of the imported function of the proprietary dynamic library so that the address of the imported function points to the address of the first instruction fragment; the step of calling the native public dynamic library of the target machine in response to the proprietary dynamic library calling the public dynamic library of the target software includes: in response to the proprietary dynamic library calling the imported function, determining the address of the first instruction fragment using the address of the imported function; performing ABI conversion on the first instruction fragment to obtain a second instruction fragment, the second instruction fragment pointing to the native public dynamic library of the target machine; and calling the native public dynamic library of the target machine using the second instruction fragment.

[0007] As one possible implementation, the method further includes: in response to the main program calling the target software's public dynamic library, directly calling the target machine's native public dynamic library.

[0008] As one possible implementation, the method further includes: redirecting the addresses of exported functions of the proprietary dynamic library so that the addresses of the exported functions point to the address of a third instruction fragment; the step of calling the translation code of the proprietary dynamic library in response to the main program calling the proprietary dynamic library of the target software includes: determining the address of the third instruction fragment using the address of the exported function in response to the main program calling the exported function; performing ABI conversion on the third instruction fragment to obtain a fourth instruction fragment, wherein the fourth instruction fragment points to the translation code; and calling the translation code using the fourth instruction fragment.

[0009] As one possible implementation, the step of calling the translation code of the proprietary dynamic library in response to the main program calling the proprietary dynamic library of the target software includes: calling the translation engine dynamic library on the target machine in response to the main program calling the proprietary dynamic library of the target software; translating the proprietary dynamic library using the translation engine dynamic library to obtain the translation code of the proprietary dynamic library; and calling the translation code of the proprietary dynamic library.

[0010] As one possible implementation, the method further includes: loading the dynamic library of the target software; identifying the instruction set architecture on which the dynamic library of the target software is based based on the ELF file of the dynamic library of the target software; if the dynamic library of the target software is based on the first instruction set architecture, calling the translation engine dynamic library to translate and redirect the dynamic library of the target software to locate the translation code of the dynamic library of the target software; if the dynamic library of the target software is based on the second instruction set architecture, directly locating the dynamic library of the target software.

[0011] As one possible implementation, the main program is the target machine's native language virtual machine.

[0012] As one possible implementation, the native language virtual machine is either a Java Virtual Machine or a .NET Virtual Machine.

[0013] As one possible implementation, one of the first instruction set architecture and the second instruction set architecture is an x86 instruction set architecture, and the other of the first instruction set architecture and the second instruction set architecture is an ARM instruction set architecture.

[0014] In a second aspect, an apparatus for running software is provided, the apparatus being used to port target software from a source machine to a target machine, the processor of the source machine being based on a first instruction set architecture, and the processor of the target machine being based on a second instruction set architecture, wherein the first instruction set architecture and the second instruction set architecture are different, the apparatus comprising: a loading module for loading the main program of the target software onto the target machine; and a first calling module for calling the translation code of the proprietary dynamic library in response to the main program calling a proprietary dynamic library of the target software; wherein the main program of the target software is based on the second instruction set architecture, and the proprietary dynamic library is based on the first instruction set architecture.

[0015] As one possible implementation, the device further includes: a second calling module, configured to call the native public dynamic library of the target machine in response to the proprietary dynamic library calling the public dynamic library of the target software.

[0016] As one possible implementation, the apparatus further includes: a first redirection module, configured to redirect the address of an imported function of the proprietary dynamic library, such that the address of the imported function points to the address of a first instruction fragment; a second calling module, configured to, in response to the proprietary dynamic library calling the imported function, determine the address of the first instruction fragment using the address of the imported function; perform ABI conversion on the first instruction fragment to obtain a second instruction fragment, the second instruction fragment pointing to the native public dynamic library of the target machine; and use the second instruction fragment to call the native public dynamic library of the target machine.

[0017] As one possible implementation, the device further includes: a third calling module, used to directly call the native public dynamic library of the target machine in response to the main program calling the public dynamic library of the target software.

[0018] As one possible implementation, the apparatus further includes: a second redirection module, configured to redirect the address of the exported function of the proprietary dynamic library, such that the address of the exported function points to the address of the third instruction fragment; a first calling module, configured to, in response to the main program calling the exported function, determine the address of the third instruction fragment using the address of the exported function; perform ABI conversion on the third instruction fragment to obtain a fourth instruction fragment, wherein the fourth instruction fragment points to the translated code; and call the translated code using the fourth instruction fragment.

[0019] As one possible implementation, the first calling module is further configured to respond to the main program calling the proprietary dynamic library of the target software, calling the translation engine dynamic library on the target machine; using the translation engine dynamic library to translate the proprietary dynamic library to obtain the translation code of the proprietary dynamic library; and calling the translation code of the proprietary dynamic library.

[0020] As one possible implementation, the apparatus further includes: a loading module for loading the dynamic library of the target software; identifying the instruction set architecture on which the dynamic library of the target software is based based on the ELF file of the dynamic library of the target software; if the dynamic library of the target software is based on the first instruction set architecture, calling the translation engine dynamic library to translate and redirect the dynamic library of the target software to locate the translation code of the dynamic library of the target software; if the dynamic library of the target software is based on the second instruction set architecture, directly locating the dynamic library of the target software.

[0021] As one possible implementation, the main program is the target machine's native language virtual machine.

[0022] As one possible implementation, the native language virtual machine is either a Java Virtual Machine or a .NET Virtual Machine.

[0023] As one possible implementation, one of the first instruction set architecture and the second instruction set architecture is an x86 instruction set architecture, and the other of the first instruction set architecture and the second instruction set architecture is an ARM instruction set architecture.

[0024] Thirdly, an apparatus for running software is provided, comprising: a memory for storing instructions; and a processor for executing the instructions stored in the memory to perform the method as described in the first aspect or any possible implementation thereof.

[0025] Fourthly, a machine-readable storage medium is provided having instructions stored thereon for performing the method as described in the first aspect or any possible implementation thereof.

[0026] Fifthly, a program product is provided, including instructions for performing the method as described in the first aspect or any possible implementation thereof.

[0027] The embodiments of this application directly load the main program of the target software (which is based on the same instruction set architecture as the target machine) on the target machine without translating the main program, thereby improving the execution performance of the software on the target machine.

[0028] In this embodiment of the application, existing dynamic libraries based on other instruction set architectures (corresponding to the proprietary dynamic libraries of the first instruction set architecture described above) are directly loaded into the software process (corresponding to the main program described above) of the new instruction set platform (corresponding to the target machine described above). This allows for the effective use of existing dynamic libraries of different instruction set architectures, enriching the software functionality of the new instruction platform. These dynamic libraries can continue to function in new programs with the new instruction set platform, thus avoiding waste. Attached Figure Description

[0029] To more clearly illustrate the technical solutions in the embodiments of this application or the background art, the accompanying drawings used in the embodiments of this application or the background art will be described below.

[0030] Figure 1 This is an example diagram of the overall structure of software based on a language virtual machine.

[0031] Figure 2 This is a flowchart illustrating the method for running software provided in an embodiment of this application.

[0032] Figure 3 It is by utilizing the embodiments of this application to Figure 1 The diagram shown is an example of the overall structure of the software obtained after porting it from the source machine to the target machine.

[0033] Figure 4 This is a flowchart illustrating the redirection operation of the exported function provided in the embodiments of this application.

[0034] Figure 5 It is in the absence of Figure 3 An example diagram illustrating the function call relationship when the addresses of imported and exported functions in a proprietary dynamic library are redirected.

[0035] Figure 6 Yes Figure 3 An example diagram illustrating the function call relationship after redirecting the addresses of imported and exported functions in a proprietary dynamic library.

[0036] Figure 7 This is a flowchart illustrating the redirection operation of the imported function provided in the embodiments of this application.

[0037] Figure 8 This is a flowchart illustrating the apparatus for running software provided in the embodiments of this application.

[0038] Figure 9 This is a schematic diagram of the device provided in the embodiments of this application. Detailed Implementation

[0039] To facilitate understanding, the basic concepts involved in the embodiments of this application will be explained first.

[0040] Binary translation technology can transform a sequence of instructions in one instruction set architecture (ISA) into a sequence of instructions in another instruction set architecture. For example, binary translation can translate a sequence of instructions in the x86 instruction set architecture into a sequence of instructions in the ARM instruction set architecture (such as ARM64).

[0041] Binary translation includes two types: static translation and dynamic translation. Static translation translates binary program file A on the source machine before execution, transforming it into binary program file B on the target machine (whose processor uses a different instruction set architecture). Based on static translation, the translation result obtained in a single step can be used multiple times. Dynamic translation translates the executed segments of the binary program during runtime. When the binary program is restarted, the binary program file needs to be translated again.

[0042] Some software includes a main program, proprietary dynamic libraries, and public dynamic libraries. The main program calls these proprietary and public dynamic libraries to jointly accomplish the software's functionality. The following explanation uses language virtual machine-based software as an example. In language virtual machine-based software, the main program is the language virtual machine itself.

[0043] A language virtual machine (or language-level virtual machine) is a type of virtual computer software that interprets and executes intermediate code or compiles intermediate code into machine code for execution. There are many types of language virtual machines, with common ones including the Java Virtual Machine (JVM) and the .NET Virtual Machine (.NET Virtual Machine). Language virtual machines can abstract away information related to the operating system platform, thus offering the advantage of running on different operating system platforms. Therefore, many software programs currently on the market are developed based on language virtual machines.

[0044] Figure 1 Taking software based on the Java Virtual Machine (JVM) as an example, this paper provides an example of the overall structure of software based on a language virtual machine. Figure 1 As shown, the software 10 runs on a machine based on the x86 instruction set architecture. The software 10 mainly consists of three parts: a Java Virtual Machine 12, a proprietary dynamic library 14, and a public dynamic library 16.

[0045] The Java Virtual Machine (JVM) 12 can simulate various computer functions on an actual computer. The JVM has its own complete hardware architecture, such as a processor, stack, and registers. It also has its own instruction set. The JVM shields users from information specific to a particular operating system platform, allowing Java programs to run on multiple operating system platforms without modification, simply by generating target code (bytecode) that runs on the JVM.

[0046] The proprietary dynamic library 14 can be used to store code or functions related to the business logic of the software 10 itself. In other words, the code required to execute the business logic of the software 10 can be made into a proprietary dynamic library for the Java Virtual Machine 12 to call.

[0047] Public dynamic libraries 16 can also be called third-party system dynamic libraries. Public dynamic libraries 16 can include two types of public dynamic libraries. The first type of dynamic library is a public dynamic library directly called by the Java Virtual Machine 12, such as... Figure 1 The first type of dynamic library is public dynamic library 16a, and the second type is public dynamic library 16b. The second type of dynamic library is the public dynamic library called by the proprietary dynamic library 14, such as... Figure 1 The public dynamic library 3.16c and public dynamic library 4.16d.

[0048] The proprietary dynamic library 14 may include an export function table and an import function table (not shown in the figure). The Java Virtual Machine 12 can call functions in the proprietary dynamic library 14 based on the export function table. The proprietary dynamic library 14 can call the public dynamic library 3.16c and the public dynamic library 4.16d based on the import function table.

[0049] When porting software from a source machine to a target machine, compatibility issues arise if the source and target machines use different instruction set architectures. Different instruction set architectures refer to differences in processor architecture design. These architectural differences prevent binary programs developed based on one instruction set architecture from running directly on a processor or machine based on another. For example, porting software based on the x86 instruction set architecture to a machine based on the arm64 instruction set architecture will result in the software not running directly.

[0050] To address the aforementioned issues, one possible solution is to perform binary translation on all parts of the software (including the main program, proprietary dynamic libraries, and public dynamic libraries mentioned above). However, translating all parts of the software involves a significant workload, and the intermediate code generated by the translated software still requires further translation, which can lead to poor software performance on the target machine.

[0051] Let's take the language virtual machine-based software mentioned above as an example. Language virtual machine-based software may consist of three parts: the language virtual machine itself, proprietary dynamic libraries, and common dynamic libraries. Therefore, when performing binary translation of language virtual machine-based software, related technologies perform static or dynamic binary translation on the language virtual machine, proprietary dynamic libraries, and common dynamic libraries. The language virtual machine generates new machine code during runtime. Therefore, if the language virtual machine is binary translated, the new machine code generated during runtime also needs to be binary translated, leading to very poor translation performance. For example, for many language virtual machine-based software programs, their execution performance on the target machine may only reach 10% of their execution performance on the source machine, or even lower. The existence of the above problems often results in language virtual machine-based software failing to function properly after binary translation.

[0052] To improve the execution performance of the software after binary translation, this embodiment does not perform binary translation on the main program of the software. The main program can directly use the native application on the target machine (i.e., the application based on the same instruction set architecture as the target machine). This avoids translating the main program of the target software and eliminates the need to translate the temporary code generated during the execution of the main program.

[0053] The embodiments of this application are described in detail below. For ease of description, the software to be ported will be referred to as the target software. The embodiments of this application do not specifically limit the function or type of the target software. As an example, the target software may be graphics processing software. As another example, the target software may also be game software or other types of software. The target software may be software running in a Linux system environment or software running in a Windows system environment.

[0054] The target software may include one or more of the following: a main program, proprietary dynamic libraries, and public dynamic libraries. Taking a language virtual machine-based software as an example, the main program can be a language virtual machine, such as a Java Virtual Machine or a .NET Virtual Machine. Of course, the main program can also be other types of applications besides language virtual machines. During runtime, the main program can call the target software's proprietary dynamic libraries and / or public dynamic libraries to implement the target software's functionality.

[0055] A target software's proprietary dynamic library can contain some or all of the code that implements the target software's functionality; in other words, it can contain the code required to execute the target software's own business logic. This proprietary dynamic library can be called by the main program to execute the target software's business logic.

[0056] The target software's public dynamic libraries can include public dynamic libraries called by the main program, as well as public dynamic libraries called by the target software's proprietary dynamic libraries. Taking the target software as an example... Figure 1 Taking the Java Virtual Machine-based software 10 as an example, the common dynamic libraries of the software 10 include common dynamic libraries 16a and 16b directly called by the Java Virtual Machine 12, as well as common dynamic libraries 16c and 16d called by the proprietary dynamic library 14.

[0057] Figure 2 A method 200 for running software is provided for embodiments of this application. This method 200 can be used to port (or transparently port) target software from a source machine to a target machine. In some embodiments, Figure 2 This method can be used to port (or transparently port) multiple dynamic libraries with different functions under different instruction set architectures from the source machine to the target machine. This allows the target software to load and execute multiple dynamic libraries with different functions under different instruction set architectures in a single process while running on the target machine, so as to obtain the response functions provided by these dynamic libraries.

[0058] The source machine can refer to the machine that originally ran the target software. In some embodiments, the source machine may also be referred to as the client. The processor of the source machine can be a processor based on a first instruction set architecture. This first instruction set architecture can be, for example, the x86 instruction set architecture or the ARM instruction set architecture (such as ARM64). Figure 2 In one embodiment, the target software is software developed based on the first instruction set architecture, therefore, the target software can run normally on the source machine.

[0059] The target machine can refer to the machine on which the target software is intended to be ported. In some embodiments, the target machine may also be referred to as the host. The processor of the target machine may be a processor based on a second instruction set architecture. This second instruction set architecture is a different instruction set architecture from the first instruction set architecture. For example, if the first instruction set architecture is x86, then the second instruction set architecture may be ARM. Similarly, if the first instruction set architecture is ARM, then the second instruction set architecture is x86.

[0060] Having introduced the concepts of target software, source machine, and target machine, the following section... Figure 2 Each step in the method is described in detail. Figure 2Method 200 includes steps S210 and S220. Steps S210 to S220 can be executed by the target machine, for example, by the processor on the target machine. As an example, step S210 can be executed by the loader on the target machine, and step S220 can be executed by the translation engine dynamic library on the target machine.

[0061] Step S210: Load the main program of the target software onto the target machine. The main program of the target software can be a program based on a second instruction set architecture. The main program of the target software can be a native application on the target machine (an application that comes with the target machine or is installed on the target machine). Taking a language virtual machine-based software as an example, the main program of the target software can be the native language virtual machine of the target machine. As can be seen from step S210, this embodiment of the application does not perform binary translation of the main program of the target software, but instead directly loads and runs the target software on the target machine.

[0062] Step S220: In response to the main program of the target software calling the proprietary dynamic library of the target software, the translation code of the proprietary dynamic library is invoked. The proprietary dynamic library of the target software is a dynamic library based on a first instruction set architecture, that is, the instruction set architecture on which the main program of the target software and the proprietary dynamic library of the target software are based is different. If the main program of the target software calls the proprietary dynamic library of the target software, the call can be redirected to call the translation code of the proprietary dynamic library instead. This application embodiment does not specifically limit the timing of the translation of the proprietary dynamic library. For example, the proprietary dynamic library can be translated before step S220 to obtain the above-mentioned translation code. Alternatively, the translation of the proprietary dynamic library can be triggered after receiving the call instruction of the main program of the target software to the proprietary dynamic library. The translation process will be illustrated in detail below with specific embodiments, and will not be described in detail here.

[0063] Before calling the translation code of the aforementioned proprietary dynamic library, the proprietary dynamic library can be loaded first. When loading the proprietary dynamic library, it can be actively identified or determined whether it is a dynamic library based on a first instruction set architecture (the first instruction set architecture can include 1 to n instruction set architectures; taking the nth instruction set architecture as an example, it can be actively determined whether the proprietary dynamic library is based on that nth instruction set architecture), and then loaded. After loading is complete, step S220 can be executed to call the translation code of the proprietary dynamic library. Instruction set architecture identification can be implemented based on ELF files, as described later.

[0064] After porting the target software to the target machine, this embodiment performs a binary translation of the target software's proprietary dynamic libraries, but does not perform a binary translation of the target software's main program (instead, it uses the target machine's native application). Therefore, this embodiment can improve the execution performance of the ported target software.

[0065] Furthermore, in the embodiments of this application, existing dynamic libraries based on other instruction set architectures (corresponding to the proprietary dynamic libraries of the first instruction set architecture described above) are directly loaded into the software process (corresponding to the main program described above) of the new instruction set platform (corresponding to the target machine described above). This allows for the effective utilization of existing dynamic libraries of different instruction set architectures, enriching the software functionality of the new instruction platform. These dynamic libraries can continue to function in new programs with the new instruction set platform, thus avoiding waste.

[0066] As mentioned earlier, target software may include not only the main program and proprietary dynamic libraries, but also common dynamic libraries. To further reduce the complexity of translation tasks during the target software porting process, in some embodiments, the common dynamic libraries of the target software may not be translated; instead, the native common dynamic libraries of the target machine may be called. The native dynamic libraries of the target machine can be understood as dynamic libraries that come with the target machine or are installed on the target machine; or, the native dynamic libraries of the target machine can also be understood as dynamic libraries that run on the target machine and are based on the same instruction set architecture as the processor of the target machine. Using the native common dynamic libraries of the target machine instead of translating the common dynamic libraries of the target software can not only further reduce the amount of binary translation, but also further improve the execution performance of the ported target software. Taking the target software as a language virtual machine-based software as an example, using the native language virtual machine and native common dynamic libraries of the target machine, and only translating the proprietary dynamic libraries of the target software, may result in the execution performance of the ported target software reaching more than 90% of that before porting.

[0067] As mentioned earlier, the target software's public dynamic libraries include those directly called by the target software's main program (such as...). Figure 1The common dynamic libraries are 16a and 16b. In some embodiments, the common dynamic libraries directly called by the main program may not be binary translated; instead, the native common dynamic libraries of the target machine may be used directly. In this embodiment, since both the main program and the common dynamic libraries called by the main program use the native program code of the target machine, and both are based on the same instruction set architecture, they can be called directly without application binary interface (ABI) conversion. In this embodiment, the common dynamic libraries called by the main program include dynamic libraries based on the first instruction set architecture (such as the proprietary dynamic libraries mentioned above) and dynamic libraries based on the second instruction set architecture (such as the native common dynamic libraries of the target machine). The main program can call either dynamic libraries based on the first instruction set architecture or dynamic libraries based on the second instruction set architecture. Therefore, the method for running software provided in this application embodiment can be understood as a hybrid execution method of multiple instruction set architectures (or multiple architecture instructions). It should be understood that the first instruction set architecture mentioned in this application embodiment is not limited to one instruction set architecture and may include 1 to n instruction set architectures (n is a positive integer greater than 1). In other words, the method for running software provided in this application embodiment can not only execute the instruction set architecture of the target machine, but also execute one or more instructions from other instruction set architectures.

[0068] In addition to the public dynamic libraries directly called by the main program, the public dynamic libraries of the target software may also include public dynamic libraries called by the target software's proprietary dynamic libraries (such as...). Figure 1 (Public dynamic libraries 3.16c and 4.16d). In some embodiments, the binary translation of the public dynamic library called by the proprietary dynamic library may be omitted, and instead, the native public dynamic library of the target machine may be used. Since the proprietary dynamic library and the native public dynamic library of the target machine are dynamic libraries developed based on different instruction set architectures, the proprietary dynamic library can be ABI converted before calling the native public dynamic library of the target machine.

[0069] The following uses the target software as an example. Figure 1 The software 10 shown is based on a language virtual machine. Taking the source machine's processor as being based on the x86 instruction set architecture and the target machine's processor as being based on the arm64 instruction set architecture as an example, the overall structure of the ported software is illustrated in more detail.

[0070] Figure 3 The embodiments of this application are shown as follows Figure 1 The diagram shows the overall software structure of software 10 after it has been ported from the source machine to the target machine. (Example:) Figure 3 As shown, in the software 10 ported to Figure 3Following the target machine shown, the Java Virtual Machine (JVM) of Software 10 uses JVM 32, which is based on the ARM64 instruction set architecture. This JVM is the native JVM of the target machine. The target machine has native common dynamic libraries I 36a and II 36b, both of which are native common dynamic libraries developed based on the ARM64 instruction set architecture. Therefore, JVM 32 can directly call common dynamic libraries I 36a and II 36b.

[0071] The Java Virtual Machine 32 calls the proprietary dynamic library 34 of the software 10 through the translation engine dynamic library 33 on the target machine. The translation engine dynamic library 33 is responsible for performing binary translation on the proprietary dynamic library 34, thereby translating the x86 instructions (instructions in the text section of the ELF file) in the proprietary dynamic library 34 into the corresponding arm64 instructions, thus obtaining the translated code 35 of the proprietary dynamic library.

[0072] The proprietary dynamic library 34 can call the target machine's native public dynamic library III 36c and public dynamic library IV 36d. Since the proprietary dynamic library 34 is based on a different instruction set architecture than public dynamic libraries III 36c and IV 36d, ABI conversion can be performed before calling it.

[0073] Before the Java Virtual Machine 32 runs, it can be loaded by the loader 31. The loader 31 can also be used to identify whether the dynamic libraries loaded by the Java Virtual Machine 32 at runtime are based on the x86 instruction set architecture. If the loaded dynamic libraries are based on the x86 instruction set architecture, the loader 31 can first load the translation engine dynamic library 33, and the translation engine dynamic library 33 can perform dynamic or static binary translation on the x86 instruction set architecture dynamic libraries.

[0074] contrast Figure 1 and Figure 3 It can be seen that, Figure 3 A portion of the software (the part outside the dashed box) directly uses the native software on the target machine, without requiring binary translation, thus reducing the translation workload and improving the execution performance of the translated software.

[0075] In some embodiments, after the main program of the target software is loaded and executed, the loading of the dynamic libraries required by the main program can be performed by a loader. During the loading process of the dynamic libraries required by the main program, the loader can identify whether the dynamic library is a native public dynamic library or a dedicated dynamic library belonging to a first instruction set architecture (the first instruction set architecture can include 1 to n instruction set architectures). If the dynamic library required by the main program is a dedicated dynamic library of the first instruction set architecture, the import and / or export functions of the dedicated dynamic library can be redirected to ensure correct code invocation. The redirection process of import and / or export functions of dedicated dynamic libraries is described in detail below.

[0076] The main program of the target software calls proprietary dynamic libraries based on the exported function table of the proprietary dynamic library. During the call, the main program can use the addresses of the exported functions to find the addresses of the functions within the proprietary dynamic library. However, when the target software runs on the target machine, locating the proprietary dynamic library itself is meaningless (because the proprietary dynamic library is based on the source machine's instruction set architecture and cannot run on the target machine); instead, the translated code of the proprietary dynamic library should be located. Therefore, in some embodiments, the addresses of the exported functions can be redirected, so that the main program's call to the proprietary dynamic library is transformed into a call to the translated code of the proprietary dynamic library.

[0077] The following is combined Figures 4 to 6 The document provides detailed examples illustrating the methods for redirecting the addresses of exported functions and the call flow of the translated code after redirection.

[0078] See Figure 4 In step S410, the addresses of the exported functions of the proprietary dynamic library (which originally pointed to the proprietary dynamic library of the target software) are redirected so that the addresses of the exported functions point to the addresses of the instruction fragments. After ABI conversion, these instruction fragments can point to the translated code of the proprietary dynamic library. The instruction fragments mentioned in this application embodiment can refer to a sequence of prologue instructions or a function. As an example, the instruction fragment can be a wrapper function for an exported function.

[0079] This application does not specifically limit the timing of the execution of step S410. In some embodiments, the redirection operation described in step S410 can be executed when the proprietary dynamic library is loaded. Furthermore, step S410 can be executed by the translation engine dynamic library mentioned above. For example, after executing the translation operation of the proprietary dynamic library, the translation engine dynamic library can generate the instruction fragment mentioned above and modify the addresses of the exported functions of the target software's proprietary dynamic library so that the addresses of the exported functions point to the instruction fragment.

[0080] The following example uses a source machine based on the x86 instruction set architecture, a target machine based on the arm64 instruction set architecture, and target software based on a Java Virtual Machine. Figure 5 and Figure 6 The above redirection operation will be illustrated with more detailed examples.

[0081] Figure 5 This is a diagram illustrating the software calling method before the translation engine's dynamic library performs translation and redirection. From Figure 5 It can be seen that when the native Java Virtual Machine 32 of the target machine runs the target software, it calls the function E_1(x86) in the proprietary dynamic library 34 of the target software based on the exported function E_1 in the exported function table 342. However, the function E_1(x86) in this proprietary dynamic library is a function based on the x86 instruction set architecture, and therefore cannot be run directly on the target machine.

[0082] Figure 6 This is a diagram illustrating how the software is called after the translation engine's dynamic library performs the translation. Figure 6 In the example above, the instruction snippet is a wrapper function. From Figure 6 As can be seen, after the translation engine dynamic library translates the target software, it can generate a wrapper function table 62 for exported functions and a translation buffer 64 for storing the translated code. The wrapper functions in this wrapper function table 62 correspond one-to-one with the exported functions in the exported function table 342, and the address of each exported function in the exported function table 342 points to its corresponding wrapper function in the wrapper function table 62. For example, in... Figure 5 In the translation engine, the address of the exported function E_1 points to the function E_1 (x86) in the proprietary dynamic library. After translation and redirection by the translation engine's dynamic library, the address of the exported function E_1 points to the wrapper function E_W_1, and the address of the wrapper function E_W_1, after ABI translation, can point to the function E_1 (arm64) in the translation buffer.

[0083] See also Figure 4 After step S410, steps S420 to S440 can be executed (corresponding to...) Figure 2 Step S220). In step S420, in response to the main program of the target software calling the exported function of the proprietary dynamic library, the address of the instruction fragment is determined using the address of the exported function. The instruction fragment mentioned in the embodiments of this application can refer to a sequence of prologue instructions or a function. As an example, the instruction fragment can be a wrapper function of the exported function. In steps S430~S440, the instruction fragment is subjected to ABI to obtain another instruction fragment (this other instruction fragment can be based on the second instruction set architecture and points to the translation code), and the translation code is called using this other instruction fragment.

[0084] The preceding text described in detail how the target software's main program redirects the addresses of exported functions of a proprietary dynamic library when calling it. When a proprietary dynamic library calls a native public dynamic library on the target machine, the addresses of imported functions of the proprietary dynamic library need to be redirected. The following section will combine... Figures 5 to 7 The document provides detailed examples illustrating how to redirect the address of an imported function and the subsequent call flow.

[0085] See Figure 7 In step S710, the addresses of imported functions in the proprietary dynamic library are redirected so that the addresses of the imported functions point to the addresses of instruction fragments. After ABI conversion, this instruction fragment can point to the native public dynamic library of the target machine. The instruction fragment mentioned in this application embodiment can refer to a sequence of prologue instructions or a function. As an example, the instruction fragment can be a wrapper function for an imported function.

[0086] As mentioned above Figure 5 and Figure 6 Let's take an example to illustrate ( Figure 6 In the example, the instruction snippet mentioned above is a wrapper function. Figure 5 If proprietary dynamic library 34 wishes to call function I_1 (arm64) in public dynamic library III 36c and function I_3 (arm64) in public dynamic library IV 36d, it needs to do so through the imported functions I_1 and I_3 in the import function table 344. However, proprietary dynamic library 34 executes in an x86-emulated manner, therefore it cannot directly call functions I_1 (arm64) and I_3 (arm64).

[0087] See Figure 6 After translating the proprietary dynamic library, the translation engine dynamic library generates, in addition to the translation buffer 64 and the wrapper function table 62 for exported functions mentioned earlier, a wrapper function table 66 for imported functions. The wrapper functions in this wrapper function table 66 correspond one-to-one with the imported functions in the imported function table 344. The address of any imported function in the imported function table 344 can point to its corresponding wrapper function in the wrapper function table 66. For example, the address of imported function I_1, which originally pointed directly to function I_1(arm64) in the public dynamic library, is changed to point to the wrapper function I_W_1. The address of imported function I_3, which originally pointed directly to function I_3(arm64) in the public dynamic library, is changed to point to the wrapper function I_W_3. After ABI conversion, wrapper functions I_W_1 and I_W_3 can point to functions I_1(arm64) and I_3(arm64) in the translation buffer. After ABI conversion, the proprietary dynamic library can call instructions based on the arm64 instruction set architecture.

[0088] See also Figure 7 After step S710, steps S720 to S740 can continue to be executed. In step S720, in response to the target software's proprietary dynamic library calling the imported function, the address of the instruction fragment is determined using the address of the imported function. The instruction fragment mentioned in this application embodiment can refer to a sequence of prologue instructions or a function. As an example, the instruction fragment can be a wrapper function for the imported function. In steps S730 to S740, the instruction fragment is ABI converted to obtain another instruction fragment (based on the second instruction set architecture and pointing to the native public dynamic library); this other instruction fragment is used to call the target machine's native public dynamic library.

[0089] As described above, this application embodiment performs binary translation of the proprietary dynamic library of the target software. The translation of the proprietary dynamic library can employ dynamic or static translation methods provided by related technologies. The translation methods provided by related technologies are all block-level translation methods. The following describes a function-level translation method provided by this application embodiment.

[0090] Specifically, in the process of translating a proprietary dynamic library (PLL), the starting address and size of each function in the PPL can first be extracted according to the address order of the text segment in the ELF file. Then, a jump table can be generated. This jump table can be used to record the starting address of the translation instruction corresponding to each instruction in the source machine. Next, each function can be translated starting from the smallest to the largest function address. During the translation process, an instruction from the source machine can be translated into an equivalent instruction in the target machine, and then the starting address of the translated instruction is recorded in the jump table. When translating a function (hereinafter referred to as function 1), if function 1 encounters a direct jump instruction, it can be determined whether the address of the function called by the direct jump instruction (hereinafter referred to as function 2) is smaller than the address of function 1. If the address of function 2 is smaller than the address of function 1, it means that the translation of function 2 is complete, and the translation address of function 2 can be found in the jump table to translate the direct jump instruction. If the address of function 2 is larger than the address of function 1, it means that the translation of function 2 has not yet begun. In this case, a space can be reserved for the jump instruction, and filled after function 2 is translated. During the translation of function 1, if an indirect jump instruction is encountered, the value of the address pointed to by the indirect jump instruction may not be determined temporarily. In this case, the indirect jump instruction can be wrapped into a function. The function can be designed to dynamically process the indirect jump instruction based on the loading information provided during subsequent loading.

[0091] This application does not specifically limit the timing of binary translation; it can be performed before or during the execution of the target software. For example, in response to the main program of the target software calling a proprietary dynamic library, the proprietary dynamic library can be binary translated to obtain its translated code. Then, the main program can call the translated code of the proprietary dynamic library to implement the business functions of the target software.

[0092] In some embodiments, when loading a dynamic library, the type of the dynamic library can be identified first to determine whether binary translation of the dynamic library is required. The identification of the dynamic library type can be based on the ELF file format; for example, type-related information of the dynamic library can be recorded in a fixed location in the ELF file header. Furthermore, in some embodiments, the identification of the dynamic library type can be performed by a loader. This loader has the ability to identify different types of ELF file formats, unlike the loaders provided by related technologies. In some embodiments, because this loader can load different types of dynamic libraries, it can be called a hybrid loader. The specific loading process is illustrated below.

[0093] For example, the target software's dynamic library can be loaded first. Then, after loading the target software's dynamic library, the instruction set architecture on which the target software's dynamic library is based can be identified based on the target software's ELF file. If the target software's dynamic library is based on a first instruction set architecture (i.e., the target software's dynamic library and the target machine are based on different instruction set architectures), the translation engine's dynamic library can be called to translate and redirect the target software's dynamic library to locate the translated code of the target software's dynamic library. The redirection process of the translated code of the target software's dynamic library is similar to that described above. Figures 4 to 7 The process is similar: redirecting the import and export functions of the target software's dynamic library to instruction snippets of those functions, and then using those snippets to redirect the translation code of the target software's dynamic library. It's worth noting that if the translation engine has already translated the dynamic library, the translation code stored in the translation buffer can be used directly, without needing to re-translate it.

[0094] Furthermore, if the target software's dynamic library is based on a second instruction set architecture (i.e., the target software's dynamic library and the target machine are based on the same instruction set architecture), the target software's dynamic library can be located directly. For example, the target software's dynamic library can be redirected based on its import and export functions (in this case, redirection can be performed directly using the import and export functions, without needing to construct the instruction fragments mentioned above).

[0095] This application does not specifically limit the timing of loading the dynamic libraries of the target software. The dynamic libraries of the target software can be loaded when the target software starts or when the target software runs. For example, when the target software starts, the dynamic libraries to be loaded recorded in the target software's ELF file can be found, and the dynamic libraries to be loaded recorded in the ELF files of the dynamic libraries to be loaded can be found. Then, when the target software starts, these dynamic libraries to be loaded can be loaded sequentially. Alternatively, during the execution of the target software, a specified dynamic library can be loaded based on a function in the target software that calls the function to load the dynamic library.

[0096] Taking a source machine based on the x86 instruction set architecture and a target machine based on the arm64 instruction set architecture as an example, during dynamic library loading, the loader can identify the type of the dynamic library to be loaded based on its ELF file format. For example, if the ELF file format of the dynamic library is the same as that of the source machine, then the dynamic library is an x86 version and requires binary translation; if the ELF file format of the dynamic library is the same as that of the target machine, then the dynamic library is an arm64 version and does not require binary translation.

[0097] In some embodiments, after loading the proprietary dynamic library and before performing binary translation of the proprietary dynamic library, it can be checked whether translated code for the proprietary dynamic library exists (because the dynamic library may have been loaded and translated previously). If translated code for the proprietary dynamic library exists, the translation stage can be skipped and the translated code can be called directly. If the translated code does not exist, the proprietary dynamic library can be binary translated, and the translated code can be saved in a buffer file for later use.

[0098] The above text combined Figures 1 to 7 The method embodiments of this application are described in detail below, in conjunction with... Figure 8 and Figure 9 The present application provides a detailed description of the apparatus embodiments. It should be understood that the descriptions of the method embodiments correspond to the descriptions of the apparatus embodiments; therefore, any parts not described in detail can be found in the foregoing method embodiments.

[0099] Figure 8 This is a schematic diagram of the structure of a device for running software provided in an embodiment of this application. Figure 8The apparatus 800 can be used to port target software from a source machine to a target machine. The processor of the source machine is based on a first instruction set architecture, and the processor of the target machine is based on a second instruction set architecture, wherein the first instruction set architecture is different from the second instruction set architecture. The apparatus 800 may include a loading module 810 and a first calling module 820. The loading module 810 can be used to load the main program of the target software onto the target machine. The first calling module 820 can be used to call the translated code of the proprietary dynamic library in response to the main program calling the proprietary dynamic library of the target software; wherein the main program of the target software is based on the second instruction set architecture, and the proprietary dynamic library is based on the first instruction set architecture.

[0100] In some embodiments, the apparatus 800 may further include: a second invocation module, configured to invoke the native public dynamic library of the target machine in response to the proprietary dynamic library invoking the public dynamic library of the target software.

[0101] In some embodiments, the apparatus 800 may further include: a first redirection module, configured to redirect the address of an imported function of the proprietary dynamic library, such that the address of the imported function points to the address of a first instruction fragment; a second calling module, configured to, in response to the proprietary dynamic library calling the imported function, determine the address of the first instruction fragment using the address of the imported function; perform ABI conversion on the first instruction fragment to obtain a second instruction fragment, the second instruction fragment pointing to the native public dynamic library of the target machine; and call the native public dynamic library of the target machine using the second instruction fragment.

[0102] In some embodiments, the apparatus 800 may further include: a third calling module, configured to directly call the native public dynamic library of the target machine in response to the main program calling the public dynamic library of the target software.

[0103] In some embodiments, the apparatus 800 may further include: a second redirection module, configured to redirect the address of an exported function of the proprietary dynamic library such that the address of the exported function points to the address of a third instruction fragment; the first calling module 820 is configured to, in response to the main program calling the exported function, determine the address of the third instruction fragment using the address of the exported function; perform ABI conversion on the third instruction fragment to obtain a fourth instruction fragment, wherein the fourth instruction fragment points to the translated code; and call the translated code using the fourth instruction fragment.

[0104] In some embodiments, the first calling module is further configured to, in response to the main program calling the proprietary dynamic library of the target software, call the translation engine dynamic library on the target machine; use the translation engine dynamic library to translate the proprietary dynamic library to obtain the translation code of the proprietary dynamic library; and call the translation code of the proprietary dynamic library.

[0105] In some embodiments, the apparatus further includes: a loading module, configured to load the dynamic library of the target software; identify the instruction set architecture on which the dynamic library of the target software is based based on the ELF file of the dynamic library of the target software; if the dynamic library of the target software is based on the first instruction set architecture, call the translation engine dynamic library to translate and redirect the dynamic library of the target software to locate the translation code of the dynamic library of the target software; if the dynamic library of the target software is based on the second instruction set architecture, directly locate the dynamic library of the target software.

[0106] In some embodiments, the main program is the native language virtual machine of the target machine.

[0107] In some embodiments, the native language virtual machine is a Java Virtual Machine or a .NET Virtual Machine.

[0108] In some embodiments, one of the first instruction set architecture and the second instruction set architecture is an x86 instruction set architecture, and the other of the first instruction set architecture and the second instruction set architecture is an ARM instruction set architecture.

[0109] Figure 9 This is a schematic structural diagram of the device according to an embodiment of this application. Figure 9 The dashed lines indicate that the unit or module is optional. The device 900 can be used to implement the methods described in the above method embodiments. The device 900 can be a computer or any type of electronic device.

[0110] The apparatus 900 may include one or more processors 910. The processor 910 may support the apparatus 900 in implementing the methods described in the preceding method embodiments. The processor 910 may be a general-purpose processor or a special-purpose processor. For example, the processor may be a central processing unit (CPU). Alternatively, the processor may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.

[0111] The apparatus 900 may further include one or more memories 920. The memories 920 store a program that can be executed by the processor 910, causing the processor 910 to perform the methods described in the preceding method embodiments. The memories 920 may be independent of the processor 910 or integrated within the processor 910.

[0112] The device 900 may also include a transceiver 930. The processor 910 can communicate with other devices via the transceiver 930. For example, the processor 910 can send and receive data with other devices via the transceiver 930.

[0113] This application also provides a machine-readable storage medium for storing a program. This machine-readable storage medium can be applied to a terminal device or network device provided in this application, and the program causes a computer to execute the methods performed by the terminal device or network device in various embodiments of this application.

[0114] This application also provides a computer program product. The computer program product includes a program. This computer program product can be applied to a terminal device or network device provided in the embodiments of this application, and the program causes a computer to execute the methods performed by the terminal device or network device in the various embodiments of this application.

[0115] This application also provides a computer program. This computer program can be applied to the terminal device or network device provided in this application, and the computer program causes the computer to execute the methods performed by the terminal device or network device in various embodiments of this application.

[0116] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any other combination. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this disclosure are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a machine-readable storage medium or transmitted from one machine-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The machine-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., digital video discs (DVDs)), or semiconductor media (e.g., solid-state drives (SSDs)).

[0117] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments of this disclosure can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this disclosure.

[0118] In the several embodiments provided in this disclosure, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

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

[0120] In addition, the functional units in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0121] The above description is merely a specific embodiment of this disclosure, but the scope of protection of this disclosure is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this disclosure should be included within the scope of protection of this disclosure. Therefore, the scope of protection of this disclosure should be determined by the scope of the claims.

Claims

1. A method of running software, characterized by, The method is used for porting target software from a source machine to a target machine, a processor of the source machine is based on a first instruction set architecture, a processor of the target machine is based on a second instruction set architecture, the first instruction set architecture is different from the second instruction set architecture, The method comprises: loading a main program of the target software on the target machine, the main program of the target software being a native application program on the target machine; in response to the main program calling a proprietary dynamic library of the target software, calling a translated code of the proprietary dynamic library; in response to the proprietary dynamic library calling a common dynamic library of the target software, calling a native common dynamic library of the target machine; wherein the main program of the target software is based on the second instruction set architecture, the proprietary dynamic library is based on the first instruction set architecture, and the call of the main program to the proprietary dynamic library of the target software is redirected to call the translated code of the proprietary dynamic library, the translated code of the proprietary dynamic library being translated by a translation engine dynamic library on the target machine.

2. The method of claim 1, wherein, The method further comprises: redirecting an address of an import function of the proprietary dynamic library so that the address of the import function points to an address of a first instruction segment; the response to the proprietary dynamic library calling the common dynamic library of the target software, calling the native common dynamic library of the target machine, comprises: in response to the proprietary dynamic library calling the import function, determining the address of the first instruction segment by using the address of the import function; performing ABI conversion on the first instruction segment to obtain a second instruction segment, the second instruction segment pointing to the native common dynamic library of the target machine; calling the native common dynamic library of the target machine by using the second instruction segment.

3. The method of claim 1, wherein, The method further comprises: in response to the main program calling the common dynamic library of the target software, directly calling the native common dynamic library of the target machine.

4. The method of claim 1, wherein, The method further comprises: redirecting an address of an export function of the proprietary dynamic library so that the address of the export function points to an address of a third instruction segment; the response to the main program calling the proprietary dynamic library of the target software, calling the translated code of the proprietary dynamic library, comprises: in response to the main program calling the export function, determining the address of the third instruction segment by using the address of the export function; performing ABI conversion on the third instruction segment to obtain a fourth instruction segment, wherein the fourth instruction segment points to the translated code; calling the translated code by using the fourth instruction segment.

5. The method of claim 1, wherein, The response to the main program calling the proprietary dynamic library of the target software, calling the translated code of the proprietary dynamic library, comprises: in response to the main program calling the proprietary dynamic library of the target software, calling the translation engine dynamic library on the target machine; performing translation on the proprietary dynamic library by using the translation engine dynamic library to obtain the translated code of the proprietary dynamic library; calling the translated code of the proprietary dynamic library.

6. The method of claim 1, wherein, The method further comprises: loading a dynamic library of the target software; According to an elf file of a dynamic library of the target software, identify an instruction set architecture on which the dynamic library of the target software is based; If the dynamic library of the target software is based on the first instruction set architecture, call the translation engine dynamic library to translate and redirect the dynamic library of the target software, so as to locate a translated code of the dynamic library of the target software; If the dynamic library of the target software is based on the second instruction set architecture, directly locate the dynamic library of the target software.

7. The method of claim 1, wherein, The main program is a native language virtual machine of the target machine.

8. The method of claim 1, wherein, The native language virtual machine is a java virtual machine or a.net virtual machine.

9. The method of claim 1, wherein, One of the first instruction set architecture and the second instruction set architecture is an x86 instruction set architecture, and the other of the first instruction set architecture and the second instruction set architecture is an arm instruction set architecture.

10. An apparatus for running software, characterized in that The apparatus is used for porting a target software from a source machine to a target machine, a processor of the source machine is based on a first instruction set architecture, a processor of the target machine is based on a second instruction set architecture, the first instruction set architecture is different from the second instruction set architecture, The apparatus comprises: a loading module, configured to load a main program of the target software on the target machine, the main program of the target software being a native application program on the target machine; a first calling module, configured to, in response to the main program calling a proprietary dynamic library of the target software, call a translated code of the proprietary dynamic library a second calling module, configured to, in response to the proprietary dynamic library calling a common dynamic library of the target software, call a native common dynamic library of the target machine; wherein the main program of the target software is based on the second instruction set architecture, the proprietary dynamic library is based on the first instruction set architecture, and the call of the main program to the proprietary dynamic library of the target software is redirected to call the translated code of the proprietary dynamic library, the translated code of the proprietary dynamic library being translated by using a translation engine dynamic library on the target machine.

11. The apparatus of claim 10, wherein, The apparatus further comprises: a first redirecting module, configured to redirect an address of an import function of the proprietary dynamic library, so that the address of the import function points to an address of a first instruction segment; the second calling module is configured to, in response to the proprietary dynamic library calling the import function, determine the address of the first instruction segment by using the address of the import function; perform ABI conversion on the first instruction segment to obtain a second instruction segment, the second instruction segment pointing to the native common dynamic library of the target machine; and call the native common dynamic library of the target machine by using the second instruction segment.

12. The apparatus of claim 10, wherein, The apparatus further comprises: a third calling module, configured to, in response to the main program calling a common dynamic library of the target software, directly call the native common dynamic library of the target machine.

13. The apparatus of claim 10, wherein, The apparatus further comprises: a second redirecting module, configured to redirect an address of an export function of the proprietary dynamic library, so that the address of the export function points to an address of a third instruction segment; The first calling module is configured to, in response to the main program calling the export function, determine an address of the third instruction segment by using an address of the export function, perform ABI conversion on the third instruction segment to obtain a fourth instruction segment, wherein the fourth instruction segment points to the translation code, and call the translation code by using the fourth instruction segment.

14. The apparatus of claim 10, wherein, The first calling module is further configured to, in response to the main program calling a proprietary dynamic library of the target software, call the translation engine dynamic library on the target machine, and perform translation on the proprietary dynamic library by using the translation engine dynamic library to obtain translation code of the proprietary dynamic library. The translation code of the proprietary dynamic library is called.

15. The apparatus of claim 10, wherein, The apparatus further includes: a loading module configured to load a dynamic library of the target software, identify an instruction set architecture on which the dynamic library of the target software is based according to an elf file of the dynamic library of the target software, call the translation engine dynamic library to perform translation and redirection on the dynamic library of the target software to locate translation code of the dynamic library of the target software if the dynamic library of the target software is based on the first instruction set architecture, and directly locate the dynamic library of the target software if the dynamic library of the target software is based on the second instruction set architecture.

16. The apparatus of claim 10, wherein, The main program is a native language virtual machine of the target machine.

17. The apparatus of claim 16, wherein, The native language virtual machine is a java virtual machine or a.net virtual machine.

18. The apparatus of claim 10, wherein, One of the first instruction set architecture and the second instruction set architecture is an x86 instruction set architecture, and the other of the first instruction set architecture and the second instruction set architecture is an arm instruction set architecture.

19. An apparatus for running software, characterized in that comprising: a memory configured to store instructions; a processor configured to execute the instructions stored in the memory to perform the method of any one of claims 1-9.

20. A machine-readable storage medium, characterized in that, instructions for performing the method of any one of claims 1-9 are stored thereon.