Remove MachOObjectFile::getObject.
authorRafael Espindola <rafael.espindola@gmail.com>
Sun, 7 Apr 2013 16:07:35 +0000 (16:07 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Sun, 7 Apr 2013 16:07:35 +0000 (16:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178986 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Object/MachO.h
lib/Object/MachOObjectFile.cpp
tools/llvm-objdump/MachODump.cpp

index 2e504155ace3eda7f9ed3844353534e3366cf646..f3b47a0f333b55aeb356fc8150a30e31150a6f38 100644 (file)
@@ -161,8 +161,9 @@ public:
   const MachOFormat::SymbolTableEntry *
     getSymbolTableEntry(DataRefImpl DRI) const;
   bool is64Bit() const;
-
-  const MachOObject *getObject() const { return MachOObj.get(); }
+  const LoadCommandInfo &getLoadCommandInfo(unsigned Index) const;
+  void ReadULEB128s(uint64_t Index, SmallVectorImpl<uint64_t> &Out) const;
+  const macho::Header &getHeader() const;
 
   static inline bool classof(const Binary *v) {
     return v->isMachO();
index 86677231c4e6d09ee500dbc591d3e3bfda1732fd..fdce21bfd7809ca28fca96cbd992057f7abd65dd 100644 (file)
@@ -45,6 +45,20 @@ bool MachOObjectFile::is64Bit() const {
   return MachOObj->is64Bit();
 }
 
+const LoadCommandInfo &
+MachOObjectFile::getLoadCommandInfo(unsigned Index) const {
+  return MachOObj->getLoadCommandInfo(Index);
+}
+
+void MachOObjectFile::ReadULEB128s(uint64_t Index,
+                                   SmallVectorImpl<uint64_t> &Out) const {
+  return MachOObj->ReadULEB128s(Index, Out);
+}
+
+const macho::Header &MachOObjectFile::getHeader() const {
+  return MachOObj->getHeader();
+}
+
 ObjectFile *ObjectFile::createMachOObjectFile(MemoryBuffer *Buffer) {
   error_code ec;
   std::string Err;
index 282f04db2e4b8b34e81311bcfff2f17aa6925acb..d3f29d2d50f63d85a388452cf6469a8727784586 100644 (file)
@@ -52,7 +52,7 @@ static cl::opt<bool>
 static cl::opt<std::string>
   DSYMFile("dsym", cl::desc("Use .dSYM file for debug info"));
 
-static const Target *GetTarget(const MachOObject *MachOObj) {
+static const Target *GetTarget(const MachOObjectFile *MachOObj) {
   // Figure out the target triple.
   if (TripleName.empty()) {
     llvm::Triple TT("unknown-unknown-unknown");
@@ -108,7 +108,7 @@ struct SymbolSorter {
 
 // Print additional information about an address, if available.
 static void DumpAddress(uint64_t Address, ArrayRef<SectionRef> Sections,
-                        const MachOObject *MachOObj, raw_ostream &OS) {
+                        const MachOObjectFile *MachOObj, raw_ostream &OS) {
   for (unsigned i = 0; i != Sections.size(); ++i) {
     uint64_t SectAddr = 0, SectSize = 0;
     Sections[i].getAddress(SectAddr);
@@ -218,15 +218,14 @@ static void getSectionsAndSymbols(const macho::Header &Header,
   }
 
   for (unsigned i = 0; i != Header.NumLoadCommands; ++i) {
-    const MachOObject::LoadCommandInfo &LCI =
-       MachOObj->getObject()->getLoadCommandInfo(i);
+    const MachOObject::LoadCommandInfo &LCI = MachOObj->getLoadCommandInfo(i);
     if (LCI.Command.Type == macho::LCT_FunctionStarts) {
       // We found a function starts segment, parse the addresses for later
       // consumption.
       const MachOFormat::LinkeditDataLoadCommand *LLC =
         MachOObj->getLinkeditDataLoadCommand(LCI);
 
-      MachOObj->getObject()->ReadULEB128s(LLC->DataOffset, FoundFns);
+      MachOObj->ReadULEB128s(LLC->DataOffset, FoundFns);
     }
   }
 }
@@ -241,9 +240,8 @@ void llvm::DisassembleInputMachO(StringRef Filename) {
 
   OwningPtr<MachOObjectFile> MachOOF(static_cast<MachOObjectFile*>(
         ObjectFile::createMachOObjectFile(Buff.take())));
-  const MachOObject *MachOObj = MachOOF->getObject();
 
-  const Target *TheTarget = GetTarget(MachOObj);
+  const Target *TheTarget = GetTarget(MachOOF.get());
   if (!TheTarget) {
     // GetTarget prints out stuff.
     return;
@@ -271,7 +269,7 @@ void llvm::DisassembleInputMachO(StringRef Filename) {
 
   outs() << '\n' << Filename << ":\n\n";
 
-  const macho::Header &Header = MachOObj->getHeader();
+  const macho::Header &Header = MachOOF->getHeader();
 
   std::vector<SectionRef> Sections;
   std::vector<SymbolRef> Symbols;
@@ -580,7 +578,7 @@ void llvm::DisassembleInputMachO(StringRef Filename) {
                 Relocs[j].second.getName(SymName);
 
                 outs() << "\t# " << SymName << ' ';
-                DumpAddress(Addr, Sections, MachOObj, outs());
+                DumpAddress(Addr, Sections, MachOOF.get(), outs());
               }
 
             // If this instructions contains an address, see if we can evaluate
@@ -589,7 +587,7 @@ void llvm::DisassembleInputMachO(StringRef Filename) {
                                                           Inst.Address,
                                                           Inst.Size);
             if (targ != -1ULL)
-              DumpAddress(targ, Sections, MachOObj, outs());
+              DumpAddress(targ, Sections, MachOOF.get(), outs());
 
             // Print debug info.
             if (diContext) {