LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ObjectFile.h
Go to the documentation of this file.
1 //===- ObjectFile.h - File format independent object file -------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares a file format independent ObjectFile class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_OBJECT_OBJECTFILE_H
15 #define LLVM_OBJECT_OBJECTFILE_H
16 
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/Object/Binary.h"
19 #include "llvm/Support/DataTypes.h"
22 #include <cstring>
23 #include <vector>
24 
25 namespace llvm {
26 namespace object {
27 
28 class ObjectFile;
29 
30 union DataRefImpl {
31  // This entire union should probably be a
32  // char[max(8, sizeof(uintptr_t))] and require the impl to cast.
33  struct {
34  uint32_t a, b;
35  } d;
36  uintptr_t p;
38  std::memset(this, 0, sizeof(DataRefImpl));
39  }
40 };
41 
42 template<class content_type>
44  content_type Current;
45 public:
46  content_iterator(content_type symb)
47  : Current(symb) {}
48 
49  const content_type* operator->() const {
50  return &Current;
51  }
52 
53  const content_type &operator*() const {
54  return Current;
55  }
56 
57  bool operator==(const content_iterator &other) const {
58  return Current == other.Current;
59  }
60 
61  bool operator!=(const content_iterator &other) const {
62  return !(*this == other);
63  }
64 
66  content_type next;
67  if (error_code ec = Current.getNext(next))
68  err = ec;
69  else
70  Current = next;
71  return *this;
72  }
73 };
74 
75 inline bool operator==(const DataRefImpl &a, const DataRefImpl &b) {
76  // Check bitwise identical. This is the only legal way to compare a union w/o
77  // knowing which member is in use.
78  return std::memcmp(&a, &b, sizeof(DataRefImpl)) == 0;
79 }
80 
81 inline bool operator<(const DataRefImpl &a, const DataRefImpl &b) {
82  // Check bitwise identical. This is the only legal way to compare a union w/o
83  // knowing which member is in use.
84  return std::memcmp(&a, &b, sizeof(DataRefImpl)) < 0;
85 }
86 
87 class SymbolRef;
89 
90 /// RelocationRef - This is a value type class that represents a single
91 /// relocation in the list of relocations in the object file.
93  DataRefImpl RelocationPimpl;
94  const ObjectFile *OwningObject;
95 
96 public:
97  RelocationRef() : OwningObject(NULL) { }
98 
99  RelocationRef(DataRefImpl RelocationP, const ObjectFile *Owner);
100 
101  bool operator==(const RelocationRef &Other) const;
102 
103  error_code getNext(RelocationRef &Result) const;
104 
105  error_code getAddress(uint64_t &Result) const;
106  error_code getOffset(uint64_t &Result) const;
107  symbol_iterator getSymbol() const;
108  error_code getType(uint64_t &Result) const;
109 
110  /// @brief Indicates whether this relocation should hidden when listing
111  /// relocations, usually because it is the trailing part of a multipart
112  /// relocation that will be printed as part of the leading relocation.
113  error_code getHidden(bool &Result) const;
114 
115  /// @brief Get a string that represents the type of this relocation.
116  ///
117  /// This is for display purposes only.
119 
120  /// @brief Get a string that represents the calculation of the value of this
121  /// relocation.
122  ///
123  /// This is for display purposes only.
125 
127  const ObjectFile *getObjectFile() const;
128 };
130 
131 /// SectionRef - This is a value type class that represents a single section in
132 /// the list of sections in the object file.
135 class SectionRef {
136  friend class SymbolRef;
137  DataRefImpl SectionPimpl;
138  const ObjectFile *OwningObject;
139 
140 public:
141  SectionRef() : OwningObject(NULL) { }
142 
143  SectionRef(DataRefImpl SectionP, const ObjectFile *Owner);
144 
145  bool operator==(const SectionRef &Other) const;
146  bool operator<(const SectionRef &Other) const;
147 
148  error_code getNext(SectionRef &Result) const;
149 
150  error_code getName(StringRef &Result) const;
151  error_code getAddress(uint64_t &Result) const;
152  error_code getSize(uint64_t &Result) const;
153  error_code getContents(StringRef &Result) const;
154 
155  /// @brief Get the alignment of this section as the actual value (not log 2).
156  error_code getAlignment(uint64_t &Result) const;
157 
158  // FIXME: Move to the normalization layer when it's created.
159  error_code isText(bool &Result) const;
160  error_code isData(bool &Result) const;
161  error_code isBSS(bool &Result) const;
162  error_code isRequiredForExecution(bool &Result) const;
163  error_code isVirtual(bool &Result) const;
164  error_code isZeroInit(bool &Result) const;
165  error_code isReadOnlyData(bool &Result) const;
166 
167  error_code containsSymbol(SymbolRef S, bool &Result) const;
168 
172 
174 };
175 
176 /// SymbolRef - This is a value type class that represents a single symbol in
177 /// the list of symbols in the object file.
178 class SymbolRef {
179  friend class SectionRef;
180  DataRefImpl SymbolPimpl;
181  const ObjectFile *OwningObject;
182 
183 public:
184  SymbolRef() : OwningObject(NULL) { }
185 
186  enum Type {
187  ST_Unknown, // Type not specified
193  };
194 
195  enum Flags LLVM_ENUM_INT_TYPE(unsigned) {
196  SF_None = 0,
197  SF_Undefined = 1U << 0, // Symbol is defined in another object file
198  SF_Global = 1U << 1, // Global symbol
199  SF_Weak = 1U << 2, // Weak symbol
200  SF_Absolute = 1U << 3, // Absolute symbol
201  SF_ThreadLocal = 1U << 4, // Thread local symbol
202  SF_Common = 1U << 5, // Symbol has common linkage
203  SF_FormatSpecific = 1U << 31 // Specific to the object file format
204  // (e.g. section symbols)
205  };
206 
207  SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner);
208 
209  bool operator==(const SymbolRef &Other) const;
210  bool operator<(const SymbolRef &Other) const;
211 
212  error_code getNext(SymbolRef &Result) const;
213 
214  error_code getName(StringRef &Result) const;
215  /// Returns the symbol virtual address (i.e. address at which it will be
216  /// mapped).
217  error_code getAddress(uint64_t &Result) const;
218  error_code getFileOffset(uint64_t &Result) const;
219  /// @brief Get the alignment of this symbol as the actual value (not log 2).
220  error_code getAlignment(uint32_t &Result) const;
221  error_code getSize(uint64_t &Result) const;
222  error_code getType(SymbolRef::Type &Result) const;
223 
224  /// Get symbol flags (bitwise OR of SymbolRef::Flags)
225  error_code getFlags(uint32_t &Result) const;
226 
227  /// @brief Get section this symbol is defined in reference to. Result is
228  /// end_sections() if it is undefined or is an absolute symbol.
229  error_code getSection(section_iterator &Result) const;
230 
231  /// @brief Get value of the symbol in the symbol table.
232  error_code getValue(uint64_t &Val) const;
233 
235 };
236 
237 /// LibraryRef - This is a value type class that represents a single library in
238 /// the list of libraries needed by a shared or dynamic object.
239 class LibraryRef {
240  friend class SectionRef;
241  DataRefImpl LibraryPimpl;
242  const ObjectFile *OwningObject;
243 
244 public:
245  LibraryRef() : OwningObject(NULL) { }
246 
247  LibraryRef(DataRefImpl LibraryP, const ObjectFile *Owner);
248 
249  bool operator==(const LibraryRef &Other) const;
250  bool operator<(const LibraryRef &Other) const;
251 
252  error_code getNext(LibraryRef &Result) const;
253 
254  // Get the path to this library, as stored in the object file.
255  error_code getPath(StringRef &Result) const;
256 
258 };
260 
261 const uint64_t UnknownAddressOrSize = ~0ULL;
262 
263 /// ObjectFile - This class is the base class for all object file types.
264 /// Concrete instances of this object are created by createObjectFile, which
265 /// figures out which type to create.
266 class ObjectFile : public Binary {
267  virtual void anchor();
270 
271 protected:
272  ObjectFile(unsigned int Type, MemoryBuffer *source);
273 
274  const uint8_t *base() const {
275  return reinterpret_cast<const uint8_t *>(Data->getBufferStart());
276  }
277 
278  // These functions are for SymbolRef to call internally. The main goal of
279  // this is to allow SymbolRef::SymbolPimpl to point directly to the symbol
280  // entry in the memory mapped object file. SymbolPimpl cannot contain any
281  // virtual functions because then it could not point into the memory mapped
282  // file.
283  //
284  // Implementations assume that the DataRefImpl is valid and has not been
285  // modified externally. It's UB otherwise.
286  friend class SymbolRef;
287  virtual error_code getSymbolNext(DataRefImpl Symb, SymbolRef &Res) const = 0;
288  virtual error_code getSymbolName(DataRefImpl Symb, StringRef &Res) const = 0;
289  virtual error_code getSymbolAddress(DataRefImpl Symb, uint64_t &Res) const = 0;
290  virtual error_code getSymbolFileOffset(DataRefImpl Symb, uint64_t &Res)const=0;
291  virtual error_code getSymbolAlignment(DataRefImpl Symb, uint32_t &Res) const;
292  virtual error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const = 0;
293  virtual error_code getSymbolType(DataRefImpl Symb,
294  SymbolRef::Type &Res) const = 0;
296  uint32_t &Res) const = 0;
298  section_iterator &Res) const = 0;
299  virtual error_code getSymbolValue(DataRefImpl Symb, uint64_t &Val) const = 0;
300 
301  // Same as above for SectionRef.
302  friend class SectionRef;
303  virtual error_code getSectionNext(DataRefImpl Sec, SectionRef &Res) const = 0;
304  virtual error_code getSectionName(DataRefImpl Sec, StringRef &Res) const = 0;
305  virtual error_code getSectionAddress(DataRefImpl Sec, uint64_t &Res) const =0;
306  virtual error_code getSectionSize(DataRefImpl Sec, uint64_t &Res) const = 0;
307  virtual error_code getSectionContents(DataRefImpl Sec, StringRef &Res)const=0;
308  virtual error_code getSectionAlignment(DataRefImpl Sec, uint64_t &Res)const=0;
309  virtual error_code isSectionText(DataRefImpl Sec, bool &Res) const = 0;
310  virtual error_code isSectionData(DataRefImpl Sec, bool &Res) const = 0;
311  virtual error_code isSectionBSS(DataRefImpl Sec, bool &Res) const = 0;
313  bool &Res) const = 0;
314  // A section is 'virtual' if its contents aren't present in the object image.
315  virtual error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const = 0;
316  virtual error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const = 0;
317  virtual error_code isSectionReadOnlyData(DataRefImpl Sec, bool &Res) const =0;
319  bool &Result) const = 0;
320  virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const = 0;
321  virtual relocation_iterator section_rel_end(DataRefImpl Sec) const = 0;
323 
324  // Same as above for RelocationRef.
325  friend class RelocationRef;
327  RelocationRef &Res) const = 0;
329  uint64_t &Res) const =0;
331  uint64_t &Res) const =0;
332  virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const = 0;
334  uint64_t &Res) const = 0;
336  SmallVectorImpl<char> &Result) const = 0;
338  SmallVectorImpl<char> &Result) const = 0;
339  virtual error_code getRelocationHidden(DataRefImpl Rel, bool &Result) const {
340  Result = false;
341  return object_error::success;
342  }
343 
344  // Same for LibraryRef
345  friend class LibraryRef;
346  virtual error_code getLibraryNext(DataRefImpl Lib, LibraryRef &Res) const = 0;
347  virtual error_code getLibraryPath(DataRefImpl Lib, StringRef &Res) const = 0;
348 
349 public:
350 
351  virtual symbol_iterator begin_symbols() const = 0;
352  virtual symbol_iterator end_symbols() const = 0;
353 
354  virtual symbol_iterator begin_dynamic_symbols() const = 0;
355  virtual symbol_iterator end_dynamic_symbols() const = 0;
356 
357  virtual section_iterator begin_sections() const = 0;
358  virtual section_iterator end_sections() const = 0;
359 
360  virtual library_iterator begin_libraries_needed() const = 0;
361  virtual library_iterator end_libraries_needed() const = 0;
362 
363  /// @brief The number of bytes used to represent an address in this object
364  /// file format.
365  virtual uint8_t getBytesInAddress() const = 0;
366 
367  virtual StringRef getFileFormatName() const = 0;
368  virtual /* Triple::ArchType */ unsigned getArch() const = 0;
369 
370  /// For shared objects, returns the name which this object should be
371  /// loaded from at runtime. This corresponds to DT_SONAME on ELF and
372  /// LC_ID_DYLIB (install name) on MachO.
373  virtual StringRef getLoadName() const = 0;
374 
375  /// @returns Pointer to ObjectFile subclass to handle this type of object.
376  /// @param ObjectPath The path to the object file. ObjectPath.isObject must
377  /// return true.
378  /// @brief Create ObjectFile from path.
379  static ObjectFile *createObjectFile(StringRef ObjectPath);
380  static ObjectFile *createObjectFile(MemoryBuffer *Object);
381 
382  static inline bool classof(const Binary *v) {
383  return v->isObject();
384  }
385 
386 public:
390 };
391 
392 // Inline function definitions.
393 inline SymbolRef::SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner)
394  : SymbolPimpl(SymbolP)
395  , OwningObject(Owner) {}
396 
397 inline bool SymbolRef::operator==(const SymbolRef &Other) const {
398  return SymbolPimpl == Other.SymbolPimpl;
399 }
400 
401 inline bool SymbolRef::operator<(const SymbolRef &Other) const {
402  return SymbolPimpl < Other.SymbolPimpl;
403 }
404 
405 inline error_code SymbolRef::getNext(SymbolRef &Result) const {
406  return OwningObject->getSymbolNext(SymbolPimpl, Result);
407 }
408 
409 inline error_code SymbolRef::getName(StringRef &Result) const {
410  return OwningObject->getSymbolName(SymbolPimpl, Result);
411 }
412 
413 inline error_code SymbolRef::getAddress(uint64_t &Result) const {
414  return OwningObject->getSymbolAddress(SymbolPimpl, Result);
415 }
416 
417 inline error_code SymbolRef::getFileOffset(uint64_t &Result) const {
418  return OwningObject->getSymbolFileOffset(SymbolPimpl, Result);
419 }
420 
421 inline error_code SymbolRef::getAlignment(uint32_t &Result) const {
422  return OwningObject->getSymbolAlignment(SymbolPimpl, Result);
423 }
424 
425 inline error_code SymbolRef::getSize(uint64_t &Result) const {
426  return OwningObject->getSymbolSize(SymbolPimpl, Result);
427 }
428 
429 inline error_code SymbolRef::getFlags(uint32_t &Result) const {
430  return OwningObject->getSymbolFlags(SymbolPimpl, Result);
431 }
432 
434  return OwningObject->getSymbolSection(SymbolPimpl, Result);
435 }
436 
438  return OwningObject->getSymbolType(SymbolPimpl, Result);
439 }
440 
441 inline error_code SymbolRef::getValue(uint64_t &Val) const {
442  return OwningObject->getSymbolValue(SymbolPimpl, Val);
443 }
444 
446  return SymbolPimpl;
447 }
448 
449 
450 /// SectionRef
452  const ObjectFile *Owner)
453  : SectionPimpl(SectionP)
454  , OwningObject(Owner) {}
455 
456 inline bool SectionRef::operator==(const SectionRef &Other) const {
457  return SectionPimpl == Other.SectionPimpl;
458 }
459 
460 inline bool SectionRef::operator<(const SectionRef &Other) const {
461  return SectionPimpl < Other.SectionPimpl;
462 }
463 
465  return OwningObject->getSectionNext(SectionPimpl, Result);
466 }
467 
468 inline error_code SectionRef::getName(StringRef &Result) const {
469  return OwningObject->getSectionName(SectionPimpl, Result);
470 }
471 
472 inline error_code SectionRef::getAddress(uint64_t &Result) const {
473  return OwningObject->getSectionAddress(SectionPimpl, Result);
474 }
475 
476 inline error_code SectionRef::getSize(uint64_t &Result) const {
477  return OwningObject->getSectionSize(SectionPimpl, Result);
478 }
479 
481  return OwningObject->getSectionContents(SectionPimpl, Result);
482 }
483 
484 inline error_code SectionRef::getAlignment(uint64_t &Result) const {
485  return OwningObject->getSectionAlignment(SectionPimpl, Result);
486 }
487 
488 inline error_code SectionRef::isText(bool &Result) const {
489  return OwningObject->isSectionText(SectionPimpl, Result);
490 }
491 
492 inline error_code SectionRef::isData(bool &Result) const {
493  return OwningObject->isSectionData(SectionPimpl, Result);
494 }
495 
496 inline error_code SectionRef::isBSS(bool &Result) const {
497  return OwningObject->isSectionBSS(SectionPimpl, Result);
498 }
499 
500 inline error_code SectionRef::isRequiredForExecution(bool &Result) const {
501  return OwningObject->isSectionRequiredForExecution(SectionPimpl, Result);
502 }
503 
504 inline error_code SectionRef::isVirtual(bool &Result) const {
505  return OwningObject->isSectionVirtual(SectionPimpl, Result);
506 }
507 
508 inline error_code SectionRef::isZeroInit(bool &Result) const {
509  return OwningObject->isSectionZeroInit(SectionPimpl, Result);
510 }
511 
512 inline error_code SectionRef::isReadOnlyData(bool &Result) const {
513  return OwningObject->isSectionReadOnlyData(SectionPimpl, Result);
514 }
515 
516 inline error_code SectionRef::containsSymbol(SymbolRef S, bool &Result) const {
517  return OwningObject->sectionContainsSymbol(SectionPimpl, S.SymbolPimpl,
518  Result);
519 }
520 
522  return OwningObject->section_rel_begin(SectionPimpl);
523 }
524 
526  return OwningObject->section_rel_end(SectionPimpl);
527 }
528 
530  return OwningObject->getRelocatedSection(SectionPimpl);
531 }
532 
534  return SectionPimpl;
535 }
536 
537 /// RelocationRef
539  const ObjectFile *Owner)
540  : RelocationPimpl(RelocationP)
541  , OwningObject(Owner) {}
542 
543 inline bool RelocationRef::operator==(const RelocationRef &Other) const {
544  return RelocationPimpl == Other.RelocationPimpl;
545 }
546 
548  return OwningObject->getRelocationNext(RelocationPimpl, Result);
549 }
550 
551 inline error_code RelocationRef::getAddress(uint64_t &Result) const {
552  return OwningObject->getRelocationAddress(RelocationPimpl, Result);
553 }
554 
555 inline error_code RelocationRef::getOffset(uint64_t &Result) const {
556  return OwningObject->getRelocationOffset(RelocationPimpl, Result);
557 }
558 
560  return OwningObject->getRelocationSymbol(RelocationPimpl);
561 }
562 
563 inline error_code RelocationRef::getType(uint64_t &Result) const {
564  return OwningObject->getRelocationType(RelocationPimpl, Result);
565 }
566 
568  const {
569  return OwningObject->getRelocationTypeName(RelocationPimpl, Result);
570 }
571 
573  const {
574  return OwningObject->getRelocationValueString(RelocationPimpl, Result);
575 }
576 
577 inline error_code RelocationRef::getHidden(bool &Result) const {
578  return OwningObject->getRelocationHidden(RelocationPimpl, Result);
579 }
580 
582  return RelocationPimpl;
583 }
584 
586  return OwningObject;
587 }
588 
589 // Inline function definitions.
590 inline LibraryRef::LibraryRef(DataRefImpl LibraryP, const ObjectFile *Owner)
591  : LibraryPimpl(LibraryP)
592  , OwningObject(Owner) {}
593 
594 inline bool LibraryRef::operator==(const LibraryRef &Other) const {
595  return LibraryPimpl == Other.LibraryPimpl;
596 }
597 
598 inline bool LibraryRef::operator<(const LibraryRef &Other) const {
599  return LibraryPimpl < Other.LibraryPimpl;
600 }
601 
603  return OwningObject->getLibraryNext(LibraryPimpl, Result);
604 }
605 
606 inline error_code LibraryRef::getPath(StringRef &Result) const {
607  return OwningObject->getLibraryPath(LibraryPimpl, Result);
608 }
609 
610 } // end namespace object
611 } // end namespace llvm
612 
613 #endif
virtual symbol_iterator begin_dynamic_symbols() const =0
DataRefImpl getRawDataRefImpl() const
Definition: ObjectFile.h:445
virtual error_code getSymbolType(DataRefImpl Symb, SymbolRef::Type &Res) const =0
error_code getHidden(bool &Result) const
Indicates whether this relocation should hidden when listing relocations, usually because it is the t...
Definition: ObjectFile.h:577
error_code isZeroInit(bool &Result) const
Definition: ObjectFile.h:508
error_code getFileOffset(uint64_t &Result) const
Definition: ObjectFile.h:417
static ObjectFile * createELFObjectFile(MemoryBuffer *Object)
virtual error_code getSymbolFlags(DataRefImpl Symb, uint32_t &Res) const =0
const char * getBufferStart() const
Definition: MemoryBuffer.h:51
error_code getValue(uint64_t &Val) const
Get value of the symbol in the symbol table.
Definition: ObjectFile.h:441
virtual error_code getRelocationNext(DataRefImpl Rel, RelocationRef &Res) const =0
const uint8_t * base() const
Definition: ObjectFile.h:274
error_code getSize(uint64_t &Result) const
Definition: ObjectFile.h:476
error_code getType(SymbolRef::Type &Result) const
Definition: ObjectFile.h:437
error_code getNext(SymbolRef &Result) const
Definition: ObjectFile.h:405
virtual error_code getSectionAlignment(DataRefImpl Sec, uint64_t &Res) const =0
error_code isVirtual(bool &Result) const
Definition: ObjectFile.h:504
bool operator<(const DataRefImpl &a, const DataRefImpl &b)
Definition: ObjectFile.h:81
error_code containsSymbol(SymbolRef S, bool &Result) const
Definition: ObjectFile.h:516
error_code getAddress(uint64_t &Result) const
Definition: ObjectFile.h:551
error_code getValueString(SmallVectorImpl< char > &Result) const
Get a string that represents the calculation of the value of this relocation.
Definition: ObjectFile.h:572
DataRefImpl getRawDataRefImpl() const
Definition: ObjectFile.h:533
section_iterator getRelocatedSection() const
Definition: ObjectFile.h:529
virtual unsigned getArch() const =0
virtual relocation_iterator section_rel_end(DataRefImpl Sec) const =0
virtual error_code getSymbolSection(DataRefImpl Symb, section_iterator &Res) const =0
virtual error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb, bool &Result) const =0
virtual library_iterator end_libraries_needed() const =0
error_code getAlignment(uint64_t &Result) const
Get the alignment of this section as the actual value (not log 2).
Definition: ObjectFile.h:484
virtual error_code getLibraryNext(DataRefImpl Lib, LibraryRef &Res) const =0
error_code getTypeName(SmallVectorImpl< char > &Result) const
Get a string that represents the type of this relocation.
Definition: ObjectFile.h:567
virtual section_iterator end_sections() const =0
static ObjectFile * createObjectFile(StringRef ObjectPath)
Create ObjectFile from path.
Definition: ObjectFile.cpp:79
virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const =0
virtual error_code getSectionSize(DataRefImpl Sec, uint64_t &Res) const =0
error_code getSize(uint64_t &Result) const
Definition: ObjectFile.h:425
virtual library_iterator begin_libraries_needed() const =0
error_code getFlags(uint32_t &Result) const
Get symbol flags (bitwise OR of SymbolRef::Flags)
Definition: ObjectFile.h:429
error_code isBSS(bool &Result) const
Definition: ObjectFile.h:496
error_code getName(StringRef &Result) const
Definition: ObjectFile.h:468
virtual error_code getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl< char > &Result) const =0
virtual error_code getSymbolValue(DataRefImpl Symb, uint64_t &Val) const =0
relocation_iterator end_relocations() const
Definition: ObjectFile.h:525
bool operator!=(const content_iterator &other) const
Definition: ObjectFile.h:61
error_code getPath(StringRef &Result) const
Definition: ObjectFile.h:606
bool operator==(const SymbolRef &Other) const
Definition: ObjectFile.h:397
virtual error_code getLibraryPath(DataRefImpl Lib, StringRef &Res) const =0
bool operator==(const LibraryRef &Other) const
Definition: ObjectFile.h:594
error_code isText(bool &Result) const
Definition: ObjectFile.h:488
virtual section_iterator begin_sections() const =0
content_iterator< SectionRef > section_iterator
Definition: ObjectFile.h:133
int memcmp(const void *s1, const void *s2, size_t n);
content_iterator(content_type symb)
Definition: ObjectFile.h:46
virtual uint8_t getBytesInAddress() const =0
The number of bytes used to represent an address in this object file format.
virtual error_code getSymbolFileOffset(DataRefImpl Symb, uint64_t &Res) const =0
bool isObject() const
Definition: Binary.h:83
bool operator==(const RelocationRef &Other) const
Definition: ObjectFile.h:543
content_iterator< SymbolRef > symbol_iterator
Definition: ObjectFile.h:87
error_code getAddress(uint64_t &Result) const
Definition: ObjectFile.h:472
symbol_iterator getSymbol() const
Definition: ObjectFile.h:559
ItTy next(ItTy it, Dist n)
Definition: STLExtras.h:154
virtual error_code getSectionNext(DataRefImpl Sec, SectionRef &Res) const =0
content_iterator< LibraryRef > library_iterator
Definition: ObjectFile.h:259
virtual symbol_iterator end_symbols() const =0
error_code getNext(LibraryRef &Result) const
Definition: ObjectFile.h:602
content_iterator< RelocationRef > relocation_iterator
Definition: ObjectFile.h:129
virtual error_code isSectionReadOnlyData(DataRefImpl Sec, bool &Res) const =0
error_code getAlignment(uint32_t &Result) const
Get the alignment of this symbol as the actual value (not log 2).
Definition: ObjectFile.h:421
bool operator<(const LibraryRef &Other) const
Definition: ObjectFile.h:598
error_code getSection(section_iterator &Result) const
Get section this symbol is defined in reference to. Result is end_sections() if it is undefined or is...
Definition: ObjectFile.h:433
content_iterator & increment(error_code &err)
Definition: ObjectFile.h:65
virtual error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const =0
error_code isReadOnlyData(bool &Result) const
Definition: ObjectFile.h:512
DataRefImpl getRawDataRefImpl() const
error_code getNext(SectionRef &Result) const
Definition: ObjectFile.h:464
bool operator==(const DataRefImpl &a, const DataRefImpl &b)
Definition: ObjectFile.h:75
virtual error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const =0
virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const =0
virtual error_code getSectionContents(DataRefImpl Sec, StringRef &Res) const =0
const uint64_t UnknownAddressOrSize
Definition: ObjectFile.h:261
struct llvm::object::DataRefImpl::@77 d
virtual error_code isSectionText(DataRefImpl Sec, bool &Res) const =0
virtual symbol_iterator end_dynamic_symbols() const =0
#define LLVM_DELETED_FUNCTION
Definition: Compiler.h:137
virtual section_iterator getRelocatedSection(DataRefImpl Sec) const
Definition: ObjectFile.cpp:36
virtual StringRef getLoadName() const =0
enum Flags LLVM_ENUM_INT_TYPE(unsigned)
Definition: ObjectFile.h:195
static bool classof(const Binary *v)
Definition: ObjectFile.h:382
error_code getAddress(uint64_t &Result) const
Definition: ObjectFile.h:413
bool operator==(const content_iterator &other) const
Definition: ObjectFile.h:57
virtual error_code getSectionAddress(DataRefImpl Sec, uint64_t &Res) const =0
virtual error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const =0
virtual error_code getSymbolName(DataRefImpl Symb, StringRef &Res) const =0
virtual error_code getSymbolNext(DataRefImpl Symb, SymbolRef &Res) const =0
error_code isRequiredForExecution(bool &Result) const
Definition: ObjectFile.h:500
virtual error_code getSymbolAlignment(DataRefImpl Symb, uint32_t &Res) const
Definition: ObjectFile.cpp:30
virtual error_code getRelocationOffset(DataRefImpl Rel, uint64_t &Res) const =0
const content_type & operator*() const
Definition: ObjectFile.h:53
virtual error_code isSectionBSS(DataRefImpl Sec, bool &Res) const =0
bool operator==(const SectionRef &Other) const
Definition: ObjectFile.h:456
virtual error_code getRelocationAddress(DataRefImpl Rel, uint64_t &Res) const =0
bool operator<(const SectionRef &Other) const
Definition: ObjectFile.h:460
error_code getContents(StringRef &Result) const
Definition: ObjectFile.h:480
virtual error_code getRelocationValueString(DataRefImpl Rel, SmallVectorImpl< char > &Result) const =0
virtual symbol_iterator begin_symbols() const =0
const content_type * operator->() const
Definition: ObjectFile.h:49
virtual error_code isSectionData(DataRefImpl Sec, bool &Res) const =0
virtual error_code getSectionName(DataRefImpl Sec, StringRef &Res) const =0
static ObjectFile * createCOFFObjectFile(MemoryBuffer *Object)
error_code isData(bool &Result) const
Definition: ObjectFile.h:492
error_code getType(uint64_t &Result) const
Definition: ObjectFile.h:563
relocation_iterator begin_relocations() const
Definition: ObjectFile.h:521
const ObjectFile * getObjectFile() const
Definition: ObjectFile.h:585
virtual error_code getRelocationHidden(DataRefImpl Rel, bool &Result) const
Definition: ObjectFile.h:339
error_code getNext(RelocationRef &Result) const
Definition: ObjectFile.h:547
virtual error_code getSymbolAddress(DataRefImpl Symb, uint64_t &Res) const =0
error_code getOffset(uint64_t &Result) const
Definition: ObjectFile.h:555
MemoryBuffer * Data
Definition: Binary.h:35
virtual StringRef getFileFormatName() const =0
virtual error_code isSectionRequiredForExecution(DataRefImpl Sec, bool &Res) const =0
bool operator<(const SymbolRef &Other) const
Definition: ObjectFile.h:401
virtual error_code getRelocationType(DataRefImpl Rel, uint64_t &Res) const =0
error_code getName(StringRef &Result) const
Definition: ObjectFile.h:409
static ObjectFile * createMachOObjectFile(MemoryBuffer *Object)
DataRefImpl getRawDataRefImpl() const
Definition: ObjectFile.h:581