[llvm] r178948 - Remove last use of InMemoryStruct from MachOObjectFile.cpp.

Rafael Espindola rafael.espindola at gmail.com
Fri Apr 5 20:50:06 PDT 2013


Author: rafael
Date: Fri Apr  5 22:50:05 2013
New Revision: 178948

URL: http://llvm.org/viewvc/llvm-project?rev=178948&view=rev
Log:
Remove last use of InMemoryStruct from MachOObjectFile.cpp.

Modified:
    llvm/trunk/include/llvm/Object/MachO.h
    llvm/trunk/lib/Object/MachOObjectFile.cpp

Modified: llvm/trunk/include/llvm/Object/MachO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/MachO.h?rev=178948&r1=178947&r2=178948&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/MachO.h (original)
+++ llvm/trunk/include/llvm/Object/MachO.h Fri Apr  5 22:50:05 2013
@@ -85,6 +85,34 @@ namespace MachOFormat {
     support::ulittle32_t StringTableOffset;
     support::ulittle32_t StringTableSize;
   };
+
+  struct SegmentLoadCommand {
+    support::ulittle32_t Type;
+    support::ulittle32_t Size;
+    char Name[16];
+    support::ulittle32_t VMAddress;
+    support::ulittle32_t VMSize;
+    support::ulittle32_t FileOffset;
+    support::ulittle32_t FileSize;
+    support::ulittle32_t MaxVMProtection;
+    support::ulittle32_t InitialVMProtection;
+    support::ulittle32_t NumSections;
+    support::ulittle32_t Flags;
+  };
+
+  struct Segment64LoadCommand {
+    support::ulittle32_t Type;
+    support::ulittle32_t Size;
+    char Name[16];
+    support::ulittle64_t VMAddress;
+    support::ulittle64_t VMSize;
+    support::ulittle64_t FileOffset;
+    support::ulittle64_t FileSize;
+    support::ulittle32_t MaxVMProtection;
+    support::ulittle32_t InitialVMProtection;
+    support::ulittle32_t NumSections;
+    support::ulittle32_t Flags;
+  };
 }
 
 typedef MachOObject::LoadCommandInfo LoadCommandInfo;
@@ -204,6 +232,10 @@ private:
   const MachOFormat::RelocationEntry *getRelocation(DataRefImpl Rel) const;
   const MachOFormat::SymtabLoadCommand *
     getSymtabLoadCommand(LoadCommandInfo LCI) const;
+  const MachOFormat::SegmentLoadCommand *
+    getSegmentLoadCommand(LoadCommandInfo LCI) const;
+  const MachOFormat::Segment64LoadCommand *
+    getSegment64LoadCommand(LoadCommandInfo LCI) const;
   std::size_t getSectionIndex(DataRefImpl Sec) const;
 
   void printRelocationTargetName(const MachOFormat::RelocationEntry *RE,

Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=178948&r1=178947&r2=178948&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Fri Apr  5 22:50:05 2013
@@ -68,6 +68,21 @@ MachOObjectFile::getSymtabLoadCommand(Lo
   return reinterpret_cast<const MachOFormat::SymtabLoadCommand*>(Data.data());
 }
 
+const MachOFormat::SegmentLoadCommand *
+MachOObjectFile::getSegmentLoadCommand(LoadCommandInfo LCI) const {
+  StringRef Data = MachOObj->getData(LCI.Offset,
+                                     sizeof(MachOFormat::SegmentLoadCommand));
+  return reinterpret_cast<const MachOFormat::SegmentLoadCommand*>(Data.data());
+}
+
+const MachOFormat::Segment64LoadCommand *
+MachOObjectFile::getSegment64LoadCommand(LoadCommandInfo LCI) const {
+  StringRef Data = MachOObj->getData(LCI.Offset,
+                                     sizeof(MachOFormat::Segment64LoadCommand));
+  return
+    reinterpret_cast<const MachOFormat::Segment64LoadCommand*>(Data.data());
+}
+
 void MachOObjectFile::moveToNextSymbol(DataRefImpl &DRI) const {
   uint32_t LoadCommandCount = MachOObj->getHeader().NumLoadCommands;
   while (DRI.d.a < LoadCommandCount) {
@@ -436,13 +451,13 @@ void MachOObjectFile::moveToNextSection(
   while (DRI.d.a < LoadCommandCount) {
     LoadCommandInfo LCI = MachOObj->getLoadCommandInfo(DRI.d.a);
     if (LCI.Command.Type == macho::LCT_Segment) {
-      InMemoryStruct<macho::SegmentLoadCommand> SegmentLoadCmd;
-      MachOObj->ReadSegmentLoadCommand(LCI, SegmentLoadCmd);
+      const MachOFormat::SegmentLoadCommand *SegmentLoadCmd =
+        getSegmentLoadCommand(LCI);
       if (DRI.d.b < SegmentLoadCmd->NumSections)
         return;
     } else if (LCI.Command.Type == macho::LCT_Segment64) {
-      InMemoryStruct<macho::Segment64LoadCommand> Segment64LoadCmd;
-      MachOObj->ReadSegment64LoadCommand(LCI, Segment64LoadCmd);
+      const MachOFormat::Segment64LoadCommand *Segment64LoadCmd =
+        getSegment64LoadCommand(LCI);
       if (DRI.d.b < Segment64LoadCmd->NumSections)
         return;
     }





More information about the llvm-commits mailing list