Browse Prior Art Database

Method for branch translation for binary rewriting systems

IP.com Disclosure Number: IPCOM000146494D
Publication Date: 2007-Feb-13
Document File: 7 page(s) / 30K

Publishing Venue

The IP.com Prior Art Database

Abstract

Disclosed is a method for branch translation for binary rewriting systems. Benefits include improved functionality and improved performance.

This text was extracted from a Microsoft Word document.
At least one non-text object (such as an image or picture) has been suppressed.
This is the abbreviated version, containing approximately 22% of the total text.

Method for branch translation for binary rewriting systems

Disclosed is a method for branch translation for binary rewriting systems. Benefits include improved functionality and improved performance.

Background

      A binary rewrite system (BRS) translates an executable to an instruction set architecture (ISA) and application binary interface (ABI) other than the specific ones for which the executable was written. To perform the translation successfully, 100% accuracy must be maintained between executable code and data. Only the code must be translated to the rewrite ISA/ABI. However, very few static compilers emit enough information to distinguish reliably between code and data. Moreover, an area of memory can contain executable code and data values with the same bit pattern.

      Alternatively, the code and data of the original program can be loaded into memory in exactly the same layout as the original ABI (referred to as the original copy). All of the code that would be executed on the original ABI for a given run must be translated to the rewrite ABI. The translation can be performed for all of the original code before the program is run. Alternatively, a smaller amount of code can be translated for execution on the rewrite ABI, executing a trace of it, then translating more as needed, such as for a just-in-time (JIT) translator.

      Translation of straight-line code is relatively straightforward. Each available register in the original ABI is represented in the rewrite ABI. Each instruction in a basic block (such as. straight-line code) is translated to one or more instructions in the target so that the homomorphism is preserved. Typically, the domain of this homomorphism does not include the rewrite code area. The original code/data area must not reference the rewrite code area addresses.

      Each branch target in the original code area must be translated to the corresponding point in the rewrite code area to prevent branching back into the original code area. When a branch instruction is index pointer (IP) relative, the target is specified as an offset to the branch instruction itself. The BRS can statically determine the branch target in the original code area, find the corresponding point in the target code area, and construct an IP-relative branch in the rewrite code area that branches to the appropriate target in the rewrite code area.

      For indirect branches, however, the situation is more complicated. The branch target cannot be statically determined. If the target is loaded from memory, the address is in the original code area, and execution must instead branch to the corresponding point in the rewrite code area (see Figure 1).

      One conventional method is for the rewritten branch to jump to the BRS or some support library, which calculates the approp...