SRI-CSL / whole-program-llvm

A toolkit for building whole-program LLVM bitcode files
MIT License
72 stars 11 forks source link

Problem in httpd #14

Closed awanish-pandey closed 7 years ago

awanish-pandey commented 7 years ago

I generated LLVM bitcode for apache 2.2.16 with the help of your tool and it gives me httpd.bc. When I am using this bit code file its always giving me seg fault. LLVM version 3.4.2

command used: CC=wllvm ../configure make make install extract-bc ./bin/httpd

when I am doing lli httpd.bc it says that pseudo instructions should be removed before code emission UNREACHABLE executed at /home/awanish/llvm/llvm-3.4.2/lib/Target/X86/X86CodeEmitter.cpp:1176! 0 libLLVM-3.4.so 0x00007fed368c1ea2 llvm::sys::PrintStackTrace(_IOFILE) + 34 1 libLLVM-3.4.so 0x00007fed368c1ac4 2 libpthread.so.0 0x00007fed35abe330 3 libc.so.6 0x00007fed3541bc37 gsignal + 55 4 libc.so.6 0x00007fed3541f028 abort + 328 5 libLLVM-3.4.so 0x00007fed368acbfc 6 libLLVM-3.4.so 0x00007fed369ce6a8 7 libLLVM-3.4.so 0x00007fed369cf932 8 libLLVM-3.4.so 0x00007fed36389d9f llvm::FPPassManager::runOnFunction(llvm::Function&) + 655 9 libLLVM-3.4.so 0x00007fed36389ec3 llvm::legacy::FunctionPassManagerImpl::run(llvm::Function&) + 163 10 libLLVM-3.4.so 0x00007fed3638a044 llvm::legacy::FunctionPassManager::run(llvm::Function&) + 84 11 libLLVM-3.4.so 0x00007fed36508434 llvm::JIT::jitTheFunction(llvm::Function, llvm::MutexGuard const&) + 36 12 libLLVM-3.4.so 0x00007fed36508a9c llvm::JIT::runJITOnFunctionUnlocked(llvm::Function, llvm::MutexGuard const&) + 28 13 libLLVM-3.4.so 0x00007fed36508cd2 llvm::JIT::getPointerToFunction(llvm::Function_) + 210 14 lli 0x0000000000406ef2 main + 3778 15 libc.so.6 0x00007fed35406f45 __libc_start_main + 245 16 lli 0x000000000040975e Stack dump:

  1. Program arguments: lli httpd.bc
  2. Running pass 'X86 Machine Code Emitter' on function '@main' Aborted (core dumped)

Please help me out. Where I am doing wrong?

ianamason commented 7 years ago

You are doing nothing wrong. In my experience lli is not at all reliable. Especially an old version like 3.4.

What are you actually trying to achieve here?

awanish-pandey commented 7 years ago

I am trying to run that hhtpd.bc file on klee it says

klee: /home/awanish/llvm/llvm-3.4.2/lib/IR/Instructions.cpp:2352: static llvm::CastInst _llvm::CastInst::Create(Instruction::CastOps, llvm::Value , llvm::Type , const llvm::Twine &, llvm::Instruction *): Assertion `castIsValid(op, S, Ty) && "Invalid cast!"' failed. 0 libLLVM-3.4.so 0x00007f3df9f4d5d5 llvm::sys::PrintStackTrace(_IOFILE) + 37 1 libLLVM-3.4.so 0x00007f3df9f4da23 2 libpthread.so.0 0x00007f3df91fe330 3 libc.so.6 0x00007f3df863fc37 gsignal + 55 4 libc.so.6 0x00007f3df8643028 abort + 328 5 libc.so.6 0x00007f3df8638bf6 6 libc.so.6 0x00007f3df8638ca2 7 libLLVM-3.4.so 0x00007f3df9a1bd9e 8 klee 0x00000000004da63a klee::OvershiftCheckPass::runOnModule(llvm::Module&) + 618 9 libLLVM-3.4.so 0x00007f3df9a2f5c7 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 999 10 klee 0x00000000004d2aea klee::KModule::prepare(klee::Interpreter::ModuleOptions const&, klee::InterpreterHandler) + 1290 11 klee 0x00000000004883c7 klee::Executor::setModule(llvm::Module, klee::Interpreter::ModuleOptions const&) + 263 12 klee 0x000000000047859c main + 4508 13 libc.so.6 0x00007f3df862af45 __libc_start_main + 245 14 klee 0x00000000004822ef Aborted (core dumped) And while compiling mysql and wireshark it says there is no main function in mysql.bc and wireshark.bc file.

ianamason commented 7 years ago

I doubt that these issues are due to wllvm, which is really doing nothing other than getting clang to emit llvm bitcode, and then link them with llvm-link.

I expect them to be due to either lli or klee or their use of libc. The last sentence is also hard to parse.

And while compiling mysql and wireshark it says there is no main function in mysql.bc and wireshark.bc file

What is "it"? klee?

If so, my guess is you would be better of asking the klee crowd.

awanish-pandey commented 7 years ago

Sorry for encrypting writing.

I was trying to build bc file for wire-shark and mysql when I did "extract-bc mysql" then it gives me mysql.bc but when I am running this bc file with either lli or klee it says main function not found. Similarly for wireshark too.

ianamason commented 7 years ago

My guess is that mysql is a library, and not an executable. Not sure about wireshark. Again though. This is not an issue with wllvm.