about summary refs log tree commit diff homepage
path: root/lib/Core/ExternalDispatcher.h
blob: d8d9dc58b089d0ac81568edac66d1f140586678c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//===-- ExternalDispatcher.h ------------------------------------*- C++ -*-===//
//
//                     The KLEE Symbolic Virtual Machine
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef KLEE_EXTERNALDISPATCHER_H
#define KLEE_EXTERNALDISPATCHER_H

#include <map>
#include <string>
#include <stdint.h>

namespace llvm {
  class ExecutionEngine;
  class Instruction;
  class Function;
  class FunctionType;
  class Module;
}

namespace klee {
  class ExternalDispatcher {
  private:
    typedef std::map<const llvm::Instruction*,llvm::Function*> dispatchers_ty;
    dispatchers_ty dispatchers;
    llvm::Module *dispatchModule;
    llvm::ExecutionEngine *executionEngine;
    std::map<std::string, void*> preboundFunctions;
    
    llvm::Function *createDispatcher(llvm::Function *f, llvm::Instruction *i);
    bool runProtectedCall(llvm::Function *f, uint64_t *args);
    
  public:
    ExternalDispatcher();
    ~ExternalDispatcher();

    /* Call the given function using the parameter passing convention of
     * ci with arguments in args[1], args[2], ... and writing the result
     * into args[0].
     */
    bool executeCall(llvm::Function *function, llvm::Instruction *i, uint64_t *args);
    void *resolveSymbol(const std::string &name);
  };  
}

#endif