Exploring Binary Translation: A Case Study
November 10, 2023
The Client
The client, a prominent corporation, sought to create a Binary Translator for the conversion of binary code into LLVM Intermediate Representation (IR) tailored for specific backend compilation. This was needed to increase compatibility while translating said binaries to the target architecture.
Problems and Challenges
- Native Architectures: Not all libraries and applications have native versions for all architectures.
- Compatibility issues: To increase compatibility without re-compiling the code, a solution to convert binaries to the target architecture was needed.
The MulticoreWare Advantage and Approach
MulticoreWare built LLVM-MCTOLL, which is an open source tool that statically (AOT) translates (or raises) binaries to LLVM IR which can be built with target backends. The supported platforms for this tool is Ubuntu and the supported input triples include x86_64, ARM32, and RISC-V(partly). The technologies used for this tool were primarily Compiler IR, and Assembly.
Find more information about our tool: Click here
Outcome
We also provided additional contributions to this client, such as:
- Function code analysis: We helped in the discovery of function prototype as well as assisted in the identification of function entries based on branch instructions. We extracted the argument list based on the stack arguments and determined the return type from the return operation.
- Stack frame abstraction: We were able to analyze function prologue and epilogue and remove the stack adjustment operations.
- Switch statements with jump tables: We identified the switch code blocks and extracted the jump tables.
Triple | VarArgs | FuncProto | StackFrame | JumpTables | SharedLibs | C++ |
---|---|---|---|---|---|---|
x86_64-linux | X | X | X | X | X | |
arm-linux | X | X | X | X | X |
Conclusion
This case study highlights how MulticoreWare’s expertise effectively facilitated the translation of binary code into LLVM IR, customized for a specific backend.
For a more comprehensive understanding of MulticoreWare’s LLVM-MCTOLL, please contact us at info@multicorewareinc.com