[Object, MachO] Introduce MachOObjectFile::load_commands() range iterator.
[oota-llvm.git] / include / llvm / Object / MachO.h
index 0fe327d6adcad2f6cc52131cc3013ff2acbd353a..63523133bacfa7a0b3272a6e0e41c741c41ed5ef 100644 (file)
@@ -190,6 +190,8 @@ public:
     const char *Ptr;      // Where in memory the load command is.
     MachO::load_command C; // The command itself.
   };
+  typedef SmallVector<LoadCommandInfo, 4> LoadCommandList;
+  typedef LoadCommandList::const_iterator load_command_iterator;
 
   MachOObjectFile(MemoryBufferRef Object, bool IsLittleEndian, bool Is64Bits,
                   std::error_code &EC);
@@ -204,9 +206,8 @@ public:
 
   std::error_code getSymbolAddress(DataRefImpl Symb,
                                    uint64_t &Res) const override;
-  std::error_code getSymbolAlignment(DataRefImpl Symb,
-                                     uint32_t &Res) const override;
-  std::error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const override;
+  uint32_t getSymbolAlignment(DataRefImpl Symb) const override;
+  uint64_t getSymbolSize(DataRefImpl Symb) const override;
   std::error_code getSymbolType(DataRefImpl Symb,
                                 SymbolRef::Type &Res) const override;
   uint32_t getSymbolFlags(DataRefImpl Symb) const override;
@@ -241,9 +242,6 @@ public:
   std::error_code
   getRelocationTypeName(DataRefImpl Rel,
                         SmallVectorImpl<char> &Result) const override;
-  std::error_code
-  getRelocationValueString(DataRefImpl Rel,
-                           SmallVectorImpl<char> &Result) const override;
   std::error_code getRelocationHidden(DataRefImpl Rel,
                                       bool &Result) const override;
   uint8_t getRelocationLength(DataRefImpl Rel) const;
@@ -274,10 +272,14 @@ public:
 
   dice_iterator begin_dices() const;
   dice_iterator end_dices() const;
-  
+
+  load_command_iterator begin_load_commands() const;
+  load_command_iterator end_load_commands() const;
+  iterator_range<load_command_iterator> load_commands() const;
+
   /// For use iterating over all exported symbols.
   iterator_range<export_iterator> exports() const;
-  
+
   /// For use examining a trie not in a MachOObjectFile.
   static iterator_range<export_iterator> exports(ArrayRef<uint8_t> Trie);
 
@@ -330,10 +332,6 @@ public:
   unsigned getAnyRelocationType(const MachO::any_relocation_info &RE) const;
   SectionRef getAnyRelocationSection(const MachO::any_relocation_info &RE) const;
 
-  // Walk load commands.
-  LoadCommandInfo getFirstLoadCommandInfo() const;
-  LoadCommandInfo getNextLoadCommandInfo(const LoadCommandInfo &L) const;
-
   // MachO specific structures.
   MachO::section getSection(DataRefImpl DRI) const;
   MachO::section_64 getSection64(DataRefImpl DRI) const;
@@ -431,10 +429,15 @@ public:
   }
 
 private:
+  // Walk load commands.
+  LoadCommandInfo getFirstLoadCommandInfo() const;
+  LoadCommandInfo getNextLoadCommandInfo(const LoadCommandInfo &L) const;
+
   typedef SmallVector<const char*, 1> SectionList;
   SectionList Sections;
   typedef SmallVector<const char*, 1> LibraryList;
   LibraryList Libraries;
+  LoadCommandList LoadCommands;
   typedef SmallVector<StringRef, 1> LibraryShortName;
   mutable LibraryShortName LibrariesShortNames;
   const char *SymtabLoadCmd;