CN102364442A - Method for transplanting Wine from x86 to advanced risc machine (ARM) platform - Google Patents

Method for transplanting Wine from x86 to advanced risc machine (ARM) platform Download PDF

Info

Publication number
CN102364442A
CN102364442A CN2011101739055A CN201110173905A CN102364442A CN 102364442 A CN102364442 A CN 102364442A CN 2011101739055 A CN2011101739055 A CN 2011101739055A CN 201110173905 A CN201110173905 A CN 201110173905A CN 102364442 A CN102364442 A CN 102364442A
Authority
CN
China
Prior art keywords
arm
wine
assembly
data structure
instruction
Prior art date
Legal status (The legal status 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 status listed.)
Granted
Application number
CN2011101739055A
Other languages
Chinese (zh)
Other versions
CN102364442B (en
Inventor
毛德操
王承志
徐鼎鼎
陈天洲
俞立呈
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
INSIGMA TECHNOLOGY Co Ltd
Original Assignee
INSIGMA TECHNOLOGY Co Ltd
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 INSIGMA TECHNOLOGY Co Ltd filed Critical INSIGMA TECHNOLOGY Co Ltd
Priority to CN201110173905.5A priority Critical patent/CN102364442B/en
Publication of CN102364442A publication Critical patent/CN102364442A/en
Application granted granted Critical
Publication of CN102364442B publication Critical patent/CN102364442B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

The invention discloses a method for transplanting Wine from x86 to an advanced risc machine (ARM) platform. Wine can simulate an execution environment of Windows application in other operating systems, so a binary Windows program can be directly run in other operating systems. The method comprises the following steps that: 1) an x86 assembly code is changed to an ARM assembly code; 2) adding a CONTEXT data structure of ARM to express a register context on the ARM; 3) adding support to central processing unit (CPU) infrastructure in ARM executable image; and 4) correcting a storage position of ITEMIDLIST data structure to guarantee the alignment of internal memory address. Due to the adoption of the method, the Wine can be run on the system utilizing an ARM platform such as a great amount of embedded systems, and a great amount of Windows programs can be directly run on different embedded platforms, so the deployment cost of different applications can be reduced.

Description

Wine is transplanted to the method for ARM platform from x86
Technical field
The present invention relates to computer run environment simulator field, operating system field and CPU architecture field, especially Wine is transplanted to the method for ARM platform from x86.
Background technology
Microsoft Windows (being called for short Windows) is an operating system common on the present desktop computer, and a plurality of different versions are arranged, and is applicable to PC, workstation and server.The Windows series of operations will reach more than 90% the end of the year 2010 in the occupation rate in desktop computer market, visible its popularity rate and pouplarity.Why Windows so receives a big reason that the user welcomes is exactly that application software on the windows platform is very many; The windows platform Application and Development is ready at first to be in most software development commercial city, and a lot of user to be unwilling to switch to other operating systems be exactly because do not have certain required application of user on the other system or make the satisfied alternate version of user.
The ARM architecture processor is present popular a kind of processor architecture, and the design of its reduced instruction set computer (RISC) is more efficient compared with the sophisticated vocabulary (CSIC) of x86 common in the desktop computer processor, and energy consumption is also lower.Therefore at present a lot of embedded devices or mobile device such as smart mobile phone have all adopted the processor of ARM framework mostly.Yet, can't on arm processor, move the Windows operating system of conventional table computer, thereby also can't move the numerous softwares in the Windows operating system because the instruction set of ARM is different fully with the x86 instruction set.
Wine is a dry run environment on the x86 processor, utilizes Wine can in other operating systems (operating system of type of being generally Unix such as Linux), directly move the executable program of Windows.Therefore utilize Wine directly obtaining application resource abundant under the Windows environment on the different operating system; Any modification of a lot of Windows application need not carrying out (not needing to recompilate) just can directly move in Wine, and keeps higher running efficiency.Yet Wine only supports the processor architecture of x86, does not support ARM, thereby can't move on numerous equipment based on ARM at present.
Summary of the invention
The present invention proposes a kind of method of Wine being transplanted to the ARM platform from x86; Thereby make and also can move numerous Windows programs on the ARM platform; Application developers can apace that original application deployment is numerous up till now equipment based on ARM in, obtain more economic benefits.
Will be with being that the Wine simulator that x86 framework CPU writes is transplanted on the CPU of ARM framework originally, the problem that at first need solve is exactly the machine code that converts the machine code of x86 instruction set into the ARM instruction set.Source code for high level language such as use C only need use the compiler cross compile that generates ARM framework machine code to get final product on PC.But Wine is in order more effectively to control bottom hardware, and some source code is to use assembly code to write, because assembly code is relevant with the cpu instruction collection, therefore needs the manual assembly code that these assembly codes is rewritten into the ARM instruction set.Concrete method is: the instruction of x86 compilation is rewritten as corresponding ARM assembly instruction one by one, and the operand in will instructing changes the ARM register into from the x86 register.Because the otherness of x86 instruction set and ARM instruction set for the x86 instruction that does not have corresponding A RM assembly instruction, needs to use many ARM assembly instructions to realize correspondence and corresponding x86 assembly instruction identical functions.
The assembly code that will rewrite following a few part is arranged:
● all assembly codes among the loader/preloader.c;
● the wine call on stack function among the libs/wine/port.c;
● the wine switch to stack function among the libs/wine/port.c.
Other has some data structures is not assembly instruction, but relevant with concrete CPU yet.CONTEXT data structure among the Wine is used to represent the register context of CPU, and the register context refers to the value of a certain all registers of moment CPU, and storage CPU is at this state constantly.Different CPU has different set of registers, so represent that the contextual CONTEXT data structure of their register is also different.Wine provides the CONTEXT data structure definition of ARM in wine/include/winnt.h; But do not provide relevant code to realize in the code; Need to replenish, increase the function that ARM register context is preserved, recovered, duplicates and concrete register value extracts.
The Windows executable image form that moves among the Wine is PE (Portable Executable), has a field to indicate this executable file to any CPU in its file header, is called CPU framework signature.For arm processor, the value of this field is IMAGE FILE MACHINE ARM or IMAGE FILE MACHINE THUMB, and the value of these two constants is respectively 0x01c0 and 0x01c2.Wine can not discern this two CPU framework signatures, so can't load or move the executable image of ARM.Therefore to add support, need to revise kernel32/process.c this CPU framework signature.
The data structure ITEMIDLIST that is defined among the include/shtypes.idl is following:
Figure BDA0000071027110000031
Being defined as of SHITEMID wherein:
Figure BDA0000071027110000032
Here the variable size of array abID, its size is recorded among the field cb, and this array is used for the store files name.When the length of filename was odd number, the size of data structure SHITEMID was an odd number, thereby the size of ITEMIDLIST also is an odd number, thus not with the boundary alignment of long word or word.In actual use, several SHITEMID data structures can join end to end and stack, and form a tabulation.Like this, if the size of first SHITEMID data structure is an odd number, the starting point of second SHITEMID data structure is not just with the boundary alignment of long word or word.The x86 processor allows such accessed that does not line up, but the arm processor internal storage access that aligns with long word or word boundary of permission only, otherwise the correctness with regard to not guaranteeing to operate.For this reason, when CPU read the numerical value of its cb field from the SHITEMID data structure of non-alignment, resulting possibly be a wrong numerical value.The present invention solves this problem through relevant function ILGetSize, ILGetNext are made amendment; The ILGetSize function is used to obtain the size of single SHITEMID data structure, and the ILGetNext function is used for obtaining the next item down address of a certain of tabulation that the SHITEMID data structure forms.Amending method is: when the single SHITEMID structure size of ILGetSize function calculation and ILGetNext function calculation the next item down address; The size of newly-increased one _ insigma_align function calculation cb part; Its computing method are if the size of abID array is an odd number; Just on this numerical value, add 1, make the boundary alignment of itself and long word or word.Through duplicating one group of SHITEMID data structure when forming a tabulation, the length of actual copy depends on the rreturn value of ILGetSize function, and rreturn value has been passed through _ adjustment of insigma_align function, the address must be an even number.Therefore in a tabulation, the starting point of each SHITEMID data structure just all is with the boundary alignment of long word or word, the problem that when having solved the arm processor access memory must align in the border.
Description of drawings
Fig. 1 is the process flow diagram of Wine being transplanted to the ARM platform from x86 of the embodiment of the invention.
Embodiment
As shown in Figure 1.Present embodiment Wine is comprised the steps: from the flow process that x86 is transplanted to the ARM platform
The first, the instruction that x86 is collected is rewritten as corresponding ARM assembly instruction one by one, and the operand in will instructing changes the ARM register into from the x86 register.Because the otherness of x86 instruction set and ARM instruction set for the x86 instruction that does not have corresponding A RM assembly instruction, needs to use many ARM assembly instructions to realize correspondence and corresponding x86 assembly instruction identical functions.
Concrete implementation method is to come the special-purpose code at compile time control compiling ARM through increasing macro definition _ arm_, so the assembly code of ARM can surround by the grand conditional compilation statement that whether defines of to be detected _ arm_.Owing to have more source code to relate to of the conversion of x86 assembly code, therefore only be illustrated here to the wine_call_on_stack function among the libs/wine/port.c to the ARM assembly code.The code of wine_call_on_stack function after conversion is following:
Figure BDA0000071027110000051
The assembly code (specific code of x86 uses " ... " to omit) of the x86 that the grand conditional compilation instruction of above code reservation _ i386_ is surrounded; The ARM assembly code that the grand conditional compilation instruction of newly-increased usefulness _ arm_ is surrounded, its code content are the correspondence of x86 to be instructed be rewritten as the ARM assembly instruction according to function.
The second, increase ARM and represent that the contextual CONTEXT data structure of register step is following:
1, under the dlls/ntdll catalogue, creates the file of signal_arm.c by name, wherein need realize the function identical, comprise functions such as save_context, restore_context with former signal_i386.c.
2, individual function copy_context is arranged in dlls/ntdll/thread.c, need to increase the replicating code of fields different among the CONTEXT to the CONTEXT of ARM and x86.
3, in the code of WineServer, need below the server catalogue, create the file of context_arm.c by name, wherein need realize the function identical, for example function such as copy_context, get_context_ip with former context_i386.c.
The 3rd, increasing the concrete grammar that ARM framework executable image PE header file CPU framework signature is supported is that the start_process function of revising among the kernel32/process.c is:
Figure BDA0000071027110000061
Situation when having increased the CPU framework signature field (FileHeader.Machine) of header file to IMAGE FILE MACHINE THUMB or IMAGE FILE MACHINE ARM in the above code is judged, makes the executable file of arm processor can be loaded operation.
The 4th; The memory location correction of ITEMIDLIST data structure needs to revise ILGetSize and ILGetNext function; All will when calculating ITEMIDLIST data structure size, increase right _ insigma_align function calls respectively, the definition of _ insigma_align function is following:
Figure BDA0000071027110000072
Surround with the macrodefined conditional compilation of superior function quilt _ Insigma_, promptly defined _ just provide the memory location to revise after Insigma_ is grand.The modification method that _ insigma_align function provides is if the size of abID array is an odd number, just on this numerical value, adds 1, makes the boundary alignment of itself and long word or word.
Amended ILGetSize function and ILGetNext function are following:
Figure BDA0000071027110000091
More than two functions when calculating SHITEMID data structure size according to whether defined _ Insigma_ is grand to be determined whether calling _ the insigma_align function obtains the start address of revised SHITEMID data structure size or next SHITEMID data structure.

Claims (5)

  1. With Wine from the method that x86 is transplanted to the ARM platform, it is characterized in that:
    1.1, to rewrite the x86 assembly code be the ARM assembly code;
    1.2, increase the CONTEXT data structure of ARM, the register context on the expression arm processor;
    1.3, increase support to ARM framework executable image PE file header CPU framework signature, make Wine can discern the ARM executable image;
    1.4, the memory location of ITEMIDLIST data structure is revised, guarantee that its memory address is with the boundary alignment of long word or word.
  2. 2. method according to claim 1 is characterized in that, rewriting x86 assembly code is that the method for ARM assembly code is:
    2.1, the instruction of x86 assembly instruction is rewritten as corresponding ARM assembly instruction one by one, and change operand the register of ARM into;
    2.2, for the x86 assembly instruction that does not have corresponding A RM assembly instruction, use many ARM assembly instructions to realize and corresponding x86 assembly instruction identical functions.
  3. 3. method according to claim 2 is characterized in that, the assembly code that needs to rewrite comprises: all assembly codes among the loader/preloader.c; Wine call on stack function among the libs/wine/port.c; Wine switch to stack function among the libs/wine/port.c.
  4. 4. method according to claim 1 is characterized in that, the support method that increases ARM framework executable image PE file header CPU framework signature is specially the judgement of increase to ARM framework signature in the file header, allows the executable image of ARM framework to be loaded execution.
  5. 5. method according to claim 1; It is characterized in that, the memory location of ITEMIDLIST data structure is revised, if the size of ITEMIDLIST data structure is an odd number; Then on original address, add 1 during calculated address, make the address even number alignment always of data structure.
CN201110173905.5A 2011-06-24 2011-06-24 Method for transplanting Wine from x86 to advanced risc machine (ARM) platform Active CN102364442B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201110173905.5A CN102364442B (en) 2011-06-24 2011-06-24 Method for transplanting Wine from x86 to advanced risc machine (ARM) platform

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201110173905.5A CN102364442B (en) 2011-06-24 2011-06-24 Method for transplanting Wine from x86 to advanced risc machine (ARM) platform

Publications (2)

Publication Number Publication Date
CN102364442A true CN102364442A (en) 2012-02-29
CN102364442B CN102364442B (en) 2014-06-25

Family

ID=45691008

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201110173905.5A Active CN102364442B (en) 2011-06-24 2011-06-24 Method for transplanting Wine from x86 to advanced risc machine (ARM) platform

Country Status (1)

Country Link
CN (1) CN102364442B (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104503819A (en) * 2015-01-05 2015-04-08 中国科学院计算技术研究所 Assembler for different operating systems (OSes) and assembly transplantation method
CN105700854A (en) * 2014-11-25 2016-06-22 杭州海康威视数字技术股份有限公司 Method and device for operating application task
CN107463423A (en) * 2017-07-31 2017-12-12 武汉斗鱼网络科技有限公司 Rely on verification method, storage medium, electronic equipment and the system of job contract tool
CN107479864A (en) * 2016-06-08 2017-12-15 龙芯中科技术有限公司 The platform transplantation method and apparatus of MapReduce Computational frames
CN112130859A (en) * 2019-06-25 2020-12-25 深信服科技股份有限公司 Application operation method, device, equipment and storage medium
CN112947994A (en) * 2021-03-09 2021-06-11 北方实验室(沈阳)股份有限公司 Credit adaptive code migration workload evaluation system and method
CN113553124A (en) * 2021-05-26 2021-10-26 武汉深之度科技有限公司 Application program running method, computing device and storage medium

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9996329B2 (en) 2016-02-16 2018-06-12 Microsoft Technology Licensing, Llc Translating atomic read-modify-write accesses

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1731347A (en) * 2004-08-06 2006-02-08 梁肇新 Linux-based Windows software compatible layer architecture
CN1755631A (en) * 2004-09-30 2006-04-05 中国科学院计算技术研究所 Library function call disposal route in the binary translation

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1731347A (en) * 2004-08-06 2006-02-08 梁肇新 Linux-based Windows software compatible layer architecture
CN1755631A (en) * 2004-09-30 2006-04-05 中国科学院计算技术研究所 Library function call disposal route in the binary translation

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
《电子测量技术》 20081031 涂小玲等 "基于ARM嵌入式应用平台的x86指令译码器设计" 第60-63页 1-5 第31卷, 第10期 *
《计算机应用》 20090831 王亚军等 "Windows程序运行于Linux系统的技术" 第2128-2131页 1-5 第29卷, 第8期 *
涂小玲等: ""基于ARM嵌入式应用平台的x86指令译码器设计"", 《电子测量技术》 *
王亚军等: ""Windows程序运行于Linux系统的技术"", 《计算机应用》 *
王燕风等: "利用WINE实现Windows到Linux的转换", 《计算机现代化》 *

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105700854A (en) * 2014-11-25 2016-06-22 杭州海康威视数字技术股份有限公司 Method and device for operating application task
CN105700854B (en) * 2014-11-25 2019-05-28 杭州海康威视数字技术股份有限公司 Run the method and device of application task
CN104503819A (en) * 2015-01-05 2015-04-08 中国科学院计算技术研究所 Assembler for different operating systems (OSes) and assembly transplantation method
CN107479864A (en) * 2016-06-08 2017-12-15 龙芯中科技术有限公司 The platform transplantation method and apparatus of MapReduce Computational frames
CN107463423A (en) * 2017-07-31 2017-12-12 武汉斗鱼网络科技有限公司 Rely on verification method, storage medium, electronic equipment and the system of job contract tool
CN107463423B (en) * 2017-07-31 2020-04-10 武汉斗鱼网络科技有限公司 Verification method, storage medium, electronic device and system depending on package tool
CN112130859A (en) * 2019-06-25 2020-12-25 深信服科技股份有限公司 Application operation method, device, equipment and storage medium
CN112947994A (en) * 2021-03-09 2021-06-11 北方实验室(沈阳)股份有限公司 Credit adaptive code migration workload evaluation system and method
CN113553124A (en) * 2021-05-26 2021-10-26 武汉深之度科技有限公司 Application program running method, computing device and storage medium
CN113553124B (en) * 2021-05-26 2022-06-21 武汉深之度科技有限公司 Application program running method, computing device and storage medium
WO2022247106A1 (en) * 2021-05-26 2022-12-01 统信软件技术有限公司 Method for running application program, and computing device and storage medium

Also Published As

Publication number Publication date
CN102364442B (en) 2014-06-25

Similar Documents

Publication Publication Date Title
CN102364442B (en) Method for transplanting Wine from x86 to advanced risc machine (ARM) platform
US9766867B2 (en) Systems and methods for improving performance of mobile applications
Steele Jr Rabbit: A compiler for Scheme
Lester The art of parallel programming
US9424050B2 (en) Parallelization and instrumentation in a producer graph oriented programming framework
US9690604B2 (en) Language-based model for asynchronous operations
US10846101B2 (en) Method and system for starting up application
EP2359247B1 (en) Transforming user script code for debugging
US8549502B2 (en) Compiler with user-defined type inference rules
JP6027020B2 (en) How to checkpoint and restore program state
CN101110055B (en) Device for implementing general use pile function in unit test and implementing method thereof
Batyuk et al. Developing and benchmarking native linux applications on android
US7320121B2 (en) Computer-implemented system and method for generating embedded code to add functionality to a user application
Guihot Pro Android apps performance optimization
Dearle Groovy for Domain-Specific Languages
CN102364433B (en) Method for realizing Wine construction tool transplanting on ARM (Advanced RISC Machines) processor
CN103443763A (en) ISA bridging including support for call to overidding virtual functions
Dastgeer et al. The PEPPHER composition tool: Performance-aware dynamic composition of applications for GPU-based systems
Kaminsky Building Parallel Programs: SMPs, Clusters & Java
EP2009547A2 (en) Method and apparatus for parallel XSL transformation with low contention and load balancing
US10496433B2 (en) Modification of context saving functions
US20110173595A1 (en) Language-based model for asynchronous operations
US10552135B1 (en) Reducing a size of an application package
CN107729118A (en) Towards the method for the modification Java Virtual Machine of many-core processor
US20140359579A1 (en) Combined data and instruction test content

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant