| Binary translation technology is an important technology for solving software migration under different architectures.With the introduction of the armv8 instruction set and the continuous launch of ARM processors by major manufacturers such as Apple,Amazon,and Huawei,ARM processors are gradually entering the desktop and server domains where x86 processors account for an absolute share.In this development process,a relatively prominent problem is that x86 closed source software cannot run directly on the machine of the ARM processor,resulting in certain obstacles to the ecological development of ARM.Currently,the dynamic binary translator widely used in the industry is QEMU.However,in the user-level dynamic binary translation mode,QEMU has a relatively obvious disadvantage: it is implemented through auxiliary function simulation for floatingpoint operations and complex instructions,resulting in reduced performance.This paper designs a user-level multi-target dynamic binary translator based on LLVM.The translator is divided into three parts: the front end,the middle end,and the back end,which are responsible for instruction parsing and upgrading to LLVM IR,LLVM IR optimization,and LLVM IR compilation and execution.Using LLVM IR as an intermediate representation in the design,the translator can quickly expand its support for multiple source and target architectures.The use of LLVM JIT ensures the rapid compilation and execution of LLVM IR.Because LLVM IR can be compiled into good target architecture instructions based on the target architecture,it can effectively convert floating-point operations and complex instructions into efficient target machine instructions,thereby overcoming the shortcomings of QEMU.This translator currently supports fast and correct translation of x86-64 closed source software in the armv8 architecture and x86-64 architecture.In addition,it has the following advantages: the ability to quickly support multiple sources and multiple targets? Full instruction set support? Fully automatic execution? Excellent performance,etc.This article uses the Open BLAS benchmark test program to test this translator and compares its performance with QEMU and Huawei Exa Gear.The test results show that the binary translation performance of the translator is far superior to QEMU,and can achieve performance testing performance comparable to that of Huawei Exa Gear.This indicates that the translator in this article can achieve multi-target systems based on intermediate representations on the one hand,and can achieve the performance of commercial binary translators with fixed sources and targets on the other hand. |