ahmedbougacha / dagger

Binary Translator to LLVM IR
Other
214 stars 51 forks source link

Issue with hello world decompilation #1

Closed sdasgup3 closed 7 years ago

sdasgup3 commented 7 years ago

With a program like

#include<stdio.h>
int main(int argc, char* argv[]) {
  printf("Hello WOrld!\n");
  return 0;
}
clang -m64 hello.c -o hello
./build/bin/llvm-dec ./hello

Gives:

  <MCInst 939>
Cannot translate instruction: 
  <MCInst 939>
Cannot translate instruction: 
  <MCInst 939>
Cannot translate instruction: 
  <MCInst 939>
Cannot translate instruction: 
  <MCInst 939>
Cannot translate instruction:

But if compiled with clang -m64 hello.c -c -o hello It correctly decompiles to IR. But the IR does not seem functional? Is the external function printf identified?

liangdzou commented 7 years ago

The problem is still there...

ahmedbougacha commented 7 years ago

c7f0d62 and 860e271 should take care of this; give it another try and let me know how it goes!

The issue was that the glibc entrypoint code (_start and friends) contains 'hlt', which should be unreachable. Additionally, it has 'rep;ret' which is an optimized alternative to 'ret'.

The problem is still there...

Patches always welcome ;)