]> git.siccegge.de Git - frida/frida.git/commitdiff
Forward port to llvm-3.5 (cip)
authorChristoph Egger <siccegge@stud.informatik.uni-erlangen.de>
Wed, 14 May 2014 09:13:45 +0000 (11:13 +0200)
committerChristoph Egger <siccegge@stud.informatik.uni-erlangen.de>
Wed, 14 May 2014 09:13:45 +0000 (11:13 +0200)
src/Binary.cxx
src/Binary.hxx
src/disassembler/Disassembler.cxx
src/disassembler/Disassembler.hxx
src/disassembler/Target.cxx
src/disassembler/Target.hxx

index 1d64b8445a0ef80bfcdfd3d87d1aa90302d8c6c5..f4e00a3f33cff31bab55686594973a94e0590da3 100644 (file)
@@ -56,8 +56,8 @@ namespace {
     std::map<std::string, SectionRef> readSections(const ObjectFile& o) {
         error_code ec;
         std::map<std::string, SectionRef> result;
-        section_iterator i(o.begin_sections()), e(o.end_sections());
-        for (; i != e; i.increment(ec)) {
+        section_iterator i(o.section_begin()), e(o.section_end());
+        for (; i != e; ++i) {
             StringRef name;
             if (error(i->getName(name))) break;
 
@@ -69,8 +69,8 @@ namespace {
     std::map<std::string, SymbolRef> readSymbols(const ObjectFile& o) {
         error_code ec;
         std::map<std::string, SymbolRef> result;
-        symbol_iterator si(o.begin_symbols()), se(o.end_symbols());
-        for (; si != se; si.increment(ec)) {
+        symbol_iterator si(o.symbol_begin()), se(o.symbol_end());
+        for (; si != se; ++si) {
             StringRef name;
             if (error(si->getName(name))) break;
 
@@ -88,13 +88,13 @@ namespace qtlldb {
         ::Disassembler d(filename);
         std::string error;
 
-        createBinary(filename, binary);
-        if (Archive *a = dyn_cast<Archive>(binary.get())) {
+        binary = createBinary(filename).get();
+        if (Archive *a = dyn_cast<Archive>(binary)) {
             std::cerr << "Got an archive!" << std::endl;
             return;
         }
 
-        o = dyn_cast<ObjectFile>(binary.get());
+        o = dyn_cast<ObjectFile>(binary);
 
         triple.setArch(Triple::ArchType(o->getArch()));
         std::string tripleName(triple.getTriple());
@@ -195,7 +195,7 @@ namespace qtlldb {
 
         if (symbols.end() != symbols.find(function)) {
             SymbolRef ref;
-            section_iterator sec(o->begin_sections());
+            section_iterator sec(o->section_begin());
 
             ref = symbols.at(function);
             if (error(ref.getSection(sec))) return;
@@ -268,9 +268,9 @@ namespace qtlldb {
 
     void Binary::disassemble_functions() {
         error_code ec;
-        for (section_iterator i = o->begin_sections(),
-                 e = o->end_sections();
-             i != e; i.increment(ec)) {
+        for (section_iterator i = o->section_begin(),
+                 e = o->section_end();
+             i != e; ++i) {
             if (error(ec)) break;
             bool text;
             if (error(i->isText(text))) break;
@@ -281,9 +281,9 @@ namespace qtlldb {
 
             // Make a list of all the symbols in this section.
             std::vector<std::pair<uint64_t, StringRef> > Symbols;
-            for (symbol_iterator si = o->begin_symbols(),
-                     se = o->end_symbols();
-                 si != se; si.increment(ec)) {
+            for (symbol_iterator si = o->symbol_begin(),
+                     se = o->symbol_end();
+                 si != se; ++si) {
                 bool contains;
                 if (!error(i->containsSymbol(*si, contains)) && contains) {
                     uint64_t Address;
@@ -364,7 +364,7 @@ namespace qtlldb {
                 outs() << '\n' << Symbols[si].second << ":\n";
 
 #ifndef NDEBUG
-                raw_ostream &DebugOut = DebugFlag ? dbgs() : nulls();
+                raw_ostream &DebugOut = nulls(); //DebugFlag ? dbgs() : nulls();
 #else
                 raw_ostream &DebugOut = nulls();
 #endif
index 180d8eefe04948d73455a9edafe7051fee14fa35..873ac06fa72ff71f50040a26249daf0457147067 100644 (file)
@@ -31,7 +31,7 @@ namespace qtlldb {
         const llvm::Target * target;
         llvm::object::ObjectFile * o;
 
-        OwningPtr<llvm::object::Binary> binary;
+               llvm::object::Binary* binary;
         OwningPtr<const llvm::MCRegisterInfo> MRI;
         OwningPtr<const llvm::MCAsmInfo> AsmInfo;
         OwningPtr<llvm::MCModule> Mod;
index babac8249a79fb9f01d66a37c1822ba8494f5885..7422df561784966652b8f7e69ebb276019f2e0ea 100644 (file)
@@ -1,17 +1,11 @@
 #include "Disassembler.hxx"
 
-namespace {
-    llvm::OwningPtr<llvm::object::Binary>&
-    constructor_helper(const std::string& filename,
-                       llvm::OwningPtr<llvm::object::Binary>& binary) {
-        createBinary(filename, binary);
-        return binary;
-    }
-}
-
+using namespace llvm;
+using namespace llvm::object;
 
 Disassembler::Disassembler(const std::string& filename) 
-    : _target(constructor_helper(filename, _binary))
+       : _binary(createBinary(filename).get())
+       , _target(_binary)
 {
     
 }
index 5ccd9ff62499c5d55e42b5ce58208d9609842fc7..13c36b6d30a481a7d2892a81a644f1f377ad9464 100644 (file)
@@ -8,8 +8,7 @@ class Disassembler {
 public:
     Disassembler(const std::string& filename);
 private:
-    llvm::OwningPtr<llvm::object::Binary> _binary;
-
+    llvm::object::Binary* _binary;
     Target _target;
 };
 
index 56042d55b0ee761ee98b57ef6d747625996490c5..bb96b0d7031a04cbb400b1e4703acbf286cc8459 100644 (file)
@@ -3,12 +3,12 @@
 
 #include <string>
 
-Target::    Target(const llvm::OwningPtr<llvm::object::Binary>& binary)
+Target::Target(llvm::object::Binary* binary)
     : _logger(log4cxx::Logger::getLogger("disassembler.Target"))
     , triple("unknown-unknown-unknown")
 {
     std::string error;
-    llvm::object::ObjectFile * o = llvm::dyn_cast<llvm::object::ObjectFile>(binary.get());
+    llvm::object::ObjectFile * o = llvm::dyn_cast<llvm::object::ObjectFile>(binary);
 
     triple.setArch(llvm::Triple::ArchType(o->getArch()));
     std::string tripleName(triple.getTriple());
index db3a4be7a661d1fd49afeb05a399ad038b25bb73..8710ba06e482e068b8fd6a986c84536897b7492a 100644 (file)
@@ -7,7 +7,7 @@
 
 class Target {
 public:
-    Target(const llvm::OwningPtr<llvm::object::Binary>& binary);
+    Target(llvm::object::Binary* binary);
 
     const llvm::Target& getTarget() const {
         return *target;