]> git.siccegge.de Git - frida/frida.git/blob - src/disassembler.old/Target.cxx
Some more notes
[frida/frida.git] / src / disassembler.old / Target.cxx
1 #include "Target.hxx"
2
3 #include <string>
4
5 Target::Target(llvm::object::Binary* binary)
6 : _logger(log4cxx::Logger::getLogger("disassembler.Target"))
7 , triple("unknown-unknown-unknown")
8 {
9 std::string error;
10 llvm::object::ObjectFile * o = llvm::dyn_cast<llvm::object::ObjectFile>(binary);
11
12 triple.setArch(llvm::Triple::ArchType(o->getArch()));
13 std::string tripleName(triple.getTriple());
14 LOG4CXX_INFO(_logger, "Detected triple " << tripleName);
15
16 target = llvm::TargetRegistry::lookupTarget("", triple, error);
17 if (!target) {
18 LOG4CXX_ERROR(_logger, "Couldn't create Target: " << error);
19 return;
20 }
21 LOG4CXX_INFO(_logger, "Target: " << target->getName());
22
23 STI.reset(target->createMCSubtargetInfo(tripleName, "", ""));
24 if (!STI) {
25 LOG4CXX_ERROR(_logger, "No subtarget for target " << tripleName);
26 return;
27 }
28 }