GrammaTech / ddisasm

A fast and accurate disassembler
https://grammatech.github.io/ddisasm/
GNU Affero General Public License v3.0
668 stars 62 forks source link

How to view or convert gtrib IR to LLVM IR #15

Open ajaymas opened 4 years ago

ajaymas commented 4 years ago

Hello, I have disassembled a simple hello binary using gtrib with the below commands.

ddisasm hello --asm hello.s

Also, I have generated hello.gtrib using the below command.

ddisasm hello --ir hello.gtrib

Now, I am not able to open or view hello.gtrib. sometimes I noticed here in the issue section there is a way to convert back to LLVM-IR or opening in some form.

Could you please help me how to see or convert hello.gtrib IR

Thanks in advance.

aeflores commented 4 years ago

Hi @ajaymas, the GTIRB representation is not directly human-readable. You can open it and manipulate it using the GTIRB API https://github.com/GrammaTech/gtirb. Here is a link to the documentation https://grammatech.github.io/gtirb/index.html and this is a tutorial on how to implement a binary transformation https://grammatech.github.io/gtirb/md_stack-stamp.html.

You can also try to load a GTIRB file into Ghidra using https://github.com/GrammaTech/gtirb-ghidra-plugin

That said, currently there is no way to translate from GTIRB to LLVM-IR. GTIRB represents a binary whereas LLVM-IR is a much higher level representation. Such a translation would be non-trivial.

SaiVK commented 2 years ago

Hello @aeflores, the https://grammatech.github.io/gtirb/md_stack-stamp.html is broken. Can you share the correct link?

Thanking you Sai

eschulte commented 2 years ago

https://grammatech.github.io/gtirb/md_stack_stamp.html (underscore not hyphen) thanks for the heads up, I'll fix the broken link.