WO2016000550A1 - Binary translation execution method and apparatus for shared libraries - Google Patents

Binary translation execution method and apparatus for shared libraries Download PDF

Info

Publication number
WO2016000550A1
WO2016000550A1 PCT/CN2015/082127 CN2015082127W WO2016000550A1 WO 2016000550 A1 WO2016000550 A1 WO 2016000550A1 CN 2015082127 W CN2015082127 W CN 2015082127W WO 2016000550 A1 WO2016000550 A1 WO 2016000550A1
Authority
WO
WIPO (PCT)
Prior art keywords
function
host
supported
shared library
client
Prior art date
Application number
PCT/CN2015/082127
Other languages
French (fr)
Chinese (zh)
Inventor
王振江
武成岗
张洪娟
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2016000550A1 publication Critical patent/WO2016000550A1/en

Links

Images

Definitions

  • the present invention relates to the field of computer technologies, and in particular, to a binary translation execution method and apparatus for a shared library.
  • the computer architecture is constantly evolving, and new processors that adapt to different needs are constantly emerging.
  • new processors When a new processor is produced, the lack of software resources is an important factor hindering its forward development. Older general-purpose processors have a wealth of software resources, but their binary programs can only run on this instruction set architecture platform. In this context, it is increasingly important to port the executable code to the new processor in the original architecture, and binary translation technology has emerged in this situation.
  • BT Binary Translation
  • translation source platform also called guest
  • a shared library usually in the binary form supported by the source platform, the shared library and the main program dependent on the shared library and all other shared libraries that the main program depends on as input (even if the target platform already has a corresponding main program)
  • a corresponding shared library that can be run on the target platform (also called a host) and a main program that depends on the shared library and all other shared libraries that the main program depends on are obtained.
  • target platform also called a host
  • main program that depends on the shared library and all other shared libraries that the main program depends on are obtained. Due to the wide application of binary translation technology, the industry has begun to conduct in-depth research.
  • the prior art binary translation system usually performs binary translation of the shared library supported by the client and the main program that depends on the shared library and all other shared libraries that the main program depends on to obtain a corresponding share that can be run on the host.
  • the library and the main program that depends on the shared library and all other shared libraries that the main program depends on may sometimes be large, which may bring a large amount to the binary translation system. Work load, which in turn may affect the user experience.
  • Embodiments of the present invention provide a binary translation execution method and apparatus for a shared library, in anticipation of reducing The amount of relevant code translation when translating the library, thereby improving the efficiency of binary translation execution, thereby improving the user experience.
  • a first aspect of the present invention provides a binary translation execution method of a shared library, where the method is applied to a host, where the host includes a first shared library supported by the host, and a second share supported by the host. a third shared library supported by the library and the client, the first shared library including a translation function, the host and the client supporting different instruction set architectures,
  • the method includes:
  • the host executes the first function to invoke a translation function in the first shared library
  • the host machine translates a function function in the third shared library with a second function function of the first function by using a translation function in the first shared library of the call to obtain a second function a third function supported by the host; wherein a function interface of the third function and a function interface of the second function are the same;
  • the host executes the third function.
  • the host machine further includes a fifth shared library supported by the host; if the second function includes calling the client support
  • the instruction of the fourth function in the fourth shared library, the step of translating the second function further includes:
  • the host translates, by the second function, an instruction that calls a fourth function in the fourth shared library into an instruction that invokes a fifth function in the fifth shared library, wherein the fourth The function has the same function as the function of the fifth function, or the function functions and function interfaces of the fourth function and the fifth function are the same.
  • the host machine further includes a fifth shared library supported by the host, when the third function invokes the client support
  • the method further includes:
  • the host machine further includes a second main program supported by the host, if the second function includes an instruction to invoke a sixth function in the first main program supported by the client, to the second function
  • the steps to translate include:
  • the host translating, by the second function, the instruction that invokes the sixth function in the first main program supported by the client into an instruction that invokes the seventh function in the second main program,
  • the functions of the sixth function and the seventh function are the same, or the function functions and function interfaces of the sixth function and the seventh function are the same.
  • the method further includes:
  • the host translates, by the third function, an instruction that calls a sixth function in the first main program supported by the client into a third function, and invokes a seventh function in the second main program.
  • the functions of the sixth function and the seventh function are the same, or the function functions and function interfaces of the sixth function and the seventh function are the same.
  • the step of translating the second function further comprising: the host machine, using the function pointer of the tenth function supported by the client as an incoming parameter, to invoke the The calling instruction of the eighth function supported by the host is replaced by a function pointer of the ninth function supported by the host as an incoming parameter to invoke a calling instruction of the eighth function supported by the host;
  • the host executes the ninth function to invoke a translation function in the first shared library to translate the tenth function, to obtain the host support
  • the host executes the eleventh function.
  • the step of translating the second function further includes:
  • the domain included in the volume is a subset of the domains included in the second structure
  • the first structure is a structure supported by the client, and the second structure is a structure supported by the host, and the twelfth function is a function supported by the host. ;
  • the first structure is a structure supported by the host
  • the second structure is a structure supported by the client
  • the twelfth function is supported by the client The function.
  • the step of translating the second function further includes: the host machine The structure pointer calls the call instruction of the thirteenth function as an incoming parameter, and translates to a call instruction that calls the thirteenth function with the second structure body pointer as an incoming parameter;
  • first structure body pointer points to the first structure body
  • second structure body pointer points to the second structure body
  • first structure body includes a domain that is a subset of the domain included in the second structure body
  • first structure is a structure supported by a client
  • second structure is a structure supported by a host
  • the thirteenth function is a function supported by the host
  • the first structure is a structure supported by the host
  • the second structure is a structure supported by the client
  • the thirteenth function is a function supported by the client.
  • the method further includes: the host replacing the third structure as the incoming parameter of the second function with the fourth structure,
  • the domain included in the third structure is a subset of the domains included in the fourth structure;
  • the fourth structure is a structure supported by a client, and the third structure is a structure supported by a host.
  • the method further includes: the host replacing the third structure pointer as an incoming parameter of the second function with a fourth a structure pointer, the fourth structure pointer points to a fourth structure body, the third structure body pointer points to a third structure body, and the third structure body includes a domain that is a domain of the fourth structure body Subset;
  • the fourth structure is a structure supported by a client, and the third structure is a structure supported by a host.
  • the method further includes: the host performing symbol on the third shared library and the host with the same name global variable reset.
  • the host performs a symbol on the third shared library and the host with the same name global variable Relocating includes: if the first global variable included in the third shared library and the N global variable of the host have the same name, the host will be the most among the first global variable and the N global variables The address of the first loaded global variable is set to the public address of the N global variables and the first global variable.
  • the host performs a symbol on a global variable of the same name of the third shared library and the host Relocating includes: after being loaded in the second shared library, the host relocates an address of a first global variable in the third shared library to a second global in the second shared library The address of the variable, wherein the declaration of the first global variable and the second global variable are the same.
  • a second aspect of the present invention provides a host machine, the host machine comprising:
  • a storage unit configured to store a first shared library supported by the host, a second shared library supported by the host, and a third shared library supported by the client, where the first shared library includes a translation function, the sink
  • the host and the client support different instruction set architectures
  • a calling unit configured to: when the first function in the second shared library is called, execute the first function to invoke a translation function in the first shared library;
  • a translation unit configured to translate, by using a translation function in the first shared library of the call, a function of the function interface of the third shared library and a second function of the first function to obtain a a third function supported by the host; wherein a function interface of the third function and a function interface of the second function are the same;
  • An execution unit configured to execute the third function.
  • the storage unit is further configured to store a fifth shared library supported by the host, where, if the second function includes calling the An instruction of a fourth function in a fourth shared library supported by the client;
  • the translation unit is also used to:
  • the storage unit is further configured to store a fifth shared library supported by the host, when the third function invokes the client support
  • the fourth function in the fourth shared library the translation unit is also used to:
  • the storage unit is further configured to: Storing a second main program supported by the host, if the second function includes an instruction to invoke a sixth function in the first main program supported by the client, the translation unit is further configured to:
  • the storage unit is further configured to: Storing a second main program supported by the host, when the third function calls a sixth function in the first main program supported by the client, the translation unit is further configured to:
  • the translation unit when the second function includes a function pointer of the tenth function supported by the client as an incoming parameter, to invoke a call instruction of an eighth function supported by the host, the translation unit further Used for:
  • the function pointer of the tenth function supported by the client is used as an incoming parameter, and the calling instruction of the eighth function supported by the host is invoked, and the function of the ninth function supported by the host is replaced.
  • a pointer as an incoming parameter to invoke a call instruction of an eighth function supported by the host; when the ninth function is called, executing the ninth function to invoke a translation function pair in the first shared library
  • the tenth function is translated to obtain an eleventh function supported by the host.
  • the translation unit is further configured to: Calling the call instruction of the twelfth function with the first structure as the incoming parameter, and translating into the call instruction of the twelfth function with the second structure as the incoming parameter, wherein the first structure includes The domain is a subset of the domains contained by the second structure;
  • the first structure is a structure supported by the client, and the second structure is a structure supported by the host, and the twelfth function is a function supported by the host. ;
  • the first structure is a structure supported by the host
  • the second structure is a structure supported by the client
  • the twelfth function is supported by the client The function.
  • the translation unit is further configured to: the host machine invokes the calling instruction that invokes the thirteenth function by using the first structure body pointer as an incoming parameter, and translates to calling the tenth with the second structure body pointer as an incoming parameter a call instruction of a three function; wherein the first structure body pointer points to the first structure body, and the second structure body pointer points to the second structure body, wherein the first structure body includes a domain a subset of the fields contained in the structure;
  • the first structure is a structure supported by a client
  • the second structure is a structure supported by a host
  • the thirteenth function is a function supported by the host
  • the first structure is a structure supported by the host
  • the second structure is a structure supported by the client
  • the thirteenth function is a function supported by the client.
  • the host machine further includes: a relocation unit, configured to perform the third-order shared library and the same-named global variable of the host machine before translating the first function in the third shared library to obtain the second function Symbol relocation.
  • a relocation unit configured to perform the third-order shared library and the same-named global variable of the host machine before translating the first function in the third shared library to obtain the second function Symbol relocation.
  • the relocation unit is specifically configured to: if the third shared library includes a first global variable and Setting N global variables of the host with the same name, setting an address of the first global variable and the first global variable loaded among the N global variables as the N global variables and the first The public address of the global variable;
  • the relocation unit is specifically configured to relocate an address of the first global variable in the third shared library to a second in the second shared library after being loaded in the second shared library The address of the global variable, wherein the declaration of the first global variable and the second global variable are the same.
  • the second shared library supported by the host can be regarded as a pseudo shared library of the third shared library supported by the client, because the second shared library
  • the first function is the same as the function interface of the second function in the third shared library, and the first function in the second shared library is mainly used to trigger the calling of the first shared library to translate the third shared library.
  • a function with the same function interface, and this can make the main program or other shared library on the host machine can be the second shared library as a bridge, indirectly calling the first share by calling a function in the second shared library.
  • Another function in the third shared library translated by the translation function in the library has the same function interface.
  • the main program or other shared library on the host can recognize and straighten. Calling the function in the second shared library, so that even if the main program or the other dependent shared library that depends on the third shared library on the client is not translated, the third shared library on the client can be indirectly called, so that Greatly reduce the strong dependency between the third shared library and the client's supporting main program (or other related shared libraries), which is beneficial to greatly reduce the amount of translation code, thereby improving the efficiency of binary translation execution, and thus Improve the user experience.
  • FIG. 1 is a schematic flowchart of a binary translation execution method of a shared library according to an embodiment of the present invention
  • FIG. 2 is a schematic flowchart diagram of another binary translation execution method of a shared library according to another embodiment of the present invention.
  • FIG. 3 is a schematic structural diagram of an x86 client running browser according to an embodiment of the present invention.
  • FIG. 3 is a schematic structural diagram of a Loongson host running browser according to an embodiment of the present invention.
  • FIG. 3-c is a schematic diagram of a conventional architecture after the Loongson host is introduced into the binary translator according to the embodiment of the present invention.
  • FIG. 3-d is a schematic diagram of a new architecture after the introduction of the binary translator by the Loongson host according to the embodiment of the present invention.
  • FIG. 3-e is a schematic diagram of code translation according to an embodiment of the present invention.
  • FIG. 3-f is a schematic diagram of another code translation related to a function pointer according to an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of a host machine according to an embodiment of the present invention.
  • FIG. 5 is a schematic diagram of another host machine according to an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of another host machine according to an embodiment of the present invention.
  • FIG. 7 is a schematic diagram of a communication system according to an embodiment of the present invention.
  • the embodiments of the present invention provide a binary translation execution method and apparatus for a shared library, so as to reduce the amount of related code translation when the shared library is translated, thereby improving the execution efficiency of the binary translation, thereby improving the user experience.
  • a binary translation execution method of the shared library is applied to the host machine, and the host machine may include the first shared library supported by the host machine and supported by the host machine. a second shared library and a third shared library supported by the client, the first shared library includes a translation function, the host machine and the client support different instruction set architectures, and the method includes: when in the second shared library When the first function is called, the host machine executes the first function to invoke the translation function in the first shared library; the host machine uses the translation function in the first shared library that is invoked to invoke the third shared library.
  • the second function of the function interface of the first function is translated to obtain the third function supported by the host machine; the function interface of the third function is the same as the function interface of the second function;
  • the host executes the third function described above.
  • FIG. 1 is a schematic flowchart of binary translation execution of a shared library according to an embodiment of the present invention.
  • a binary translation execution method of a shared library provided by an embodiment of the present invention may include the following contents:
  • the host machine executes the first function described above to invoke the translation function in the first shared library.
  • the host machine may include a first shared library supported by the host, a second shared library supported by the host, and a third shared library supported by the client, wherein the host and the client support different instruction sets.
  • Architecture may include a first shared library supported by the host, a second shared library supported by the host, and a third shared library supported by the client, wherein the host and the client support different instruction sets.
  • the host machine translates, by using the translation function in the first shared library that is invoked, the second function of the function interface and the function interface of the first function in the third shared library to obtain the foregoing function.
  • the third function supported by the host.
  • the function interface of the third function is the same as the function interface of the second function.
  • first function in the second shared library may be any one of the second shared libraries, or the first function in the second shared library may be any one of the second shared libraries. a specific function.
  • step of translating the second function may be performed first, and then the step of executing the foregoing third function may be performed, and in other possible implementations, it may be performed on one side.
  • the step of translating the second function described above performs the above-described step of executing the third function described above, that is, performing the third function and translating the second function may be interleaved.
  • the second shared library supported by the host can be regarded as a pseudo shared library of the third shared library supported by the client, because the second shared library
  • the first function is the same as the function interface of the second function in the third shared library, and the first function in the second shared library is mainly used to trigger the calling of the first shared library to translate the third shared library.
  • a function with the same function interface, and this can make the main program or other shared library on the host machine can be the second shared library as a bridge, indirectly calling the first share by calling a function in the second shared library.
  • the first shared library includes a translation function, that is, the binary translator is compiled into the first shared library, when the function in the third shared library supported by the client needs to be called, the first shared library is related to the called
  • the function is dynamically translated, which is beneficial to improve the pertinence and effectiveness of translation, and is beneficial to reduce the amount of invalid translation work, thereby further reducing the amount of translation code, thereby further improving the execution efficiency of binary translation, thereby further improving the user experience.
  • the translation of the above second function may involve various aspects, and the specific translation manner may also be various, as exemplified below.
  • the host machine further includes a fifth shared library supported by the host machine; if the second function includes an instruction for calling a fourth function in the fourth shared library supported by the client.
  • the step of translating the second function may further include: the host machine translating, by the host machine, the instruction for calling the fourth function in the fourth shared library included in the second function into calling the fifth shared library.
  • the instruction of the fifth function wherein the functions of the fourth function and the function of the fifth function are the same, or the function functions and function interfaces of the fourth function and the fifth function are the same. It can be understood that the above host translates the instruction of the second function included in the second shared library to the instruction of calling the fifth function in the fifth shared library, which can be regarded as one.
  • the library function packaging technology replaces the call of a function in a shared library supported by the client with a function that has the same function or a function function and a function interface in a shared library supported by the host. This is beneficial to improve the utilization of the local shared library of the host machine, and further reduce the translation of the function code of the client-related shared library, thereby further reducing the amount of code translation.
  • the host machine may further include a fifth shared library supported by the host machine, where the third function invokes the fourth shared library supported by the client.
  • the method may further include: the host machine translating, by the host function, the instruction of the fourth function included in the fourth shared library supported by the third function into the third function calling the foregoing The instruction of the fifth function in the shared library; wherein the function function and the function interface of the fourth function and the fifth function are the same, or the functions of the fourth function and the fifth function are the same.
  • the host machine translates the instruction including the fourth function in the fourth shared library included in the third function into an instruction that invokes the fifth function in the fifth shared library, which can be regarded as an essential Is a library function wrapper technology, that is, the call to a function in a shared library supported by the client can be replaced by the same function or function function and function interface in a shared library supported by the host.
  • the call of the function which is beneficial to improve the utilization of the local shared library of the host, further reduce the translation of the function code of the client-related shared library, thereby further reducing the amount of code translation.
  • the host machine further includes a second main program supported by the host machine, where the second function includes an instruction to invoke a sixth function in the first main program supported by the client.
  • the step of translating the second function may further include: the host machine translating, by the host function, the instruction that invokes the sixth function in the first main program supported by the client by the second function to call the foregoing The instruction of the seventh function in the two main programs, wherein the functions of the sixth function and the function of the seventh function are the same, or the function functions and function interfaces of the sixth function and the seventh function are the same.
  • the above-mentioned second function includes the instruction for calling the sixth function in the first main program supported by the client, and the instruction for calling the seventh function in the second main program is essentially regarded as Is a library function wrapper technology, that is, the call to a function in the main program supported by the client is replaced by a call to a function with the same function or the same function and function interface in the main program supported by the host.
  • This is beneficial to improve the utilization of the local shared library of the host machine, and further reduce the translation of the function code of the client-related shared library, thereby further reducing the amount of code translation.
  • the host machine further includes a second main program supported by the host machine, when the third function invokes a sixth function in the first main program supported by the client,
  • the method further includes: the host machine translating, by the host function, an instruction of the third function included in the first main program supported by the third function to the third function to invoke the second main a call of a seventh function in the program, wherein the functions of the sixth function and the function of the seventh function are the same, or the function functions and function interfaces of the sixth function and the seventh function are the same.
  • the above-mentioned third function includes the instruction for calling the sixth function in the first main program supported by the client, and the instruction for calling the seventh function in the second main program is substantially Seen as a library function wrapper technology, that is, you can replace the call to a function in the main program supported by the client with the same function or the function and function interface in the main program supported by the host.
  • the call of the function which is beneficial to improve the utilization of the host's local shared library, further reduce the translation of the function code of the client-related shared library, thereby further reducing the amount of code translation.
  • the step of translating the second function may further include: the host machine adopts the function pointer of the tenth function supported by the client as the incoming parameter, and invokes the calling instruction of the eighth function supported by the host, and replaces it with The function pointer of the ninth function supported by the host machine is used as an incoming parameter to invoke the calling instruction of the eighth function supported by the host.
  • the host machine executes the ninth function to invoke the translation function in the first shared library to translate the tenth function, to obtain an eleventh function supported by the host machine,
  • the host executes the eleventh function described above.
  • the third year function includes a function pointer of the function S01 supported by the host machine as an incoming parameter, to invoke a call instruction of the S02 function supported by the host, when the function is When S01 is called, the host machine executes the above function S01, and the host does not translate the above function S001.
  • the step of translating the second function may further include: The host invokes the above-mentioned call instruction of the twelfth function with the first structure as the incoming parameter, and translates the call instruction of the twelfth function with the second structure as the incoming parameter,
  • the domain included in the first structure is a subset of the domains included in the second structure.
  • the first structure is a structure supported by the client, and the second structure is a structure supported by the host, and the twelfth function is a function supported by the host; or the first structure
  • the body is a structure supported by the host machine, and the second structure is a structure supported by the client, and the twelfth function is a function supported by the client.
  • the domain included in the first structure may be the same as the domain included in the second structure.
  • the step of translating the second function may further include:
  • the host machine invokes the above-mentioned call instruction that invokes the thirteenth function with the first structure body pointer as an incoming parameter, and translates the call instruction of the thirteenth function with the second structure body pointer as an incoming parameter.
  • the first structure pointer points to the first structure
  • the second structure pointer points to the second structure
  • the first structure includes a field that is a subset of the domains included in the second structure.
  • the first structure is a structure supported by a client
  • the second structure is a structure supported by a host
  • the thirteenth function is a function supported by the host.
  • the first structure is a structure supported by the host
  • the second structure is a structure supported by the client
  • the thirteenth function is a function supported by the client.
  • the domain included in the first structure may be the same as the domain included in the second structure.
  • the method may further include: the third structure that the host machine uses as the incoming parameter of the second function
  • the body is replaced by a fourth structure
  • the third structure includes a domain of a subset of domains included in the fourth structure; wherein the fourth structure is a client-supported structure, and the third structure A structure supported by the host.
  • the domain included in the third structure described above may be the same as the domain included in the fourth structure.
  • the method may further include: the foregoing, by the host, as an incoming parameter of the second function
  • the third structure pointer is replaced with a fourth structure body pointer
  • the fourth structure body pointer is directed to the fourth structure body
  • the third structure body pointer is directed to the third structure body
  • the third structure body includes the fourth structure body A subset of the included domains.
  • the fourth structure body is supported by the client The structure
  • the third structure is a structure supported by a host.
  • the domain included in the third structure described above may be the same as the domain included in the fourth structure.
  • the above exemplifies some possible implementations of the translation second function
  • the translation translation second function may also involve some other operations related to translation, of course, in practical applications, other translation operations may also be involved, of course, the above translation operations They may also be nested with each other, and the specific methods are not described here.
  • the method may further include: the foregoing host machine, the third shared library, and the foregoing The host's global variable of the same name is symbol relocated.
  • the symbol relocation of the global variable of the same name of the third shared library and the host machine by the host machine includes: if the first global variable included in the third shared library and the N global variable of the host have the same name, The host machine sets an address of the first global variable and the first global variable loaded among the N global variables to a common address of the N global variables and the first global variable.
  • the symbol relocation of the global variable of the same name of the third shared library and the host machine by the host machine includes: after the second shared library is loaded, the host machine is the first one of the third shared libraries.
  • the address of the global variable is relocated to the address of the second global variable in the second shared library, wherein the declaration of the first global variable and the second global variable is the same.
  • the first global variable may be any global variable included in the third shared library.
  • the first global variable may also be a specific global variable included in the third shared library.
  • the host and the client of the embodiments of the present invention support different instruction set architectures.
  • the host and the client can respectively support one of the following instruction set architectures: the POWER instruction set architecture and the x86 instruction set system. Architecture, Loongson instruction set architecture and MIPS instruction set architecture.
  • the client mainly supports the x86 instruction set architecture, and the host supports the Loongson command.
  • the architecture of the system Take the architecture of the system as an example.
  • a client supporting the x86 instruction set architecture may be referred to as an x86 client
  • a host supporting the Loongson instruction set architecture may be referred to as a Loongson host.
  • the Loongson host machine can run the open source Firefox browser (the browser can be regarded as the main program), but the flash playback plugin (ie flashplayer.so shared library) in the browser is developed by Adobe. Assume that the flash player plugin is not open source and only provides the version under the x86 instruction set architecture, so it cannot be used in the Firefox browser of the Godson host.
  • the flash playback plugin ie flashplayer.so shared library
  • the browser supported by the Loongson host can be called the Loongson browser, and the shared library supported by the Loongson host is called the Loongson shared library.
  • a browser supported by an x86 client can be referred to as an x86 browser, and a shared library supported by an x86 client can be referred to as an x86 shared library.
  • FIG. 3-a shows a software architecture for an x86 client running an x86 browser.
  • the x86 browser may call functions in various x86 shared libraries (including flash play plugins); the flash play plugin may also call functions from other x86 shared libraries; the flash play plugin may also call functions in the x86 browser.
  • the binary translator In the existing binary translation scheme, the binary translator is the main program of the Loongson host, and its architecture can be specifically shown in Figure 3-c.
  • the binary translator not only needs to translate the flash playback plug-in running the x86 client, but also needs to translate and run.
  • X86 browsers and other x86 shared libraries therefore, because of the need to translate x86 shared libraries and x86 browsers, which makes the translation code large, affecting the efficiency of translation operations.
  • the binary translator is compiled into a first shared library bt.so on the Loongson host (an example implementation of the first shared library in the above embodiment), the first shared library Bt.so can be called by the Loongson browser, and the x86 client's flash play plugin is translated by the first shared library bt.so, as shown in Figure 3-d. Because the x86 code that needs to be translated and run is greatly reduced, it is beneficial to greatly improve the efficiency of translation operation.
  • FIG. 2 is a schematic flowchart of binary translation execution of another shared library according to another embodiment of the present invention. As shown in FIG. 2, another shared library provided by another embodiment of the present invention is provided.
  • the binary translation execution method can include the following:
  • the Loongson host compiles the binary translator into the first shared library bt.so.
  • the Loongson host machine loads the pseudo flash play plugin flashplayer_ls.so (the pseudo flash play plugin flashplayer_ls.so can be regarded as an example implementation of the second shared library in the above embodiment) to be loaded into the Loongson browser.
  • the function interface provided by the pseudo flash playback plug-in flashplayer_ls.so and the x86flash playback plug-in flashplayer_x86.so provides a function.
  • the interface is the same. Among them, you can find the global function symbols from the symbol table by parsing the binary files of the x86flash playback plug-in. These global function symbols are the function interfaces of the x86flash playback plug-in, and the function interface of the x86flash playback plug-in is provided as a function provided by the pseudo-flash playback plug-in. interface.
  • the Loongson host can also load the first shared library bt.so, and can also initialize the x86 runtime environment (such as simulated x86 registers, memory, etc.) and the translated Loongson code buffer through the first shared library bt.so. Wait.
  • the x86 runtime environment such as simulated x86 registers, memory, etc.
  • the Loongson host executes the first function in the pseudo flash playback plug-in flashplayer_ls.so to call the first shared library bt.so
  • the translation function x86_exec translates the function function in the x86flash playback plug-in flashplayer_x86.so with the second function (such as the NPP_New function) of the function interface of the first function to obtain a third function, and executes the third function.
  • Figure 3-e shows the second function in the x86flash playback plug-in flashplayer_x86.so (the NPP_New function is shown in Figure 3-e), and the Loongson host machine is translated. The third function supported.
  • the foregoing Loongson host further includes a fifth shared library supported by the Loongson host; if the second function includes a fourth shared library (such as libc.so) supported by the x86 client.
  • the instruction of the fourth function (such as the malloc function), wherein the step of translating the second function may further include: the Loongson host invoking the second function included in the fourth shared library (such as libc.
  • An instruction of a fourth function (such as a malloc function) in so) is translated into an instruction that invokes a fifth function in the fifth shared library, wherein the fourth function and the fifth function are The function and function interface are the same.
  • the Loongson host machine translates the instruction of the second function included in the second shared library mentioned above into the instruction of calling the fifth function in the fifth shared library, which can be regarded as one.
  • the library function wrapper technology is to replace the call of a function in a shared library supported by the x86 client with a function with the same function or the same function and function interface in a shared library supported by the Loongson host. Calling, which is beneficial to improve the utilization of the local shared library of the Loongson host, further reducing the translation of the function code of the shared library of the x86 client, thereby further reducing the amount of code translation.
  • the Loongson host machine further includes a fifth shared library supported by the Loongson host, and the third function calls the fourth shared library supported by the x86 client (for example, libc.so
  • the fourth function for example, the malloc function
  • the above-mentioned Loongson host may include the fourth shared library supported by the above-mentioned x86 client including the third function (such as the fourth function in libc.so (for example, the malloc function).
  • an instruction translated into the third function of the fifth shared library in the fifth shared function wherein the function function and the function interface of the fourth function and the fifth function are the same, or the fourth function and the foregoing
  • the functions of the five functions have the same function.
  • the above-mentioned Loongson host translates the instruction of the third function included in the third function to the fifth function in the fifth shared library.
  • it can be regarded as a library function wrapper technology, that is, the call to a function in a shared library supported by the x86 client can be replaced with the Loongson host.
  • the function of the shared function in a shared library is the same or the function function and function interface are the same function call, which is beneficial to improve the utilization of the local shared library of the Loongson host, and further reduce the function code of the shared library of the x86 client.
  • the translation helps to further reduce the amount of code translation.
  • the Loongson host machine further includes a Loongson browser supported by the Loongson host machine, and if the second function includes an instruction to invoke a sixth function (such as the NPN_PostURL function) in the x86 browser,
  • the step of translating the second function may further include: the above-mentioned Loongson host translating, by the above-mentioned second function, the instruction of the sixth function (such as the NPN_PostURL function) in the x86 browser supported by the x86 client described above into a call.
  • the instruction of the seventh function (such as the NPN_PostURL function) in the Loongson browser, wherein the function function and the function interface of the sixth function and the seventh function are the same.
  • the instruction of the sixth function in the x86 browser supported by the above x86 client is translated into the instruction of calling the seventh function in the Loongson browser, which can be regarded as a library function packaging technology, which is about to be an x86 client.
  • the call of a function in the supported x86 browser is replaced by the call of the same function and function interface in the Loongson browser supported by the Loongson host, which is beneficial to improve the local shared library utilization of the Loongson host. , further reducing the translation of the function code of the x86 client-related shared library, thereby further reducing the amount of code translation.
  • the Loongson host machine further includes the Loongson browser supported by the Loongson host, and the third function in the x86 browser supported by the x86 client is used as the sixth function (
  • the above-mentioned Loongson host may translate the instruction of the sixth function included in the x86 browser supported by the above-mentioned x86 client into the third function to call the above-mentioned Loongson browser.
  • a call of a seven function such as an NPN_PostURL function
  • the functions of the sixth function and the function of the seventh function are the same, or the function functions and function interfaces of the sixth function and the seventh function are the same.
  • the above-mentioned third function includes the above-mentioned instruction for calling the sixth function in the x86 browser supported by the x86 client, and the instruction for calling the seventh function in the Loongson browser is substantially visible.
  • a library function wrapper technology that is, you can replace the call of a function in the main program supported by the x86 client with the same function or function function and function interface in the main program supported by the Loongson host.
  • the same function call which is beneficial to improve the utilization of the local shared library of the Loongson host, further reducing the translation of the function code of the shared library of the x86 client, thereby further reducing the amount of code translation.
  • the Loongson host machine executes the first function in the pseudo flash play plugin flashplayer_ls.so to call the translation function x86_exec in the first shared library bt.so to the x86flash play plugin flashplayer_x86.so Before the second function is translated to get the third function, the Loongson host can execute the x86 loader or the related function in the first shared library bt.so to play the above x86flash plugin flashplayer_x86.so and the Loongson host. A symbolic relocation is performed on the global variable of the same name.
  • the Loongson host can execute the related function in the first shared library bt.so to read the global variable list in the Loongson running environment and the x86 running environment.
  • Shared global variables for both, based on their memory loading The order (ie, the loading order of the browser, shared library, and flash player plugin in the same runtime environment) is re-symbolized. After this process, the code in the two runtime environments can access the same global variable normally.
  • the Loongson host executes a loader or a related function in the first shared library bt.so to perform symbol relocation on the x86flash playback plug-in flashplayer_x86.so and the same-named global variable of the Loongson host, which may include: If the x86flash playback plugin flashplayer_x86.so contains the first global variable and the same name of the N global variable of the Loongson host, the Loongson host executes the loader or the first shared library bt.so related function to the above first global variable and The address of the first global variable loaded among the N global variables is set to the public address of the N global variables and the first global variable, and the N is a positive integer.
  • the Loongson host performs a loader or a related function in the first shared library bt.so to perform symbol relocation on the x86flash playback plug-in flashplayer_x86.so and the same-named global variable of the Loongson host, which may include: playing in a pseudo flash.
  • the address of the first global variable of the x86 flash playback plug-in flashplayer_x86.so is relocated to the address of the second global variable in the pseudo-flash playback plug-in flashplayer_ls.so.
  • the declaration of the first global variable and the second global variable are the same.
  • the first global variable mentioned above may be any global variable included in the x86flash playback plug-in flashplayer_x86.so.
  • the first global variable may also be a specific global variable included in the x86flash playback plugin flashplayer_x86.so.
  • the symbol relocation mode of each global variable included in the x86flash playback plug-in flashplayer_x86.so can be similar to the symbol relocation mode of the first global variable.
  • the Loongson browser, the Loongson shared library, and the x86flash playback plug-in flashplayer_x86.so may pass function pointers through the arguments and return values of function calls.
  • the function A of the x86flash playback plug-in flashplayer_x86.so may call the function B in the Loongson graphics shared library with the function pointer x86_foo as the incoming parameter; the function B will use the function pointer to call the function pointed to by the function pointer x86_foo.
  • function B in the actual program may be the function g_signal_connect, register a click event for a control (such as a button), or set a timer for gtk_timeout_add.
  • Loongson browser or Loongson shared library calls the function of the x86flash playback plugin flashplayer_x86.so
  • the function pointer can be subjected to a certain translation process, which is beneficial to ensure the correctness of the function operation.
  • the first type of value conversion when the second function includes a function pointer of the tenth function supported by the above x86 client (such as the x86 function pointer x86_foo) as an incoming parameter, to invoke the calling instruction of the eighth function supported by the Loongson host.
  • the Loongson host can execute a correlation function in the first shared library bt.so to generate a ninth function (which can be regarded as a pseudo-base function (such as the x86_foo function in FIG.
  • the function pointer of the tenth function supported by the above x86 client is used as an incoming parameter to call the calling instruction of the eighth function supported by the above-mentioned Loongson host, and is replaced by the function pointer of the ninth function supported by the Loongson host.
  • the function, the above tenth function is translated, and the eleventh function supported by the Loongson host machine is obtained, and the Loongson host performs the eleventh function described above.
  • the introduction of the ninth function as a bridge is beneficial to realizing the translation of the function pointed to by the function pointer at a suitable timing, which is beneficial to avoid errors as much as possible.
  • the second function pointer replaced is in accordance with the Loongson host.
  • the application binary interface can be called by the Loongson host function.
  • the second type of value conversion if the incoming parameter of the second function includes a third function pointer, and the third function pointer is a function pointer of the above-mentioned Loongson host machine (the third function pointer may be determined according to the structure of the function pointer as the above-mentioned Loongson The function pointer of the host is still a function pointer of the above x86 client), and the call of the second function to the eleventh function pointed to by the third function pointer is translated into the above-mentioned third function pointing to the third function pointer The call of the eleventh function.
  • the definition of the same structure on the x86 client and the Loongson host may be different, and the structure may add null data between the domain and the domain in order to meet the data alignment requirements of each domain.
  • the binary format of the same structure on the x86 client and the Loongson host is not necessarily the same.
  • the Loongson host may use the first structure as the incoming
  • the parameter calls the calling instruction of the twelfth function, and translates into calling instruction of the twelfth function by using the second structure as the incoming parameter, and the first structure includes the domain of the domain included in the second structure. set.
  • the first structure is a structure supported by the x86 client
  • the second structure is a structure supported by the Loongson host
  • the twelfth function is a function supported by the Loongson host
  • the above A structure is a structure supported by the Loongson host
  • the second structure is a structure supported by the x86 client
  • the twelfth function is a function supported by the x86 client.
  • the domain included in the first structure described above may be the same as the domain included in the second structure.
  • the step of translating the second function may further include:
  • the Loongson host machine invokes the above-mentioned call instruction of the thirteenth function with the first structure body pointer as an incoming parameter, and translates the call instruction of the thirteenth function with the second structure body pointer as an incoming parameter.
  • the first structure body pointer points to the first structure body
  • the second structure body pointer points to the second structure body
  • the first structure body includes a domain that is a subset of the domains included in the second structure body.
  • the first structure is a structure supported by an x86 client
  • the second structure is a structure supported by a Loongson host
  • the thirteenth function is a function supported by the Loongson host.
  • the first structure is a structure supported by a Loongson host
  • the second structure is a structure supported by an x86 client
  • the thirteenth function is a function supported by the x86 client.
  • the domain included in the first structure may be the same as the domain included in the second structure.
  • the third type of value conversion mode 1 can also be performed on the domain. If a domain in the first structure is also a structure pointer, the third class value can also be made to the domain. Conversion method 2. Wherein, if a certain field in the first structure is a function pointer, the first type of value conversion can be performed on the domain. And so on.
  • the Loongson host may replace the third structure as the incoming parameter of the second function with the fourth structure, and the third structure includes the domain And a subset of the domains included in the fourth structure; wherein the fourth structure is a structure supported by an x86 client, and the third structure is a structure supported by a Loongson host.
  • the domain included in the third structure described above may be the same as the domain included in the fourth structure.
  • the Godson host may replace the third structure body pointer as the incoming parameter of the second function with the fourth structure body pointer, and the fourth structure body
  • the pointer points to the fourth structure
  • the third structure pointer points to the third structure
  • the third structure includes a field which is a subset of the fields included in the fourth structure.
  • the fourth structure is a structure supported by an x86 client
  • the third structure is a structure supported by a Loongson host.
  • the domain included in the third structure described above may be the same as the domain included in the fourth structure. .
  • the fourth type of value conversion mode 1 can also be performed on the domain. If a certain field in the third structure is also a structure pointer, the fourth type of value conversion mode 2 can also be performed on the domain. Wherein, if a certain field in the third structure is a function pointer, the second type of value conversion can be performed on the domain. And so on.
  • the second shared library supported by the Loongson host machine (pseudo flash play plugin flashplayer_ls.so) can be regarded as the third shared library supported by the x86 client (x86 flash play plugin).
  • the function of the first function in the second shared library and the second function in the third shared library are the same (that is, the function interface provided by the second shared library and the third shared library described above)
  • the first function in the second shared library is mainly used to trigger the calling of the first shared library to translate the function having the same function interface in the third shared library, and this It can make the main program or other shared library on the Loongson host machine, and the second shared library can be used as a bridge to indirectly call the translation function translated by the first shared library by calling a function in the second shared library.
  • Another function in the third shared library with the same function interface, due to the The second shared library is supported by the Loongson host.
  • the main program or other shared libraries on the Loongson host can recognize and directly call the functions in the second shared library, so that even if the third shared library is not dependent on the x86 client.
  • the main program or other dependent shared libraries are translated, and can also be executed indirectly on the third shared library on the x86 client, which greatly reduces the support main program (or other related sharing) of the third shared library and the x86 client. Strong dependency between libraries), which helps to greatly reduce the amount of translation code, which can improve the efficiency of binary translation execution, thereby improving the user experience. .
  • the first shared library is compiled by the binary translator, when the function in the third shared library supported by the x86 client is called, the first shared library dynamically translates the called related function, so that It is beneficial to improve the pertinence and effectiveness of translation, and thus help to reduce the amount of invalid translation work, which in turn helps to further reduce the amount of translation code, thereby further improving the execution efficiency of binary translation, thereby further improving the user experience.
  • the client supports the x86 instruction set architecture and supports the Loongson instruction set architecture.
  • the host machine supports the x86 instruction set architecture or other instruction set architecture.
  • the implementation method of the client supporting the Loongson instruction set architecture or other instruction set architecture can be similarly referred to, and will not be described here.
  • an embodiment of the present invention provides a host 400 that can include a storage unit 410, a calling unit 420, a translation unit 430, and an execution unit 440.
  • the storage unit 410 is configured to store a first shared library supported by the host, a second shared library supported by the host, and a third shared library supported by the client, where the first shared library includes a translation function, the host and the foregoing
  • the client supports a different instruction set architecture.
  • the calling unit 420 is configured to execute the first function to invoke the translation function in the first shared library when the first function in the second shared library is called.
  • the translation unit 430 is configured to translate the second function of the function interface in the third shared library and the function interface of the first function by using the translation function in the first shared library that is invoked to obtain the host machine.
  • the executing unit 440 is configured to execute the third function described above.
  • the foregoing storage unit 410 is further configured to store a fifth shared library supported by the host machine, where the second function includes: calling the fourth shared library supported by the client. The instruction of the fourth function.
  • the above translation unit 430 can also be used to:
  • the foregoing storage unit 410 is further configured to store a fifth shared library supported by the host, where the third function invokes a fourth shared library supported by the client.
  • the above translation unit 430 is further configured to:
  • the foregoing storage unit 410 is further configured to store a second main program supported by the host, if the second function includes calling the first main program supported by the client.
  • the instruction of the sixth function, the translation unit 430 is further configured to:
  • the foregoing storage unit 410 is further configured to store the second main program supported by the host, when the third function invokes the first main program supported by the client.
  • the above translation unit 430 is further configured to:
  • the calling instruction of the eighth function supported by the host is invoked.
  • the above translation unit 430 can also be used to:
  • the function pointer of the tenth function supported by the above client is used as an incoming parameter, and the calling instruction of the eighth function supported by the host is invoked, and the function pointer of the ninth function supported by the host is used as the incoming function.
  • a parameter to invoke a call instruction of an eighth function supported by the host machine; when the ninth function is called, executing the ninth function to invoke the translation function in the first shared library to translate the tenth function The eleventh function supported by the above host.
  • the translation unit 430 is further configured to use the first The structure invokes the call instruction of the twelfth function as an incoming parameter, and translates to call the twelfth function with the second structure as the incoming parameter, wherein the first structure includes the second field A subset of the fields that the structure contains.
  • the first structure is a structure supported by the client, and the second structure is a structure supported by the host, and the twelfth function is a function supported by the host.
  • the first structure may be a structure supported by the host, and the second structure is a structure supported by the client, and the twelfth function is a function supported by the client.
  • the translation unit 430 is further configured to: The host invokes the above-mentioned calling instruction that invokes the thirteenth function with the first structure body pointer as an incoming parameter, and translates to call the thirteenth function calling instruction with the second structure body pointer as an incoming parameter; wherein, the first structure The body pointer points to the first structure body, and the second structure body pointer points to the second structure body, wherein the first structure body includes a domain that is a subset of the domains included in the second structure body.
  • the first structure is a structure supported by a client
  • the second structure is a structure supported by a host
  • the thirteenth function is a function supported by the host.
  • the first structure is a structure supported by the host
  • the second structure is a structure supported by the client
  • the thirteenth function is a function supported by the client.
  • the host machine further includes:
  • the relocation unit 450 is configured to perform symbol relocation on the third shared library and the global variable of the same name of the host machine before translating the first function in the third shared library to obtain the second function.
  • the relocation unit 450 may be specifically configured to: if the first global variable included in the third shared library and the N global variable of the host have the same name, first among the first global variable and the N global variables The address of the loaded global variable is set to the above N global variables and the public address of the first global variable;
  • the relocation unit 450 is specifically configured to relocate the address of the first global variable in the third shared library to the second global variable in the second shared library after being loaded in the second shared library.
  • the second shared library supported by the host 400 can be regarded as a pseudo shared library of the third shared library supported by the client, because the second shared library
  • the first function is the same as the function interface of the second function in the third shared library, and the first function in the second shared library is mainly used to trigger the calling of the first shared library to translate the third shared library.
  • a function having the same function interface, and this allows the main program or other shared library on the host machine 400 to be a bridge of the second shared library, and indirectly calling the first function by calling a function in the second shared library.
  • the library indirectly calls the execution, which greatly reduces the strong dependency between the third shared library and the client's supporting main program (or other related shared libraries), which helps to greatly reduce the amount of translation code, thereby improving The efficiency of binary translation execution, which in turn enhances the user experience.
  • FIG. 5 is a schematic diagram of a host 500 according to an embodiment of the present invention.
  • the host 500 may include at least one bus 501, at least one processor 502 connected to the bus 501, and connected to the bus 501.
  • the memory 503 is configured to store the first shared library supported by the host, the second shared library supported by the host, and the third shared library supported by the client.
  • the first shared library includes a translation function.
  • the processor 502 calls the code stored in the memory 503 through the bus 501 for executing the first function to invoke the translation function in the first shared library when the first function in the second shared library is called.
  • Translating by using the translation function in the first shared library, the third function of the function interface in the third shared library and the function interface of the first function, to obtain the third function supported by the host machine.
  • the function interface of the third function is the same as the function interface of the second function; and the third function is executed.
  • the foregoing memory 503 is further configured to store a fifth shared library supported by the host machine, where the second function includes a fourth shared library that is supported by the client.
  • the instruction of the four functions; the processor 502 is further configured to: translate the instruction included in the second function, which is the fourth function in the fourth shared library, into an instruction to invoke the fifth function in the fifth shared library, where
  • the functions of the fourth function and the functions of the fifth function are the same, or the function functions and function interfaces of the fourth function and the fifth function are the same.
  • the foregoing memory 503 is further configured to store a fifth shared library supported by the host, where the third function invokes a fourth shared library supported by the client.
  • the processor 502 is further configured to: translate the instruction included in the third function, which is the fourth function in the fourth shared library supported by the client, into the third function to invoke the fifth shared library.
  • the instruction of the fifth function; the function of the fourth function and the function of the fifth function are the same, or the function and function interface of the fourth function and the fifth function are the same.
  • the foregoing memory 503 is further configured to store the second main program supported by the host, if the second function includes the first one of the first main programs supported by the client.
  • the six function instruction, the processor 502 is also used to:
  • the foregoing memory 503 is further configured to store a second main program supported by the host, where the third function invokes a first main program supported by the client.
  • the processor 502 is further configured to: translate the instruction included in the third function, which is the sixth function in the first main program supported by the client, into the third function, and invoke the second main program.
  • the function of the seventh function is the same as the function of the sixth function and the function function of the seventh function.
  • the calling instruction of the eighth function supported by the host is invoked.
  • the processor 502 is further configured to: use the function pointer of the tenth function supported by the client as the incoming parameter, and invoke the calling instruction of the eighth function supported by the host, and replace it with the host machine.
  • the function pointer of the ninth function is used as an input parameter to call the call instruction of the eighth function supported by the host machine; when the ninth function is called, the ninth function is executed to invoke the translation function in the first shared library. Translating the above tenth function to obtain the eleventh function supported by the above host.
  • the processor 502 when the second function includes a call instruction that invokes a twelfth function with the first structure as an incoming parameter, the processor 502 is further configured to use the first structure
  • the body invokes the call instruction of the twelfth function as an incoming parameter, and translates to call the twelfth function with the second structure as the incoming parameter, wherein the first structure includes the second structure A subset of the fields that the body contains.
  • the first structure is a structure supported by the client, and the second structure is a structure supported by the host, and the twelfth function is a function supported by the host.
  • the first structure may be a structure supported by the host, and the second structure is a structure supported by the client, and the twelfth function is a function supported by the client.
  • the processor 502 when the second function includes a call instruction that invokes a thirteenth function by using the first structure body pointer as an incoming parameter, the processor 502 is further configured to use the host machine.
  • the above calling instruction of the thirteenth function is invoked by using the first structure body pointer as an incoming parameter, and is translated into a call instruction of the thirteenth function by using the second structure body pointer as an incoming parameter;
  • the first structure body pointer points to the first structure body, and the second structure body pointer points to the second structure body, wherein the first structure body includes a domain that is a subset of the domains included in the second structure body.
  • the first structure is a structure supported by a client
  • the second structure is a structure supported by a host
  • the thirteenth function is a function supported by the host.
  • the first structure is a structure supported by the host
  • the second structure is a structure supported by the client
  • the thirteenth function is a function supported by the client.
  • the processor 502 is further configured to: before the first function in the third shared library is translated to obtain the second function, to the foregoing third shared library and the host machine Symbolic relocation of the global variable of the same name.
  • the processor 502 is further configured to: if the first global variable included in the third shared library and the N global variable of the host have the same name, first load the first global variable and the N global variables.
  • the address of the global variable is set to the above N global variables and the public address of the first global variable;
  • the processor 502 is further configured to relocate the address of the first global variable in the third shared library to the second global variable in the second shared library after being loaded in the second shared library.
  • the second shared library supported by the host 500 can be regarded as a pseudo shared library of the third shared library supported by the client, because the second shared library
  • the first function is the same as the function interface of the second function in the third shared library, and the first function in the second shared library is mainly used to trigger the calling of the first shared library to translate the third shared library.
  • a function having the same function interface, and this allows the main program or other shared library on the host 500 to be a bridge of the second shared library, and the indirect call is first by calling a function in the second shared library.
  • the main program of the three shared libraries or other dependent shared libraries for translation, or indirect calls to the third shared library on the client which greatly reduces the support of the third shared library and the client (or other Strong dependencies between related shared libraries), which greatly reduces the amount of translation code, which can improve the efficiency of binary translation execution, thereby improving the user experience.
  • FIG. 6 is a structural block diagram of a host machine 600 according to another embodiment of the present invention.
  • the host machine 600 can include at least one processor 601, at least one network interface 604, a memory 605, and at least one communication bus 602.
  • Communication bus 602 is used to implement connection communication between these components.
  • the host machine 600 optionally includes a user interface 603, including a display (such as a touch screen, a liquid crystal display, a holographic or a projector, etc.), a pointing device (such as a mouse, a trackball touch panel or Touch screen, etc.), camera and/or sound pickup device, etc.
  • a display such as a touch screen, a liquid crystal display, a holographic or a projector, etc.
  • a pointing device such as a mouse, a trackball touch panel or Touch screen, etc.
  • camera and/or sound pickup device etc.
  • the memory 602 can include read only memory and random access memory and provides instructions and data to the processor 601. A portion of the memory 602 may also include a non-volatile random access memory.
  • the memory 605 stores the following elements, executable modules or data structures, or a subset thereof, or their extension set:
  • the operating system 6051 includes various system programs for implementing various basic services and processing hardware-based tasks.
  • the application module 6052 includes various applications for implementing various application services.
  • the application module 6052 may include, but is not limited to, at least one of the storage unit 410, the calling unit 420, the translation unit 430, the execution unit 440, and the relocation unit 450.
  • the host machine 600 and the client support different instruction set architectures.
  • the memory 605 is configured to store the first shared library supported by the host, the second shared library supported by the host, and the third shared library supported by the client.
  • the first shared library includes a translation function.
  • the processor 601 executes the first function to invoke the translation in the first shared library when the first function in the second shared library is invoked by calling the program or instruction stored in the memory 605.
  • a function using the translation function in the first shared library called to translate the function function interface in the third shared library and the second function function interface of the first function Obtaining a third function supported by the host machine; wherein the function interface of the third function is the same as the function interface of the second function; and the third function is executed.
  • the foregoing memory 605 is further configured to store a fifth shared library supported by the host machine, where the second function includes a fourth shared library that is supported by the client.
  • the instruction of the four functions; the processor 601 is further configured to: translate the instruction of the second function included in the second shared library included in the second function to an instruction that invokes the fifth function in the fifth shared library, wherein
  • the functions of the fourth function and the functions of the fifth function are the same, or the function functions and function interfaces of the fourth function and the fifth function are the same.
  • the foregoing memory 605 is further configured to store a fifth shared library supported by the host, where the third function invokes a fourth shared library supported by the client.
  • the processor 601 is further configured to: translate the instruction included in the third function, which is the fourth function in the fourth shared library supported by the client, into the third function to invoke the fifth shared library.
  • the instruction of the fifth function; the function of the fourth function and the function of the fifth function are the same, or the function and function interface of the fourth function and the fifth function are the same.
  • the foregoing memory 605 is further configured to store the second main program supported by the host, if the second function includes the first one of the first main programs supported by the client.
  • the six function instruction, the processor 601 is also used to:
  • the foregoing memory 605 is further configured to store a second main program supported by the host, where the third function invokes a first main program supported by the client.
  • the processor 601 is further configured to: translate the instruction included in the third function, which is the sixth function included in the first main program supported by the client, into the third function, and invoke the second main program.
  • the function of the seventh function is the same as the function of the sixth function and the function function of the seventh function.
  • the processor 601 can also be used to: the function of the tenth function supported by the above client.
  • the pointer is used as an incoming parameter, and the calling instruction of the eighth function supported by the above host is called, and the function pointer of the ninth function supported by the host is used as an incoming parameter to call the eighth function supported by the host. Calling the instruction; when the ninth function is called, executing the ninth function to invoke the translation function in the first shared library to translate the tenth function to obtain the eleventh function supported by the host.
  • the processor 601 when the second function includes a call instruction that invokes a twelfth function with the first structure as an incoming parameter, the processor 601 is further configured to use the first structure
  • the body invokes the call instruction of the twelfth function as an incoming parameter, and translates to call the twelfth function with the second structure as the incoming parameter, wherein the first structure includes the second structure A subset of the fields that the body contains.
  • the first structure is a structure supported by the client, and the second structure is a structure supported by the host, and the twelfth function is a function supported by the host.
  • the first structure may be a structure supported by the host, and the second structure is a structure supported by the client, and the twelfth function is a function supported by the client.
  • the processor 601 when the second function includes a call instruction that invokes a thirteenth function by using the first structure body pointer as an incoming parameter, the processor 601 is further configured to use the host machine.
  • the calling instruction that invokes the thirteenth function by using the first structure body pointer as an incoming parameter is translated into a calling instruction that calls the thirteenth function with the second structure body pointer as an incoming parameter; wherein the first structure body pointer Pointing to the first structure, the second structure pointer points to the second structure, wherein the first structure includes a domain that is a subset of the domains included in the second structure.
  • the first structure is a structure supported by a client
  • the second structure is a structure supported by a host
  • the thirteenth function is a function supported by the host.
  • the first structure is a structure supported by the host
  • the second structure is a structure supported by the client
  • the thirteenth function is a function supported by the client.
  • the processor 601 is further configured to: before the first function in the third shared library is translated to obtain the second function, to the foregoing third shared library and the foregoing The host's global variable of the same name is symbol relocated.
  • the processor 601 is further configured to: if the first global variable included in the third shared library and the N global variables of the host have the same name, first load the first global variable and the N global variables The address of the global variable is set to the above N global variables and the public address of the first global variable.
  • the processor 601 is further configured to relocate an address of the first global variable in the third shared library to a second global variable in the second shared library after being loaded in the second shared library.
  • the second shared library supported by the host 600 can be regarded as a pseudo shared library of the third shared library supported by the client, because the second shared library
  • the first function is the same as the function interface of the second function in the third shared library, and the first function in the second shared library is mainly used to trigger the calling of the first shared library to translate the third shared library.
  • a function having the same function interface, and this allows the main program or other shared library on the host machine 600 to be the second shared library as a bridge, and the indirect call is first by calling a function in the second shared library.
  • Another function having the same function interface in the third shared library translated by the translation function in the shared library since the second shared library is supported by the host 600, the main program or other shared library on the host machine 600 can Identifying and directly calling functions in the second shared library, so that even if the main program on the client that depends on the third shared library or other dependent shared libraries is not translated, the third total on the client
  • the library indirectly calls the execution, which greatly reduces the strong dependency between the third shared library and the client's supporting main program (or other related shared libraries), which helps to greatly reduce the amount of translation code, thereby improving The efficiency of binary translation execution, which in turn enhances the user experience.
  • an embodiment of the present invention further provides a communication system, which may include: a first computing node 710 and a second computing node 720.
  • the first computing node 710 and the second computing node 720 can be interconnected by an internetwork.
  • the second computing node 720 and the first computing node 710 support different instruction collectives. Department architecture.
  • the second computing node 720 includes a first shared library supported by the second computing node 720 and a second shared library supported by the second computing node 720.
  • the first shared library includes a translation function.
  • the first computing node 710 is configured to send, to the second computing node 720, a third shared library supported by the first computing node 710.
  • a second computing node 720 configured to receive a third shared library from the first computing node 710; when the first function in the second shared library is invoked, execute the first function to invoke the first shared library Translating a function; using the translation function in the first shared library mentioned above, translating the function function interface in the third shared library with the second function function interface of the first function to obtain the second computing node
  • the third function supported by 720; the function interface of the third function is the same as the function interface of the second function; and the third function is executed.
  • first function in the second shared library may be any one of the second shared libraries, or the first function in the second shared library may be any one of the second shared libraries. a specific function.
  • the translation of the above second function may involve various aspects, and the specific translation manner may also be various, as exemplified below.
  • the second computing node 720 further includes a fifth shared library supported by the second computing node 720; if the second function includes the fourth supported by the first computing node 710
  • the instruction of the fourth function in the shared library the second computing node 720 is further configured to translate the instruction included in the second function, which is the fourth function in the fourth shared library, into the calling the fifth shared library.
  • the instruction of the fifth function wherein the functions of the fourth function and the function of the fifth function are the same, or the function functions and function interfaces of the fourth function and the fifth function are the same.
  • the foregoing second computing node 720 translates the instruction of the second function included in the second shared library that is included in the second function into an instruction that invokes the fifth function in the fifth shared library, which is substantially It is a library function packaging technology, that is, the call of a function in a shared library supported by the first computing node 710 is replaced by the function function or function function of a shared library supported by the second computing node 720.
  • the function interface is the same function call, which is beneficial to improve the utilization of the local shared library of the second computing node 720, further reducing the translation of the function code of the shared library associated with the first computing node 710, thereby further reducing the code. Translation volume.
  • the second computing node 720 further includes a fifth shared library supported by the second computing node 720, where the third function invokes the fourth supported by the first computing node 710.
  • the second computing node 720 is further configured to translate the instruction of the fourth function included in the third shared library supported by the first computing node 710 into the foregoing
  • the third function calls the instruction of the fifth function in the fifth shared library; wherein the function function and the function interface of the fourth function and the fifth function are the same, or the functions of the fourth function and the fifth function are the same.
  • the foregoing second computing node 720 translates the instruction of the third function included in the third function, which is called the fourth function in the fourth shared library, into an instruction that invokes the fifth function in the fifth shared library, in essence, It can be seen as a library function packaging technique, that is, the function of a function in a shared library supported by the first computing node 710 can be replaced with a function function in a shared library supported by the second computing node 720.
  • the same or the function function and the function interface are the same function call, which is beneficial to improve the utilization of the second shared node 720 local shared library, further reducing the translation of the function code of the shared library associated with the first computing node 710, and thus Help to further reduce the amount of code translation.
  • the second computing node 720 further includes a second main program supported by the second computing node 720, where the second function includes calling the first supported by the first computing node 710.
  • the second function node 720 is further configured to translate the instruction of the sixth function included in the first main program supported by the first computing node 710, which is included in the second function, into the instruction of the sixth function in the main program.
  • the instruction of the seventh function in the second main program is called, wherein the functions of the sixth function and the seventh function are the same, or the function functions and function interfaces of the sixth function and the seventh function are the same.
  • the above-mentioned second function includes the instruction that invokes the sixth function in the first main program supported by the first computing node 710, and translates the instruction into the seventh function in the second main program, essentially It can be regarded as a library function packaging technology, that is, the call of a function in the main program supported by the first computing node 710 is replaced by the function function or the function function in the main program supported by the second computing node 720.
  • the function interface is the same function call, which is beneficial to improve the utilization of the local shared library of the second computing node 720, further reducing the translation of the function code of the shared library associated with the first computing node 710, thereby further reducing the code. Translation volume.
  • the second computing node 720 further includes a second main program supported by the second computing node 720, where the third function invokes the first supported by the first computing node 710.
  • the second computing node 720 is further configured to translate the instruction included in the third function, which is the sixth function in the first main program supported by the first computing node 710, into the foregoing.
  • the three functions call the call of the seventh function in the second main program, the functions of the sixth function and the function of the seventh function are the same, or the function functions and function interfaces of the sixth function and the seventh function are the same.
  • the above-mentioned third function includes the instruction that invokes the sixth function in the first main program supported by the first computing node 710, and translates the instruction into the seventh function in the second main program.
  • it can be regarded as a library function packaging technique, that is, the function of a function in the main program supported by the first computing node 710 can be replaced with the function function in the main program supported by the second computing node 720.
  • the same or the function function and the function interface are the same function call, which is beneficial to improve the utilization of the local shared library of the second computing node 720, further reducing the translation of the function code of the shared library associated with the first computing node 710, and further Help to further reduce the amount of code translation.
  • the eighth function supported by the second computing node 720 is invoked.
  • the second computing node 720 is further configured to use the function pointer of the tenth function supported by the first computing node 710 as an incoming parameter to invoke the eighth function supported by the second computing node 720.
  • the instruction is invoked, and the function pointer of the ninth function supported by the second computing node 720 is used as an incoming parameter to invoke the calling instruction of the eighth function supported by the second computing node 720.
  • the second computing node 720 executes the ninth function to invoke the translation function in the first shared library to translate the tenth function, and the second computing node 720 supports the second computing node 720.
  • the eleventh function the second computing node 720 executes the eleventh function described above. It can be understood that, in the above scenario where the function pointer exists, the introduction of the ninth function as a bridge is beneficial to realizing the translation of the function pointed to by the function pointer at a suitable timing, which is beneficial to avoid errors as much as possible.
  • the second computing node when the third year function includes a function pointer of the function S01 supported by the second computing node 720 as an incoming parameter, the second computing node is invoked.
  • the calling instruction of the S02 function supported by 720 when the above function S01 is called, the second computing node 720 executes the above function S01, and the second computing node 720 does not translate the function S001.
  • the second computing node 720 when the second function includes a call instruction that invokes a twelfth function with the first structure as an incoming parameter, the second computing node 720 is further configured to: The body invokes the call instruction of the twelfth function as an incoming parameter, and translates to call the twelfth function with the second structure as the incoming parameter, and the first structure includes the domain containing the second structure A subset of the domain.
  • the first structure is a structure supported by the first computing node 710
  • the second structure is a structure supported by the second computing node 720
  • the twelfth function is supported by the second computing node 720.
  • the first structure is a structure supported by the second computing node 720
  • the second structure is a structure supported by the first computing node 710
  • the twelfth function is the first calculating The function supported by node 710.
  • the domain included in the first structure may be the same as the domain included in the second structure.
  • the second computing node 720 when the second function includes a call instruction that invokes a thirteenth function with the first structure body pointer as an incoming parameter, the second computing node 720 is further configured to:
  • the structure pointer calls the call instruction of the thirteenth function as an incoming parameter, and translates to a call instruction that calls the thirteenth function with the second structure body pointer as an incoming parameter.
  • the first structure pointer points to the first structure, the second structure pointer points to the second structure, and the first structure includes a field that is a subset of the domains included in the second structure.
  • the first structure is a structure supported by the first computing node 710
  • the second structure is a structure supported by the second computing node 720
  • the thirteenth function is supported by the second computing node 720. function.
  • the first structure is a structure supported by the second computing node 720
  • the second structure is a structure supported by the first computing node 710
  • the thirteenth function is a function supported by the first computing node 710.
  • the domain included in the first structure may be the same as the domain included in the second structure.
  • the second computing node 720 when the incoming parameter of the second function includes the third structure, the second computing node 720 is further configured to use the third parameter as the second function.
  • the structure is replaced by a fourth structure, and the domain included in the third structure is a subset of domains included in the fourth structure; wherein the fourth structure is a structure supported by the first computing node 710, and the above
  • the third structure is a structure supported by the second computing node 720.
  • the above third structural package The domain included may be the same as the domain included in the fourth structure described above.
  • the second computing node 720 is further configured to use the third parameter as the incoming parameter of the second function.
  • the structure pointer is replaced with a fourth structure body pointer, the fourth structure body pointer is directed to the fourth structure body, the third structure body pointer is directed to the third structure body, and the third structure body includes a domain containing the fourth structure body A subset of the domain.
  • the fourth structure is a structure supported by the first computing node 710, and the third structure is a structure supported by the second computing node 720.
  • the domain included in the third structure described above may be the same as the domain included in the fourth structure.
  • the above exemplifies some possible implementations of the translation second function
  • the translation translation second function may also involve some other operations related to translation, of course, in practical applications, other translation operations may also be involved, of course, the above translation operations They may also be nested with each other, and the specific methods are not described here.
  • the second computing node 720 is further configured to use the third shared library and The global variable of the same name of the second computing node 720 described above performs symbol relocation.
  • the second computing node 720 performing symbol relocation on the global variable of the same name of the third shared library and the second computing node 720 includes: if the third shared library includes the first global variable and the second computing node 720 The N global variables have the same name, and the second computing node 720 sets the addresses of the first global variable and the first global variable loaded among the N global variables to the N global variables and the first global variable. Public address.
  • the second computing node 720 performing symbol relocation on the global variable of the same name of the third shared library and the second computing node 720 includes: after being loaded in the second shared library, the second computing node 720 The address of the first global variable in the third shared library is relocated to the address of the second global variable in the second shared library, wherein the declaration of the first global variable and the second global variable is the same.
  • the first global variable may be any global variable included in the third shared library.
  • the first global variable may also be a specific global variable included in the third shared library.
  • the second computing node 720 and the first computing node 710 of the embodiment of the present invention support different instruction set architectures.
  • the second computing node 720 and the first computing node 710 can respectively support one of the following instruction set architectures.
  • the second computing node 720 supporting the different instruction set architectures and the first computing node 710 can mutually transmit the shared libraries supported by each, for example, the foregoing first computing node 710 performs the second computing.
  • the node 720 passes the third shared library, wherein the second shared library supported by the second computing node 720 introduced in the second computing node 720 can be regarded as a pseudo shared by the third shared library supported by the first computing node 710.
  • the library is to translate the function of the third shared library with the same function interface, and this can make the main program or other shared library on the second computing node 720, the second shared library can be used as a bridge, by calling the second shared library.
  • the main program or other shared library on the second computing node 720 can recognize and directly invoke functions in the second shared library, such that even if the third computing library is not dependent on the first computing node 710
  • the program or other dependent shared library is translated, and the third shared library on the first computing node 710 can also be invoked indirectly, which greatly reduces the supporting main program of the third shared library and the first computing node 710 ( Strong dependencies between other related shared libraries), which greatly reduces the amount of translation code, which improves the efficiency of binary translation execution and thus improves the user experience.
  • the first shared library includes a translation function, that is, the binary translator is compiled into the first shared library, when the function in the third shared library supported by the first computing node 710 is called, the first shared library is
  • the related functions are called for dynamic translation, which is beneficial to improve the pertinence and effectiveness of translation, and is beneficial to reduce the amount of invalid translation work, thereby further reducing the amount of translation code, thereby further improving the execution efficiency of binary translation, thereby further enhancing users.
  • dynamic translation which is beneficial to improve the pertinence and effectiveness of translation, and is beneficial to reduce the amount of invalid translation work, thereby further reducing the amount of translation code, thereby further improving the execution efficiency of binary translation, thereby further enhancing users.
  • the embodiment of the present invention further provides a computer storage medium, wherein the computer storage medium may store a program, where the program includes some or all of the steps of the binary translation execution method of any one of the shared libraries described in the foregoing method embodiments. .
  • the disclosed apparatus may be implemented in other ways.
  • the device embodiments described above are merely illustrative.
  • the division of the unit is only a logical function division.
  • there may be another division manner for example, multiple units or components may be combined or may be Integrate into another system, or some features can be ignored or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be electrical or otherwise.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
  • the integrated unit if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention is essential or the part contributing to the prior art or the entire technical solution.
  • the portion or portion may be embodied in the form of a software product stored in a storage medium, including instructions for causing a computer device (which may be a personal computer, server or network device, etc.) to perform various embodiments of the present invention. All or part of the steps of the method described.
  • the foregoing storage medium includes: a U disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk, and the like. .

Landscapes

  • Stored Programmes (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

Disclosed are a binary translation execution method and apparatus for shared libraries. The binary translation execution method for shared libraries may comprise: when a first function in a second shared library is called, a host executes the first function to call a translation function in a first shared library; the host translates a second function, having the same function interface as that of the first function, in a third shared library by using the called translation function in the first shared library, so as to obtain a third function supported by the host, a function interface of the third function being the same as the function interface of the second function; and the host executes the third function. The solution provided in embodiments of the present invention helps to reduce the amount of relevant code translation in shared library translation, and thus increases execution efficiency of binary translation and improves user experience.

Description

共享库的二进制翻译执行方法和装置Binary translation execution method and device of shared library 技术领域Technical field
本发明涉及计算机技术领域,具体涉及一种共享库的二进制翻译执行方法和装置。The present invention relates to the field of computer technologies, and in particular, to a binary translation execution method and apparatus for a shared library.
背景技术Background technique
计算机体系结构不断发展,适应不同需求的新处理器不断涌现。当一种新处理器产生时,软件资源的匮乏是阻碍其向前发展的一个重要因素。老牌通用处理器有着丰富的软件资源,但其二进制程序仅能够在本指令集体系结构平台上运行。在这种背景下,移植原有体系结构中可执行代码到新处理器的工作越来越重要,二进制翻译技术在这种情况下应运而生。The computer architecture is constantly evolving, and new processors that adapt to different needs are constantly emerging. When a new processor is produced, the lack of software resources is an important factor hindering its forward development. Older general-purpose processors have a wealth of software resources, but their binary programs can only run on this instruction set architecture platform. In this context, it is increasingly important to port the executable code to the new processor in the original architecture, and binary translation technology has emerged in this situation.
其中,二进制翻译(BT,Binary Translation)技术是一种重要的跨指令集体系结构(ISA Instruction Set Architecture)进行代码迁移的技术,通常BT技术在翻译源平台(也可称客户机(guest))的某共享库时,通常是以源平台支持的二进制形式的该共享库和依赖该共享库的主程序及该主程序依赖的其他所有共享库作为输入(即使目标平台上本来已有对应主程序),通过对输入信息翻译得到可以在目标平台(也称宿主机(host))运行的相应共享库和依赖该共享库的主程序及该主程序依赖的其他所有共享库。由于二进制翻译技术具有十分广泛应用,目前业内已经开始对其进行深入研究。Among them, Binary Translation (BT) technology is an important technology for code migration across ISA Instruction Set Architecture. Usually BT technology is used in translation source platform (also called guest). a shared library, usually in the binary form supported by the source platform, the shared library and the main program dependent on the shared library and all other shared libraries that the main program depends on as input (even if the target platform already has a corresponding main program) By translating the input information, a corresponding shared library that can be run on the target platform (also called a host) and a main program that depends on the shared library and all other shared libraries that the main program depends on are obtained. Due to the wide application of binary translation technology, the industry has begun to conduct in-depth research.
现有技术的二进制翻译系统通常是将客户机支持的共享库和依赖该共享库的主程序及该主程序依赖的其他所有共享库全部进行二进制翻译,以得到可在宿主机上运行的相应共享库和依赖该共享库的主程序及该主程序依赖的其他所有共享库,然而,这使得现有二进制翻译系统需翻译的代码量有些时候可能比较巨大,进而可能给二进制翻译系统带来很大工作负担,进而可能影响到用户体验。The prior art binary translation system usually performs binary translation of the shared library supported by the client and the main program that depends on the shared library and all other shared libraries that the main program depends on to obtain a corresponding share that can be run on the host. The library and the main program that depends on the shared library and all other shared libraries that the main program depends on. However, the amount of code that the existing binary translation system needs to translate may sometimes be large, which may bring a large amount to the binary translation system. Work load, which in turn may affect the user experience.
发明内容Summary of the invention
本发明实施例提供共享库的二进制翻译执行方法和装置,以期待能减少翻 译共享库时的相关代码翻译量,从而提高二进制翻译的执行效率,进而提升用户体验。Embodiments of the present invention provide a binary translation execution method and apparatus for a shared library, in anticipation of reducing The amount of relevant code translation when translating the library, thereby improving the efficiency of binary translation execution, thereby improving the user experience.
本发明第一方面提供一种共享库的二进制翻译执行方法,所述方法应用于宿主机,所述宿主机中包括所述宿主机支持的第一共享库、所述宿主机支持的第二共享库和客户机支持的第三共享库,所述第一共享库包括翻译函数,所述宿主机和所述客户机支持不同的指令集体系架构,A first aspect of the present invention provides a binary translation execution method of a shared library, where the method is applied to a host, where the host includes a first shared library supported by the host, and a second share supported by the host. a third shared library supported by the library and the client, the first shared library including a translation function, the host and the client supporting different instruction set architectures,
所述方法包括:The method includes:
当所述第二共享库中的第一函数被调用时,所述宿主机执行所述第一函数以调用所述第一共享库中的翻译函数;When the first function in the second shared library is called, the host executes the first function to invoke a translation function in the first shared library;
所述宿主机利用所述调用的所述第一共享库中的翻译函数,对所述第三共享库中的函数接口与所述第一函数的函数接口相同的第二函数进行翻译,以得到所述宿主机支持的第三函数;其中,所述第三函数的函数接口和所述第二函数的函数接口相同;The host machine translates a function function in the third shared library with a second function function of the first function by using a translation function in the first shared library of the call to obtain a second function a third function supported by the host; wherein a function interface of the third function and a function interface of the second function are the same;
所述宿主机执行所述第三函数。The host executes the third function.
结合第一方面,在第一方面的第一种可能的实施方式中,所述宿主机中还包括所述宿主机支持的第五共享库;若所述第二函数包括调用所述客户机支持的第四共享库中的第四函数的指令,对所述第二函数进行翻译的步骤,还包括:With reference to the first aspect, in a first possible implementation manner of the first aspect, the host machine further includes a fifth shared library supported by the host; if the second function includes calling the client support The instruction of the fourth function in the fourth shared library, the step of translating the second function, further includes:
所述宿主机将所述第二函数包括的调用所述第四共享库中的第四函数的指令,翻译成调用所述第五共享库中的第五函数的指令,其中,所述第四函数和所述第五函数的函数功能相同,或者,所述第四函数和所述第五函数的函数功能和函数接口均相同。The host translates, by the second function, an instruction that calls a fourth function in the fourth shared library into an instruction that invokes a fifth function in the fifth shared library, wherein the fourth The function has the same function as the function of the fifth function, or the function functions and function interfaces of the fourth function and the fifth function are the same.
结合第一方面,在第一方面的第二种可能的实施方式中,所述宿主机中还包括所述宿主机支持的第五共享库,当所述第三函数调用所述客户机支持的第四共享库中的第四函数时,所述方法还包括:With reference to the first aspect, in a second possible implementation manner of the first aspect, the host machine further includes a fifth shared library supported by the host, when the third function invokes the client support When the fourth function in the fourth shared library, the method further includes:
所述宿主机将所述第三函数包括的调用所述客户机支持的第四共享库中的第四函数的指令,翻译成所述第三函数调用所述第五共享库中第五函数的指令;其中,所述第四函数和所述第五函数的函数功能相同,或者,所述第四函数和所述第五函数的函数功能和函数接口均相同。 Transmitting, by the host machine, an instruction of the third function included in the third function that is called by the third function to the third function in the fifth shared library An instruction; wherein the functions of the fourth function and the fifth function are the same, or the function functions and function interfaces of the fourth function and the fifth function are the same.
结合第一方面或第一方面的第一种可能的实施方式或第一方面的第二种可能的实施方式,在第一方面的第三种可能的实施方式中,In conjunction with the first aspect or the first possible implementation of the first aspect or the second possible implementation of the first aspect, in a third possible implementation of the first aspect,
所述宿主机中还包括所述宿主机支持的第二主程序,若所述第二函数包括调用所述客户机支持的第一主程序中的第六函数的指令,对所述第二函数进行翻译的步骤,还包括:The host machine further includes a second main program supported by the host, if the second function includes an instruction to invoke a sixth function in the first main program supported by the client, to the second function The steps to translate include:
所述宿主机将所述第二函数包括的所述调用所述客户机支持的第一主程序中的第六函数的指令,翻译成调用所述第二主程序中的第七函数的指令,其中,所述第六函数和所述第七函数的函数功能相同,或者,所述第六函数和所述第七函数的函数功能和函数接口均相同。The host translating, by the second function, the instruction that invokes the sixth function in the first main program supported by the client into an instruction that invokes the seventh function in the second main program, The functions of the sixth function and the seventh function are the same, or the function functions and function interfaces of the sixth function and the seventh function are the same.
结合第一方面或第一方面的第一种可能的实施方式或第一方面的第二种可能的实施方式,在第一方面的第四种可能的实施方式中,所述宿主机中还包括所述宿主机支持的第二主程序,当所述第三函数调用所述客户机支持的第一主程序中的第六函数时,所述方法还包括:With reference to the first aspect, or the first possible implementation manner of the first aspect, or the second possible implementation manner of the first aspect, in a fourth possible implementation manner of the first aspect, The second main program supported by the host, when the third function calls the sixth function in the first main program supported by the client, the method further includes:
所述宿主机将所述第三函数包括的调用所述客户机支持的第一主程序中的第六函数的指令,翻译成所述第三函数调用所述第二主程序中的第七函数的调用,其中,所述第六函数和所述第七函数的函数功能相同,或者,所述第六函数和所述第七函数的函数功能和函数接口均相同。The host translates, by the third function, an instruction that calls a sixth function in the first main program supported by the client into a third function, and invokes a seventh function in the second main program. And the functions of the sixth function and the seventh function are the same, or the function functions and function interfaces of the sixth function and the seventh function are the same.
结合第一方面或第一方面的第一种可能的实施方式或第一方面的第二种可能的实施方式或第一方面的第三种可能的实施方式或第一方面的第四种可能的实施方式,在第一方面的第五种可能的实施方式中,当所述第二函数包括以所述客户机支持的第十函数的函数指针作为传入参数,以调用所述宿主机支持的第八函数的调用指令,对所述第二函数进行翻译的步骤,还包括:所述宿主机将所述以所述客户机支持的第十函数的函数指针作为传入参数,以调用所述宿主机支持的第八函数的调用指令,替换为,以所述宿主机支持的第九函数的函数指针作为传入参数,以调用所述宿主机支持的第八函数的调用指令;Combining the first aspect or the first possible implementation of the first aspect or the second possible implementation of the first aspect or the third possible implementation of the first aspect or the fourth possible implementation of the first aspect Embodiment, in a fifth possible implementation manner of the first aspect, when the second function includes a function pointer of a tenth function supported by the client as an incoming parameter, to invoke the host support The invoking instruction of the eighth function, the step of translating the second function, further comprising: the host machine, using the function pointer of the tenth function supported by the client as an incoming parameter, to invoke the The calling instruction of the eighth function supported by the host is replaced by a function pointer of the ninth function supported by the host as an incoming parameter to invoke a calling instruction of the eighth function supported by the host;
其中,当所述第九函数被调用时,所述宿主机执行所述第九函数以调用所述第一共享库中的翻译函数对所述第十函数进行翻译,得到所述宿主机支持的第十一函数,所述宿主机执行所述第十一函数。 Wherein, when the ninth function is called, the host executes the ninth function to invoke a translation function in the first shared library to translate the tenth function, to obtain the host support In an eleventh function, the host executes the eleventh function.
结合第一方面或第一方面的第一种可能的实施方式或第一方面的第二种可能的实施方式或第一方面的第三种可能的实施方式或第一方面的第四种可能的实施方式或第一方面的第五种可能的实施方式,在第一方面的第六种可能的实施方式中,当所述第二函数包括以第一结构体作为传入参数调用第十二函数的调用指令,对所述第二函数进行翻译的步骤,还包括:Combining the first aspect or the first possible implementation of the first aspect or the second possible implementation of the first aspect or the third possible implementation of the first aspect or the fourth possible implementation of the first aspect The fifth possible implementation manner of the first aspect, in the sixth possible implementation manner of the first aspect, when the second function includes calling the twelfth function with the first structure as an incoming parameter The calling instruction, the step of translating the second function, further includes:
所述宿主机将所述以第一结构体作为传入参数调用第十二函数的调用指令翻译为,以第二结构体作为传入参数调用第十二函数的调用指令,所述第一结构体包含的域为所述第二结构体包含的域的子集;Transmitting, by the host machine, the calling instruction that invokes the twelfth function with the first structure as an incoming parameter, and calling the calling instruction of the twelfth function with the second structural body as an incoming parameter, the first structure The domain included in the volume is a subset of the domains included in the second structure;
其中,所述第一结构体为所述客户机支持的结构体,且所述第二结构体为所述宿主机支持的结构体,且所述第十二函数为所述宿主机支持的函数;The first structure is a structure supported by the client, and the second structure is a structure supported by the host, and the twelfth function is a function supported by the host. ;
或者,所述第一结构体为所述宿主机支持的结构体,并且所述第二结构体为所述客户机支持的结构体,并且所述第十二函数为所述所述客户机支持的函数。Or the first structure is a structure supported by the host, and the second structure is a structure supported by the client, and the twelfth function is supported by the client The function.
结合第一方面或第一方面的第一种可能的实施方式或第一方面的第二种可能的实施方式或第一方面的第三种可能的实施方式或第一方面的第四种可能的实施方式或第一方面的第五种可能的实施方式或第一方面的第六种可能的实施方式,在第一方面的第七种可能的实施方式中,Combining the first aspect or the first possible implementation of the first aspect or the second possible implementation of the first aspect or the third possible implementation of the first aspect or the fourth possible implementation of the first aspect The fifth possible implementation manner of the first aspect or the sixth possible implementation manner of the first aspect, in the seventh possible implementation manner of the first aspect,
当所述第二函数包括以第一结构体指针作为传入参数调用第十三函数的调用指令,对所述第二函数进行翻译的步骤,还包括:所述宿主机将所述以第一结构体指针作为传入参数调用第十三函数的调用指令,翻译为,以第二结构体指针作为传入参数调用第十三函数的调用指令;When the second function includes a call instruction that invokes the thirteenth function with the first structure body pointer as an incoming parameter, the step of translating the second function further includes: the host machine The structure pointer calls the call instruction of the thirteenth function as an incoming parameter, and translates to a call instruction that calls the thirteenth function with the second structure body pointer as an incoming parameter;
其中,所述第一结构体指针指向第一结构体,所述第二结构体指针指向第二结构体,所述第一结构体包含的域为所述第二结构体包含的域的子集;Wherein the first structure body pointer points to the first structure body, the second structure body pointer points to the second structure body, and the first structure body includes a domain that is a subset of the domain included in the second structure body ;
其中,所述第一结构体为客户机支持的结构体,且所述第二结构体为宿主机支持的结构体,且所述第十三函数为所述宿主机支持的函数;或者所述第一结构体为宿主机支持的结构体,并且所述第二结构体为客户机支持的结构体,且所述第十三函数为所述客户机支持的函数。Wherein the first structure is a structure supported by a client, and the second structure is a structure supported by a host, and the thirteenth function is a function supported by the host; or The first structure is a structure supported by the host, and the second structure is a structure supported by the client, and the thirteenth function is a function supported by the client.
结合第一方面或第一方面的第一种可能的实施方式或第一方面的第二种 可能的实施方式或第一方面的第三种可能的实施方式或第一方面的第四种可能的实施方式或第一方面的第五种可能的实施方式或第一方面的第六种可能的实施方式或第一方面的第七种可能的实施方式,在第一方面的第八种可能的实施方式中,Combining the first aspect or the first possible implementation of the first aspect or the second aspect of the first aspect A possible implementation or a third possible implementation of the first aspect or a fourth possible implementation of the first aspect or a fifth possible implementation of the first aspect or a sixth possible implementation of the first aspect Embodiments or a seventh possible implementation of the first aspect, in an eighth possible implementation of the first aspect,
当所述第二函数的传入参数包括第三结构体,所述方法还包括:所述宿主机将作为所述第二函数的传入参数的第三结构体替换为第四结构体,所述第三结构体包含的域为所述第四结构体包含的域的子集;When the incoming parameter of the second function includes the third structure, the method further includes: the host replacing the third structure as the incoming parameter of the second function with the fourth structure, The domain included in the third structure is a subset of the domains included in the fourth structure;
其中,所述第四结构体为客户机支持的结构体,且所述第三结构体为宿主机支持的结构体。The fourth structure is a structure supported by a client, and the third structure is a structure supported by a host.
结合第一方面或第一方面的第一种可能的实施方式或第一方面的第二种可能的实施方式或第一方面的第三种可能的实施方式或第一方面的第四种可能的实施方式或第一方面的第五种可能的实施方式或第一方面的第六种可能的实施方式或第一方面的第七种可能的实施方式,在第一方面的第九种可能的实施方式中,Combining the first aspect or the first possible implementation of the first aspect or the second possible implementation of the first aspect or the third possible implementation of the first aspect or the fourth possible implementation of the first aspect A fifth possible implementation of the first aspect or a sixth possible implementation of the first aspect or a seventh possible implementation of the first aspect, the ninth possible implementation of the first aspect In the way,
当所述第二函数的传入参数包括第三结构体指针,所述方法还包括:所述宿主机将作为所述第二函数的传入参数的所述第三结构体指针替换为第四结构体指针,所述第四结构体指针指向第四结构体,所述第三结构体指针指向第三结构体,所述第三结构体包含的域为所述第四结构体包含的域的子集;When the incoming parameter of the second function includes a third structure pointer, the method further includes: the host replacing the third structure pointer as an incoming parameter of the second function with a fourth a structure pointer, the fourth structure pointer points to a fourth structure body, the third structure body pointer points to a third structure body, and the third structure body includes a domain that is a domain of the fourth structure body Subset;
其中,所述第四结构体为客户机支持的结构体,且所述第三结构体为宿主机支持的结构体。The fourth structure is a structure supported by a client, and the third structure is a structure supported by a host.
结合第一方面或第一方面的第一种可能的实施方式或第一方面的第二种可能的实施方式或第一方面的第三种可能的实施方式或第一方面的第四种可能的实施方式或第一方面的第五种可能的实施方式或第一方面的第六种可能的实施方式或第一方面的第七种可能的实施方式或第一方面的第八种可能的实施方式或第一方面的第九种可能的实施方式,在第一方面的第十种可能的实施方式中,Combining the first aspect or the first possible implementation of the first aspect or the second possible implementation of the first aspect or the third possible implementation of the first aspect or the fourth possible implementation of the first aspect Embodiment or a fifth possible implementation of the first aspect or a sixth possible implementation of the first aspect or a seventh possible implementation of the first aspect or an eighth possible implementation of the first aspect Or a ninth possible implementation manner of the first aspect, in the tenth possible implementation manner of the first aspect,
所述对第三共享库中的第一函数进行翻译以得到第二函数之前,所述方法还包括:所述宿主机对所述第三共享库和所述宿主机的同名全局变量进行符号 重定位。Before the first function in the third shared library is translated to obtain the second function, the method further includes: the host performing symbol on the third shared library and the host with the same name global variable reset.
结合第一方面的第十种可能的实施方式,在第一方面的第十一种可能的实施方式中,所述宿主机对所述第三共享库和所述宿主机的同名全局变量进行符号重定位包括:若所述第三共享库包含的第一全局变量和所述宿主机的N个全局变量同名,所述宿主机将所述第一全局变量和所述N个全局变量之中最先加载的全局变量的地址,设定为所述N个全局变量和所述第一全局变量的公共地址。In conjunction with the tenth possible implementation of the first aspect, in an eleventh possible implementation manner of the first aspect, the host performs a symbol on the third shared library and the host with the same name global variable Relocating includes: if the first global variable included in the third shared library and the N global variable of the host have the same name, the host will be the most among the first global variable and the N global variables The address of the first loaded global variable is set to the public address of the N global variables and the first global variable.
结合第一方面的第十种可能的实施方式,在第一方面的第十二种可能的实施方式中,所述宿主机对所述第三共享库和所述宿主机的同名全局变量进行符号重定位包括:在所述第二共享库中被加载之后,所述宿主机将所述第三共享库中的第一全局变量的地址,重定位为所述第二共享库中的第二全局变量的地址,其中,所述第一全局变量和所述第二全局变量的声明相同。With reference to the tenth possible implementation manner of the first aspect, in a twelfth possible implementation manner of the first aspect, the host performs a symbol on a global variable of the same name of the third shared library and the host Relocating includes: after being loaded in the second shared library, the host relocates an address of a first global variable in the third shared library to a second global in the second shared library The address of the variable, wherein the declaration of the first global variable and the second global variable are the same.
本发明第二方面提供一种宿主机,所述宿主机包括:A second aspect of the present invention provides a host machine, the host machine comprising:
存储单元,用于存储所述宿主机支持的第一共享库、所述宿主机支持的第二共享库和客户机支持的第三共享库,所述第一共享库包括翻译函数,所述宿主机和所述客户机支持不同的指令集体系架构;a storage unit, configured to store a first shared library supported by the host, a second shared library supported by the host, and a third shared library supported by the client, where the first shared library includes a translation function, the sink The host and the client support different instruction set architectures;
调用单元,用于当所述第二共享库中的第一函数被调用时,执行所述第一函数以调用所述第一共享库中的翻译函数;a calling unit, configured to: when the first function in the second shared library is called, execute the first function to invoke a translation function in the first shared library;
翻译单元,用于利用所述调用的第一共享库中的翻译函数,对所述第三共享库中的函数接口与所述第一函数的函数接口相同的第二函数进行翻译,以得到所述宿主机支持的第三函数;其中,所述第三函数的函数接口和所述第二函数的函数接口相同;a translation unit, configured to translate, by using a translation function in the first shared library of the call, a function of the function interface of the third shared library and a second function of the first function to obtain a a third function supported by the host; wherein a function interface of the third function and a function interface of the second function are the same;
执行单元,用于执行所述第三函数。An execution unit, configured to execute the third function.
结合第二方面,在第二方面的第一种可能的实施方式中,所述存储单元还用于存储所述宿主机支持的第五共享库;其中,若所述第二函数包括调用所述客户机支持的第四共享库中的第四函数的指令;With reference to the second aspect, in a first possible implementation manner of the second aspect, the storage unit is further configured to store a fifth shared library supported by the host, where, if the second function includes calling the An instruction of a fourth function in a fourth shared library supported by the client;
所述翻译单元还用于:The translation unit is also used to:
将所述第二函数包括的调用所述第四共享库中的第四函数的指令,翻译成 调用所述第五共享库中的第五函数的指令,其中,所述第四函数和所述第五函数的函数功能相同,或者,所述第四函数和所述第五函数的函数功能和函数接口均相同。Translating, by the second function, an instruction to invoke a fourth function in the fourth shared library into An instruction to invoke a fifth function in the fifth shared library, wherein functions of the fourth function and the fifth function are the same, or function functions of the fourth function and the fifth function are The function interfaces are the same.
结合第二方面,在第二方面的第二种可能的实施方式中,所述存储单元还用于存储所述宿主机支持的第五共享库,当所述第三函数调用所述客户机支持的第四共享库中的第四函数时,所述翻译单元还用于:In conjunction with the second aspect, in a second possible implementation of the second aspect, the storage unit is further configured to store a fifth shared library supported by the host, when the third function invokes the client support The fourth function in the fourth shared library, the translation unit is also used to:
将所述第三函数包括的调用所述客户机支持的第四共享库中的第四函数的指令,翻译成所述第三函数调用所述第五共享库中第五函数的指令;所述第四函数和所述第五函数的函数功能相同,或者,所述第四函数和所述第五函数的函数功能和函数接口均相同。Translating, by the third function, an instruction that invokes a fourth function in a fourth shared library supported by the client into an instruction that the third function calls a fifth function in the fifth shared library; The functions of the fourth function and the function of the fifth function are the same, or the function functions and function interfaces of the fourth function and the fifth function are the same.
结合第二方面或第二方面的第一种可能的实施方式或第二方面的第二种可能的实施方式,在第二方面的第三种可能的实施方式中,所述存储单元还用于存储所述宿主机支持的第二主程序,若所述第二函数包括调用所述客户机支持的第一主程序中的第六函数的指令,所述翻译单元还用于:In conjunction with the second aspect or the first possible implementation of the second aspect or the second possible implementation of the second aspect, in a third possible implementation of the second aspect, the storage unit is further configured to: Storing a second main program supported by the host, if the second function includes an instruction to invoke a sixth function in the first main program supported by the client, the translation unit is further configured to:
将所述第二函数包括的所述调用所述客户机支持的第一主程序中的第六函数的指令,翻译成调用所述第二主程序中的第七函数的指令,其中,所述第六函数和所述第七函数的函数功能相同,或者,所述第六函数和所述第七函数的函数功能和函数接口均相同。Translating, by the second function, the instruction that invokes the sixth function in the first main program supported by the client into an instruction that invokes a seventh function in the second main program, wherein The functions of the sixth function and the function of the seventh function are the same, or the function functions and function interfaces of the sixth function and the seventh function are the same.
结合第二方面或第二方面的第一种可能的实施方式或第二方面的第二种可能的实施方式,在第二方面的第四种可能的实施方式中,所述存储单元还用于存储所述宿主机支持的第二主程序,当所述第三函数调用所述客户机支持的第一主程序中的第六函数时,所述翻译单元还用于:In conjunction with the second aspect or the first possible implementation of the second aspect or the second possible implementation of the second aspect, in a fourth possible implementation of the second aspect, the storage unit is further configured to: Storing a second main program supported by the host, when the third function calls a sixth function in the first main program supported by the client, the translation unit is further configured to:
将所述第三函数包括的调用所述客户机支持的第一主程序中的第六函数的指令,翻译成所述第三函数调用所述第二主程序中的第七函数的调用,所述第六函数和所述第七函数的函数功能相同,或者,所述第六函数和所述第七函数的函数功能和函数接口均相同。Translating, by the third function, an instruction that invokes a sixth function in the first main program supported by the client into a call of the third function in the third main program The functions of the sixth function and the seventh function are the same, or the function functions and function interfaces of the sixth function and the seventh function are the same.
可选的,当所述第二函数包括以所述客户机支持的第十函数的函数指针作为传入参数,以调用所述宿主机支持的第八函数的调用指令,所述翻译单元还 用于:Optionally, when the second function includes a function pointer of the tenth function supported by the client as an incoming parameter, to invoke a call instruction of an eighth function supported by the host, the translation unit further Used for:
将所述以所述客户机支持的第十函数的函数指针作为传入参数,以调用所述宿主机支持的第八函数的调用指令,替换为以所述宿主机支持的第九函数的函数指针作为传入参数,以调用所述宿主机支持的第八函数的调用指令;当所述第九函数被调用时,执行所述第九函数以调用所述第一共享库中的翻译函数对所述第十函数进行翻译,得到所述宿主机支持的第十一函数。The function pointer of the tenth function supported by the client is used as an incoming parameter, and the calling instruction of the eighth function supported by the host is invoked, and the function of the ninth function supported by the host is replaced. a pointer as an incoming parameter to invoke a call instruction of an eighth function supported by the host; when the ninth function is called, executing the ninth function to invoke a translation function pair in the first shared library The tenth function is translated to obtain an eleventh function supported by the host.
结合第二方面或第二方面的第一种可能的实施方式或第二方面的第二种可能的实施方式或第二方面的第三种可能的实施方式或第二方面的第四种可能的实施方式,在第二方面的第五种可能的实施方式中,当所述第二函数包括以第一结构体作为传入参数调用第十二函数的调用指令,所述翻译单元还用于将所述以第一结构体作为传入参数调用第十二函数的调用指令,翻译为,以第二结构体作为传入参数调用第十二函数的调用指令,其中,所述第一结构体包含的域为所述第二结构体包含的域的子集;Combining the second aspect or the first possible implementation of the second aspect or the second possible implementation of the second aspect or the third possible implementation of the second aspect or the fourth possible implementation of the second aspect Embodiment, in a fifth possible implementation manner of the second aspect, when the second function includes a calling instruction that invokes a twelfth function by using the first structure as an incoming parameter, the translation unit is further configured to: Calling the call instruction of the twelfth function with the first structure as the incoming parameter, and translating into the call instruction of the twelfth function with the second structure as the incoming parameter, wherein the first structure includes The domain is a subset of the domains contained by the second structure;
其中,所述第一结构体为所述客户机支持的结构体,且所述第二结构体为所述宿主机支持的结构体,且所述第十二函数为所述宿主机支持的函数;The first structure is a structure supported by the client, and the second structure is a structure supported by the host, and the twelfth function is a function supported by the host. ;
或者,所述第一结构体为所述宿主机支持的结构体,并且所述第二结构体为所述客户机支持的结构体,并且所述第十二函数为所述所述客户机支持的函数。Or the first structure is a structure supported by the host, and the second structure is a structure supported by the client, and the twelfth function is supported by the client The function.
结合第二方面或第二方面的第一种可能的实施方式或第二方面的第二种可能的实施方式或第二方面的第三种可能的实施方式或第二方面的第四种可能的实施方式或第二方面的第五种可能的实施方式,在第二方面的第六种可能的实施方式中,当所述第二函数包括以第一结构体指针作为传入参数调用第十三函数的调用指令,Combining the second aspect or the first possible implementation of the second aspect or the second possible implementation of the second aspect or the third possible implementation of the second aspect or the fourth possible implementation of the second aspect The fifth possible implementation manner of the second aspect, in the sixth possible implementation manner of the second aspect, when the second function includes calling the thirteenth with the first structure body pointer as an incoming parameter The call instruction of the function,
所述翻译单元还用于:所述宿主机将所述以第一结构体指针作为传入参数调用第十三函数的调用指令,翻译为,以第二结构体指针作为传入参数调用第十三函数的调用指令;其中,所述第一结构体指针指向第一结构体,所述第二结构体指针指向第二结构体,其中,所述第一结构体包含的域为所述第二结构体包含的域的子集; The translation unit is further configured to: the host machine invokes the calling instruction that invokes the thirteenth function by using the first structure body pointer as an incoming parameter, and translates to calling the tenth with the second structure body pointer as an incoming parameter a call instruction of a three function; wherein the first structure body pointer points to the first structure body, and the second structure body pointer points to the second structure body, wherein the first structure body includes a domain a subset of the fields contained in the structure;
其中,所述第一结构体为客户机支持的结构体,且所述第二结构体为宿主机支持的结构体,且所述第十三函数为所述宿主机支持的函数;The first structure is a structure supported by a client, and the second structure is a structure supported by a host, and the thirteenth function is a function supported by the host;
或者所述第一结构体为宿主机支持的结构体,并且所述第二结构体为客户机支持的结构体,且所述第十三函数为所述客户机支持的函数。Or the first structure is a structure supported by the host, and the second structure is a structure supported by the client, and the thirteenth function is a function supported by the client.
结合第二方面或第二方面的第一种可能的实施方式或第二方面的第二种可能的实施方式或第二方面的第三种可能的实施方式或第二方面的第四种可能的实施方式或第二方面的第五种可能的实施方式或第二方面的第六种可能的实施方式,在第二方面的第七种可能的实施方式中,Combining the second aspect or the first possible implementation of the second aspect or the second possible implementation of the second aspect or the third possible implementation of the second aspect or the fourth possible implementation of the second aspect The fifth possible implementation manner of the second aspect or the sixth possible implementation manner of the second aspect, in the seventh possible implementation manner of the second aspect,
所述宿主机还包括:重定位单元,用于在对第三共享库中的第一函数进行翻译以得到第二函数之前,对所述第三共享库和所述宿主机的同名全局变量进行符号重定位。The host machine further includes: a relocation unit, configured to perform the third-order shared library and the same-named global variable of the host machine before translating the first function in the third shared library to obtain the second function Symbol relocation.
结合第二方面的第七种可能的实施方式,在第二方面的第八种可能的实施方式中,所述重定位单元具体用于,若所述第三共享库包含的第一全局变量和所述宿主机的N个全局变量同名,将所述第一全局变量和所述N个全局变量之中最先加载的全局变量的地址,设定为所述N个全局变量和所述第一全局变量的公共地址;With reference to the seventh possible implementation of the second aspect, in an eighth possible implementation manner of the second aspect, the relocation unit is specifically configured to: if the third shared library includes a first global variable and Setting N global variables of the host with the same name, setting an address of the first global variable and the first global variable loaded among the N global variables as the N global variables and the first The public address of the global variable;
或者,or,
所述重定位单元具体用于,在所述第二共享库中被加载之后,将所述第三共享库中的第一全局变量的地址,重定位为所述第二共享库中的第二全局变量的地址,其中,所述第一全局变量和所述第二全局变量的声明相同。The relocation unit is specifically configured to relocate an address of the first global variable in the third shared library to a second in the second shared library after being loaded in the second shared library The address of the global variable, wherein the declaration of the first global variable and the second global variable are the same.
可以看出,本发明实施例方案中,引入的宿主机支持的第二共享库,可看成是客户机支持的第三共享库的一个伪共享库,因为,所述第二共享库中的第一函数和所述第三共享库中的第二函数的函数接口相同,所述第二共享库中的第一函数主要是用来触发调用第一共享库是来翻译第三共享库中的具有相同函数接口的函数,而这就可使得宿主机上的主程序或其他共享库,可以第二共享库为桥梁,通过调用第二共享库中的某函数,来间接的调用被第一共享库中的翻译函数所翻译的第三共享库中的具有相同函数接口的另一函数,由于第二共享库是宿主机支持的,因此,宿主机上的主程序或其他共享库能够识别和直 接调用第二共享库中的函数,这样可实现即使不对客户机上依赖第三共享库的主程序或其他依赖的共享库进行翻译,也可对客户机上的第三共享库间接调用执行,这样就极大的降低了第三共享库与客户机的支持主程序(或其他相关共享库)之间的强依赖性,这有利于极大减少翻译代码量,从而可提高二进制翻译执行的效率,进而提升用户体验。It can be seen that, in the solution of the embodiment of the present invention, the second shared library supported by the host can be regarded as a pseudo shared library of the third shared library supported by the client, because the second shared library The first function is the same as the function interface of the second function in the third shared library, and the first function in the second shared library is mainly used to trigger the calling of the first shared library to translate the third shared library. A function with the same function interface, and this can make the main program or other shared library on the host machine can be the second shared library as a bridge, indirectly calling the first share by calling a function in the second shared library. Another function in the third shared library translated by the translation function in the library has the same function interface. Since the second shared library is supported by the host, the main program or other shared library on the host can recognize and straighten. Calling the function in the second shared library, so that even if the main program or the other dependent shared library that depends on the third shared library on the client is not translated, the third shared library on the client can be indirectly called, so that Greatly reduce the strong dependency between the third shared library and the client's supporting main program (or other related shared libraries), which is beneficial to greatly reduce the amount of translation code, thereby improving the efficiency of binary translation execution, and thus Improve the user experience.
附图说明DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the description of the prior art will be briefly described below. Obviously, the drawings in the following description are only It is a certain embodiment of the present invention, and other drawings can be obtained from those skilled in the art without any creative work.
图1是本发明的一个实施例提供的一种共享库的二进制翻译执行方法的流程示意图;1 is a schematic flowchart of a binary translation execution method of a shared library according to an embodiment of the present invention;
图2是本发明的另一个实施例提供的另一种共享库的二进制翻译执行方法的流程示意图;FIG. 2 is a schematic flowchart diagram of another binary translation execution method of a shared library according to another embodiment of the present invention; FIG.
图3-a是本发明实施例提供的一种x86客户机运行浏览器的架构示意图;FIG. 3 is a schematic structural diagram of an x86 client running browser according to an embodiment of the present invention; FIG.
图3-b是本发明实施例提供的一种龙芯宿主机运行浏览器的架构示意图;FIG. 3 is a schematic structural diagram of a Loongson host running browser according to an embodiment of the present invention; FIG.
图3-c是本发明实施例提供的龙芯宿主机引入二进制翻译器之后的一种常规架构示意图;FIG. 3-c is a schematic diagram of a conventional architecture after the Loongson host is introduced into the binary translator according to the embodiment of the present invention;
图3-d是本发明实施例提供的龙芯宿主机引入二进制翻译器之后的一种新架构示意图;FIG. 3-d is a schematic diagram of a new architecture after the introduction of the binary translator by the Loongson host according to the embodiment of the present invention; FIG.
图3-e是本发明实施例提供的一种代码翻译的示意图;FIG. 3-e is a schematic diagram of code translation according to an embodiment of the present invention;
图3-f是本发明实施例提供的另一种涉及函数指针的代码翻译的示意图;FIG. 3-f is a schematic diagram of another code translation related to a function pointer according to an embodiment of the present invention;
图4是本发明实施例提供的一种宿主机的示意图;4 is a schematic diagram of a host machine according to an embodiment of the present invention;
图5是本发明实施例提供的另一种宿主机的示意图;FIG. 5 is a schematic diagram of another host machine according to an embodiment of the present invention; FIG.
图6是本发明实施例提供的另一种宿主机的示意图;6 is a schematic diagram of another host machine according to an embodiment of the present invention;
图7是本发明实施例提供的一种通信系统的示意图。FIG. 7 is a schematic diagram of a communication system according to an embodiment of the present invention.
具体实施方式 detailed description
本发明实施例提供共享库的二进制翻译执行方法和装置,以期待能减少翻译共享库时的相关代码翻译量,从而提高二进制翻译的执行效率,进而提升用户体验。The embodiments of the present invention provide a binary translation execution method and apparatus for a shared library, so as to reduce the amount of related code translation when the shared library is translated, thereby improving the execution efficiency of the binary translation, thereby improving the user experience.
为了使本技术领域的人员更好地理解本发明方案,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚地描述,显然,所描述的实施例仅仅是本发明一部分的实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly described in conjunction with the drawings in the embodiments of the present invention. Some embodiments of the invention, rather than all of the embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts shall fall within the scope of the present invention.
以下分别进行详细说明。The details are described below separately.
本发明的说明书和权利要求书及上述附图中的术语“第一”、“第二”、“第三”和“第四”等是用于区别不同的对象,而非用于描述特定顺序。此外,术语“包括”和“具有”以及它们任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、系统、产品或设备没有限定于已列出的步骤或单元,而是可选地还包括没有列出的步骤或单元,或可选地还包括对于这些过程、方法、产品或设备固有的其它步骤或单元。The terms "first", "second", "third" and "fourth" and the like in the specification and claims of the present invention and the above drawings are used to distinguish different objects, and are not intended to describe a specific order. . Furthermore, the terms "comprises" and "comprising" and "comprising" are intended to cover a non-exclusive inclusion. For example, a process, method, system, product, or device that comprises a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units not listed, or alternatively Other steps or units inherent to these processes, methods, products or equipment.
本发明共享库的二进制翻译执行方法的一个实施例,一种共享库的二进制翻译执行方法所应用于宿主机,上述宿主机中可包括上述宿主机支持的第一共享库、上述宿主机支持的第二共享库和客户机支持的第三共享库,该第一共享库包括翻译函数,上述宿主机和上述客户机支持不同的指令集体系架构,上述方法包括:当上述第二共享库中的第一函数被调用时,上述宿主机执行上述第一函数以调用上述第一共享库中的翻译函数;上述宿主机利用上述调用的上述第一共享库中的翻译函数,对上述第三共享库中的函数接口与上述第一函数的函数接口相同的第二函数进行翻译,以得到上述宿主机支持的第三函数;上述第三函数的函数接口和上述第二函数的函数接口相同;上述宿主机执行上述第三函数。An embodiment of the binary translation execution method of the shared library of the present invention, a binary translation execution method of the shared library is applied to the host machine, and the host machine may include the first shared library supported by the host machine and supported by the host machine. a second shared library and a third shared library supported by the client, the first shared library includes a translation function, the host machine and the client support different instruction set architectures, and the method includes: when in the second shared library When the first function is called, the host machine executes the first function to invoke the translation function in the first shared library; the host machine uses the translation function in the first shared library that is invoked to invoke the third shared library. The second function of the function interface of the first function is translated to obtain the third function supported by the host machine; the function interface of the third function is the same as the function interface of the second function; The host executes the third function described above.
参见图1,图1为本发明的一个实施例提供的一种共享库的二进制翻译执行的流程示意图。如图1所示,本发明的一个实施例提供的一种共享库的二进制翻译执行方法可包括以下内容: Referring to FIG. 1, FIG. 1 is a schematic flowchart of binary translation execution of a shared library according to an embodiment of the present invention. As shown in FIG. 1, a binary translation execution method of a shared library provided by an embodiment of the present invention may include the following contents:
101、当上述第二共享库中的第一函数被调用(其中,第二共享库中的第一函数可能被主程序调用,当然第二共享库中的第一函数也可能被第二共享库或其他共享库中的函数调用)时,上述宿主机执行上述第一函数以调用上述第一共享库中的翻译函数。101. When the first function in the second shared library is called, wherein the first function in the second shared library may be called by the main program, of course, the first function in the second shared library may also be the second shared library. Or the function call in the other shared library, the host machine executes the first function described above to invoke the translation function in the first shared library.
其中,宿主机中可包括上述宿主机支持的第一共享库、上述宿主机支持的第二共享库和客户机支持的第三共享库,其中,上述宿主机和上述客户机支持不同的指令集体系架构。The host machine may include a first shared library supported by the host, a second shared library supported by the host, and a third shared library supported by the client, wherein the host and the client support different instruction sets. Architecture.
102、上述宿主机利用上述调用的上述第一共享库中的翻译函数,对上述第三共享库中的,函数接口与上述第一函数的函数接口相同的第二函数进行翻译,以得到上述宿主机支持的第三函数。其中,上述第三函数的函数接口和上述第二函数的函数接口相同。102. The host machine translates, by using the translation function in the first shared library that is invoked, the second function of the function interface and the function interface of the first function in the third shared library to obtain the foregoing function. The third function supported by the host. The function interface of the third function is the same as the function interface of the second function.
可以理解,上述第二共享库中的上述第一函数例如可为第二共享库中的任意一个函数,或者,上述第二共享库中的上述第一函数也可为第二共享库中的某个特定的函数。It is to be understood that the first function in the second shared library may be any one of the second shared libraries, or the first function in the second shared library may be any one of the second shared libraries. a specific function.
103、执行上述第三函数。103. Perform the third function described above.
可以理解的是,对上述第二函数进行翻译的步骤,和执行上述第三函数的步骤之间并没有必然的执行先后顺序。其中,在一些可能的实施方式中,可能是先执行对上述第二函数进行翻译的步骤,而后执行上述执行上述第三函数的步骤,而在另一些可能的实施方式中,也可能是一边执行对上述第二函数进行翻译的步骤,一边执行上述执行上述第三函数的步骤,也就是说,执行上述第三函数和对上述第二函数进行翻译有可能是交错执行的。It can be understood that there is no necessary execution order between the step of translating the above second function and the step of executing the above third function. In some possible implementations, the step of translating the second function may be performed first, and then the step of executing the foregoing third function may be performed, and in other possible implementations, it may be performed on one side. The step of translating the second function described above performs the above-described step of executing the third function described above, that is, performing the third function and translating the second function may be interleaved.
可以看出,本发明实施例方案中,引入的宿主机支持的第二共享库,可看成是客户机支持的第三共享库的一个伪共享库,因为,所述第二共享库中的第一函数和所述第三共享库中的第二函数的函数接口相同,所述第二共享库中的第一函数主要是用来触发调用第一共享库是来翻译第三共享库中的具有相同函数接口的函数,而这就可使得宿主机上的主程序或其他共享库,可以第二共享库为桥梁,通过调用第二共享库中的某函数,来间接的调用被第一共享库中的翻译函数所翻译的第三共享库中的具有相同函数接口的另一函数,由于第二 共享库是宿主机支持的,因此,宿主机上的主程序或其他共享库能够识别和直接调用第二共享库中的函数,这样可实现即使不对客户机上依赖第三共享库的主程序或其他依赖的共享库进行翻译,也可对客户机上的第三共享库间接调用执行,这样就极大的降低了第三共享库与客户机的支持主程序(或其他相关共享库)之间的强依赖性,这有利于极大减少翻译代码量,从而可提高二进制翻译执行的效率,进而提升用户体验。It can be seen that, in the solution of the embodiment of the present invention, the second shared library supported by the host can be regarded as a pseudo shared library of the third shared library supported by the client, because the second shared library The first function is the same as the function interface of the second function in the third shared library, and the first function in the second shared library is mainly used to trigger the calling of the first shared library to translate the third shared library. A function with the same function interface, and this can make the main program or other shared library on the host machine can be the second shared library as a bridge, indirectly calling the first share by calling a function in the second shared library. Another function in the third shared library translated by the translation function in the library with the same function interface, due to the second The shared library is supported by the host, so the main program or other shared library on the host can recognize and directly call the function in the second shared library, which can realize the main program or other even if it is not dependent on the third shared library on the client. Dependent shared library for translation, or indirect call to the third shared library on the client, which greatly reduces the strong between the third shared library and the client's supporting main program (or other related shared libraries) Dependency, which helps to greatly reduce the amount of translation code, which can improve the efficiency of binary translation execution, thereby improving the user experience.
进一步的,由于第一共享库是包含翻译函数,即将二进制翻译器编译成第一共享库,在需调用客户机支持的第三共享库中的函数时,第一共享库才对被调用的相关函数进行动态翻译,这样有利于提高翻译的针对性和有效性,有利于减少无效翻译工作量,进而有利于进一步减少翻译代码量,从而进一步提高二进制翻译的执行效率,进而进一步提升用户体验。Further, since the first shared library includes a translation function, that is, the binary translator is compiled into the first shared library, when the function in the third shared library supported by the client needs to be called, the first shared library is related to the called The function is dynamically translated, which is beneficial to improve the pertinence and effectiveness of translation, and is beneficial to reduce the amount of invalid translation work, thereby further reducing the amount of translation code, thereby further improving the execution efficiency of binary translation, thereby further improving the user experience.
其中,对上述第二函数进行翻译可能涉及多方面,具体翻译方式也可能是多种多样,下面进行举例说明。Among them, the translation of the above second function may involve various aspects, and the specific translation manner may also be various, as exemplified below.
在本发明的一些可能的实施方式中,上述宿主机中还包括上述宿主机支持的第五共享库;若上述第二函数包括调用上述客户机支持的第四共享库中的第四函数的指令,其中,对上述第二函数进行翻译的步骤,还可包括:上述宿主机将上述第二函数包括的调用上述第四共享库中的第四函数的指令,翻译成调用上述第五共享库中的第五函数的指令,其中,上述第四函数和上述第五函数的函数功能相同,或者,上述第四函数和上述第五函数的函数功能和函数接口均相同。可以理解,上述宿主机将上述第二函数包括的调用上述第四共享库中的第四函数的指令,翻译成调用上述第五共享库中的第五函数的指令,本质上可看做是一种库函数包装技术,即将对客户机支持的某共享库中的某函数的调用,替换为对宿主机支持的某共享库中的函数功能相同或函数功能和函数接口均相同的函数的调用,这样有利于提高对宿主机的本地共享库的利用率,进一步减少对客户机相关共享库的函数代码的翻译,进而有利于进一步减少代码翻译量。In some possible implementation manners of the present invention, the host machine further includes a fifth shared library supported by the host machine; if the second function includes an instruction for calling a fourth function in the fourth shared library supported by the client. The step of translating the second function may further include: the host machine translating, by the host machine, the instruction for calling the fourth function in the fourth shared library included in the second function into calling the fifth shared library. The instruction of the fifth function, wherein the functions of the fourth function and the function of the fifth function are the same, or the function functions and function interfaces of the fourth function and the fifth function are the same. It can be understood that the above host translates the instruction of the second function included in the second shared library to the instruction of calling the fifth function in the fifth shared library, which can be regarded as one. The library function packaging technology replaces the call of a function in a shared library supported by the client with a function that has the same function or a function function and a function interface in a shared library supported by the host. This is beneficial to improve the utilization of the local shared library of the host machine, and further reduce the translation of the function code of the client-related shared library, thereby further reducing the amount of code translation.
在本发明的另一些可能的实施方式中,上述宿主机中还可进一步包括上述宿主机支持的第五共享库,当上述第三函数调用上述客户机支持的第四共享库 中的第四函数时,上述方法还可包括:上述宿主机将上述第三函数包括的调用上述客户机支持的第四共享库中的第四函数的指令,翻译成上述第三函数调用上述第五共享库中第五函数的指令;其中,上述第四函数和上述第五函数的函数功能和函数接口均相同,或者,上述第四函数和上述第五函数的函数功能相同。可以理解的是,上述宿主机将上述第三函数包括的调用上述第四共享库中的第四函数的指令,翻译成调用上述第五共享库中的第五函数的指令,本质上可看做是一种库函数包装技术,即,可将对客户机支持的某共享库中的某函数的调用,替换为对宿主机支持的某共享库中的函数功能相同或函数功能和函数接口均相同的函数的调用,这样有利于提高宿主机本地共享库的利用率,进一步减少对客户机相关共享库的函数代码的翻译,进而有利于进一步减少代码翻译量。In another possible implementation manner of the present invention, the host machine may further include a fifth shared library supported by the host machine, where the third function invokes the fourth shared library supported by the client. In the fourth function, the method may further include: the host machine translating, by the host function, the instruction of the fourth function included in the fourth shared library supported by the third function into the third function calling the foregoing The instruction of the fifth function in the shared library; wherein the function function and the function interface of the fourth function and the fifth function are the same, or the functions of the fourth function and the fifth function are the same. It can be understood that the host machine translates the instruction including the fourth function in the fourth shared library included in the third function into an instruction that invokes the fifth function in the fifth shared library, which can be regarded as an essential Is a library function wrapper technology, that is, the call to a function in a shared library supported by the client can be replaced by the same function or function function and function interface in a shared library supported by the host. The call of the function, which is beneficial to improve the utilization of the local shared library of the host, further reduce the translation of the function code of the client-related shared library, thereby further reducing the amount of code translation.
在本发明的一些可能的实施方式中,上述宿主机中还包括上述宿主机支持的第二主程序,若上述第二函数包括调用上述客户机支持的第一主程序中的第六函数的指令,对上述第二函数进行翻译的步骤,还可进一步包括:上述宿主机将上述第二函数包括的上述调用上述客户机支持的第一主程序中的第六函数的指令,翻译成调用上述第二主程序中的第七函数的指令,其中,上述第六函数和上述第七函数的函数功能相同,或者,上述第六函数和上述第七函数的函数功能和函数接口均相同。可以理解,将上述第二函数包括的上述调用上述客户机支持的第一主程序中的第六函数的指令,翻译成调用上述第二主程序中的第七函数的指令,本质上可看做是一种库函数包装技术,即将对客户机支持的主程序中的某函数的调用,替换为对宿主机支持的主程序中的函数功能相同或函数功能和函数接口均相同的函数的调用,这样有利于提高对宿主机的本地共享库的利用率,进一步减少对客户机相关共享库的函数代码的翻译,进而有利于进一步减少代码翻译量。In some possible implementation manners of the present invention, the host machine further includes a second main program supported by the host machine, where the second function includes an instruction to invoke a sixth function in the first main program supported by the client. The step of translating the second function may further include: the host machine translating, by the host function, the instruction that invokes the sixth function in the first main program supported by the client by the second function to call the foregoing The instruction of the seventh function in the two main programs, wherein the functions of the sixth function and the function of the seventh function are the same, or the function functions and function interfaces of the sixth function and the seventh function are the same. It can be understood that the above-mentioned second function includes the instruction for calling the sixth function in the first main program supported by the client, and the instruction for calling the seventh function in the second main program is essentially regarded as Is a library function wrapper technology, that is, the call to a function in the main program supported by the client is replaced by a call to a function with the same function or the same function and function interface in the main program supported by the host. This is beneficial to improve the utilization of the local shared library of the host machine, and further reduce the translation of the function code of the client-related shared library, thereby further reducing the amount of code translation.
在本发明的另一些可能的实施方式中,上述宿主机中还包括上述宿主机支持的第二主程序,当上述第三函数调用上述客户机支持的第一主程序中的第六函数时,上述方法还包括:上述宿主机将上述第三函数包括的调用上述客户机支持的第一主程序中的第六函数的指令,翻译成上述第三函数调用上述第二主 程序中的第七函数的调用,其中,上述第六函数和上述第七函数的函数功能相同,或者,上述第六函数和上述第七函数的函数功能和函数接口均相同。可以理解的是,将上述第三函数包括的上述调用上述客户机支持的第一主程序中的第六函数的指令,翻译成调用上述第二主程序中的第七函数的指令,本质上可看做是一种库函数包装技术,即,可以将对客户机支持的主程序中的某函数的调用,替换为对宿主机支持的主程序中的函数功能相同或函数功能和函数接口均相同的函数的调用,这样有利于提高对宿主机的本地共享库的利用率,进一步减少对客户机相关共享库的函数代码的翻译,进而有利于进一步减少代码翻译量。In another possible implementation manner of the present invention, the host machine further includes a second main program supported by the host machine, when the third function invokes a sixth function in the first main program supported by the client, The method further includes: the host machine translating, by the host function, an instruction of the third function included in the first main program supported by the third function to the third function to invoke the second main a call of a seventh function in the program, wherein the functions of the sixth function and the function of the seventh function are the same, or the function functions and function interfaces of the sixth function and the seventh function are the same. It can be understood that the above-mentioned third function includes the instruction for calling the sixth function in the first main program supported by the client, and the instruction for calling the seventh function in the second main program is substantially Seen as a library function wrapper technology, that is, you can replace the call to a function in the main program supported by the client with the same function or the function and function interface in the main program supported by the host. The call of the function, which is beneficial to improve the utilization of the host's local shared library, further reduce the translation of the function code of the client-related shared library, thereby further reducing the amount of code translation.
在本发明的一些可能的实施方式中,当上述第二函数包括以上述客户机支持的第十函数的函数指针作为传入参数,以调用上述宿主机支持的第八函数的调用指令,对上述第二函数进行翻译的步骤,还可包括:上述宿主机将上述以上述客户机支持的第十函数的函数指针作为传入参数,以调用上述宿主机支持的第八函数的调用指令,替换为,以上述宿主机支持的第九函数的函数指针作为传入参数,以调用上述宿主机支持的第八函数的调用指令。其中,当上述第九函数被调用时,上述宿主机执行上述第九函数以调用上述第一共享库中的翻译函数对上述第十函数进行翻译,得到上述宿主机支持的第十一函数,上述宿主机执行上述第十一函数。可以理解,在上述存在函数指针的场景下,引入上述第九函数作为桥梁,有利于实现在较合适的时机对函数指针所指向的函数进行翻译,有利于尽量避免出现错误。In some possible implementation manners of the present invention, when the second function includes a function pointer of the tenth function supported by the client as an incoming parameter, to invoke the calling instruction of the eighth function supported by the host, The step of translating the second function may further include: the host machine adopts the function pointer of the tenth function supported by the client as the incoming parameter, and invokes the calling instruction of the eighth function supported by the host, and replaces it with The function pointer of the ninth function supported by the host machine is used as an incoming parameter to invoke the calling instruction of the eighth function supported by the host. Wherein, when the ninth function is called, the host machine executes the ninth function to invoke the translation function in the first shared library to translate the tenth function, to obtain an eleventh function supported by the host machine, The host executes the eleventh function described above. It can be understood that, in the above scenario where the function pointer exists, the introduction of the ninth function as a bridge is beneficial to realizing the translation of the function pointed to by the function pointer at a suitable timing, which is beneficial to avoid errors as much as possible.
在本发明的一些可能的实施方式中,当上述第三年函数包括以上述宿主机支持的函数S01的函数指针作为传入参数,以调用上述宿主机支持的S02函数的调用指令,当上述函数S01被调用时,上述宿主机执行上述函数S01,宿主机不翻译上述函数S001。In some possible implementation manners of the present invention, when the third year function includes a function pointer of the function S01 supported by the host machine as an incoming parameter, to invoke a call instruction of the S02 function supported by the host, when the function is When S01 is called, the host machine executes the above function S01, and the host does not translate the above function S001.
在本发明的一些可能的实施方式中,当上述第二函数包括以第一结构体作为传入参数调用第十二函数的调用指令,对上述第二函数进行翻译的步骤还可以包括:上述宿主机将上述以第一结构体作为传入参数调用第十二函数的调用指令,翻译为,以第二结构体作为传入参数调用第十二函数的调用指令,上述 第一结构体包含的域为上述第二结构体包含的域的子集。其中,上述第一结构体为上述客户机支持的结构体,并且上述第二结构体为上述宿主机支持的结构体,且上述第十二函数为上述宿主机支持的函数;或者上述第一结构体为上述宿主机支持的结构体,并且上述第二结构体为上述客户机支持的结构体,并且上述第十二函数为上述上述客户机支持的函数。例如,上述第一结构体包含的域与上述第二结构体包含的域可以相同。In some possible implementations of the present invention, when the second function includes a call instruction that invokes the twelfth function with the first structure as an incoming parameter, the step of translating the second function may further include: The host invokes the above-mentioned call instruction of the twelfth function with the first structure as the incoming parameter, and translates the call instruction of the twelfth function with the second structure as the incoming parameter, The domain included in the first structure is a subset of the domains included in the second structure. The first structure is a structure supported by the client, and the second structure is a structure supported by the host, and the twelfth function is a function supported by the host; or the first structure The body is a structure supported by the host machine, and the second structure is a structure supported by the client, and the twelfth function is a function supported by the client. For example, the domain included in the first structure may be the same as the domain included in the second structure.
在本发明的一些可能的实施方式中,当上述第二函数包括以第一结构体指针作为传入参数调用第十三函数的调用指令,对上述第二函数进行翻译的步骤还可包括:上述宿主机将上述以第一结构体指针作为传入参数调用第十三函数的调用指令,翻译为,以第二结构体指针作为传入参数调用第十三函数的调用指令。其中,上述第一结构体指针指向第一结构体,上述第二结构体指针指向第二结构体,上述第一结构体包含的域为上述第二结构体包含的域的子集。其中,上述第一结构体为客户机支持的结构体,且上述第二结构体为宿主机支持的结构体,且上述第十三函数为上述宿主机支持的函数。或者上述第一结构体为宿主机支持的结构体,并且上述第二结构体为客户机支持的结构体,且上述第十三函数为上述客户机支持的函数。例如,上述第一结构体包含的域与上述第二结构体包含的域可以相同。In some possible implementations of the present invention, when the second function includes a call instruction that invokes the thirteenth function with the first structure body pointer as an incoming parameter, the step of translating the second function may further include: The host machine invokes the above-mentioned call instruction that invokes the thirteenth function with the first structure body pointer as an incoming parameter, and translates the call instruction of the thirteenth function with the second structure body pointer as an incoming parameter. The first structure pointer points to the first structure, the second structure pointer points to the second structure, and the first structure includes a field that is a subset of the domains included in the second structure. The first structure is a structure supported by a client, and the second structure is a structure supported by a host, and the thirteenth function is a function supported by the host. Or the first structure is a structure supported by the host, and the second structure is a structure supported by the client, and the thirteenth function is a function supported by the client. For example, the domain included in the first structure may be the same as the domain included in the second structure.
在本发明的一些可能的实施方式中,当上述第二函数的传入参数包括第三结构体,上述方法还可进一步包括:上述宿主机将作为上述第二函数的传入参数的第三结构体替换为第四结构体,上述第三结构体包含的域为上述第四结构体包含的域的子集;其中,上述第四结构体为客户机支持的结构体,且上述第三结构体为宿主机支持的结构体。例如,上述第三结构体包含的域与上述第四结构体包含的域可以相同。In some possible implementation manners of the present invention, when the incoming parameter of the second function includes the third structure, the method may further include: the third structure that the host machine uses as the incoming parameter of the second function The body is replaced by a fourth structure, and the third structure includes a domain of a subset of domains included in the fourth structure; wherein the fourth structure is a client-supported structure, and the third structure A structure supported by the host. For example, the domain included in the third structure described above may be the same as the domain included in the fourth structure.
在本发明的一些可能的实施方式中,当上述第二函数的传入参数包括第三结构体指针,上述方法还可进一步包括:上述宿主机将作为上述第二函数的传入参数的上述第三结构体指针替换为第四结构体指针,上述第四结构体指针指向第四结构体,上述第三结构体指针指向第三结构体,上述第三结构体包含的域为上述第四结构体包含的域的子集。其中,上述第四结构体为客户机支持的 结构体,且上述第三结构体为宿主机支持的结构体。例如,上述第三结构体包含的域与上述第四结构体包含的域可以相同。In some possible implementation manners of the present invention, when the incoming parameter of the second function includes the third structure pointer, the method may further include: the foregoing, by the host, as an incoming parameter of the second function The third structure pointer is replaced with a fourth structure body pointer, the fourth structure body pointer is directed to the fourth structure body, the third structure body pointer is directed to the third structure body, and the third structure body includes the fourth structure body A subset of the included domains. Wherein the fourth structure body is supported by the client The structure, and the third structure is a structure supported by a host. For example, the domain included in the third structure described above may be the same as the domain included in the fourth structure.
其中,上述举例了一些翻译第二函数可能实施方式,以及翻译翻译第二函数还可能涉及与翻译相关的一些其他操作,当然在实际应用,还可能涉及其他的翻译操作,当然上述的翻译操作之间也可能相互进行嵌套,具体方式此处不再赘述。Wherein, the above exemplifies some possible implementations of the translation second function, and the translation translation second function may also involve some other operations related to translation, of course, in practical applications, other translation operations may also be involved, of course, the above translation operations They may also be nested with each other, and the specific methods are not described here.
此外,在本发明的一些可能的实施方式中,上述对第三共享库中的第一函数进行翻译以得到第二函数之前,上述方法还可包括:上述宿主机对上述第三共享库和上述宿主机的同名全局变量进行符号重定位。In addition, in some possible implementation manners of the present invention, before the first function in the third shared library is translated to obtain the second function, the method may further include: the foregoing host machine, the third shared library, and the foregoing The host's global variable of the same name is symbol relocated.
举例来说,上述宿主机对上述第三共享库和上述宿主机的同名全局变量进行符号重定位包括:若上述第三共享库包含的第一全局变量和上述宿主机的N个全局变量同名,上述宿主机将上述第一全局变量和上述N个全局变量之中最先加载的全局变量的地址,设定为上述N个全局变量和上述第一全局变量的公共地址。For example, the symbol relocation of the global variable of the same name of the third shared library and the host machine by the host machine includes: if the first global variable included in the third shared library and the N global variable of the host have the same name, The host machine sets an address of the first global variable and the first global variable loaded among the N global variables to a common address of the N global variables and the first global variable.
又例如,上述宿主机对上述第三共享库和上述宿主机的同名全局变量进行符号重定位包括:在上述第二共享库中被加载之后,上述宿主机将上述第三共享库中的第一全局变量的地址,重定位为上述第二共享库中的第二全局变量的地址,其中,上述第一全局变量和上述第二全局变量的声明相同。For another example, the symbol relocation of the global variable of the same name of the third shared library and the host machine by the host machine includes: after the second shared library is loaded, the host machine is the first one of the third shared libraries. The address of the global variable is relocated to the address of the second global variable in the second shared library, wherein the declaration of the first global variable and the second global variable is the same.
可以理解的是,上述第一全局变量可为上述第三共享库包含的任意一个全局变量。或者,上述第一全局变量也可为上述第三共享库包含的某个特定的全局变量。It can be understood that the first global variable may be any global variable included in the third shared library. Alternatively, the first global variable may also be a specific global variable included in the third shared library.
其中,本发明实施例的宿主机和客户机支持不同的指令集体系架构,例如宿主机和客户机可以分别支持如下指令集体系架构中的其中一种:POWER指令集体系架构、x86指令集体系架构、龙芯指令集体系架构和MIPS指令集体系架构。The host and the client of the embodiments of the present invention support different instruction set architectures. For example, the host and the client can respectively support one of the following instruction set architectures: the POWER instruction set architecture and the x86 instruction set system. Architecture, Loongson instruction set architecture and MIPS instruction set architecture.
为便于更好的理解和实施本发明实施例的上述技术方案,下面通过一些具体的应用场景进行举例说明。To facilitate a better understanding and implementation of the foregoing technical solutions of the embodiments of the present invention, the following is exemplified by some specific application scenarios.
下面举例中主要以客户机支持x86指令集体系架构,宿主机支持龙芯指令 集体系架构为例。其中,在下面的举例描述中,支持x86指令集体系架构的客户机可以称之为x86客户机,支持龙芯指令集体系架构的宿主机可以称之为龙芯宿主机。In the following example, the client mainly supports the x86 instruction set architecture, and the host supports the Loongson command. Take the architecture of the system as an example. Among them, in the following example description, a client supporting the x86 instruction set architecture may be referred to as an x86 client, and a host supporting the Loongson instruction set architecture may be referred to as a Loongson host.
例如,假设龙芯宿主机上可以运行开源的火狐(Firefox)浏览器(浏览器可看做是主程序),但是浏览器中的flash播放插件(即flashplayer.so共享库)是由Adobe公司开发,假设flash播放插件不开源且只提供x86指令集体系架构下的版本,因此在龙芯宿主机的Firefox浏览器内无法使用。For example, suppose that the Loongson host machine can run the open source Firefox browser (the browser can be regarded as the main program), but the flash playback plugin (ie flashplayer.so shared library) in the browser is developed by Adobe. Assume that the flash player plugin is not open source and only provides the version under the x86 instruction set architecture, so it cannot be used in the Firefox browser of the Godson host.
为简化描述,下面可将龙芯宿主机支持的浏览器称之为龙芯浏览器,龙芯宿主机支持的共享库称之为龙芯共享库。类似的,可将x86客户机支持的浏览器称之为x86浏览器,可将x86客户机支持的共享库称之为x86共享库。In order to simplify the description, the browser supported by the Loongson host can be called the Loongson browser, and the shared library supported by the Loongson host is called the Loongson shared library. Similarly, a browser supported by an x86 client can be referred to as an x86 browser, and a shared library supported by an x86 client can be referred to as an x86 shared library.
参见图3-a,图3-a示出了x86客户机运行x86浏览器的一种软件架构。x86浏览器可能调用各种x86共享库(包括flash播放插件)里的函数;flash播放插件也可能会调用其它x86共享库里的函数;flash播放插件还可能会调用x86浏览器里的函数。See Figure 3-a, which shows a software architecture for an x86 client running an x86 browser. The x86 browser may call functions in various x86 shared libraries (including flash play plugins); the flash play plugin may also call functions from other x86 shared libraries; the flash play plugin may also call functions in the x86 browser.
其中,在x86客户机上,这些程序是齐全的。在龙芯宿主机上,龙芯浏览器和其它的x86共享库都可用开源代码编译生成,但龙芯宿主机缺少flash播放插件这个共享库,具体如图3-b举例所示。Among them, on x86 clients, these programs are complete. On the Loongson host, the Loongson browser and other x86 shared libraries can be compiled and generated with open source code, but the Loongson host lacks the shared library of flash playback plugins, as shown in Figure 3-b.
现有的二进制翻译方案中,二进制翻译器作为龙芯宿主机的主程序,其架构具体可例如图3-c所示,二进制翻译器不仅需翻译运行x86客户机的flash播放插件,还需要翻译运行x86浏览器和其他x86共享库,因此,由于需要翻译各x86共享库和x86浏览器,这使得翻译代码量较大,影响了翻译运行效率。In the existing binary translation scheme, the binary translator is the main program of the Loongson host, and its architecture can be specifically shown in Figure 3-c. The binary translator not only needs to translate the flash playback plug-in running the x86 client, but also needs to translate and run. X86 browsers and other x86 shared libraries, therefore, because of the need to translate x86 shared libraries and x86 browsers, which makes the translation code large, affecting the efficiency of translation operations.
在本发明一些实施例的技术方案中,二进制翻译器被编译成龙芯宿主机上的第一共享库bt.so(上述实施例中的第一共享库的一种举例实现),第一共享库bt.so可被龙芯浏览器调用,而x86客户机的flash播放插件被第一共享库bt.so翻译后运行,架构如图3-d所示。由于需翻译运行的x86代码大大减少,有利于极大提高翻译运行效率。In a technical solution of some embodiments of the present invention, the binary translator is compiled into a first shared library bt.so on the Loongson host (an example implementation of the first shared library in the above embodiment), the first shared library Bt.so can be called by the Loongson browser, and the x86 client's flash play plugin is translated by the first shared library bt.so, as shown in Figure 3-d. Because the x86 code that needs to be translated and run is greatly reduced, it is beneficial to greatly improve the efficiency of translation operation.
参见图2,图2为本发明的另一个实施例提供的另一种共享库的二进制翻译执行的流程示意图。如图2所示,本发明的另一个实施例提供的另一种共享库 的二进制翻译执行方法可包括以下内容:Referring to FIG. 2, FIG. 2 is a schematic flowchart of binary translation execution of another shared library according to another embodiment of the present invention. As shown in FIG. 2, another shared library provided by another embodiment of the present invention is provided. The binary translation execution method can include the following:
201、龙芯宿主机将二进制翻译器编译成第一共享库bt.so。201. The Loongson host compiles the binary translator into the first shared library bt.so.
202、龙芯宿主机将伪flash播放插件flashplayer_ls.so(该伪flash播放插件flashplayer_ls.so可看做是上述实施例中的第二共享库的一种举例实现)加载到龙芯浏览器。202. The Loongson host machine loads the pseudo flash play plugin flashplayer_ls.so (the pseudo flash play plugin flashplayer_ls.so can be regarded as an example implementation of the second shared library in the above embodiment) to be loaded into the Loongson browser.
其中,伪flash播放插件flashplayer_ls.so提供的函数接口和x86flash播放插件flashplayer_x86.so(其中,x86flash播放插件flashplayer_x86.so可看做是上述实施例中第三共享库的一种举例实现)提供的函数接口相同。其中,可通过解析x86flash播放插件的二进制文件,从其符号表中寻找全局函数符号,这些全局函数符号即为x86flash播放插件的函数接口,而x86flash播放插件的函数接口作为伪flash播放插件提供的函数接口。The function interface provided by the pseudo flash playback plug-in flashplayer_ls.so and the x86flash playback plug-in flashplayer_x86.so (where the x86flash playback plug-in flashplayer_x86.so can be regarded as an example implementation of the third shared library in the above embodiment) provides a function. The interface is the same. Among them, you can find the global function symbols from the symbol table by parsing the binary files of the x86flash playback plug-in. These global function symbols are the function interfaces of the x86flash playback plug-in, and the function interface of the x86flash playback plug-in is provided as a function provided by the pseudo-flash playback plug-in. interface.
当然,龙芯宿主机还可加载第一共享库bt.so,还可通过第一共享库bt.so来初始化x86运行环境(例如模拟的x86寄存器、内存等)、以及翻译后的龙芯代码缓冲区等。Of course, the Loongson host can also load the first shared library bt.so, and can also initialize the x86 runtime environment (such as simulated x86 registers, memory, etc.) and the translated Loongson code buffer through the first shared library bt.so. Wait.
203、当伪flash播放插件flashplayer_ls.so之中的第一函数被龙芯浏览器调用时,龙芯宿主机执行伪flash播放插件flashplayer_ls.so之中的第一函数,以调用第一共享库bt.so中的翻译函数x86_exec,对x86flash播放插件flashplayer_x86.so中的函数接口与第一函数的函数接口相同的第二函数(如NPP_New函数)进行翻译以得到第三函数,执行第三函数。203. When the first function of the pseudo flash playback plug-in flashplayer_ls.so is called by the Loongson browser, the Loongson host executes the first function in the pseudo flash playback plug-in flashplayer_ls.so to call the first shared library bt.so The translation function x86_exec translates the function function in the x86flash playback plug-in flashplayer_x86.so with the second function (such as the NPP_New function) of the function interface of the first function to obtain a third function, and executes the third function.
参见图3-e,其中,图3-e举例示出了x86flash播放插件flashplayer_x86.so中的第二函数(图3-e中举例为NPP_New函数),以及对其进行翻译后得到的龙芯宿主机支持的第三函数。Referring to Figure 3-e, Figure 3-e shows the second function in the x86flash playback plug-in flashplayer_x86.so (the NPP_New function is shown in Figure 3-e), and the Loongson host machine is translated. The third function supported.
在本发明一些可能的实施方式中,上述龙芯宿主机中还包括上述龙芯宿主机支持的第五共享库;若上述第二函数包括调用上述x86客户机支持的第四共享库(如libc.so)中的第四函数(如malloc函数)的指令,其中,对上述第二函数进行翻译的步骤,还可包括:龙芯宿主机将上述第二函数包括的调用上述第四共享库(如libc.so)中的第四函数(如malloc函数)的指令,翻译成调用上述第五共享库中的第五函数的指令,其中,上述第四函数和上述第五函数的 函数功能和函数接口均相同。可以理解,龙芯宿主机将上述第二函数包括的调用上述第四共享库中的第四函数的指令,翻译成调用上述第五共享库中的第五函数的指令,本质上可看做是一种库函数包装技术,即将对x86客户机支持的某共享库中的某函数的调用,替换为对龙芯宿主机支持的某共享库中的函数功能相同或函数功能和函数接口均相同的函数的调用,这样有利于提高对龙芯宿主机的本地共享库的利用率,进一步减少对x86客户机相关共享库的函数代码的翻译,进而有利于进一步减少代码翻译量。In some possible implementation manners of the present invention, the foregoing Loongson host further includes a fifth shared library supported by the Loongson host; if the second function includes a fourth shared library (such as libc.so) supported by the x86 client. The instruction of the fourth function (such as the malloc function), wherein the step of translating the second function may further include: the Loongson host invoking the second function included in the fourth shared library (such as libc. An instruction of a fourth function (such as a malloc function) in so) is translated into an instruction that invokes a fifth function in the fifth shared library, wherein the fourth function and the fifth function are The function and function interface are the same. It can be understood that the Loongson host machine translates the instruction of the second function included in the second shared library mentioned above into the instruction of calling the fifth function in the fifth shared library, which can be regarded as one. The library function wrapper technology is to replace the call of a function in a shared library supported by the x86 client with a function with the same function or the same function and function interface in a shared library supported by the Loongson host. Calling, which is beneficial to improve the utilization of the local shared library of the Loongson host, further reducing the translation of the function code of the shared library of the x86 client, thereby further reducing the amount of code translation.
在本发明另一些可能的实施方式中,上述龙芯宿主机中还包括上述龙芯宿主机支持的第五共享库,当上述第三函数调用上述x86客户机支持的第四共享库(例如libc.so)中的第四函数(例如malloc函数)时,上述龙芯宿主机可将上述第三函数包括的调用上述x86客户机支持的第四共享库(如libc.so中的第四函数(例如malloc函数)的指令,翻译成上述第三函数调用上述第五共享库中第五函数的指令;其中上述第四函数和上述第五函数的函数功能和函数接口均相同,或者上述第四函数和上述第五函数的函数功能相同。可以理解,上述龙芯宿主机将所第三函数包括的调用上述第四共享库中的第四函数的指令,翻译成调用上述第五共享库中的第五函数的指令,本质上可看做是一种库函数包装技术,即,可以将对x86客户机支持的某共享库中的某函数的调用,替换为对龙芯宿主机支持的某共享库中的函数功能相同或函数功能和函数接口均相同的函数的调用,这样有利于提高对龙芯宿主机本地共享库的利用率,进一步减少对x86客户机相关共享库的函数代码的翻译,进而有利于进一步减少代码翻译量。In another possible implementation manner of the present invention, the Loongson host machine further includes a fifth shared library supported by the Loongson host, and the third function calls the fourth shared library supported by the x86 client (for example, libc.so The fourth function (for example, the malloc function), the above-mentioned Loongson host may include the fourth shared library supported by the above-mentioned x86 client including the third function (such as the fourth function in libc.so (for example, the malloc function). And an instruction translated into the third function of the fifth shared library in the fifth shared function; wherein the function function and the function interface of the fourth function and the fifth function are the same, or the fourth function and the foregoing The functions of the five functions have the same function. It can be understood that the above-mentioned Loongson host translates the instruction of the third function included in the third function to the fifth function in the fifth shared library. In essence, it can be regarded as a library function wrapper technology, that is, the call to a function in a shared library supported by the x86 client can be replaced with the Loongson host. The function of the shared function in a shared library is the same or the function function and function interface are the same function call, which is beneficial to improve the utilization of the local shared library of the Loongson host, and further reduce the function code of the shared library of the x86 client. The translation, in turn, helps to further reduce the amount of code translation.
在本发明一些可能的实施方式中,上述龙芯宿主机中还包括上述龙芯宿主机支持的龙芯浏览器,若第二函数包括调用x86浏览器中的第六函数(如NPN_PostURL函数)的指令,对第二函数进行翻译的步骤,还可包括:上述龙芯宿主机将上述第二函数包括的上述调用上述x86客户机支持的x86浏览器中的第六函数(如NPN_PostURL函数)的指令,翻译成调用龙芯浏览器中的第七函数(如NPN_PostURL函数)的指令,其中,上述第六函数和上述第七函数的函数功能和函数接口均相同。可以理解,将上述第二函数包括的上述调 用上述x86客户机支持的x86浏览器中的第六函数的指令,翻译成调用龙芯浏览器中的第七函数的指令,本质上可看做是一种库函数包装技术,即将对x86客户机支持的x86浏览器中的某函数的调用,替换为对龙芯宿主机支持的龙芯浏览器中的函数功能和函数接口均相同函数的调用,这样有利于提高对龙芯宿主机的本地共享库利用率,进一步减少对x86客户机相关共享库的函数代码的翻译,进而有利于进一步减少代码翻译量。In some possible implementation manners of the present invention, the Loongson host machine further includes a Loongson browser supported by the Loongson host machine, and if the second function includes an instruction to invoke a sixth function (such as the NPN_PostURL function) in the x86 browser, The step of translating the second function may further include: the above-mentioned Loongson host translating, by the above-mentioned second function, the instruction of the sixth function (such as the NPN_PostURL function) in the x86 browser supported by the x86 client described above into a call. The instruction of the seventh function (such as the NPN_PostURL function) in the Loongson browser, wherein the function function and the function interface of the sixth function and the seventh function are the same. It can be understood that the above second function is included in the above adjustment The instruction of the sixth function in the x86 browser supported by the above x86 client is translated into the instruction of calling the seventh function in the Loongson browser, which can be regarded as a library function packaging technology, which is about to be an x86 client. The call of a function in the supported x86 browser is replaced by the call of the same function and function interface in the Loongson browser supported by the Loongson host, which is beneficial to improve the local shared library utilization of the Loongson host. , further reducing the translation of the function code of the x86 client-related shared library, thereby further reducing the amount of code translation.
在本发明的另一些可能的实施方式中,上述龙芯宿主机中还包括上述龙芯宿主机支持的龙芯浏览器,当上述第三函数调用上述x86客户机支持的x86浏览器中的第六函数(如NPN_PostURL函数)时,上述龙芯宿主机可将上述第三函数包括的调用上述x86客户机支持的x86浏览器中的第六函数的指令,翻译成上述第三函数调用上述龙芯浏览器中的第七函数(如NPN_PostURL函数)的调用,其中,上述第六函数和上述第七函数的函数功能相同,或者上述第六函数和上述第七函数的函数功能和函数接口均相同。可以理解的是,将上述第三函数包括的上述调用上述x86客户机支持的x86浏览器中的第六函数的指令,翻译成调用上述龙芯浏览器中的第七函数的指令,本质上可看做是一种库函数包装技术,即,可以将对x86客户机支持的主程序中的某函数的调用,替换为对龙芯宿主机支持的主程序中的函数功能相同或函数功能和函数接口均相同的函数的调用,这样有利于提高对龙芯宿主机的本地共享库的利用率,进一步减少对x86客户机相关共享库的函数代码的翻译,进而有利于进一步减少代码翻译量。In another possible implementation manner of the present invention, the Loongson host machine further includes the Loongson browser supported by the Loongson host, and the third function in the x86 browser supported by the x86 client is used as the sixth function ( For example, when the NPN_PostURL function is used, the above-mentioned Loongson host may translate the instruction of the sixth function included in the x86 browser supported by the above-mentioned x86 client into the third function to call the above-mentioned Loongson browser. a call of a seven function (such as an NPN_PostURL function), wherein the functions of the sixth function and the function of the seventh function are the same, or the function functions and function interfaces of the sixth function and the seventh function are the same. It can be understood that the above-mentioned third function includes the above-mentioned instruction for calling the sixth function in the x86 browser supported by the x86 client, and the instruction for calling the seventh function in the Loongson browser is substantially visible. Is a library function wrapper technology, that is, you can replace the call of a function in the main program supported by the x86 client with the same function or function function and function interface in the main program supported by the Loongson host. The same function call, which is beneficial to improve the utilization of the local shared library of the Loongson host, further reducing the translation of the function code of the shared library of the x86 client, thereby further reducing the amount of code translation.
在本发明一些可能的实施方式中,龙芯宿主机在执行伪flash播放插件flashplayer_ls.so中的第一函数,以调用第一共享库bt.so中的翻译函数x86_exec对x86flash播放插件flashplayer_x86.so中的第二函数进行翻译以得到第三函数之前,龙芯宿主机可执行x86装载器(loader)或者第一共享库bt.so中的相关函数,以对上述x86flash播放插件flashplayer_x86.so和龙芯宿主机上的同名全局变量进行符号重定位。具体的,龙芯宿主机执行x86装载器完成初步符号重定位后,龙芯宿主机可执行第一共享库bt.so中的相关函数,以读取龙芯运行环境和x86运行环境中的全局变量列表,对两者共有全局变量,根据它们内存装载 顺序(即浏览器、共享库和flash播放插件在同一运行环境里的装载顺序)重新进行符号重定位。经过这一过程,两个运行环境里的代码可正常访问同一个全局变量。In some possible implementation manners of the present invention, the Loongson host machine executes the first function in the pseudo flash play plugin flashplayer_ls.so to call the translation function x86_exec in the first shared library bt.so to the x86flash play plugin flashplayer_x86.so Before the second function is translated to get the third function, the Loongson host can execute the x86 loader or the related function in the first shared library bt.so to play the above x86flash plugin flashplayer_x86.so and the Loongson host. A symbolic relocation is performed on the global variable of the same name. Specifically, after the Loongson host performs the initial symbol relocation by executing the x86 loader, the Loongson host can execute the related function in the first shared library bt.so to read the global variable list in the Loongson running environment and the x86 running environment. Shared global variables for both, based on their memory loading The order (ie, the loading order of the browser, shared library, and flash player plugin in the same runtime environment) is re-symbolized. After this process, the code in the two runtime environments can access the same global variable normally.
其中,对上述x86flash播放插件flashplayer_x86.so和龙芯宿主机的同名全局变量进行符号重定位的具体方式可能多种多样,下面进行举例说明。Among them, the specific ways of symbol relocation of the above-mentioned x86flash playback plug-in flashplayer_x86.so and the Loongson host's global variable of the same name may be various, as exemplified below.
举例来说,龙芯宿主机执行装载器(loader)或第一共享库bt.so中的相关函数以对上述x86flash播放插件flashplayer_x86.so和龙芯宿主机的同名全局变量进行符号重定位,可包括:若x86flash播放插件flashplayer_x86.so包含的第一全局变量和龙芯宿主机的N个全局变量同名,龙芯宿主机执行装载器或第一共享库bt.so的相关函数,以将上述第一全局变量和上述N个全局变量之中最先加载的全局变量的地址,设定为上述N个全局变量和上述第一全局变量的公共地址,上述N为正整数。For example, the Loongson host executes a loader or a related function in the first shared library bt.so to perform symbol relocation on the x86flash playback plug-in flashplayer_x86.so and the same-named global variable of the Loongson host, which may include: If the x86flash playback plugin flashplayer_x86.so contains the first global variable and the same name of the N global variable of the Loongson host, the Loongson host executes the loader or the first shared library bt.so related function to the above first global variable and The address of the first global variable loaded among the N global variables is set to the public address of the N global variables and the first global variable, and the N is a positive integer.
又例如,龙芯宿主机执行装载器或第一共享库bt.so中的相关函数以对上述x86flash播放插件flashplayer_x86.so和龙芯宿主机的同名全局变量进行符号重定位,可包括:在伪flash播放插件flashplayer_ls.so被加载之后,将上述x86flash播放插件flashplayer_x86.so的第一全局变量的地址,重定位为伪flash播放插件flashplayer_ls.so中的第二全局变量的地址。其中,上述第一全局变量和上述第二全局变量的声明相同。For another example, the Loongson host performs a loader or a related function in the first shared library bt.so to perform symbol relocation on the x86flash playback plug-in flashplayer_x86.so and the same-named global variable of the Loongson host, which may include: playing in a pseudo flash. After the plug-in flashplayer_ls.so is loaded, the address of the first global variable of the x86 flash playback plug-in flashplayer_x86.so is relocated to the address of the second global variable in the pseudo-flash playback plug-in flashplayer_ls.so. The declaration of the first global variable and the second global variable are the same.
可以理解,上述第一全局变量可为x86flash播放插件flashplayer_x86.so包含的任意一个全局变量。或者,上述第一全局变量也可为x86flash播放插件flashplayer_x86.so包含的某个特定的全局变量。其中,x86flash播放插件flashplayer_x86.so包含的每个全局变量的符号重定位方式,均可类似于第一全局变量的符号重定位方式。It can be understood that the first global variable mentioned above may be any global variable included in the x86flash playback plug-in flashplayer_x86.so. Alternatively, the first global variable may also be a specific global variable included in the x86flash playback plugin flashplayer_x86.so. The symbol relocation mode of each global variable included in the x86flash playback plug-in flashplayer_x86.so can be similar to the symbol relocation mode of the first global variable.
此外,龙芯浏览器、龙芯共享库和x86flash播放插件flashplayer_x86.so之间可能会通过函数调用的传参和返回值方式来传递函数指针。例如x86flash播放插件flashplayer_x86.so中的函数A,有可能以函数指针x86_foo作为传入参数来调用龙芯图形共享库里的函数B;函数B将会使用该函数指针调用函数指针x86_foo所指向的函数。 In addition, the Loongson browser, the Loongson shared library, and the x86flash playback plug-in flashplayer_x86.so may pass function pointers through the arguments and return values of function calls. For example, the function A of the x86flash playback plug-in flashplayer_x86.so may call the function B in the Loongson graphics shared library with the function pointer x86_foo as the incoming parameter; the function B will use the function pointer to call the function pointed to by the function pointer x86_foo.
例如,实际程序中的函数B可能是函数g_signal_connect,给控件(如按钮)注册点击事件,或gtk_timeout_add设定计时器等。For example, function B in the actual program may be the function g_signal_connect, register a click event for a control (such as a button), or set a timer for gtk_timeout_add.
类似地,龙芯浏览器或龙芯共享库在调用x86flash播放插件flashplayer_x86.so中的函数时,也有可能会把龙芯函数指针(例如ls_bar)作为传入参数,传递给调用x86flash播放插件flashplayer_x86.so中的函数。Similarly, when the Loongson browser or Loongson shared library calls the function of the x86flash playback plugin flashplayer_x86.so, it is also possible to pass the Loongson function pointer (such as ls_bar) as an incoming parameter to the x86flash playback plugin flashplayer_x86.so. function.
当x86客户机与龙芯宿主机的函数之间相互调用时,若传参涉及函数指针,则可对该函数指针进行一定的翻译处理,这样有利于保障函数运行的正确性。When the x86 client and the function of the Loongson host call each other, if the argument refers to the function pointer, the function pointer can be subjected to a certain translation process, which is beneficial to ensure the correctness of the function operation.
第1类值转换:当上述第二函数包括以上述x86客户机支持的第十函数的函数指针(如x86函数指针x86_foo)作为传入参数,以调用龙芯宿主机支持的第八函数的调用指令,上述龙芯宿主机可执行第一共享库bt.so中的相关函数以生成第九函数(可看成是一种类伪库函数(如图3-f中的x86_foo”函数)),将上述以上述x86客户机支持的第十函数的函数指针作为传入参数,以调用上述龙芯宿主机支持的第八函数的调用指令,替换为,以上述龙芯宿主机支持的第九函数的函数指针作为传入参数,以调用上述龙芯宿主机支持的第八函数的调用指令。其中,当上述第九函数被调用时,上述龙芯宿主机执行上述第九函数以调用第一共享库bt.so中的翻译函数,对上述第十函数进行翻译,得到上述龙芯宿主机支持的第十一函数,龙芯宿主机执行上述第十一函数。可以理解,在存在函数指针的上述场景下,引入上述第九函数作为桥梁,有利于实现在较合适的时机对函数指针所指向的函数进行翻译,有利于尽量避免出现错误。其中替换的第二函数指针符合龙芯宿主机的应用程序二进制接口,能够被龙芯宿主机函数调用。The first type of value conversion: when the second function includes a function pointer of the tenth function supported by the above x86 client (such as the x86 function pointer x86_foo) as an incoming parameter, to invoke the calling instruction of the eighth function supported by the Loongson host. The Loongson host can execute a correlation function in the first shared library bt.so to generate a ninth function (which can be regarded as a pseudo-base function (such as the x86_foo function in FIG. 3-f)), The function pointer of the tenth function supported by the above x86 client is used as an incoming parameter to call the calling instruction of the eighth function supported by the above-mentioned Loongson host, and is replaced by the function pointer of the ninth function supported by the Loongson host. Entering a parameter to invoke a call instruction of the eighth function supported by the Loongson host, wherein when the ninth function is invoked, the Loongson host executes the ninth function to invoke the translation in the first shared library bt.so The function, the above tenth function is translated, and the eleventh function supported by the Loongson host machine is obtained, and the Loongson host performs the eleventh function described above. It can be understood that in the presence of the function finger In the above scenario of the pin, the introduction of the ninth function as a bridge is beneficial to realizing the translation of the function pointed to by the function pointer at a suitable timing, which is beneficial to avoid errors as much as possible. The second function pointer replaced is in accordance with the Loongson host. The application binary interface can be called by the Loongson host function.
第2类值转换:若上述第二函数的传入参数包括第三函数指针,且上述第三函数指针为上述龙芯宿主机的函数指针(可根据函数指针的结构确定第三函数指针为上述龙芯宿主机的函数指针还是为上述x86客户机的函数指针),将上述第二函数对第三函数指针指向的第十一函数的调用,翻译成上述第三函数对上述第三函数指针指向的上述第十一函数的调用。The second type of value conversion: if the incoming parameter of the second function includes a third function pointer, and the third function pointer is a function pointer of the above-mentioned Loongson host machine (the third function pointer may be determined according to the structure of the function pointer as the above-mentioned Loongson The function pointer of the host is still a function pointer of the above x86 client), and the call of the second function to the eleventh function pointed to by the third function pointer is translated into the above-mentioned third function pointing to the third function pointer The call of the eleventh function.
此外,同一结构体在x86客户机和龙芯宿主机上的定义可能不同,并且结构体为了满足其中各个域的数据对齐要求,可能在域和域之间增加空数据。这 些情况都使得同一结构体在x86客户机和龙芯宿主机上的二进制格式不一定相同。当这些结构体作为传入参数传递给另一个运行环境来访问时,可能会访问到错误的结构体内位置,因此可能需要对传递的结构体进行翻译。In addition, the definition of the same structure on the x86 client and the Loongson host may be different, and the structure may add null data between the domain and the domain in order to meet the data alignment requirements of each domain. This In some cases, the binary format of the same structure on the x86 client and the Loongson host is not necessarily the same. When these structures are passed as input parameters to another runtime environment, they may access the wrong structure body location, so it may be necessary to translate the passed structure.
第3类值转换方式1:Type 3 value conversion method 1:
在本发明的一些可能的实施方式中,当上述第二函数包括以第一结构体作为传入参数调用第十二函数的调用指令,上述龙芯宿主机可将上述以第一结构体作为传入参数调用第十二函数的调用指令,翻译为,以第二结构体作为传入参数调用第十二函数的调用指令,上述第一结构体包含的域为上述第二结构体包含的域的子集。其中,第一结构体为上述x86客户机支持的结构体,并且上述第二结构体为上述龙芯宿主机支持的结构体,且上述第十二函数为上述龙芯宿主机支持的函数;或者上述第一结构体为上述龙芯宿主机支持的结构体,并且上述第二结构体为上述x86客户机支持的结构体,并且上述第十二函数为上述上述x86客户机支持的函数。例如上述第一结构体包含的域与上述第二结构体包含的域可以相同。In some possible implementation manners of the present invention, when the second function includes a call instruction that invokes the twelfth function with the first structure as an incoming parameter, the Loongson host may use the first structure as the incoming The parameter calls the calling instruction of the twelfth function, and translates into calling instruction of the twelfth function by using the second structure as the incoming parameter, and the first structure includes the domain of the domain included in the second structure. set. The first structure is a structure supported by the x86 client, and the second structure is a structure supported by the Loongson host, and the twelfth function is a function supported by the Loongson host; or the above A structure is a structure supported by the Loongson host, and the second structure is a structure supported by the x86 client, and the twelfth function is a function supported by the x86 client. For example, the domain included in the first structure described above may be the same as the domain included in the second structure.
第3类值转换方式2:Type 3 value conversion method 2:
在本发明的一些可能的实施方式中,当上述第二函数包括以第一结构体指针作为传入参数调用第十三函数的调用指令,对上述第二函数进行翻译的步骤还可包括:上述龙芯宿主机将上述以第一结构体指针作为传入参数调用第十三函数的调用指令,翻译为,以第二结构体指针作为传入参数调用第十三函数的调用指令。其中,上述第一结构体指针指向第一结构体,第二结构体指针指向第二结构体,上述第一结构体包含的域为上述第二结构体包含的域的子集。其中,上述第一结构体为x86客户机支持的结构体,且上述第二结构体为龙芯宿主机支持的结构体,且上述第十三函数为上述龙芯宿主机支持的函数。或者上述第一结构体为龙芯宿主机支持的结构体,并且上述第二结构体为x86客户机支持的结构体,且上述第十三函数为上述x86客户机支持的函数。例如,上述第一结构体包含的域与上述第二结构体包含的域可以相同。In some possible implementations of the present invention, when the second function includes a call instruction that invokes the thirteenth function with the first structure body pointer as an incoming parameter, the step of translating the second function may further include: The Loongson host machine invokes the above-mentioned call instruction of the thirteenth function with the first structure body pointer as an incoming parameter, and translates the call instruction of the thirteenth function with the second structure body pointer as an incoming parameter. The first structure body pointer points to the first structure body, the second structure body pointer points to the second structure body, and the first structure body includes a domain that is a subset of the domains included in the second structure body. The first structure is a structure supported by an x86 client, and the second structure is a structure supported by a Loongson host, and the thirteenth function is a function supported by the Loongson host. Or the first structure is a structure supported by a Loongson host, and the second structure is a structure supported by an x86 client, and the thirteenth function is a function supported by the x86 client. For example, the domain included in the first structure may be the same as the domain included in the second structure.
其中,如果第一结构体中的某域也是结构体,则可对该域也做第3类值转换方式1。如果第一结构体中的某域也是结构体指针,则可对该域也做第3类值 转换方式2。其中,如果第一结构体中的某域为函数指针,则可对该域做第1类值转换。以此类推。Wherein, if a certain domain in the first structure is also a structure, the third type of value conversion mode 1 can also be performed on the domain. If a domain in the first structure is also a structure pointer, the third class value can also be made to the domain. Conversion method 2. Wherein, if a certain field in the first structure is a function pointer, the first type of value conversion can be performed on the domain. And so on.
第4类值转换方式1:Type 4 value conversion method 1:
当上述第二函数的传入参数包括第三结构体,上述龙芯宿主机可将作为上述第二函数的传入参数的第三结构体替换为第四结构体,上述第三结构体包含的域为上述第四结构体包含的域的子集;其中,上述第四结构体为x86客户机支持的结构体,且上述第三结构体为龙芯宿主机支持的结构体。例如,上述第三结构体包含的域与上述第四结构体包含的域可以相同。When the incoming parameter of the second function includes the third structure, the Loongson host may replace the third structure as the incoming parameter of the second function with the fourth structure, and the third structure includes the domain And a subset of the domains included in the fourth structure; wherein the fourth structure is a structure supported by an x86 client, and the third structure is a structure supported by a Loongson host. For example, the domain included in the third structure described above may be the same as the domain included in the fourth structure.
第4类值转换方式2:Type 4 value conversion method 2:
当上述第二函数的传入参数包括第三结构体指针,龙芯宿主机可将作为上述第二函数的传入参数的上述第三结构体指针替换为第四结构体指针,上述第四结构体指针指向第四结构体,上述第三结构体指针指向第三结构体,上述第三结构体包含的域为上述第四结构体包含的域的子集。其中,上述第四结构体为x86客户机支持的结构体,且上述第三结构体为龙芯宿主机支持的结构体。例如,上述第三结构体包含的域与上述第四结构体包含的域可以相同。。When the incoming parameter of the second function includes the third structure body pointer, the Godson host may replace the third structure body pointer as the incoming parameter of the second function with the fourth structure body pointer, and the fourth structure body The pointer points to the fourth structure, the third structure pointer points to the third structure, and the third structure includes a field which is a subset of the fields included in the fourth structure. The fourth structure is a structure supported by an x86 client, and the third structure is a structure supported by a Loongson host. For example, the domain included in the third structure described above may be the same as the domain included in the fourth structure. .
其中,如果第三结构体中的某域也是结构体,则可对该域也做第4类值转换方式1。如果第三结构体中的某域也是结构体指针,则可对该域也做第4类值转换方式2。其中,如果第三结构体中的某域为函数指针,则可对该域做第2类值转换。以此类推。Wherein, if a certain domain in the third structure is also a structure, the fourth type of value conversion mode 1 can also be performed on the domain. If a certain field in the third structure is also a structure pointer, the fourth type of value conversion mode 2 can also be performed on the domain. Wherein, if a certain field in the third structure is a function pointer, the second type of value conversion can be performed on the domain. And so on.
可以看出,本实施例方案中,引入的龙芯宿主机支持的第二共享库(伪flash播放插件flashplayer_ls.so),可看成是x86客户机支持的第三共享库(x86flash播放插件)的一个伪共享库,因为,上述第二共享库中的第一函数和上述第三共享库中的第二函数的函数接口相同(就是说,第二共享库提供的函数接口与上述第三共享库提供的函数接口之间存在非空交集),上述第二共享库中的第一函数主要是用来触发调用第一共享库是来翻译第三共享库中的具有相同函数接口的函数,而这就可使得龙芯宿主机上的主程序或其他共享库,可以第二共享库为桥梁,通过调用第二共享库中的某函数,来间接的调用被第一共享库中的翻译函数所翻译的第三共享库中的具有相同函数接口的另一函数,由于第 二共享库是龙芯宿主机支持的,因此,龙芯宿主机上的主程序或其他共享库能够识别和直接调用第二共享库中的函数,这样可实现即使不对x86客户机上依赖第三共享库的主程序或其他依赖的共享库进行翻译,也可对x86客户机上的第三共享库间接调用执行,这样就极大的降低了第三共享库与x86客户机的支持主程序(或其他相关共享库)之间的强依赖性,这有利于极大减少翻译代码量,从而可提高二进制翻译执行的效率,进而提升用户体验。。It can be seen that, in the solution of the embodiment, the second shared library supported by the Loongson host machine (pseudo flash play plugin flashplayer_ls.so) can be regarded as the third shared library supported by the x86 client (x86 flash play plugin). a pseudo shared library, because the function of the first function in the second shared library and the second function in the third shared library are the same (that is, the function interface provided by the second shared library and the third shared library described above) There is a non-empty intersection between the provided function interfaces, and the first function in the second shared library is mainly used to trigger the calling of the first shared library to translate the function having the same function interface in the third shared library, and this It can make the main program or other shared library on the Loongson host machine, and the second shared library can be used as a bridge to indirectly call the translation function translated by the first shared library by calling a function in the second shared library. Another function in the third shared library with the same function interface, due to the The second shared library is supported by the Loongson host. Therefore, the main program or other shared libraries on the Loongson host can recognize and directly call the functions in the second shared library, so that even if the third shared library is not dependent on the x86 client. The main program or other dependent shared libraries are translated, and can also be executed indirectly on the third shared library on the x86 client, which greatly reduces the support main program (or other related sharing) of the third shared library and the x86 client. Strong dependency between libraries), which helps to greatly reduce the amount of translation code, which can improve the efficiency of binary translation execution, thereby improving the user experience. .
进一步的,由于第一共享库是将二进制翻译器编译得到的,在需调用x86客户机支持的第三共享库中的函数时,第一共享库才对被调用的相关函数进行动态翻译,这样有利于提高翻译的针对性和有效性,进而有利于减少无效翻译工作量,进而有利于进一步减少翻译代码量,从而进一步提高二进制翻译的执行效率,进而进一步提升用户体验。Further, since the first shared library is compiled by the binary translator, when the function in the third shared library supported by the x86 client is called, the first shared library dynamically translates the called related function, so that It is beneficial to improve the pertinence and effectiveness of translation, and thus help to reduce the amount of invalid translation work, which in turn helps to further reduce the amount of translation code, thereby further improving the execution efficiency of binary translation, thereby further improving the user experience.
可以理解,上述举例中主要是以客户机支持x86指令集体系架构,支持龙芯指令集体系架构来举例说明的。而宿主机支持x86指令集体系架构或其他指令集体系架构,客户机支持龙芯指令集体系架构或其他指令集体系架构等场景下得实施方式可类似参考,此处不再赘述。It can be understood that the above examples mainly illustrate that the client supports the x86 instruction set architecture and supports the Loongson instruction set architecture. The host machine supports the x86 instruction set architecture or other instruction set architecture. The implementation method of the client supporting the Loongson instruction set architecture or other instruction set architecture can be similarly referred to, and will not be described here.
下面还提供用于实施上述方案的相关装置。Related devices for implementing the above schemes are also provided below.
参见图4,本发明实施例提供一种宿主机400可包括:存储单元410、调用单元420、翻译单元430和执行单元440。Referring to FIG. 4, an embodiment of the present invention provides a host 400 that can include a storage unit 410, a calling unit 420, a translation unit 430, and an execution unit 440.
存储单元410,用于存储上述宿主机支持的第一共享库、上述宿主机支持的第二共享库和客户机支持的第三共享库,上述第一共享库包括翻译函数,上述宿主机和上述客户机支持不同的指令集体系架构。The storage unit 410 is configured to store a first shared library supported by the host, a second shared library supported by the host, and a third shared library supported by the client, where the first shared library includes a translation function, the host and the foregoing The client supports a different instruction set architecture.
调用单元420,用于当上述第二共享库中的第一函数被调用时,执行上述第一函数以调用上述第一共享库中的翻译函数。The calling unit 420 is configured to execute the first function to invoke the translation function in the first shared library when the first function in the second shared library is called.
翻译单元430,用于利用上述调用的第一共享库中的翻译函数,对上述第三共享库中的函数接口与上述第一函数的函数接口相同的第二函数进行翻译,以得到上述宿主机支持的第三函数;其中,上述第三函数的函数接口和上述第二函数的函数接口相同。The translation unit 430 is configured to translate the second function of the function interface in the third shared library and the function interface of the first function by using the translation function in the first shared library that is invoked to obtain the host machine. A third function supported; wherein the function interface of the third function is the same as the function interface of the second function.
执行单元440,用于执行上述第三函数。 The executing unit 440 is configured to execute the third function described above.
可选的,在本发明一些可能的实施方式中,上述存储单元410还用于存储上述宿主机支持的第五共享库;若上述第二函数包括调用上述客户机支持的第四共享库中的第四函数的指令。Optionally, in some possible implementation manners of the present disclosure, the foregoing storage unit 410 is further configured to store a fifth shared library supported by the host machine, where the second function includes: calling the fourth shared library supported by the client. The instruction of the fourth function.
上述翻译单元430还可用于:The above translation unit 430 can also be used to:
将上述第二函数包括的调用上述第四共享库中的第四函数的指令,翻译成调用上述第五共享库中的第五函数的指令,其中,上述第四函数和上述第五函数的函数功能相同,或者,上述第四函数和上述第五函数的函数功能和函数接口均相同。Converting, by the second function, an instruction that calls the fourth function in the fourth shared library to an instruction that invokes the fifth function in the fifth shared library, wherein the fourth function and the function of the fifth function The functions are the same, or the function functions and function interfaces of the fourth function and the fifth function described above are the same.
可选的,在本发明另一些可能的实施方式中,上述存储单元410还用于存储上述宿主机支持的第五共享库,当上述第三函数调用上述客户机支持的第四共享库中的第四函数时,上述翻译单元430还用于:Optionally, in another possible implementation manner of the present invention, the foregoing storage unit 410 is further configured to store a fifth shared library supported by the host, where the third function invokes a fourth shared library supported by the client. In the fourth function, the above translation unit 430 is further configured to:
将上述第三函数包括的调用上述客户机支持的第四共享库中的第四函数的指令,翻译成上述第三函数调用上述第五共享库中第五函数的指令;上述第四函数和上述第五函数的函数功能相同,或者,上述第四函数和上述第五函数的函数功能和函数接口均相同。Translating, by the third function, an instruction for calling a fourth function in the fourth shared library supported by the client to an instruction of the third function calling the fifth function in the fifth shared library; the fourth function and the foregoing The functions of the fifth function have the same function, or the function functions and function interfaces of the fourth function and the fifth function described above are the same.
可选的,在本发明一些可能的实施方式中,上述存储单元410还用于存储上述宿主机支持的第二主程序,若上述第二函数包括调用上述客户机支持的第一主程序中的第六函数的指令,上述翻译单元430还用于:Optionally, in some possible implementation manners of the present disclosure, the foregoing storage unit 410 is further configured to store a second main program supported by the host, if the second function includes calling the first main program supported by the client. The instruction of the sixth function, the translation unit 430 is further configured to:
将上述第二函数包括的上述调用上述客户机支持的第一主程序中的第六函数的指令,翻译成调用上述第二主程序中的第七函数的指令,其中,上述第六函数和上述第七函数的函数功能相同,或者,上述第六函数和上述第七函数的函数功能和函数接口均相同。Translating, by the foregoing second function, the instruction for calling the sixth function in the first main program supported by the client to an instruction for calling the seventh function in the second main program, wherein the sixth function and the foregoing The functions of the seventh function are the same, or the function functions and function interfaces of the sixth function and the seventh function described above are the same.
可选的,在本发明另一些可能的实施方式中,上述存储单元410还用于存储上述宿主机支持的第二主程序,当上述第三函数调用上述客户机支持的第一主程序中的第六函数时,上述翻译单元430还用于:Optionally, in another possible implementation manner of the present invention, the foregoing storage unit 410 is further configured to store the second main program supported by the host, when the third function invokes the first main program supported by the client. In the sixth function, the above translation unit 430 is further configured to:
将上述第三函数包括的调用上述客户机支持的第一主程序中的第六函数的指令,翻译成上述第三函数调用上述第二主程序中的第七函数的调用,上述第六函数和上述第七函数的函数功能相同,或者,上述第六函数和上述第七函 数的函数功能和函数接口均相同。Translating, by the third function, an instruction for calling a sixth function in the first main program supported by the client, into a call of the third function in the third main program, the sixth function and The function of the seventh function described above has the same function, or the sixth function and the seventh function described above The function functions and function interfaces of the number are the same.
可选的,在本发明一些可能的实施方式中,当上述第二函数包括以上述客户机支持的第十函数的函数指针作为传入参数,以调用上述宿主机支持的第八函数的调用指令,上述翻译单元430还可用于:Optionally, in some possible implementation manners of the present invention, when the second function includes a function pointer of the tenth function supported by the client as an incoming parameter, the calling instruction of the eighth function supported by the host is invoked. The above translation unit 430 can also be used to:
将上述以上述客户机支持的第十函数的函数指针作为传入参数,以调用上述宿主机支持的第八函数的调用指令,替换为以上述宿主机支持的第九函数的函数指针作为传入参数,以调用上述宿主机支持的第八函数的调用指令;当上述第九函数被调用时,执行上述第九函数以调用上述第一共享库中的翻译函数对上述第十函数进行翻译,得到上述宿主机支持的第十一函数。The function pointer of the tenth function supported by the above client is used as an incoming parameter, and the calling instruction of the eighth function supported by the host is invoked, and the function pointer of the ninth function supported by the host is used as the incoming function. a parameter to invoke a call instruction of an eighth function supported by the host machine; when the ninth function is called, executing the ninth function to invoke the translation function in the first shared library to translate the tenth function The eleventh function supported by the above host.
可选的,在本发明一些可能的实施方式中,当上述第二函数包括以第一结构体作为传入参数调用第十二函数的调用指令,上述翻译单元430还用于将上述以第一结构体作为传入参数调用第十二函数的调用指令,翻译为,以第二结构体作为传入参数调用第十二函数的调用指令,其中,上述第一结构体包含的域为上述第二结构体包含的域的子集。其中,上述第一结构体为上述客户机支持的结构体,且上述第二结构体为上述宿主机支持的结构体,且上述第十二函数为上述宿主机支持的函数。或者,上述第一结构体可为上述宿主机支持的结构体,并且上述第二结构体为上述客户机支持的结构体,并且上述第十二函数为上述上述客户机支持的函数。Optionally, in some possible implementation manners of the present invention, when the second function includes a call instruction that invokes a twelfth function by using the first structure as an incoming parameter, the translation unit 430 is further configured to use the first The structure invokes the call instruction of the twelfth function as an incoming parameter, and translates to call the twelfth function with the second structure as the incoming parameter, wherein the first structure includes the second field A subset of the fields that the structure contains. The first structure is a structure supported by the client, and the second structure is a structure supported by the host, and the twelfth function is a function supported by the host. Alternatively, the first structure may be a structure supported by the host, and the second structure is a structure supported by the client, and the twelfth function is a function supported by the client.
可选的,在本发明另一些可能的实施方式中,当上述第二函数包括以第一结构体指针作为传入参数调用第十三函数的调用指令,上述翻译单元430还用于:上述宿主机将上述以第一结构体指针作为传入参数调用第十三函数的调用指令,翻译为,以第二结构体指针作为传入参数调用第十三函数的调用指令;其中,上述第一结构体指针指向第一结构体,上述第二结构体指针指向第二结构体,其中,上述第一结构体包含的域为上述第二结构体包含的域的子集。其中,上述第一结构体为客户机支持的结构体,且上述第二结构体为宿主机支持的结构体,且上述第十三函数为上述宿主机支持的函数。或者上述第一结构体为宿主机支持的结构体,并且上述第二结构体为客户机支持的结构体,且上述第十三函数为上述客户机支持的函数。 Optionally, in another possible implementation manner of the present invention, when the second function includes a call instruction that invokes a thirteenth function by using the first structure body pointer as an incoming parameter, the translation unit 430 is further configured to: The host invokes the above-mentioned calling instruction that invokes the thirteenth function with the first structure body pointer as an incoming parameter, and translates to call the thirteenth function calling instruction with the second structure body pointer as an incoming parameter; wherein, the first structure The body pointer points to the first structure body, and the second structure body pointer points to the second structure body, wherein the first structure body includes a domain that is a subset of the domains included in the second structure body. The first structure is a structure supported by a client, and the second structure is a structure supported by a host, and the thirteenth function is a function supported by the host. Or the first structure is a structure supported by the host, and the second structure is a structure supported by the client, and the thirteenth function is a function supported by the client.
可选的,在本发明一些可能的实施方式中,上述宿主机还包括:Optionally, in some possible implementation manners of the present invention, the host machine further includes:
重定位单元450,用于在对第三共享库中的第一函数进行翻译以得到第二函数之前,对上述第三共享库和上述宿主机的同名全局变量进行符号重定位。The relocation unit 450 is configured to perform symbol relocation on the third shared library and the global variable of the same name of the host machine before translating the first function in the third shared library to obtain the second function.
例如,重定位单元450可具体用于,若上述第三共享库包含的第一全局变量和上述宿主机的N个全局变量同名,将上述第一全局变量和上述N个全局变量之中最先加载的全局变量的地址,设定为上述N个全局变量和上述第一全局变量的公共地址;For example, the relocation unit 450 may be specifically configured to: if the first global variable included in the third shared library and the N global variable of the host have the same name, first among the first global variable and the N global variables The address of the loaded global variable is set to the above N global variables and the public address of the first global variable;
又例如,重定位单元450具体用于在上述第二共享库中被加载之后,将上述第三共享库中的第一全局变量的地址,重定位为上述第二共享库中的第二全局变量的地址,其中,上述第一全局变量和上述第二全局变量的声明相同。For example, the relocation unit 450 is specifically configured to relocate the address of the first global variable in the third shared library to the second global variable in the second shared library after being loaded in the second shared library. An address, wherein the first global variable is the same as the second global variable.
可以理解的是,本实施例的宿主机400的各功能模块的功能可根据上述方法实施例中的方法具体实现,其具体实现过程可以参照上述方法实施例的相关描述,此处不再赘述。It is to be understood that the functions of the functional modules of the host 400 of the present embodiment may be specifically implemented according to the method in the foregoing method embodiments. For the specific implementation process, refer to the related description of the foregoing method embodiments, and details are not described herein again.
可以看出,本实施例方案中,引入的宿主机400支持的第二共享库,可看成是客户机支持的第三共享库的一个伪共享库,因为,所述第二共享库中的第一函数和所述第三共享库中的第二函数的函数接口相同,所述第二共享库中的第一函数主要是用来触发调用第一共享库是来翻译第三共享库中的具有相同函数接口的函数,而这就可使得宿主机400上的主程序或其他共享库,可以第二共享库为桥梁,通过调用第二共享库中的某函数,来间接的调用被第一共享库中的翻译函数所翻译的第三共享库中的具有相同函数接口的另一函数,由于第二共享库是宿主机400支持的,因此,宿主机400上的主程序或其他共享库能够识别和直接调用第二共享库中的函数,这样可实现即使不对客户机上依赖第三共享库的主程序或其他依赖的共享库进行翻译,也可对客户机上的第三共享库间接调用执行,这样就极大的降低了第三共享库与客户机的支持主程序(或其他相关共享库)之间的强依赖性,这有利于极大减少翻译代码量,从而可提高二进制翻译执行的效率,进而提升用户体验。It can be seen that, in the solution of the embodiment, the second shared library supported by the host 400 can be regarded as a pseudo shared library of the third shared library supported by the client, because the second shared library The first function is the same as the function interface of the second function in the third shared library, and the first function in the second shared library is mainly used to trigger the calling of the first shared library to translate the third shared library. A function having the same function interface, and this allows the main program or other shared library on the host machine 400 to be a bridge of the second shared library, and indirectly calling the first function by calling a function in the second shared library. Another function having the same function interface in the third shared library translated by the translation function in the shared library, since the second shared library is supported by the host 400, the main program or other shared library on the host 400 can Identifying and directly calling functions in the second shared library, so that even if the main program on the client that depends on the third shared library or other dependent shared libraries is not translated, the third total on the client The library indirectly calls the execution, which greatly reduces the strong dependency between the third shared library and the client's supporting main program (or other related shared libraries), which helps to greatly reduce the amount of translation code, thereby improving The efficiency of binary translation execution, which in turn enhances the user experience.
参见图5,图5为本发明实施例提供的宿主机500的示意图,宿主机500可包括至少一个总线501、与总线501相连的至少一个处理器502以及与总线501相连 的至少一个存储器503。Referring to FIG. 5, FIG. 5 is a schematic diagram of a host 500 according to an embodiment of the present invention. The host 500 may include at least one bus 501, at least one processor 502 connected to the bus 501, and connected to the bus 501. At least one memory 503.
其中,上述宿主机和上述客户机支持不同的指令集体系架构。存储器503用于存储上述宿主机支持的第一共享库、上述宿主机支持的第二共享库和客户机支持的第三共享库。其中,上述第一共享库包括翻译函数。Among them, the above host machine and the above client support different instruction set architectures. The memory 503 is configured to store the first shared library supported by the host, the second shared library supported by the host, and the third shared library supported by the client. Wherein, the first shared library includes a translation function.
其中,处理器502通过总线501,调用存储器503中存储的代码以用于当上述第二共享库中的第一函数被调用时,执行上述第一函数以调用上述第一共享库中的翻译函数;利用上述调用的第一共享库中的翻译函数,对上述第三共享库中的函数接口与上述第一函数的函数接口相同的第二函数进行翻译,以得到上述宿主机支持的第三函数;其中,上述第三函数的函数接口和上述第二函数的函数接口相同;执行上述第三函数。The processor 502 calls the code stored in the memory 503 through the bus 501 for executing the first function to invoke the translation function in the first shared library when the first function in the second shared library is called. Translating, by using the translation function in the first shared library, the third function of the function interface in the third shared library and the function interface of the first function, to obtain the third function supported by the host machine. Wherein the function interface of the third function is the same as the function interface of the second function; and the third function is executed.
可选的,在本发明一些可能的实施方式中,上述存储器503还用于存储上述宿主机支持的第五共享库;若上述第二函数包括调用上述客户机支持的第四共享库中的第四函数的指令;处理器502还可用于:将上述第二函数包括的调用上述第四共享库中的第四函数的指令,翻译成调用上述第五共享库中的第五函数的指令,其中,上述第四函数和上述第五函数的函数功能相同,或者,上述第四函数和上述第五函数的函数功能和函数接口均相同。Optionally, in some possible implementation manners of the present disclosure, the foregoing memory 503 is further configured to store a fifth shared library supported by the host machine, where the second function includes a fourth shared library that is supported by the client. The instruction of the four functions; the processor 502 is further configured to: translate the instruction included in the second function, which is the fourth function in the fourth shared library, into an instruction to invoke the fifth function in the fifth shared library, where The functions of the fourth function and the functions of the fifth function are the same, or the function functions and function interfaces of the fourth function and the fifth function are the same.
可选的,在本发明另一些可能的实施方式中,上述存储器503还用于存储上述宿主机支持的第五共享库,当上述第三函数调用上述客户机支持的第四共享库中的第四函数时,上述处理器502还用于:将上述第三函数包括的调用上述客户机支持的第四共享库中的第四函数的指令,翻译成上述第三函数调用上述第五共享库中第五函数的指令;上述第四函数和上述第五函数的函数功能相同,或者,上述第四函数和上述第五函数的函数功能和函数接口均相同。Optionally, in another possible implementation manner of the present invention, the foregoing memory 503 is further configured to store a fifth shared library supported by the host, where the third function invokes a fourth shared library supported by the client. In the fourth function, the processor 502 is further configured to: translate the instruction included in the third function, which is the fourth function in the fourth shared library supported by the client, into the third function to invoke the fifth shared library. The instruction of the fifth function; the function of the fourth function and the function of the fifth function are the same, or the function and function interface of the fourth function and the fifth function are the same.
可选的,在本发明一些可能的实施方式中,上述存储器503还用于存储上述宿主机支持的第二主程序,若上述第二函数包括调用上述客户机支持的第一主程序中的第六函数的指令,处理器502还用于:Optionally, in some possible implementation manners of the present invention, the foregoing memory 503 is further configured to store the second main program supported by the host, if the second function includes the first one of the first main programs supported by the client. The six function instruction, the processor 502 is also used to:
将上述第二函数包括的上述调用上述客户机支持的第一主程序中的第六函数的指令,翻译成调用上述第二主程序中的第七函数的指令,其中,上述第六函数和上述第七函数的函数功能相同,或者,上述第六函数和上述第七函数 的函数功能和函数接口均相同。Translating, by the foregoing second function, the instruction for calling the sixth function in the first main program supported by the client to an instruction for calling the seventh function in the second main program, wherein the sixth function and the foregoing The function of the seventh function has the same function, or the sixth function and the seventh function described above The function functions and function interfaces are the same.
可选的,在本发明另一些可能的实施方式中,上述存储器503还用于存储上述宿主机支持的第二主程序,当上述第三函数调用上述客户机支持的第一主程序中的第六函数时,上述处理器502还用于:将上述第三函数包括的调用上述客户机支持的第一主程序中的第六函数的指令,翻译成上述第三函数调用上述第二主程序中的第七函数的调用,上述第六函数和上述第七函数的函数功能相同,或者,上述第六函数和上述第七函数的函数功能和函数接口均相同。Optionally, in another possible implementation manner of the present invention, the foregoing memory 503 is further configured to store a second main program supported by the host, where the third function invokes a first main program supported by the client. The processor 502 is further configured to: translate the instruction included in the third function, which is the sixth function in the first main program supported by the client, into the third function, and invoke the second main program. The function of the seventh function is the same as the function of the sixth function and the function function of the seventh function.
可选的,在本发明一些可能的实施方式中,当上述第二函数包括以上述客户机支持的第十函数的函数指针作为传入参数,以调用上述宿主机支持的第八函数的调用指令,上述处理器502还可用于:将上述以上述客户机支持的第十函数的函数指针作为传入参数,以调用上述宿主机支持的第八函数的调用指令,替换为以上述宿主机支持的第九函数的函数指针作为传入参数,以调用上述宿主机支持的第八函数的调用指令;当上述第九函数被调用时,执行上述第九函数以调用上述第一共享库中的翻译函数对上述第十函数进行翻译,得到上述宿主机支持的第十一函数。Optionally, in some possible implementation manners of the present invention, when the second function includes a function pointer of the tenth function supported by the client as an incoming parameter, the calling instruction of the eighth function supported by the host is invoked. The processor 502 is further configured to: use the function pointer of the tenth function supported by the client as the incoming parameter, and invoke the calling instruction of the eighth function supported by the host, and replace it with the host machine. The function pointer of the ninth function is used as an input parameter to call the call instruction of the eighth function supported by the host machine; when the ninth function is called, the ninth function is executed to invoke the translation function in the first shared library. Translating the above tenth function to obtain the eleventh function supported by the above host.
可选的,在本发明一些可能的实施方式中,当上述第二函数包括以第一结构体作为传入参数调用第十二函数的调用指令,处理器502还用于将上述以第一结构体作为传入参数调用第十二函数的调用指令,翻译为,以第二结构体作为传入参数调用第十二函数的调用指令,其中,上述第一结构体包含的域为上述第二结构体包含的域的子集。其中,上述第一结构体为上述客户机支持的结构体,且上述第二结构体为上述宿主机支持的结构体,且上述第十二函数为上述宿主机支持的函数。或者,上述第一结构体可为上述宿主机支持的结构体,并且上述第二结构体为上述客户机支持的结构体,并且上述第十二函数为上述上述客户机支持的函数。Optionally, in some possible implementation manners of the present invention, when the second function includes a call instruction that invokes a twelfth function with the first structure as an incoming parameter, the processor 502 is further configured to use the first structure The body invokes the call instruction of the twelfth function as an incoming parameter, and translates to call the twelfth function with the second structure as the incoming parameter, wherein the first structure includes the second structure A subset of the fields that the body contains. The first structure is a structure supported by the client, and the second structure is a structure supported by the host, and the twelfth function is a function supported by the host. Alternatively, the first structure may be a structure supported by the host, and the second structure is a structure supported by the client, and the twelfth function is a function supported by the client.
可选的,在本发明另一些可能的实施方式中,当上述第二函数包括以第一结构体指针作为传入参数调用第十三函数的调用指令,处理器502还用于上述宿主机将上述以第一结构体指针作为传入参数调用第十三函数的调用指令,翻译为,以第二结构体指针作为传入参数调用第十三函数的调用指令;其中,上 述第一结构体指针指向第一结构体,上述第二结构体指针指向第二结构体,其中,上述第一结构体包含的域为上述第二结构体包含的域的子集。其中,上述第一结构体为客户机支持的结构体,且上述第二结构体为宿主机支持的结构体,且上述第十三函数为上述宿主机支持的函数。或者上述第一结构体为宿主机支持的结构体,并且上述第二结构体为客户机支持的结构体,且上述第十三函数为上述客户机支持的函数。Optionally, in another possible implementation manner of the present invention, when the second function includes a call instruction that invokes a thirteenth function by using the first structure body pointer as an incoming parameter, the processor 502 is further configured to use the host machine. The above calling instruction of the thirteenth function is invoked by using the first structure body pointer as an incoming parameter, and is translated into a call instruction of the thirteenth function by using the second structure body pointer as an incoming parameter; The first structure body pointer points to the first structure body, and the second structure body pointer points to the second structure body, wherein the first structure body includes a domain that is a subset of the domains included in the second structure body. The first structure is a structure supported by a client, and the second structure is a structure supported by a host, and the thirteenth function is a function supported by the host. Or the first structure is a structure supported by the host, and the second structure is a structure supported by the client, and the thirteenth function is a function supported by the client.
可选的,在本发明一些可能的实施方式中,处理器502还用于在对第三共享库中的第一函数进行翻译以得到第二函数之前,对上述第三共享库和上述宿主机的同名全局变量进行符号重定位。Optionally, in some possible implementation manners of the present invention, the processor 502 is further configured to: before the first function in the third shared library is translated to obtain the second function, to the foregoing third shared library and the host machine Symbolic relocation of the global variable of the same name.
例如,处理器502还用于,若上述第三共享库包含的第一全局变量和上述宿主机的N个全局变量同名,将上述第一全局变量和上述N个全局变量之中最先加载的全局变量的地址,设定为上述N个全局变量和上述第一全局变量的公共地址;For example, the processor 502 is further configured to: if the first global variable included in the third shared library and the N global variable of the host have the same name, first load the first global variable and the N global variables. The address of the global variable is set to the above N global variables and the public address of the first global variable;
又例如,处理器502还用于在上述第二共享库中被加载之后,将上述第三共享库中的第一全局变量的地址,重定位为上述第二共享库中的第二全局变量的地址,其中,上述第一全局变量和上述第二全局变量的声明相同。For another example, the processor 502 is further configured to relocate the address of the first global variable in the third shared library to the second global variable in the second shared library after being loaded in the second shared library. An address, wherein the first global variable and the second global variable are declared the same.
可以理解的是,本实施例的宿主机500的各功能模块的功能可根据上述方法实施例中的方法具体实现,其具体实现过程可以参照上述方法实施例的相关描述,此处不再赘述。It is to be understood that the functions of the functional modules of the host device 500 of the present embodiment may be specifically implemented according to the method in the foregoing method embodiments. For the specific implementation process, reference may be made to the related description of the foregoing method embodiments, and details are not described herein again.
可以看出,本实施例方案中,引入的宿主机500支持的第二共享库,可看成是客户机支持的第三共享库的一个伪共享库,因为,所述第二共享库中的第一函数和所述第三共享库中的第二函数的函数接口相同,所述第二共享库中的第一函数主要是用来触发调用第一共享库是来翻译第三共享库中的具有相同函数接口的函数,而这就可使得宿主机500上的主程序或其他共享库,可以第二共享库为桥梁,通过调用第二共享库中的某函数,来间接的调用被第一共享库中的翻译函数所翻译的第三共享库中的具有相同函数接口的另一函数,由于第二共享库是宿主机500支持的,因此,宿主机500上的主程序或其他共享库能够识别和直接调用第二共享库中的函数,这样可实现即使不对客户机上依赖第 三共享库的主程序或其他依赖的共享库进行翻译,也可对客户机上的第三共享库间接调用执行,这样就极大的降低了第三共享库与客户机的支持主程序(或其他相关共享库)之间的强依赖性,这有利于极大减少翻译代码量,从而可提高二进制翻译执行的效率,进而提升用户体验。It can be seen that, in the solution of the embodiment, the second shared library supported by the host 500 can be regarded as a pseudo shared library of the third shared library supported by the client, because the second shared library The first function is the same as the function interface of the second function in the third shared library, and the first function in the second shared library is mainly used to trigger the calling of the first shared library to translate the third shared library. A function having the same function interface, and this allows the main program or other shared library on the host 500 to be a bridge of the second shared library, and the indirect call is first by calling a function in the second shared library. Another function having the same function interface in the third shared library translated by the translation function in the shared library, since the second shared library is supported by the host 500, the main program or other shared library on the host 500 can Identify and directly call functions in the second shared library, which can be implemented even if it is not dependent on the client The main program of the three shared libraries or other dependent shared libraries for translation, or indirect calls to the third shared library on the client, which greatly reduces the support of the third shared library and the client (or other Strong dependencies between related shared libraries), which greatly reduces the amount of translation code, which can improve the efficiency of binary translation execution, thereby improving the user experience.
参见图6,图6是本发明的另一个实施例提供的宿主机600的结构框图。宿主机600可包括至少1个处理器601、至少1个网络接口604、存储器605和至少1个通信总线602。通信总线602用于实现这些组件之间的连接通信。其中,该宿主机600可选的包含用户接口603,包括显示器(例如触摸屏、液晶显示器、全息成像(holographic)或者投影(projector)等)、点击设备(例如鼠标、轨迹球(trackball)触感板或触摸屏等)、摄像头和/或拾音装置等。Referring to FIG. 6, FIG. 6 is a structural block diagram of a host machine 600 according to another embodiment of the present invention. The host machine 600 can include at least one processor 601, at least one network interface 604, a memory 605, and at least one communication bus 602. Communication bus 602 is used to implement connection communication between these components. Wherein, the host machine 600 optionally includes a user interface 603, including a display (such as a touch screen, a liquid crystal display, a holographic or a projector, etc.), a pointing device (such as a mouse, a trackball touch panel or Touch screen, etc.), camera and/or sound pickup device, etc.
其中,存储器602可以包括只读存储器和随机存取存储器,并向处理器601提供指令和数据。其中,存储器602中的一部分还可以包括非易失性随机存取存储器。The memory 602 can include read only memory and random access memory and provides instructions and data to the processor 601. A portion of the memory 602 may also include a non-volatile random access memory.
在一些实施方式中,存储器605存储了如下的元素,可执行模块或者数据结构,或者他们的子集,或者他们的扩展集:In some implementations, the memory 605 stores the following elements, executable modules or data structures, or a subset thereof, or their extension set:
操作系统6051,包含各种系统程序,用于实现各种基础业务以及处理基于硬件的任务。The operating system 6051 includes various system programs for implementing various basic services and processing hardware-based tasks.
应用程序模块6052,包含各种应用程序,用于实现各种应用业务。The application module 6052 includes various applications for implementing various application services.
应用程序模块6052中可包括但不限于存储单元410、调用单元420、翻译单元430、执行单元440和重定位单元450中的至少一个等。The application module 6052 may include, but is not limited to, at least one of the storage unit 410, the calling unit 420, the translation unit 430, the execution unit 440, and the relocation unit 450.
在本发明实施例中,上述宿主机600和上述客户机支持不同的指令集体系架构。存储器605用于存储上述宿主机支持的第一共享库、上述宿主机支持的第二共享库和客户机支持的第三共享库。In the embodiment of the present invention, the host machine 600 and the client support different instruction set architectures. The memory 605 is configured to store the first shared library supported by the host, the second shared library supported by the host, and the third shared library supported by the client.
其中,上述第一共享库包括翻译函数。Wherein, the first shared library includes a translation function.
在本发明实施例中,通过调用存储器605存储的程序或指令,处理器601当上述第二共享库中的第一函数被调用时,执行上述第一函数以调用上述第一共享库中的翻译函数;利用上述调用的第一共享库中的翻译函数,对上述第三共享库中的函数接口与上述第一函数的函数接口相同的第二函数进行翻译,以 得到上述宿主机支持的第三函数;其中,上述第三函数的函数接口和上述第二函数的函数接口相同;执行上述第三函数。In the embodiment of the present invention, the processor 601 executes the first function to invoke the translation in the first shared library when the first function in the second shared library is invoked by calling the program or instruction stored in the memory 605. a function: using the translation function in the first shared library called to translate the function function interface in the third shared library and the second function function interface of the first function Obtaining a third function supported by the host machine; wherein the function interface of the third function is the same as the function interface of the second function; and the third function is executed.
可选的,在本发明一些可能的实施方式中,上述存储器605还用于存储上述宿主机支持的第五共享库;若上述第二函数包括调用上述客户机支持的第四共享库中的第四函数的指令;处理器601还可用于:将上述第二函数包括的调用上述第四共享库中的第四函数的指令,翻译成调用上述第五共享库中的第五函数的指令,其中,上述第四函数和上述第五函数的函数功能相同,或者,上述第四函数和上述第五函数的函数功能和函数接口均相同。Optionally, in some possible implementation manners of the present invention, the foregoing memory 605 is further configured to store a fifth shared library supported by the host machine, where the second function includes a fourth shared library that is supported by the client. The instruction of the four functions; the processor 601 is further configured to: translate the instruction of the second function included in the second shared library included in the second function to an instruction that invokes the fifth function in the fifth shared library, wherein The functions of the fourth function and the functions of the fifth function are the same, or the function functions and function interfaces of the fourth function and the fifth function are the same.
可选的,在本发明另一些可能的实施方式中,上述存储器605还用于存储上述宿主机支持的第五共享库,当上述第三函数调用上述客户机支持的第四共享库中的第四函数时,上述处理器601还用于:将上述第三函数包括的调用上述客户机支持的第四共享库中的第四函数的指令,翻译成上述第三函数调用上述第五共享库中第五函数的指令;上述第四函数和上述第五函数的函数功能相同,或者,上述第四函数和上述第五函数的函数功能和函数接口均相同。Optionally, in another possible implementation manner of the present invention, the foregoing memory 605 is further configured to store a fifth shared library supported by the host, where the third function invokes a fourth shared library supported by the client. In the fourth function, the processor 601 is further configured to: translate the instruction included in the third function, which is the fourth function in the fourth shared library supported by the client, into the third function to invoke the fifth shared library. The instruction of the fifth function; the function of the fourth function and the function of the fifth function are the same, or the function and function interface of the fourth function and the fifth function are the same.
可选的,在本发明一些可能的实施方式中,上述存储器605还用于存储上述宿主机支持的第二主程序,若上述第二函数包括调用上述客户机支持的第一主程序中的第六函数的指令,处理器601还用于:Optionally, in some possible implementation manners of the present invention, the foregoing memory 605 is further configured to store the second main program supported by the host, if the second function includes the first one of the first main programs supported by the client. The six function instruction, the processor 601 is also used to:
将上述第二函数包括的上述调用上述客户机支持的第一主程序中的第六函数的指令,翻译成调用上述第二主程序中的第七函数的指令,其中,上述第六函数和上述第七函数的函数功能相同,或者,上述第六函数和上述第七函数的函数功能和函数接口均相同。Translating, by the foregoing second function, the instruction for calling the sixth function in the first main program supported by the client to an instruction for calling the seventh function in the second main program, wherein the sixth function and the foregoing The functions of the seventh function are the same, or the function functions and function interfaces of the sixth function and the seventh function described above are the same.
可选的,在本发明另一些可能的实施方式中,上述存储器605还用于存储上述宿主机支持的第二主程序,当上述第三函数调用上述客户机支持的第一主程序中的第六函数时,上述处理器601还用于:将上述第三函数包括的调用上述客户机支持的第一主程序中的第六函数的指令,翻译成上述第三函数调用上述第二主程序中的第七函数的调用,上述第六函数和上述第七函数的函数功能相同,或者,上述第六函数和上述第七函数的函数功能和函数接口均相同。Optionally, in another possible implementation manner of the present invention, the foregoing memory 605 is further configured to store a second main program supported by the host, where the third function invokes a first main program supported by the client. The processor 601 is further configured to: translate the instruction included in the third function, which is the sixth function included in the first main program supported by the client, into the third function, and invoke the second main program. The function of the seventh function is the same as the function of the sixth function and the function function of the seventh function.
可选的,在本发明一些可能的实施方式中,当上述第二函数包括以上述客 户机支持的第十函数的函数指针作为传入参数,以调用上述宿主机支持的第八函数的调用指令,上述处理器601还可用于:将上述以上述客户机支持的第十函数的函数指针作为传入参数,以调用上述宿主机支持的第八函数的调用指令,替换为以上述宿主机支持的第九函数的函数指针作为传入参数,以调用上述宿主机支持的第八函数的调用指令;当上述第九函数被调用时,执行上述第九函数以调用上述第一共享库中的翻译函数对上述第十函数进行翻译,得到上述宿主机支持的第十一函数。Optionally, in some possible implementation manners of the present invention, when the foregoing second function includes the foregoing The function pointer of the tenth function supported by the home machine is used as an incoming parameter to invoke the calling instruction of the eighth function supported by the host, and the processor 601 can also be used to: the function of the tenth function supported by the above client. The pointer is used as an incoming parameter, and the calling instruction of the eighth function supported by the above host is called, and the function pointer of the ninth function supported by the host is used as an incoming parameter to call the eighth function supported by the host. Calling the instruction; when the ninth function is called, executing the ninth function to invoke the translation function in the first shared library to translate the tenth function to obtain the eleventh function supported by the host.
可选的,在本发明一些可能的实施方式中,当上述第二函数包括以第一结构体作为传入参数调用第十二函数的调用指令,处理器601还用于将上述以第一结构体作为传入参数调用第十二函数的调用指令,翻译为,以第二结构体作为传入参数调用第十二函数的调用指令,其中,上述第一结构体包含的域为上述第二结构体包含的域的子集。其中,上述第一结构体为上述客户机支持的结构体,且上述第二结构体为上述宿主机支持的结构体,且上述第十二函数为上述宿主机支持的函数。或者,上述第一结构体可为上述宿主机支持的结构体,并且上述第二结构体为上述客户机支持的结构体,并且上述第十二函数为上述上述客户机支持的函数。Optionally, in some possible implementation manners of the present invention, when the second function includes a call instruction that invokes a twelfth function with the first structure as an incoming parameter, the processor 601 is further configured to use the first structure The body invokes the call instruction of the twelfth function as an incoming parameter, and translates to call the twelfth function with the second structure as the incoming parameter, wherein the first structure includes the second structure A subset of the fields that the body contains. The first structure is a structure supported by the client, and the second structure is a structure supported by the host, and the twelfth function is a function supported by the host. Alternatively, the first structure may be a structure supported by the host, and the second structure is a structure supported by the client, and the twelfth function is a function supported by the client.
可选的,在本发明另一些可能的实施方式中,当上述第二函数包括以第一结构体指针作为传入参数调用第十三函数的调用指令,处理器601还用于上述宿主机将上述以第一结构体指针作为传入参数调用第十三函数的调用指令,翻译为,以第二结构体指针作为传入参数调用第十三函数的调用指令;其中,上述第一结构体指针指向第一结构体,上述第二结构体指针指向第二结构体,其中,上述第一结构体包含的域为上述第二结构体包含的域的子集。其中,上述第一结构体为客户机支持的结构体,且上述第二结构体为宿主机支持的结构体,且上述第十三函数为上述宿主机支持的函数。或者上述第一结构体为宿主机支持的结构体,并且上述第二结构体为客户机支持的结构体,且上述第十三函数为上述客户机支持的函数。Optionally, in another possible implementation manner of the present invention, when the second function includes a call instruction that invokes a thirteenth function by using the first structure body pointer as an incoming parameter, the processor 601 is further configured to use the host machine. The calling instruction that invokes the thirteenth function by using the first structure body pointer as an incoming parameter is translated into a calling instruction that calls the thirteenth function with the second structure body pointer as an incoming parameter; wherein the first structure body pointer Pointing to the first structure, the second structure pointer points to the second structure, wherein the first structure includes a domain that is a subset of the domains included in the second structure. The first structure is a structure supported by a client, and the second structure is a structure supported by a host, and the thirteenth function is a function supported by the host. Or the first structure is a structure supported by the host, and the second structure is a structure supported by the client, and the thirteenth function is a function supported by the client.
可选的,在本发明一些可能的实施方式中,处理器601还用于在对第三共享库中的第一函数进行翻译以得到第二函数之前,对上述第三共享库和上述宿 主机的同名全局变量进行符号重定位。Optionally, in some possible implementation manners of the present invention, the processor 601 is further configured to: before the first function in the third shared library is translated to obtain the second function, to the foregoing third shared library and the foregoing The host's global variable of the same name is symbol relocated.
例如,处理器601还用于,若上述第三共享库包含的第一全局变量和上述宿主机的N个全局变量同名,将上述第一全局变量和上述N个全局变量之中最先加载的全局变量的地址,设定为上述N个全局变量和上述第一全局变量的公共地址。For example, the processor 601 is further configured to: if the first global variable included in the third shared library and the N global variables of the host have the same name, first load the first global variable and the N global variables The address of the global variable is set to the above N global variables and the public address of the first global variable.
又例如,处理器601还用于在上述第二共享库中被加载之后,将上述第三共享库中的第一全局变量的地址,重定位为上述第二共享库中的第二全局变量的地址,其中,上述第一全局变量和上述第二全局变量的声明相同。For another example, the processor 601 is further configured to relocate an address of the first global variable in the third shared library to a second global variable in the second shared library after being loaded in the second shared library. An address, wherein the first global variable and the second global variable are declared the same.
可以理解的是,本实施例的宿主机600的各功能模块的功能可根据上述方法实施例中的方法具体实现,其具体实现过程可以参照上述方法实施例的相关描述,此处不再赘述。It is to be understood that the functions of the functional modules of the host device 600 of the present embodiment may be specifically implemented according to the method in the foregoing method embodiments. For the specific implementation process, reference may be made to the related description of the foregoing method embodiments, and details are not described herein again.
可以看出,本实施例方案中,引入的宿主机600支持的第二共享库,可看成是客户机支持的第三共享库的一个伪共享库,因为,所述第二共享库中的第一函数和所述第三共享库中的第二函数的函数接口相同,所述第二共享库中的第一函数主要是用来触发调用第一共享库是来翻译第三共享库中的具有相同函数接口的函数,而这就可使得宿主机600上的主程序或其他共享库,可以第二共享库为桥梁,通过调用第二共享库中的某函数,来间接的调用被第一共享库中的翻译函数所翻译的第三共享库中的具有相同函数接口的另一函数,由于第二共享库是宿主机600支持的,因此,宿主机600上的主程序或其他共享库能够识别和直接调用第二共享库中的函数,这样可实现即使不对客户机上依赖第三共享库的主程序或其他依赖的共享库进行翻译,也可对客户机上的第三共享库间接调用执行,这样就极大的降低了第三共享库与客户机的支持主程序(或其他相关共享库)之间的强依赖性,这有利于极大减少翻译代码量,从而可提高二进制翻译执行的效率,进而提升用户体验。It can be seen that, in the solution of the embodiment, the second shared library supported by the host 600 can be regarded as a pseudo shared library of the third shared library supported by the client, because the second shared library The first function is the same as the function interface of the second function in the third shared library, and the first function in the second shared library is mainly used to trigger the calling of the first shared library to translate the third shared library. A function having the same function interface, and this allows the main program or other shared library on the host machine 600 to be the second shared library as a bridge, and the indirect call is first by calling a function in the second shared library. Another function having the same function interface in the third shared library translated by the translation function in the shared library, since the second shared library is supported by the host 600, the main program or other shared library on the host machine 600 can Identifying and directly calling functions in the second shared library, so that even if the main program on the client that depends on the third shared library or other dependent shared libraries is not translated, the third total on the client The library indirectly calls the execution, which greatly reduces the strong dependency between the third shared library and the client's supporting main program (or other related shared libraries), which helps to greatly reduce the amount of translation code, thereby improving The efficiency of binary translation execution, which in turn enhances the user experience.
参见图7,本发明实施例还提供一种通信系统,可包括:第一计算节点710和第二计算节点720。其中,第一计算节点710和第二计算节点720可通过互联网络互联。Referring to FIG. 7, an embodiment of the present invention further provides a communication system, which may include: a first computing node 710 and a second computing node 720. The first computing node 710 and the second computing node 720 can be interconnected by an internetwork.
其中,上述第二计算节点720和上述第一计算节点710支持不同的指令集体 系架构。上述第二计算节点720包括上述第二计算节点720支持的第一共享库和上述第二计算节点720支持的第二共享库。其中,第一共享库包括翻译函数。The second computing node 720 and the first computing node 710 support different instruction collectives. Department architecture. The second computing node 720 includes a first shared library supported by the second computing node 720 and a second shared library supported by the second computing node 720. Wherein, the first shared library includes a translation function.
第一计算节点710,用于向第二计算节点720发送第一计算节点710支持的第三共享库。The first computing node 710 is configured to send, to the second computing node 720, a third shared library supported by the first computing node 710.
第二计算节点720,用于接收来自第一计算节点710的第三共享库;当上述第二共享库中的第一函数被调用时,执行上述第一函数以调用上述第一共享库中的翻译函数;利用上述调用的上述第一共享库中的翻译函数,对上述第三共享库中的函数接口与上述第一函数的函数接口相同的第二函数进行翻译,以得到上述第二计算节点720支持的第三函数;上述第三函数的函数接口和上述第二函数的函数接口相同;执行上述第三函数。a second computing node 720, configured to receive a third shared library from the first computing node 710; when the first function in the second shared library is invoked, execute the first function to invoke the first shared library Translating a function; using the translation function in the first shared library mentioned above, translating the function function interface in the third shared library with the second function function interface of the first function to obtain the second computing node The third function supported by 720; the function interface of the third function is the same as the function interface of the second function; and the third function is executed.
可以理解,上述第二共享库中的上述第一函数例如可为第二共享库中的任意一个函数,或者,上述第二共享库中的上述第一函数也可为第二共享库中的某个特定的函数。It is to be understood that the first function in the second shared library may be any one of the second shared libraries, or the first function in the second shared library may be any one of the second shared libraries. a specific function.
其中,对上述第二函数进行翻译可能涉及多方面,具体翻译方式也可能是多种多样,下面进行举例说明。Among them, the translation of the above second function may involve various aspects, and the specific translation manner may also be various, as exemplified below.
在本发明的一些可能的实施方式中,上述第二计算节点720中还包括上述第二计算节点720支持的第五共享库;若上述第二函数包括调用上述第一计算节点710支持的第四共享库中的第四函数的指令,上述第二计算节点720还用于将上述第二函数包括的调用上述第四共享库中的第四函数的指令,翻译成调用上述第五共享库中的第五函数的指令,其中,上述第四函数和上述第五函数的函数功能相同,或者,上述第四函数和上述第五函数的函数功能和函数接口均相同。可以理解,上述第二计算节点720将上述第二函数包括的调用上述第四共享库中的第四函数的指令,翻译成调用上述第五共享库中的第五函数的指令,本质上可看做是一种库函数包装技术,即将对第一计算节点710支持的某共享库中的某函数的调用,替换为对第二计算节点720支持的某共享库中的函数功能相同或函数功能和函数接口均相同的函数的调用,这样有利于提高对第二计算节点720的本地共享库的利用率,进一步减少对第一计算节点710相关共享库的函数代码的翻译,进而有利于进一步减少代码翻译量。 In some possible implementation manners of the present invention, the second computing node 720 further includes a fifth shared library supported by the second computing node 720; if the second function includes the fourth supported by the first computing node 710 The instruction of the fourth function in the shared library, the second computing node 720 is further configured to translate the instruction included in the second function, which is the fourth function in the fourth shared library, into the calling the fifth shared library. The instruction of the fifth function, wherein the functions of the fourth function and the function of the fifth function are the same, or the function functions and function interfaces of the fourth function and the fifth function are the same. It can be understood that the foregoing second computing node 720 translates the instruction of the second function included in the second shared library that is included in the second function into an instruction that invokes the fifth function in the fifth shared library, which is substantially It is a library function packaging technology, that is, the call of a function in a shared library supported by the first computing node 710 is replaced by the function function or function function of a shared library supported by the second computing node 720. The function interface is the same function call, which is beneficial to improve the utilization of the local shared library of the second computing node 720, further reducing the translation of the function code of the shared library associated with the first computing node 710, thereby further reducing the code. Translation volume.
在本发明的另一些可能的实施方式中,上述第二计算节点720中还包括上述第二计算节点720支持的第五共享库,当上述第三函数调用上述第一计算节点710支持的第四共享库中的第四函数时,第二计算节点720还用于,将上述第三函数包括的调用上述第一计算节点710支持的第四共享库中的第四函数的指令,翻译成上述第三函数调用上述第五共享库中第五函数的指令;其中上述第四函数和上述第五函数的函数功能和函数接口均相同,或者上述第四函数和上述第五函数的函数功能相同。可以理解的是,上述第二计算节点720将上述第三函数包括的调用上述第四共享库中的第四函数的指令,翻译成调用上述第五共享库中的第五函数的指令,本质上可看做是一种库函数包装技术,即,可将对第一计算节点710支持的某共享库中的某函数的调用,替换为对第二计算节点720支持的某共享库中的函数功能相同或函数功能和函数接口均相同的函数的调用,这样有利于提高对第二计算节点720本地共享库的利用率,进一步减少对第一计算节点710相关共享库的函数代码的翻译,进而有利于进一步减少代码翻译量。In another possible implementation manner of the present invention, the second computing node 720 further includes a fifth shared library supported by the second computing node 720, where the third function invokes the fourth supported by the first computing node 710. When the fourth function in the library is shared, the second computing node 720 is further configured to translate the instruction of the fourth function included in the third shared library supported by the first computing node 710 into the foregoing The third function calls the instruction of the fifth function in the fifth shared library; wherein the function function and the function interface of the fourth function and the fifth function are the same, or the functions of the fourth function and the fifth function are the same. It can be understood that the foregoing second computing node 720 translates the instruction of the third function included in the third function, which is called the fourth function in the fourth shared library, into an instruction that invokes the fifth function in the fifth shared library, in essence, It can be seen as a library function packaging technique, that is, the function of a function in a shared library supported by the first computing node 710 can be replaced with a function function in a shared library supported by the second computing node 720. The same or the function function and the function interface are the same function call, which is beneficial to improve the utilization of the second shared node 720 local shared library, further reducing the translation of the function code of the shared library associated with the first computing node 710, and thus Help to further reduce the amount of code translation.
在本发明的一些可能的实施方式中,上述第二计算节点720中还包括上述第二计算节点720支持的第二主程序,若上述第二函数包括调用上述第一计算节点710支持的第一主程序中的第六函数的指令,上述第二计算节点720还用于将上述第二函数包括的上述调用上述第一计算节点710支持的第一主程序中的第六函数的指令,翻译成调用上述第二主程序中的第七函数的指令,其中,上述第六函数和上述第七函数的函数功能相同,或者,上述第六函数和上述第七函数的函数功能和函数接口均相同。可以理解,将上述第二函数包括的上述调用上述第一计算节点710支持的第一主程序中的第六函数的指令,翻译成调用上述第二主程序中的第七函数的指令,本质上可看做是一种库函数包装技术,即将对第一计算节点710支持的主程序中的某函数的调用,替换为对第二计算节点720支持的主程序中的函数功能相同或函数功能和函数接口均相同的函数的调用,这样有利于提高对第二计算节点720的本地共享库的利用率,进一步减少对第一计算节点710相关共享库的函数代码的翻译,进而有利于进一步减少代码翻译量。 In some possible implementation manners of the present invention, the second computing node 720 further includes a second main program supported by the second computing node 720, where the second function includes calling the first supported by the first computing node 710. The second function node 720 is further configured to translate the instruction of the sixth function included in the first main program supported by the first computing node 710, which is included in the second function, into the instruction of the sixth function in the main program. The instruction of the seventh function in the second main program is called, wherein the functions of the sixth function and the seventh function are the same, or the function functions and function interfaces of the sixth function and the seventh function are the same. It can be understood that the above-mentioned second function includes the instruction that invokes the sixth function in the first main program supported by the first computing node 710, and translates the instruction into the seventh function in the second main program, essentially It can be regarded as a library function packaging technology, that is, the call of a function in the main program supported by the first computing node 710 is replaced by the function function or the function function in the main program supported by the second computing node 720. The function interface is the same function call, which is beneficial to improve the utilization of the local shared library of the second computing node 720, further reducing the translation of the function code of the shared library associated with the first computing node 710, thereby further reducing the code. Translation volume.
在本发明的另一些可能的实施方式中,上述第二计算节点720中还包括上述第二计算节点720支持的第二主程序,当上述第三函数调用上述第一计算节点710支持的第一主程序中的第六函数时,上述第二计算节点720还用于将上述第三函数包括的调用上述第一计算节点710支持的第一主程序中的第六函数的指令,翻译成上述第三函数调用上述第二主程序中的第七函数的调用,上述第六函数和上述第七函数的函数功能相同,或者,上述第六函数和上述第七函数的函数功能和函数接口均相同。可以理解的是,将上述第三函数包括的上述调用上述第一计算节点710支持的第一主程序中的第六函数的指令,翻译成调用上述第二主程序中的第七函数的指令,本质上可看做是一种库函数包装技术,即,可以将对第一计算节点710支持的主程序中的某函数的调用,替换为对第二计算节点720支持的主程序中的函数功能相同或函数功能和函数接口均相同的函数的调用,这样有利于提高对第二计算节点720的本地共享库的利用率,进一步减少对第一计算节点710相关共享库的函数代码的翻译,进而有利于进一步减少代码翻译量。In another possible implementation manner of the present invention, the second computing node 720 further includes a second main program supported by the second computing node 720, where the third function invokes the first supported by the first computing node 710. In the sixth function of the main program, the second computing node 720 is further configured to translate the instruction included in the third function, which is the sixth function in the first main program supported by the first computing node 710, into the foregoing The three functions call the call of the seventh function in the second main program, the functions of the sixth function and the function of the seventh function are the same, or the function functions and function interfaces of the sixth function and the seventh function are the same. It can be understood that the above-mentioned third function includes the instruction that invokes the sixth function in the first main program supported by the first computing node 710, and translates the instruction into the seventh function in the second main program. Essentially, it can be regarded as a library function packaging technique, that is, the function of a function in the main program supported by the first computing node 710 can be replaced with the function function in the main program supported by the second computing node 720. The same or the function function and the function interface are the same function call, which is beneficial to improve the utilization of the local shared library of the second computing node 720, further reducing the translation of the function code of the shared library associated with the first computing node 710, and further Help to further reduce the amount of code translation.
在本发明的一些可能的实施方式中,当上述第二函数包括以上述第一计算节点710支持的第十函数的函数指针作为传入参数,以调用上述第二计算节点720支持的第八函数的调用指令,上述第二计算节点720还用于,将上述以上述第一计算节点710支持的第十函数的函数指针作为传入参数,以调用上述第二计算节点720支持的第八函数的调用指令,替换为,以上述第二计算节点720支持的第九函数的函数指针作为传入参数,以调用上述第二计算节点720支持的第八函数的调用指令。其中,当上述第九函数被调用时,上述第二计算节点720执行上述第九函数以调用上述第一共享库中的翻译函数对上述第十函数进行翻译,得到上述第二计算节点720支持的第十一函数,上述第二计算节点720执行上述第十一函数。可以理解,在上述存在函数指针的场景下,引入上述第九函数作为桥梁,有利于实现在较合适的时机对函数指针所指向的函数进行翻译,有利于尽量避免出现错误。In some possible implementation manners of the present invention, when the second function includes a function pointer of the tenth function supported by the first computing node 710 as an incoming parameter, the eighth function supported by the second computing node 720 is invoked. The second computing node 720 is further configured to use the function pointer of the tenth function supported by the first computing node 710 as an incoming parameter to invoke the eighth function supported by the second computing node 720. The instruction is invoked, and the function pointer of the ninth function supported by the second computing node 720 is used as an incoming parameter to invoke the calling instruction of the eighth function supported by the second computing node 720. When the ninth function is called, the second computing node 720 executes the ninth function to invoke the translation function in the first shared library to translate the tenth function, and the second computing node 720 supports the second computing node 720. In the eleventh function, the second computing node 720 executes the eleventh function described above. It can be understood that, in the above scenario where the function pointer exists, the introduction of the ninth function as a bridge is beneficial to realizing the translation of the function pointed to by the function pointer at a suitable timing, which is beneficial to avoid errors as much as possible.
在本发明的一些可能的实施方式中,当上述第三年函数包括以上述第二计算节点720支持的函数S01的函数指针作为传入参数,以调用上述第二计算节点 720支持的S02函数的调用指令,当上述函数S01被调用时,上述第二计算节点720执行上述函数S01,第二计算节点720不翻译上述函数S001。In some possible implementation manners of the present invention, when the third year function includes a function pointer of the function S01 supported by the second computing node 720 as an incoming parameter, the second computing node is invoked. The calling instruction of the S02 function supported by 720, when the above function S01 is called, the second computing node 720 executes the above function S01, and the second computing node 720 does not translate the function S001.
在本发明一些可能的实施方式中,当上述第二函数包括以第一结构体作为传入参数调用第十二函数的调用指令,上述第二计算节点720还用于,将上述以第一结构体作为传入参数调用第十二函数的调用指令,翻译为,以第二结构体作为传入参数调用第十二函数的调用指令,上述第一结构体包含的域为上述第二结构体包含的域的子集。上述第一结构体为上述第一计算节点710支持的结构体,并且上述第二结构体为上述第二计算节点720支持的结构体,且上述第十二函数为上述第二计算节点720支持的函数;或者上述第一结构体为上述第二计算节点720支持的结构体,且上述第二结构体为上述第一计算节点710支持的结构体,且上述第十二函数为上述上述第一计算节点710支持的函数。例如,上述第一结构体包含的域与上述第二结构体包含的域可以相同。In some possible implementation manners of the present invention, when the second function includes a call instruction that invokes a twelfth function with the first structure as an incoming parameter, the second computing node 720 is further configured to: The body invokes the call instruction of the twelfth function as an incoming parameter, and translates to call the twelfth function with the second structure as the incoming parameter, and the first structure includes the domain containing the second structure A subset of the domain. The first structure is a structure supported by the first computing node 710, and the second structure is a structure supported by the second computing node 720, and the twelfth function is supported by the second computing node 720. a function; or the first structure is a structure supported by the second computing node 720, and the second structure is a structure supported by the first computing node 710, and the twelfth function is the first calculating The function supported by node 710. For example, the domain included in the first structure may be the same as the domain included in the second structure.
在本发明一些可能的实施方式中,当上述第二函数包括以第一结构体指针作为传入参数调用第十三函数的调用指令,上述第二计算节点720还用于,将上述以第一结构体指针作为传入参数调用第十三函数的调用指令,翻译为,以第二结构体指针作为传入参数调用第十三函数的调用指令。其中,上述第一结构体指针指向第一结构体,上述第二结构体指针指向第二结构体,上述第一结构体包含的域为上述第二结构体包含的域的子集。其中,上述第一结构体为第一计算节点710支持的结构体,且上述第二结构体为第二计算节点720支持的结构体,且上述第十三函数为上述第二计算节点720支持的函数。或者上述第一结构体为第二计算节点720支持的结构体,并且上述第二结构体为第一计算节点710支持的结构体,且上述第十三函数为上述第一计算节点710支持的函数。例如,上述第一结构体包含的域与上述第二结构体包含的域可以相同。In some possible implementation manners of the present invention, when the second function includes a call instruction that invokes a thirteenth function with the first structure body pointer as an incoming parameter, the second computing node 720 is further configured to: The structure pointer calls the call instruction of the thirteenth function as an incoming parameter, and translates to a call instruction that calls the thirteenth function with the second structure body pointer as an incoming parameter. The first structure pointer points to the first structure, the second structure pointer points to the second structure, and the first structure includes a field that is a subset of the domains included in the second structure. The first structure is a structure supported by the first computing node 710, and the second structure is a structure supported by the second computing node 720, and the thirteenth function is supported by the second computing node 720. function. Or the first structure is a structure supported by the second computing node 720, and the second structure is a structure supported by the first computing node 710, and the thirteenth function is a function supported by the first computing node 710. . For example, the domain included in the first structure may be the same as the domain included in the second structure.
在本发明的一些可能的实施方式中,当上述第二函数的传入参数包括第三结构体,所上述第二计算节点720还用于,将作为上述第二函数的传入参数的第三结构体替换为第四结构体,上述第三结构体包含的域为上述第四结构体包含的域的子集;其中,上述第四结构体为第一计算节点710支持的结构体,且上述第三结构体为第二计算节点720支持的结构体。例如,上述第三结构体包 含的域与上述第四结构体包含的域可以相同。In some possible implementation manners of the present invention, when the incoming parameter of the second function includes the third structure, the second computing node 720 is further configured to use the third parameter as the second function. The structure is replaced by a fourth structure, and the domain included in the third structure is a subset of domains included in the fourth structure; wherein the fourth structure is a structure supported by the first computing node 710, and the above The third structure is a structure supported by the second computing node 720. For example, the above third structural package The domain included may be the same as the domain included in the fourth structure described above.
在本发明的一些可能的实施方式中,当上述第二函数的传入参数包括第三结构体指针,第二计算节点720还用于,将作为上述第二函数的传入参数的上述第三结构体指针替换为第四结构体指针,上述第四结构体指针指向第四结构体,上述第三结构体指针指向第三结构体,上述第三结构体包含的域为上述第四结构体包含的域的子集。其中,上述第四结构体为第一计算节点710支持的结构体,且上述第三结构体为第二计算节点720支持的结构体。例如,上述第三结构体包含的域与上述第四结构体包含的域可以相同。In some possible implementations of the present invention, when the incoming parameter of the second function includes the third structure pointer, the second computing node 720 is further configured to use the third parameter as the incoming parameter of the second function. The structure pointer is replaced with a fourth structure body pointer, the fourth structure body pointer is directed to the fourth structure body, the third structure body pointer is directed to the third structure body, and the third structure body includes a domain containing the fourth structure body A subset of the domain. The fourth structure is a structure supported by the first computing node 710, and the third structure is a structure supported by the second computing node 720. For example, the domain included in the third structure described above may be the same as the domain included in the fourth structure.
其中,上述举例了一些翻译第二函数可能实施方式,以及翻译翻译第二函数还可能涉及与翻译相关的一些其他操作,当然在实际应用,还可能涉及其他的翻译操作,当然上述的翻译操作之间也可能相互进行嵌套,具体方式此处不再赘述。Wherein, the above exemplifies some possible implementations of the translation second function, and the translation translation second function may also involve some other operations related to translation, of course, in practical applications, other translation operations may also be involved, of course, the above translation operations They may also be nested with each other, and the specific methods are not described here.
此外,在本发明的一些可能的实施方式中,上述对第三共享库中的第一函数进行翻译以得到第二函数之前,上述第二计算节点720还用于,对上述第三共享库和上述第二计算节点720的同名全局变量进行符号重定位。In addition, in some possible implementation manners of the present invention, before the first function in the third shared library is translated to obtain the second function, the second computing node 720 is further configured to use the third shared library and The global variable of the same name of the second computing node 720 described above performs symbol relocation.
例如,上述第二计算节点720对上述第三共享库和上述第二计算节点720的同名全局变量进行符号重定位包括:若上述第三共享库包含的第一全局变量和上述第二计算节点720的N个全局变量同名,上述第二计算节点720将上述第一全局变量和上述N个全局变量之中最先加载的全局变量的地址,设定为上述N个全局变量和上述第一全局变量的公共地址。For example, the second computing node 720 performing symbol relocation on the global variable of the same name of the third shared library and the second computing node 720 includes: if the third shared library includes the first global variable and the second computing node 720 The N global variables have the same name, and the second computing node 720 sets the addresses of the first global variable and the first global variable loaded among the N global variables to the N global variables and the first global variable. Public address.
又例如,上述第二计算节点720对上述第三共享库和上述第二计算节点720的同名全局变量进行符号重定位包括:在上述第二共享库中被加载之后,上述第二计算节点720将上述第三共享库中的第一全局变量的地址,重定位为上述第二共享库中的第二全局变量的地址,其中,上述第一全局变量和上述第二全局变量的声明相同。For another example, the second computing node 720 performing symbol relocation on the global variable of the same name of the third shared library and the second computing node 720 includes: after being loaded in the second shared library, the second computing node 720 The address of the first global variable in the third shared library is relocated to the address of the second global variable in the second shared library, wherein the declaration of the first global variable and the second global variable is the same.
可以理解的是,上述第一全局变量可为上述第三共享库包含的任意一个全局变量。或者,上述第一全局变量也可为上述第三共享库包含的某个特定的全局变量。 It can be understood that the first global variable may be any global variable included in the third shared library. Alternatively, the first global variable may also be a specific global variable included in the third shared library.
其中,本发明实施例的第二计算节点720和第一计算节点710支持不同的指令集体系架构,例如第二计算节点720和第一计算节点710可分别支持如下指令集体系架构中的其中一种:POWER指令集体系架构、x86指令集体系架构、龙芯指令集体系架构和MIPS指令集体系架构。The second computing node 720 and the first computing node 710 of the embodiment of the present invention support different instruction set architectures. For example, the second computing node 720 and the first computing node 710 can respectively support one of the following instruction set architectures. Kinds: POWER instruction set architecture, x86 instruction set architecture, Loongson instruction set architecture and MIPS instruction set architecture.
可以理解的是,本实施例的宿主机400的各功能模块的功能可根据上述方法实施例中的方法具体实现,其具体实现过程可以参照上述方法实施例的相关描述,此处不再赘述。It is to be understood that the functions of the functional modules of the host 400 of the present embodiment may be specifically implemented according to the method in the foregoing method embodiments. For the specific implementation process, refer to the related description of the foregoing method embodiments, and details are not described herein again.
可以看出,本实施例方案中,支持不同的指令集体系架构的第二计算节点720和上述第一计算节点710可互传各自支持的共享库,例如上述第一计算节点710向第二计算节点720传递第三共享库,其中,在第二计算节点720中引入的第二计算节点720支持的第二共享库,可看成是第一计算节点710支持的第三共享库的一个伪共享库,因为,第二共享库中的第一函数和所述第三共享库中的第二函数的函数接口相同,所述第二共享库中的第一函数主要是用来触发调用第一共享库是来翻译第三共享库中的具有相同函数接口的函数,而这就可使得第二计算节点720上的主程序或其他共享库,可以第二共享库为桥梁,通过调用第二共享库中的某函数,来间接的调用被第一共享库中的翻译函数所翻译的第三共享库中的具有相同函数接口的另一函数,由于第二共享库是第二计算节点720支持的,因此,第二计算节点720上的主程序或其他共享库能够识别和直接调用第二共享库中的函数,这样可实现即使不对第一计算节点710上依赖第三共享库的主程序或其他依赖的共享库进行翻译,也可对第一计算节点710上的第三共享库间接调用执行,这样就极大的降低了第三共享库与第一计算节点710的支持主程序(或其他相关共享库)之间的强依赖性,这有利于极大减少翻译代码量,从而可提高二进制翻译执行的效率,进而提升用户体验。It can be seen that, in the solution of the embodiment, the second computing node 720 supporting the different instruction set architectures and the first computing node 710 can mutually transmit the shared libraries supported by each, for example, the foregoing first computing node 710 performs the second computing. The node 720 passes the third shared library, wherein the second shared library supported by the second computing node 720 introduced in the second computing node 720 can be regarded as a pseudo shared by the third shared library supported by the first computing node 710. a library, because the first function in the second shared library and the function interface of the second function in the third shared library are the same, the first function in the second shared library is mainly used to trigger the first share to be called The library is to translate the function of the third shared library with the same function interface, and this can make the main program or other shared library on the second computing node 720, the second shared library can be used as a bridge, by calling the second shared library. a function in the indirect call to another function in the third shared library translated by the translation function in the first shared library having the same function interface, since the second shared library is the second computational section Supported by 720, therefore, the main program or other shared library on the second computing node 720 can recognize and directly invoke functions in the second shared library, such that even if the third computing library is not dependent on the first computing node 710 The program or other dependent shared library is translated, and the third shared library on the first computing node 710 can also be invoked indirectly, which greatly reduces the supporting main program of the third shared library and the first computing node 710 ( Strong dependencies between other related shared libraries), which greatly reduces the amount of translation code, which improves the efficiency of binary translation execution and thus improves the user experience.
进一步的,由于第一共享库是包含翻译函数,即将二进制翻译器编译成第一共享库,在需调用第一计算节点710支持的第三共享库中的函数时,第一共享库才对被调用的相关函数进行动态翻译,这样有利于提高翻译的针对性和有效性,有利于减少无效翻译工作量,进而有利于进一步减少翻译代码量,从而进一步提高二进制翻译的执行效率,进而进一步提升用户体验。 Further, since the first shared library includes a translation function, that is, the binary translator is compiled into the first shared library, when the function in the third shared library supported by the first computing node 710 is called, the first shared library is The related functions are called for dynamic translation, which is beneficial to improve the pertinence and effectiveness of translation, and is beneficial to reduce the amount of invalid translation work, thereby further reducing the amount of translation code, thereby further improving the execution efficiency of binary translation, thereby further enhancing users. Experience.
本发明实施例还提供一种计算机存储介质,其中,该计算机存储介质可存储有程序,该程序执行时包括上述方法实施例中记载的任意一种共享库的二进制翻译执行方法的部分或全部步骤。The embodiment of the present invention further provides a computer storage medium, wherein the computer storage medium may store a program, where the program includes some or all of the steps of the binary translation execution method of any one of the shared libraries described in the foregoing method embodiments. .
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本发明并不受所描述的动作顺序的限制,因为依据本发明,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定是本发明所必须的。It should be noted that, for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations, but those skilled in the art should understand that the present invention is not limited by the described action sequence. Because certain steps may be performed in other sequences or concurrently in accordance with the present invention. In addition, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。In the above embodiments, the descriptions of the various embodiments are different, and the details that are not detailed in a certain embodiment can be referred to the related descriptions of other embodiments.
在本申请所提供的几个实施例中,应该理解到,所揭露的装置,可通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性或其它的形式。In the several embodiments provided herein, it should be understood that the disclosed apparatus may be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the unit is only a logical function division. In actual implementation, there may be another division manner, for example, multiple units or components may be combined or may be Integrate into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be electrical or otherwise.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全 部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可为个人计算机、服务器或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。The integrated unit, if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention is essential or the part contributing to the prior art or the entire technical solution. The portion or portion may be embodied in the form of a software product stored in a storage medium, including instructions for causing a computer device (which may be a personal computer, server or network device, etc.) to perform various embodiments of the present invention. All or part of the steps of the method described. The foregoing storage medium includes: a U disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk, and the like. .
以上所述,以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。 The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to be limiting; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art will understand that The technical solutions described in the embodiments are modified, or some of the technical features are replaced by equivalents; and the modifications or substitutions do not deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims (23)

  1. 一种共享库的二进制翻译执行方法,其特征在于,所述方法应用于宿主机,所述宿主机中包括所述宿主机支持的第一共享库、所述宿主机支持的第二共享库和客户机支持的第三共享库,所述第一共享库包括翻译函数,所述宿主机和所述客户机支持不同的指令集体系架构,A binary translation execution method of a shared library, wherein the method is applied to a host machine, where the host machine includes a first shared library supported by the host machine, a second shared library supported by the host machine, and a third shared library supported by the client, the first shared library including a translation function, the host and the client supporting different instruction set architectures,
    所述方法包括:The method includes:
    当所述第二共享库中的第一函数被调用时,所述宿主机执行所述第一函数以调用所述第一共享库中的翻译函数;When the first function in the second shared library is called, the host executes the first function to invoke a translation function in the first shared library;
    所述宿主机利用所述调用的所述第一共享库中的翻译函数,对所述第三共享库中的函数接口与所述第一函数的函数接口相同的第二函数进行翻译,以得到所述宿主机支持的第三函数;其中,所述第三函数的函数接口和所述第二函数的函数接口相同;The host machine translates a function function in the third shared library with a second function function of the first function by using a translation function in the first shared library of the call to obtain a second function a third function supported by the host; wherein a function interface of the third function and a function interface of the second function are the same;
    所述宿主机执行所述第三函数。The host executes the third function.
  2. 根据权利要求1所述的方法,其特征在于,所述宿主机中还包括所述宿主机支持的第五共享库;若所述第二函数包括调用所述客户机支持的第四共享库中的第四函数的指令,对所述第二函数进行翻译的步骤,还包括:The method according to claim 1, wherein said host machine further comprises a fifth shared library supported by said host; if said second function comprises calling said fourth shared library supported by said client The instruction of the fourth function, the step of translating the second function, further includes:
    所述宿主机将所述第二函数包括的调用所述第四共享库中的第四函数的指令,翻译成调用所述第五共享库中的第五函数的指令,其中,所述第四函数和所述第五函数的函数功能相同,或者,所述第四函数和所述第五函数的函数功能和函数接口均相同。The host translates, by the second function, an instruction that calls a fourth function in the fourth shared library into an instruction that invokes a fifth function in the fifth shared library, wherein the fourth The function has the same function as the function of the fifth function, or the function functions and function interfaces of the fourth function and the fifth function are the same.
  3. 根据权利要求1所述的方法,其特征在于,所述宿主机中还包括所述宿主机支持的第五共享库,当所述第三函数调用所述客户机支持的第四共享库中的第四函数时,所述方法还包括:The method according to claim 1, wherein the host machine further comprises a fifth shared library supported by the host, when the third function calls a fourth shared library supported by the client. In the fourth function, the method further includes:
    所述宿主机将所述第三函数包括的调用所述客户机支持的第四共享库中的第四函数的指令,翻译成所述第三函数调用所述第五共享库中第五函数的指令;其中,所述第四函数和所述第五函数的函数功能相同,或者,所述第四函数和所述第五函数的函数功能和函数接口均相同。 Transmitting, by the host machine, an instruction of the third function included in the third function that is called by the third function to the third function in the fifth shared library An instruction; wherein the functions of the fourth function and the fifth function are the same, or the function functions and function interfaces of the fourth function and the fifth function are the same.
  4. 根据权利要求1所述的方法,其特征在于,所述宿主机中还包括所述宿主机支持的第二主程序,若所述第二函数包括调用所述客户机支持的第一主程序中的第六函数的指令,对所述第二函数进行翻译的步骤,还包括:The method according to claim 1, wherein said host machine further comprises a second main program supported by said host, if said second function comprises calling said first main program supported by said client The instruction of the sixth function, the step of translating the second function, further includes:
    所述宿主机将所述第二函数包括的所述调用所述客户机支持的第一主程序中的第六函数的指令,翻译成调用所述第二主程序中的第七函数的指令,其中,所述第六函数和所述第七函数的函数功能相同,或者,所述第六函数和所述第七函数的函数功能和函数接口均相同。The host translating, by the second function, the instruction that invokes the sixth function in the first main program supported by the client into an instruction that invokes the seventh function in the second main program, The functions of the sixth function and the seventh function are the same, or the function functions and function interfaces of the sixth function and the seventh function are the same.
  5. 根据权利要求1所述的方法,其特征在于,所述宿主机中还包括所述宿主机支持的第二主程序,当所述第三函数调用所述客户机支持的第一主程序中的第六函数时,所述方法还包括:The method according to claim 1, wherein said host machine further comprises a second main program supported by said host, when said third function calls said first main program supported by said client In the sixth function, the method further includes:
    所述宿主机将所述第三函数包括的调用所述客户机支持的第一主程序中的第六函数的指令,翻译成所述第三函数调用所述第二主程序中的第七函数的调用,其中,所述第六函数和所述第七函数的函数功能相同,或者,所述第六函数和所述第七函数的函数功能和函数接口均相同。The host translates, by the third function, an instruction that calls a sixth function in the first main program supported by the client into a third function, and invokes a seventh function in the second main program. And the functions of the sixth function and the seventh function are the same, or the function functions and function interfaces of the sixth function and the seventh function are the same.
  6. 根据权利要求1所述的方法,其特征在于,当所述第二函数包括以所述客户机支持的第十函数的函数指针作为传入参数,以调用所述宿主机支持的第八函数的调用指令,对所述第二函数进行翻译的步骤,还包括:所述宿主机将所述以所述客户机支持的第十函数的函数指针作为传入参数,以调用所述宿主机支持的第八函数的调用指令,替换为,以所述宿主机支持的第九函数的函数指针作为传入参数,以调用所述宿主机支持的第八函数的调用指令;The method according to claim 1, wherein when said second function comprises a function pointer of a tenth function supported by said client as an incoming parameter to invoke an eighth function supported by said host The step of translating the second function, the method further includes: the host uses the function pointer of the tenth function supported by the client as an incoming parameter to invoke the host support The calling instruction of the eighth function is replaced by a function pointer of the ninth function supported by the host as an incoming parameter to invoke a calling instruction of the eighth function supported by the host;
    其中,当所述第九函数被调用时,所述宿主机执行所述第九函数以调用所述第一共享库中的翻译函数对所述第十函数进行翻译,得到所述宿主机支持的第十一函数,所述宿主机执行所述第十一函数。Wherein, when the ninth function is called, the host executes the ninth function to invoke a translation function in the first shared library to translate the tenth function, to obtain the host support In an eleventh function, the host executes the eleventh function.
  7. 根据权利要求1所述的方法,其特征在于,当所述第二函数包括以第一结构体作为传入参数调用第十二函数的调用指令,对所述第二函数进行翻译的步骤,还包括:The method according to claim 1, wherein when said second function comprises a call instruction for calling a twelfth function with the first structure as an incoming parameter, the step of translating said second function is further include:
    所述宿主机将所述以第一结构体作为传入参数调用第十二函数的调用指令翻译为,以第二结构体作为传入参数调用第十二函数的调用指令,所述第一 结构体包含的域为所述第二结构体包含的域的子集;Transmitting, by the host machine, the calling instruction that invokes the twelfth function with the first structure as an incoming parameter, and calling the calling instruction of the twelfth function with the second structural body as an incoming parameter, the first The domain included in the structure is a subset of the domains included in the second structure;
    其中,所述第一结构体为所述客户机支持的结构体,且所述第二结构体为所述宿主机支持的结构体,且所述第十二函数为所述宿主机支持的函数;The first structure is a structure supported by the client, and the second structure is a structure supported by the host, and the twelfth function is a function supported by the host. ;
    或者,所述第一结构体为所述宿主机支持的结构体,并且所述第二结构体为所述客户机支持的结构体,并且所述第十二函数为所述所述客户机支持的函数。Or the first structure is a structure supported by the host, and the second structure is a structure supported by the client, and the twelfth function is supported by the client The function.
  8. 根据权利要求1所述的方法,其特征在于,The method of claim 1 wherein
    当所述第二函数包括以第一结构体指针作为传入参数调用第十三函数的调用指令,对所述第二函数进行翻译的步骤,还包括:所述宿主机将所述以第一结构体指针作为传入参数调用第十三函数的调用指令,翻译为,以第二结构体指针作为传入参数调用第十三函数的调用指令;When the second function includes a call instruction that invokes the thirteenth function with the first structure body pointer as an incoming parameter, the step of translating the second function further includes: the host machine The structure pointer calls the call instruction of the thirteenth function as an incoming parameter, and translates to a call instruction that calls the thirteenth function with the second structure body pointer as an incoming parameter;
    其中,所述第一结构体指针指向第一结构体,所述第二结构体指针指向第二结构体,所述第一结构体包含的域为所述第二结构体包含的域的子集;Wherein the first structure body pointer points to the first structure body, the second structure body pointer points to the second structure body, and the first structure body includes a domain that is a subset of the domain included in the second structure body ;
    其中,所述第一结构体为客户机支持的结构体,且所述第二结构体为宿主机支持的结构体,且所述第十三函数为所述宿主机支持的函数;或者所述第一结构体为宿主机支持的结构体,并且所述第二结构体为客户机支持的结构体,且所述第十三函数为所述客户机支持的函数。Wherein the first structure is a structure supported by a client, and the second structure is a structure supported by a host, and the thirteenth function is a function supported by the host; or The first structure is a structure supported by the host, and the second structure is a structure supported by the client, and the thirteenth function is a function supported by the client.
  9. 根据权利要求1所述的方法,其特征在于,当所述第二函数的传入参数包括第三结构体,所述方法还包括:所述宿主机将作为所述第二函数的传入参数的第三结构体替换为第四结构体,所述第三结构体包含的域为所述第四结构体包含的域的子集;The method according to claim 1, wherein when the incoming parameter of the second function comprises a third structure, the method further comprises: the host machine as an incoming parameter of the second function The third structure is replaced with a fourth structure, and the third structure includes a domain that is a subset of the domains included in the fourth structure;
    其中,所述第四结构体为客户机支持的结构体,且所述第三结构体为宿主机支持的结构体。The fourth structure is a structure supported by a client, and the third structure is a structure supported by a host.
  10. 根据权利要求1所述的方法,其特征在于,当所述第二函数的传入参数包括第三结构体指针,所述方法还包括:所述宿主机将作为所述第二函数的传入参数的所述第三结构体指针替换为第四结构体指针,所述第四结构体指针指向第四结构体,所述第三结构体指针指向第三结构体,所述第三结构体包含的域为所述第四结构体包含的域的子集; The method of claim 1 wherein when the incoming parameter of the second function includes a third struct pointer, the method further comprises: the host will pass in as the second function The third structure body pointer of the parameter is replaced by a fourth structure body pointer, the fourth structure body pointer is directed to the fourth structure body, the third structure body pointer is directed to the third structure body, and the third structure body includes The domain is a subset of the domains included in the fourth structure;
    其中,所述第四结构体为客户机支持的结构体,且所述第三结构体为宿主机支持的结构体。The fourth structure is a structure supported by a client, and the third structure is a structure supported by a host.
  11. 根据权利要求1至10任意一项所述的方法,其特征在于,A method according to any one of claims 1 to 10, characterized in that
    所述对第三共享库中的第一函数进行翻译以得到第二函数之前,所述方法还包括:所述宿主机对所述第三共享库和所述宿主机的同名全局变量进行符号重定位。Before the first function in the third shared library is translated to obtain the second function, the method further includes: the host performing symbol weight on the third shared library and the host with the same name global variable Positioning.
  12. 根据权利要求11的方法,其特征在于,所述宿主机对所述第三共享库和所述宿主机的同名全局变量进行符号重定位包括:若所述第三共享库包含的第一全局变量和所述宿主机的N个全局变量同名,所述宿主机将所述第一全局变量和所述N个全局变量之中最先加载的全局变量的地址,设定为所述N个全局变量和所述第一全局变量的公共地址。The method of claim 11, wherein the symbol relocating the same-named global variable of the third shared library and the host by the host comprises: if the third shared library includes the first global variable And the host has the same name as the N global variables of the host, and the host sets an address of the first global variable and the first global variable loaded among the N global variables to the N global variables. And a public address of the first global variable.
  13. 根据权利要求11的方法,其特征在于,所述宿主机对所述第三共享库和所述宿主机的同名全局变量进行符号重定位包括:在所述第二共享库中被加载之后,所述宿主机将所述第三共享库中的第一全局变量的地址,重定位为所述第二共享库中的第二全局变量的地址,其中,所述第一全局变量和所述第二全局变量的声明相同。The method of claim 11, wherein the symbol relocation of the third shared library and the host of the same name global variable by the host machine comprises: after being loaded in the second shared library, Resetting the address of the first global variable in the third shared library to the address of the second global variable in the second shared library, wherein the first global variable and the second The declaration of global variables is the same.
  14. 一种宿主机,其特征在于,所述宿主机包括:A host machine, characterized in that the host machine comprises:
    存储单元,用于存储所述宿主机支持的第一共享库、所述宿主机支持的第二共享库和客户机支持的第三共享库,所述第一共享库包括翻译函数,所述宿主机和所述客户机支持不同的指令集体系架构;a storage unit, configured to store a first shared library supported by the host, a second shared library supported by the host, and a third shared library supported by the client, where the first shared library includes a translation function, the sink The host and the client support different instruction set architectures;
    调用单元,用于当所述第二共享库中的第一函数被调用时,执行所述第一函数以调用所述第一共享库中的翻译函数;a calling unit, configured to: when the first function in the second shared library is called, execute the first function to invoke a translation function in the first shared library;
    翻译单元,用于利用所述调用的第一共享库中的翻译函数,对所述第三共享库中的函数接口与所述第一函数的函数接口相同的第二函数进行翻译,以得到所述宿主机支持的第三函数;其中,所述第三函数的函数接口和所述第二函数的函数接口相同;a translation unit, configured to translate, by using a translation function in the first shared library of the call, a function of the function interface of the third shared library and a second function of the first function to obtain a a third function supported by the host; wherein a function interface of the third function and a function interface of the second function are the same;
    执行单元,用于执行所述第三函数。An execution unit, configured to execute the third function.
  15. 根据权利要求14所述的宿主机,其特征在于,所述存储单元还用于存 储所述宿主机支持的第五共享库;其中,若所述第二函数包括调用所述客户机支持的第四共享库中的第四函数的指令;The host machine according to claim 14, wherein said storage unit is further configured to store And storing, by the host, a fifth shared library; wherein, if the second function includes an instruction to invoke a fourth function in a fourth shared library supported by the client;
    所述翻译单元还用于:The translation unit is also used to:
    将所述第二函数包括的调用所述第四共享库中的第四函数的指令,翻译成调用所述第五共享库中的第五函数的指令,其中,所述第四函数和所述第五函数的函数功能相同,或者,所述第四函数和所述第五函数的函数功能和函数接口均相同。Translating, by the second function, an instruction that invokes a fourth function in the fourth shared library into an instruction that invokes a fifth function in the fifth shared library, wherein the fourth function and the The functions of the fifth function are the same, or the function functions and function interfaces of the fourth function and the fifth function are the same.
  16. 根据权利要求14所述的宿主机,其特征在于,所述存储单元还用于存储所述宿主机支持的第五共享库,当所述第三函数调用所述客户机支持的第四共享库中的第四函数时,所述翻译单元还用于:The host according to claim 14, wherein the storage unit is further configured to store a fifth shared library supported by the host, and when the third function calls a fourth shared library supported by the client In the fourth function, the translation unit is also used to:
    将所述第三函数包括的调用所述客户机支持的第四共享库中的第四函数的指令,翻译成所述第三函数调用所述第五共享库中第五函数的指令;所述第四函数和所述第五函数的函数功能相同,或者,所述第四函数和所述第五函数的函数功能和函数接口均相同。Translating, by the third function, an instruction that invokes a fourth function in a fourth shared library supported by the client into an instruction that the third function calls a fifth function in the fifth shared library; The functions of the fourth function and the function of the fifth function are the same, or the function functions and function interfaces of the fourth function and the fifth function are the same.
  17. 根据权利要求14所述的宿主机,其特征在于,所述存储单元还用于存储所述宿主机支持的第二主程序,若所述第二函数包括调用所述客户机支持的第一主程序中的第六函数的指令,所述翻译单元还用于:The host according to claim 14, wherein said storage unit is further configured to store a second main program supported by said host, if said second function comprises invoking said first host supported by said client An instruction of a sixth function in the program, the translation unit is further configured to:
    将所述第二函数包括的所述调用所述客户机支持的第一主程序中的第六函数的指令,翻译成调用所述第二主程序中的第七函数的指令,其中,所述第六函数和所述第七函数的函数功能相同,或者,所述第六函数和所述第七函数的函数功能和函数接口均相同。Translating, by the second function, the instruction that invokes the sixth function in the first main program supported by the client into an instruction that invokes a seventh function in the second main program, wherein The functions of the sixth function and the function of the seventh function are the same, or the function functions and function interfaces of the sixth function and the seventh function are the same.
  18. 根据权利要求14所述的宿主机,其特征在于,所述存储单元还用于存储所述宿主机支持的第二主程序,当所述第三函数调用所述客户机支持的第一主程序中的第六函数时,所述翻译单元还用于:The host according to claim 14, wherein said storage unit is further configured to store a second main program supported by said host, and when said third function calls said first main program supported by said client In the sixth function, the translation unit is also used to:
    将所述第三函数包括的调用所述客户机支持的第一主程序中的第六函数的指令,翻译成所述第三函数调用所述第二主程序中的第七函数的调用,所述第六函数和所述第七函数的函数功能相同,或者,所述第六函数和所述第七函数的函数功能和函数接口均相同。 Translating, by the third function, an instruction that invokes a sixth function in the first main program supported by the client into a call of the third function in the third main program The functions of the sixth function and the seventh function are the same, or the function functions and function interfaces of the sixth function and the seventh function are the same.
  19. 根据权利要求14所述的宿主机,其特征在于,当所述第二函数包括以所述客户机支持的第十函数的函数指针作为传入参数,以调用所述宿主机支持的第八函数的调用指令,所述翻译单元还用于:The host machine according to claim 14, wherein when said second function includes a function pointer of a tenth function supported by said client as an incoming parameter to call an eighth function supported by said host Calling instruction, the translation unit is also used to:
    将所述以所述客户机支持的第十函数的函数指针作为传入参数,以调用所述宿主机支持的第八函数的调用指令,替换为以所述宿主机支持的第九函数的函数指针作为传入参数,以调用所述宿主机支持的第八函数的调用指令;当所述第九函数被调用时,执行所述第九函数以调用所述第一共享库中的翻译函数对所述第十函数进行翻译,得到所述宿主机支持的第十一函数。The function pointer of the tenth function supported by the client is used as an incoming parameter, and the calling instruction of the eighth function supported by the host is invoked, and the function of the ninth function supported by the host is replaced. a pointer as an incoming parameter to invoke a call instruction of an eighth function supported by the host; when the ninth function is called, executing the ninth function to invoke a translation function pair in the first shared library The tenth function is translated to obtain an eleventh function supported by the host.
  20. 根据权利要求14所述的宿主机,其特征在于,当所述第二函数包括以第一结构体作为传入参数调用第十二函数的调用指令,所述翻译单元还用于将所述以第一结构体作为传入参数调用第十二函数的调用指令,翻译为,以第二结构体作为传入参数调用第十二函数的调用指令,其中,所述第一结构体包含的域为所述第二结构体包含的域的子集;The host machine according to claim 14, wherein when said second function comprises a call instruction for calling a twelfth function with the first structure as an incoming parameter, said translation unit is further configured to: The first structure body calls the call instruction of the twelfth function as an incoming parameter, and translates into a call instruction that calls the twelfth function with the second structure body as an incoming parameter, wherein the first structure body includes a domain a subset of domains included in the second structure;
    其中,所述第一结构体为所述客户机支持的结构体,且所述第二结构体为所述宿主机支持的结构体,且所述第十二函数为所述宿主机支持的函数;The first structure is a structure supported by the client, and the second structure is a structure supported by the host, and the twelfth function is a function supported by the host. ;
    或者,所述第一结构体为所述宿主机支持的结构体,并且所述第二结构体为所述客户机支持的结构体,并且所述第十二函数为所述所述客户机支持的函数。Or the first structure is a structure supported by the host, and the second structure is a structure supported by the client, and the twelfth function is supported by the client The function.
  21. 根据权利要求14所述的宿主机,其特征在于,当所述第二函数包括以第一结构体指针作为传入参数调用第十三函数的调用指令,The host machine according to claim 14, wherein when said second function comprises a call instruction for calling a thirteenth function with the first structure body pointer as an incoming parameter,
    所述翻译单元还用于:所述宿主机将所述以第一结构体指针作为传入参数调用第十三函数的调用指令,翻译为,以第二结构体指针作为传入参数调用第十三函数的调用指令;其中,所述第一结构体指针指向第一结构体,所述第二结构体指针指向第二结构体,其中,所述第一结构体包含的域为所述第二结构体包含的域的子集;The translation unit is further configured to: the host machine invokes the calling instruction that invokes the thirteenth function by using the first structure body pointer as an incoming parameter, and translates to calling the tenth with the second structure body pointer as an incoming parameter a call instruction of a three function; wherein the first structure body pointer points to the first structure body, and the second structure body pointer points to the second structure body, wherein the first structure body includes a domain a subset of the fields contained in the structure;
    其中,所述第一结构体为客户机支持的结构体,且所述第二结构体为宿主机支持的结构体,且所述第十三函数为所述宿主机支持的函数;The first structure is a structure supported by a client, and the second structure is a structure supported by a host, and the thirteenth function is a function supported by the host;
    或者所述第一结构体为宿主机支持的结构体,并且所述第二结构体为客户 机支持的结构体,且所述第十三函数为所述客户机支持的函数。Or the first structure is a structure supported by the host, and the second structure is a client A structure supported by the machine, and the thirteenth function is a function supported by the client.
  22. 根据权利要求14至21任意一项所述的宿主机,其特征在于,A host machine according to any one of claims 14 to 21, characterized in that
    所述宿主机还包括:重定位单元,用于在对第三共享库中的第一函数进行翻译以得到第二函数之前,对所述第三共享库和所述宿主机的同名全局变量进行符号重定位。The host machine further includes: a relocation unit, configured to perform the third-order shared library and the same-named global variable of the host machine before translating the first function in the third shared library to obtain the second function Symbol relocation.
  23. 根据权利要求22的宿主机,其特征在于,A host according to claim 22, wherein
    所述重定位单元具体用于,若所述第三共享库包含的第一全局变量和所述宿主机的N个全局变量同名,将所述第一全局变量和所述N个全局变量之中最先加载的全局变量的地址,设定为所述N个全局变量和所述第一全局变量的公共地址;The relocation unit is specifically configured to: if the first global variable included in the third shared library and the N global variables of the host have the same name, the first global variable and the N global variables are included The address of the first loaded global variable is set to the public address of the N global variables and the first global variable;
    或者,or,
    所述重定位单元具体用于,在所述第二共享库中被加载之后,将所述第三共享库中的第一全局变量的地址,重定位为所述第二共享库中的第二全局变量的地址,其中,所述第一全局变量和所述第二全局变量的声明相同。 The relocation unit is specifically configured to relocate an address of the first global variable in the third shared library to a second in the second shared library after being loaded in the second shared library The address of the global variable, wherein the declaration of the first global variable and the second global variable are the same.
PCT/CN2015/082127 2014-06-30 2015-06-23 Binary translation execution method and apparatus for shared libraries WO2016000550A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410306773.2A CN105335203B (en) 2014-06-30 2014-06-30 The binary translation of shared library executes method and apparatus
CN201410306773.2 2014-06-30

Publications (1)

Publication Number Publication Date
WO2016000550A1 true WO2016000550A1 (en) 2016-01-07

Family

ID=55018434

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/082127 WO2016000550A1 (en) 2014-06-30 2015-06-23 Binary translation execution method and apparatus for shared libraries

Country Status (2)

Country Link
CN (1) CN105335203B (en)
WO (1) WO2016000550A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10235178B2 (en) 2017-06-02 2019-03-19 Microsoft Technology Licensing, Llc Performance scaling for binary translation

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107085514B (en) * 2017-03-06 2021-02-19 北京安博通科技股份有限公司 Shared library upgrading method and device
CN107704236B (en) * 2017-09-30 2021-03-19 苏州浪潮智能科技有限公司 Method and apparatus for managing common functions in software development system
US10152313B1 (en) 2017-12-19 2018-12-11 International Business Machines Corporation Shared library transformation on the same architecture

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1892602A (en) * 2005-07-01 2007-01-10 中国科学院计算技术研究所 Method for processing library function call in binary translation
CN101452395A (en) * 2007-11-28 2009-06-10 无锡江南计算技术研究所 Processing method for calling and returning function, and binary translation method and system
US20090271172A1 (en) * 2008-04-24 2009-10-29 International Business Machines Corporation Emulating A Computer Run Time Environment
US20130326489A1 (en) * 2012-05-30 2013-12-05 Vector Fabrics B.V. Method and system for translating non-native instructions

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1892602A (en) * 2005-07-01 2007-01-10 中国科学院计算技术研究所 Method for processing library function call in binary translation
CN101452395A (en) * 2007-11-28 2009-06-10 无锡江南计算技术研究所 Processing method for calling and returning function, and binary translation method and system
US20090271172A1 (en) * 2008-04-24 2009-10-29 International Business Machines Corporation Emulating A Computer Run Time Environment
US20130326489A1 (en) * 2012-05-30 2013-12-05 Vector Fabrics B.V. Method and system for translating non-native instructions

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10235178B2 (en) 2017-06-02 2019-03-19 Microsoft Technology Licensing, Llc Performance scaling for binary translation

Also Published As

Publication number Publication date
CN105335203B (en) 2018-10-19
CN105335203A (en) 2016-02-17

Similar Documents

Publication Publication Date Title
Bruening et al. Transparent dynamic instrumentation
CN108762815B (en) Method for realizing Android running environment based on non-virtualization system architecture
Lagar-Cavilla et al. Snowflock: Virtual machine cloning as a first-class cloud primitive
JP5139975B2 (en) Function level just-in-time conversion engine with multiple path optimizations
JP6559793B2 (en) Binary conversion at the shared object level
US10303491B2 (en) Method and device of running application program across systems
Shuja et al. Towards native code offloading based MCC frameworks for multimedia applications: A survey
JP6316694B2 (en) Cloud-scale heterogeneous data center management infrastructure
US9983869B2 (en) Adaptive interface for cross-platform component generation
US9720703B2 (en) Data driven hardware chips initialization via hardware procedure framework
US10691580B1 (en) Diagnosing applications that use hardware acceleration through emulation
WO2016000550A1 (en) Binary translation execution method and apparatus for shared libraries
US20200272482A1 (en) Unikernel provisioning
WO2014107540A1 (en) Software interface for a hardware device
Hale et al. Electrical Engineering and Computer Science Department
US20200241906A1 (en) Efficient userspace driver isolation by shallow virtual machines
JP5886450B2 (en) Hybrid emulation and kernel function processing system and method
EP2941694B1 (en) Capability based device driver framework
US20110173595A1 (en) Language-based model for asynchronous operations
Penneman et al. Evaluation of dynamic binary translation techniques for full system virtualisation on ARMv7-A
Wang et al. DisTA: Generic dynamic taint tracking for java-based distributed systems
US20240004670A1 (en) Computer system executing multiple operating systems
Satyanarayanan et al. One-click time travel
US20240143485A1 (en) Presubmit Test Run Minimization Analysis Using Runtime Isolation Guarantees
US11698806B2 (en) Hypercall acceleration for nested virtual machines

Legal Events

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

Ref document number: 15815507

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15815507

Country of ref document: EP

Kind code of ref document: A1