Coder Social home page Coder Social logo

cojocar / bin2llvm Goto Github PK

View Code? Open in Web Editor NEW
140.0 12.0 17.0 324 KB

A binary to LLVM translator

License: Apache License 2.0

Python 11.40% C++ 67.49% CMake 0.49% LLVM 1.39% Makefile 0.78% C 1.29% Shell 3.60% Gherkin 3.84% Ruby 0.94% Assembly 8.79%
reverse-engineering binary-translation llvm arm disassembler

bin2llvm's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bin2llvm's Issues

Cannot build on Ubuntu 18

Tried to build this project on Ubuntu 18.04 with gcc 7.3.0. I executed the scripts setup.sh and build.sh as written in README and got this error:

In file included from /media/UserData/Youda/CVUT/DIP/Implementace/frameworks/bin2llvm-build/llvm-native/include/llvm/Support/DataTypes.h:37:
/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/cmath:45:15: fatal error: 'math.h' file not found
#include_next <math.h>
              ^

Looks like the build script somehow messes up with the environment and include directories, so that it cannot find them at their standard locations.

Support of AMD64

Is support of AMD64 planned?

[xaionaro@void helloworld]$ readelf -h /tmp/helloworld/helloworld 
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x44e250
  Start of program headers:          64 (bytes into file)
  Start of section headers:          456 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         7
  Size of section headers:           64 (bytes)
  Number of section headers:         23
  Section header string table index: 3
[xaionaro@void helloworld]$ docker run -v /tmp:/tmp --rm -t docker.io/cojocar/bin2llvm /bin/bash -c "/usr/local/bin2llvm/bin/bin2llvm.py --file /tmp/helloworld/helloworld"
Press Ctrl+C
INFO:bin2llvm:Using /tmp/bin2llvm-3jkewR as temp_dir
Traceback (most recent call last):
  File "/usr/local/bin2llvm/bin/bin2llvm.py", line 855, in <module>
    main()
  File "/usr/local/bin2llvm/bin/bin2llvm.py", line 631, in main
    cfg, isThumbIn = do_elf(args.file[0], args.temp_dir)
  File "/usr/local/bin2llvm/bin/bin2llvm-pymodules/elf_parser.py", line 51, in do_elf
    raise Exception("Architecture not supported")
Exception: Architecture not supported

Docker output file

INFO:bin2llvm:Use entry: 0x0001b71c
INFO:bin2llvm:Use entry: 0x00026efc
INFO:bin2llvm:Use entry: 0x00000000
WARNING:bin2llvm:(passes) crashed with entry: 0x00000000
INFO:bin2llvm:FINAL output is in /tmp/bin2llvm-n349ai/final.bc (370 functions)

I ran the sample command in the docker container and I get this end result. However, I cannot fine the /tmp/bin2llvm-n349ai/final.bc file. Where is this located?

Not Compiling on macOS

Seems like a issue related to LLVM3.2 itself, can I replace it with LLVM5.X/4.X ?

Development/bin2llvm-build/llvm-3.2.src.native/lib/Analysis/LazyValueInfo.cpp:998:14: error: 
      no matching member function for call to 'insert'
    worklist.insert(worklist.end(), succ_begin(ToUpdate), succ_end(ToUpdate));
    ~~~~~~~~~^~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:706:14: note: 
      candidate function not viable: no known conversion from 'succ_iterator'
      (aka 'SuccIterator<llvm::TerminatorInst *, llvm::BasicBlock>') to
      'size_type' (aka 'unsigned long') for 2nd argument
    iterator insert(const_iterator __position, size_type __n, const_refe...
             ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:710:14: note: 
      candidate template ignored: disabled by 'enable_if' [with _InputIterator =
      llvm::SuccIterator<llvm::TerminatorInst *, llvm::BasicBlock>]
             __is_input_iterator  <_InputIterator>::value &&
             ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:721:13: note: 
      candidate template ignored: disabled by 'enable_if' [with _ForwardIterator
      = llvm::SuccIterator<llvm::TerminatorInst *, llvm::BasicBlock>]
            __is_forward_iterator<_ForwardIterator>::value &&
            ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:698:14: note: 
      candidate function not viable: requires 2 arguments, but 3 were provided
    iterator insert(const_iterator __position, const_reference __x);
             ^
1 error generated.

And this is my native compiler:

[bin2llvm] clang -v                                                                                                                                                                    master  ✱
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Arm to llvm-ir

Hi.
I want to translate arm assembly code to llvm-ir staticly for a try by translating simple code. In my opinion, I should translate arm instruction to llvm-ir one by one, and then replace arm instructions by a script. Maybe I think it too simple.

But I didn't find enough data to do this. It seems that the instructions about jump is difficult and the list of AMT is too large. What's more, I'm not sure how to translate some arm instructions to llvm-ir, and how to design whole infrastructure of target .ll file just according to assembly code?

Do you have some reference data about the translation job? And could you give me some references?
best regards.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.