TDT09 Topic 12


I don't care what CPU you use - binary translation

The dominance of x86 processors over the last decades has motivated many software developers to only provide software for the 32 and 64 bit versions of Intel's and AMD's CPUs. However, there are more cost and energy efficient architectures out there waiting to take the place of x86 on desktops and servers (as demonstrated by Apple's recent announcement to switch to their own "Apple Silicon" ARM-based architecture); in addition, x86 could never gain much relevance in other market segments, such as embedded and mobile systems.

One of the most prevalent problems when switching to a new instruction set architecture (ISA) is that there are large amounts of old ("legacy") software that is still required by the users. While some of this software can be recompiled with some effort, other software cannot be adapted on source-code level since the source code isn't available or the company that produced the program is long defunct.

One approach to enable software compiled for an incompatible ISA to run on a different one is to translate the binary program, e.g. replace x86 machine instructions by semantically equivalent ARM instructions. There are two general approaches to do this, which both have positive and negative aspects. One approach is to statically compile the old binary in order to generate one for the new ISA, whereas the other is to dynamically translate section of the old code while execution the program. This just-in-time ("JIT") translation is also known from high-level virtual machines, e.g. for Java. Of course, there are also hybrid techniques in use.

However, binary translation is a rather old technique and has been used to adapt old software in many environments. Nevertheless, it is still a relevant field of research, especially considering the possible adaptation of single-threaded software to run efficiently on new multicore architectures [6] There have been numerous approaches to binary translation over the last decades. Academic results include Walkabout and UQBT by Cristina Cifuentes [1,2] and many others. Examples from industry include the binary translators developed at DEC [4], IBM [3] and Intel [5]. A comprehensive overview can be found in [7].

Binary translation is a problem concerning the hardware/software interface since is requires detailed knowlegde of the source and target instruction set architectures, some microarchitectural details (caches, pipelines etc.) to ensure not only correctly, but also efficiently translated code, as well as an insight into the code generated by the source machine compilers, since programmers might have used tricks or side effects never envisioned by the original architects of that ISA. Paper [4] has some nice examples of real-world problems in binary translation. A really nice hands-on introduction to building your own static binary translator based on an emulator can be found at [8].

References

  1. Cristina Cifuentes, Vishv M Malhotra. Binary translation: Static, dynamic, retargetable? ICSM Volume 96, 1996 pdf
  2. Cristina Cifuentes, Mike Van Emmerik. UQBT: Adaptable binary translation at low cost. IEEE Computer Vol. 33 Nr. 3, 2000 pdf
  3. K. Ebcioglu, E. Altman, M. Gschwind and S. Sathaye, "Dynamic binary translation and optimization," in IEEE Transactions on Computers, vol. 50, no. 6, pp. 529-548, June 2001 link
  4. Richard L. Sites et al., Binary Translation. Comm. of the ACM Vol. 36, No. 2, Feb. 93 pdf
  5. Baraz, Leonid; Devor, Tevi; Etzion, Orna; Goldenberg, Shalom; Skaletsky, Alex; Wang, Yun; Zemach, Yigal (2003). IA-32 Execution Layer: a two-phase dynamic translator designed to support IA-32 applications on Itanium-based systems. Proceedings of ACM MICRO 36. Washington, DC, USA link
  6. Ding-Yong Hong et al. Improving SIMD Parallelism via Dynamic Binary Translation. ACM TECS Feb. 2018 link
  7. Kim Hazelwood. Dynamic Binary Modification: Tools, Techniques, and Applications. Synthesis Lectures on Computer Architecture 2011 pdf
  8. Graham Toal. An Emulator Writer's HOWTO for Static Binary Translation link