LLVM  10.0.0svn
ObjectFile.h
Go to the documentation of this file.
1 //===- ObjectFile.h - File format independent object file -------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares a file format independent ObjectFile class.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_OBJECT_OBJECTFILE_H
14 #define LLVM_OBJECT_OBJECTFILE_H
15 
16 #include "llvm/ADT/DenseMapInfo.h"
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/ADT/Triple.h"
22 #include "llvm/Object/Binary.h"
23 #include "llvm/Object/Error.h"
25 #include "llvm/Support/Casting.h"
26 #include "llvm/Support/Error.h"
29 #include <cassert>
30 #include <cstdint>
31 #include <memory>
32 #include <system_error>
33 
34 namespace llvm {
35 
36 class ARMAttributeParser;
37 
38 namespace object {
39 
40 class COFFObjectFile;
41 class MachOObjectFile;
42 class ObjectFile;
43 class SectionRef;
44 class SymbolRef;
45 class symbol_iterator;
46 class WasmObjectFile;
47 
49 
50 /// This is a value type class that represents a single relocation in the list
51 /// of relocations in the object file.
53  DataRefImpl RelocationPimpl;
54  const ObjectFile *OwningObject = nullptr;
55 
56 public:
57  RelocationRef() = default;
58  RelocationRef(DataRefImpl RelocationP, const ObjectFile *Owner);
59 
60  bool operator==(const RelocationRef &Other) const;
61 
62  void moveNext();
63 
64  uint64_t getOffset() const;
65  symbol_iterator getSymbol() const;
66  uint64_t getType() const;
67 
68  /// Get a string that represents the type of this relocation.
69  ///
70  /// This is for display purposes only.
71  void getTypeName(SmallVectorImpl<char> &Result) const;
72 
74  const ObjectFile *getObject() const;
75 };
76 
78 
79 /// This is a value type class that represents a single section in the list of
80 /// sections in the object file.
81 class SectionRef {
82  friend class SymbolRef;
83 
84  DataRefImpl SectionPimpl;
85  const ObjectFile *OwningObject = nullptr;
86 
87 public:
88  SectionRef() = default;
89  SectionRef(DataRefImpl SectionP, const ObjectFile *Owner);
90 
91  bool operator==(const SectionRef &Other) const;
92  bool operator!=(const SectionRef &Other) const;
93  bool operator<(const SectionRef &Other) const;
94 
95  void moveNext();
96 
98  uint64_t getAddress() const;
99  uint64_t getIndex() const;
100  uint64_t getSize() const;
101  Expected<StringRef> getContents() const;
102 
103  /// Get the alignment of this section as the actual value (not log 2).
104  uint64_t getAlignment() const;
105 
106  bool isCompressed() const;
107  /// Whether this section contains instructions.
108  bool isText() const;
109  /// Whether this section contains data, not instructions.
110  bool isData() const;
111  /// Whether this section contains BSS uninitialized data.
112  bool isBSS() const;
113  bool isVirtual() const;
114  bool isBitcode() const;
115  bool isStripped() const;
116 
117  /// Whether this section will be placed in the text segment, according to the
118  /// Berkeley size format. This is true if the section is allocatable, and
119  /// contains either code or readonly data.
120  bool isBerkeleyText() const;
121  /// Whether this section will be placed in the data segment, according to the
122  /// Berkeley size format. This is true if the section is allocatable and
123  /// contains data (e.g. PROGBITS), but is not text.
124  bool isBerkeleyData() const;
125 
126  bool containsSymbol(SymbolRef S) const;
127 
128  relocation_iterator relocation_begin() const;
129  relocation_iterator relocation_end() const;
131  return make_range(relocation_begin(), relocation_end());
132  }
133  section_iterator getRelocatedSection() const;
134 
136  const ObjectFile *getObject() const;
137 };
138 
140  const static uint64_t UndefSection = UINT64_MAX;
141 
142  uint64_t Address = 0;
143  uint64_t SectionIndex = UndefSection;
144 };
145 
146 inline bool operator<(const SectionedAddress &LHS,
147  const SectionedAddress &RHS) {
148  return std::tie(LHS.SectionIndex, LHS.Address) <
149  std::tie(RHS.SectionIndex, RHS.Address);
150 }
151 
152 inline bool operator==(const SectionedAddress &LHS,
153  const SectionedAddress &RHS) {
154  return std::tie(LHS.SectionIndex, LHS.Address) ==
155  std::tie(RHS.SectionIndex, RHS.Address);
156 }
157 
158 /// This is a value type class that represents a single symbol in the list of
159 /// symbols in the object file.
160 class SymbolRef : public BasicSymbolRef {
161  friend class SectionRef;
162 
163 public:
164  enum Type {
165  ST_Unknown, // Type not specified
170  ST_Other
171  };
172 
173  SymbolRef() = default;
174  SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner);
176  assert(isa<ObjectFile>(BasicSymbolRef::getObject()));
177  }
178 
180  /// Returns the symbol virtual address (i.e. address at which it will be
181  /// mapped).
182  Expected<uint64_t> getAddress() const;
183 
184  /// Return the value of the symbol depending on the object this can be an
185  /// offset or a virtual address.
186  uint64_t getValue() const;
187 
188  /// Get the alignment of this symbol as the actual value (not log 2).
189  uint32_t getAlignment() const;
190  uint64_t getCommonSize() const;
192 
193  /// Get section this symbol is defined in reference to. Result is
194  /// end_sections() if it is undefined or is an absolute symbol.
196 
197  const ObjectFile *getObject() const;
198 };
199 
201 public:
205  cast<ObjectFile>(B->getObject()))) {}
206 
207  const SymbolRef *operator->() const {
209  return static_cast<const SymbolRef*>(&P);
210  }
211 
212  const SymbolRef &operator*() const {
214  return static_cast<const SymbolRef&>(P);
215  }
216 };
217 
218 /// This class is the base class for all object file types. Concrete instances
219 /// of this object are created by createObjectFile, which figures out which type
220 /// to create.
221 class ObjectFile : public SymbolicFile {
222  virtual void anchor();
223 
224 protected:
225  ObjectFile(unsigned int Type, MemoryBufferRef Source);
226 
227  const uint8_t *base() const {
228  return reinterpret_cast<const uint8_t *>(Data.getBufferStart());
229  }
230 
231  // These functions are for SymbolRef to call internally. The main goal of
232  // this is to allow SymbolRef::SymbolPimpl to point directly to the symbol
233  // entry in the memory mapped object file. SymbolPimpl cannot contain any
234  // virtual functions because then it could not point into the memory mapped
235  // file.
236  //
237  // Implementations assume that the DataRefImpl is valid and has not been
238  // modified externally. It's UB otherwise.
239  friend class SymbolRef;
240 
241  virtual Expected<StringRef> getSymbolName(DataRefImpl Symb) const = 0;
242  Error printSymbolName(raw_ostream &OS,
243  DataRefImpl Symb) const override;
244  virtual Expected<uint64_t> getSymbolAddress(DataRefImpl Symb) const = 0;
245  virtual uint64_t getSymbolValueImpl(DataRefImpl Symb) const = 0;
246  virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const;
247  virtual uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const = 0;
248  virtual Expected<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const = 0;
250  getSymbolSection(DataRefImpl Symb) const = 0;
251 
252  // Same as above for SectionRef.
253  friend class SectionRef;
254 
255  virtual void moveSectionNext(DataRefImpl &Sec) const = 0;
256  virtual Expected<StringRef> getSectionName(DataRefImpl Sec) const = 0;
257  virtual uint64_t getSectionAddress(DataRefImpl Sec) const = 0;
258  virtual uint64_t getSectionIndex(DataRefImpl Sec) const = 0;
259  virtual uint64_t getSectionSize(DataRefImpl Sec) const = 0;
261  getSectionContents(DataRefImpl Sec) const = 0;
262  virtual uint64_t getSectionAlignment(DataRefImpl Sec) const = 0;
263  virtual bool isSectionCompressed(DataRefImpl Sec) const = 0;
264  virtual bool isSectionText(DataRefImpl Sec) const = 0;
265  virtual bool isSectionData(DataRefImpl Sec) const = 0;
266  virtual bool isSectionBSS(DataRefImpl Sec) const = 0;
267  // A section is 'virtual' if its contents aren't present in the object image.
268  virtual bool isSectionVirtual(DataRefImpl Sec) const = 0;
269  virtual bool isSectionBitcode(DataRefImpl Sec) const;
270  virtual bool isSectionStripped(DataRefImpl Sec) const;
271  virtual bool isBerkeleyText(DataRefImpl Sec) const;
272  virtual bool isBerkeleyData(DataRefImpl Sec) const;
273  virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const = 0;
274  virtual relocation_iterator section_rel_end(DataRefImpl Sec) const = 0;
275  virtual section_iterator getRelocatedSection(DataRefImpl Sec) const;
276 
277  // Same as above for RelocationRef.
278  friend class RelocationRef;
279  virtual void moveRelocationNext(DataRefImpl &Rel) const = 0;
280  virtual uint64_t getRelocationOffset(DataRefImpl Rel) const = 0;
281  virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const = 0;
282  virtual uint64_t getRelocationType(DataRefImpl Rel) const = 0;
283  virtual void getRelocationTypeName(DataRefImpl Rel,
284  SmallVectorImpl<char> &Result) const = 0;
285 
286  uint64_t getSymbolValue(DataRefImpl Symb) const;
287 
288 public:
289  ObjectFile() = delete;
290  ObjectFile(const ObjectFile &other) = delete;
291 
292  uint64_t getCommonSymbolSize(DataRefImpl Symb) const {
293  assert(getSymbolFlags(Symb) & SymbolRef::SF_Common);
294  return getCommonSymbolSizeImpl(Symb);
295  }
296 
297  virtual std::vector<SectionRef> dynamic_relocation_sections() const {
298  return std::vector<SectionRef>();
299  }
300 
303  return symbol_iterator_range(symbol_begin(), symbol_end());
304  }
305 
306  virtual section_iterator section_begin() const = 0;
307  virtual section_iterator section_end() const = 0;
308 
311  return section_iterator_range(section_begin(), section_end());
312  }
313 
314  /// The number of bytes used to represent an address in this object
315  /// file format.
316  virtual uint8_t getBytesInAddress() const = 0;
317 
318  virtual StringRef getFileFormatName() const = 0;
319  virtual Triple::ArchType getArch() const = 0;
320  virtual SubtargetFeatures getFeatures() const = 0;
321  virtual void setARMSubArch(Triple &TheTriple) const { }
324  };
325 
326  /// Create a triple from the data in this object file.
327  Triple makeTriple() const;
328 
329  /// Maps a debug section name to a standard DWARF section name.
330  virtual StringRef mapDebugSectionName(StringRef Name) const { return Name; }
331 
332  /// True if this is a relocatable object (.o/.obj).
333  virtual bool isRelocatableObject() const = 0;
334 
335  /// @returns Pointer to ObjectFile subclass to handle this type of object.
336  /// @param ObjectPath The path to the object file. ObjectPath.isObject must
337  /// return true.
338  /// Create ObjectFile from path.
340  createObjectFile(StringRef ObjectPath);
341 
343  createObjectFile(MemoryBufferRef Object, llvm::file_magic Type);
346  return createObjectFile(Object, llvm::file_magic::unknown);
347  }
348 
349  static bool classof(const Binary *v) {
350  return v->isObject();
351  }
352 
354  createCOFFObjectFile(MemoryBufferRef Object);
355 
357  createXCOFFObjectFile(MemoryBufferRef Object, unsigned FileType);
358 
360  createELFObjectFile(MemoryBufferRef Object);
361 
363  createMachOObjectFile(MemoryBufferRef Object,
364  uint32_t UniversalCputype = 0,
365  uint32_t UniversalIndex = 0);
366 
368  createWasmObjectFile(MemoryBufferRef Object);
369 };
370 
371 // Inline function definitions.
372 inline SymbolRef::SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner)
373  : BasicSymbolRef(SymbolP, Owner) {}
374 
377 }
378 
381 }
382 
383 inline uint64_t SymbolRef::getValue() const {
385 }
386 
389 }
390 
391 inline uint64_t SymbolRef::getCommonSize() const {
393 }
394 
397 }
398 
401 }
402 
403 inline const ObjectFile *SymbolRef::getObject() const {
405  return cast<ObjectFile>(O);
406 }
407 
408 /// SectionRef
410  const ObjectFile *Owner)
411  : SectionPimpl(SectionP)
412  , OwningObject(Owner) {}
413 
414 inline bool SectionRef::operator==(const SectionRef &Other) const {
415  return OwningObject == Other.OwningObject &&
416  SectionPimpl == Other.SectionPimpl;
417 }
418 
419 inline bool SectionRef::operator!=(const SectionRef &Other) const {
420  return !(*this == Other);
421 }
422 
423 inline bool SectionRef::operator<(const SectionRef &Other) const {
424  assert(OwningObject == Other.OwningObject);
425  return SectionPimpl < Other.SectionPimpl;
426 }
427 
428 inline void SectionRef::moveNext() {
429  return OwningObject->moveSectionNext(SectionPimpl);
430 }
431 
433  return OwningObject->getSectionName(SectionPimpl);
434 }
435 
436 inline uint64_t SectionRef::getAddress() const {
437  return OwningObject->getSectionAddress(SectionPimpl);
438 }
439 
440 inline uint64_t SectionRef::getIndex() const {
441  return OwningObject->getSectionIndex(SectionPimpl);
442 }
443 
444 inline uint64_t SectionRef::getSize() const {
445  return OwningObject->getSectionSize(SectionPimpl);
446 }
447 
450  OwningObject->getSectionContents(SectionPimpl);
451  if (!Res)
452  return Res.takeError();
453  return StringRef(reinterpret_cast<const char *>(Res->data()), Res->size());
454 }
455 
456 inline uint64_t SectionRef::getAlignment() const {
457  return OwningObject->getSectionAlignment(SectionPimpl);
458 }
459 
460 inline bool SectionRef::isCompressed() const {
461  return OwningObject->isSectionCompressed(SectionPimpl);
462 }
463 
464 inline bool SectionRef::isText() const {
465  return OwningObject->isSectionText(SectionPimpl);
466 }
467 
468 inline bool SectionRef::isData() const {
469  return OwningObject->isSectionData(SectionPimpl);
470 }
471 
472 inline bool SectionRef::isBSS() const {
473  return OwningObject->isSectionBSS(SectionPimpl);
474 }
475 
476 inline bool SectionRef::isVirtual() const {
477  return OwningObject->isSectionVirtual(SectionPimpl);
478 }
479 
480 inline bool SectionRef::isBitcode() const {
481  return OwningObject->isSectionBitcode(SectionPimpl);
482 }
483 
484 inline bool SectionRef::isStripped() const {
485  return OwningObject->isSectionStripped(SectionPimpl);
486 }
487 
488 inline bool SectionRef::isBerkeleyText() const {
489  return OwningObject->isBerkeleyText(SectionPimpl);
490 }
491 
492 inline bool SectionRef::isBerkeleyData() const {
493  return OwningObject->isBerkeleyData(SectionPimpl);
494 }
495 
497  return OwningObject->section_rel_begin(SectionPimpl);
498 }
499 
501  return OwningObject->section_rel_end(SectionPimpl);
502 }
503 
505  return OwningObject->getRelocatedSection(SectionPimpl);
506 }
507 
509  return SectionPimpl;
510 }
511 
512 inline const ObjectFile *SectionRef::getObject() const {
513  return OwningObject;
514 }
515 
516 /// RelocationRef
518  const ObjectFile *Owner)
519  : RelocationPimpl(RelocationP)
520  , OwningObject(Owner) {}
521 
522 inline bool RelocationRef::operator==(const RelocationRef &Other) const {
523  return RelocationPimpl == Other.RelocationPimpl;
524 }
525 
526 inline void RelocationRef::moveNext() {
527  return OwningObject->moveRelocationNext(RelocationPimpl);
528 }
529 
530 inline uint64_t RelocationRef::getOffset() const {
531  return OwningObject->getRelocationOffset(RelocationPimpl);
532 }
533 
535  return OwningObject->getRelocationSymbol(RelocationPimpl);
536 }
537 
538 inline uint64_t RelocationRef::getType() const {
539  return OwningObject->getRelocationType(RelocationPimpl);
540 }
541 
543  return OwningObject->getRelocationTypeName(RelocationPimpl, Result);
544 }
545 
547  return RelocationPimpl;
548 }
549 
550 inline const ObjectFile *RelocationRef::getObject() const {
551  return OwningObject;
552 }
553 
554 } // end namespace object
555 
556 template <> struct DenseMapInfo<object::SectionRef> {
557  static bool isEqual(const object::SectionRef &A,
558  const object::SectionRef &B) {
559  return A == B;
560  }
562  return object::SectionRef({}, nullptr);
563  }
566  TS.p = (uintptr_t)-1;
567  return object::SectionRef(TS, nullptr);
568  }
569  static unsigned getHashValue(const object::SectionRef &Sec) {
571  return hash_combine(Raw.p, Raw.d.a, Raw.d.b);
572  }
573 };
574 
575 } // end namespace llvm
576 
577 #endif // LLVM_OBJECT_OBJECTFILE_H
const content_type & operator*() const
Definition: SymbolicFile.h:78
static uint64_t getSymbolValue(const MCSymbol &Symbol, const MCAsmLayout &Layout)
virtual bool isBerkeleyData(DataRefImpl Sec) const
Definition: ObjectFile.cpp:83
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Expected< StringRef > getName() const
Definition: ObjectFile.h:375
uint64_t getValue() const
Return the value of the symbol depending on the object this can be an offset or a virtual address...
Definition: ObjectFile.h:383
uint64_t getOffset() const
Definition: ObjectFile.h:530
bool operator!=(const SectionRef &Other) const
Definition: ObjectFile.h:419
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
bool isStripped() const
Definition: ObjectFile.h:484
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:948
virtual bool isSectionBSS(DataRefImpl Sec) const =0
This class is the base class for all object file types.
Definition: ObjectFile.h:221
bool operator==(const RelocationRef &Other) const
Definition: ObjectFile.h:522
Expected< StringRef > getContents() const
Definition: ObjectFile.h:448
virtual Expected< ArrayRef< uint8_t > > getSectionContents(DataRefImpl Sec) const =0
virtual uint64_t getRelocationOffset(DataRefImpl Rel) const =0
const uint8_t * base() const
Definition: ObjectFile.h:227
uint32_t getAlignment() const
Get the alignment of this symbol as the actual value (not log 2).
Definition: ObjectFile.h:387
Error takeError()
Take ownership of the stored error.
Definition: Error.h:552
const ObjectFile * getObject() const
Definition: ObjectFile.h:550
virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const
Definition: ObjectFile.cpp:67
virtual Expected< StringRef > getSymbolName(DataRefImpl Symb) const =0
virtual bool isSectionStripped(DataRefImpl Sec) const
Definition: ObjectFile.cpp:77
relocation_iterator relocation_end() const
Definition: ObjectFile.h:500
virtual relocation_iterator section_rel_end(DataRefImpl Sec) const =0
void getTypeName(SmallVectorImpl< char > &Result) const
Get a string that represents the type of this relocation.
Definition: ObjectFile.h:542
static uint32_t getAlignment(const MCSectionCOFF &Sec)
uint64_t getAddress() const
Definition: ObjectFile.h:436
DataRefImpl getRawDataRefImpl() const
Definition: SymbolicFile.h:203
static StringRef getSymbolName(SymbolKind SymKind)
This is a value type class that represents a single relocation in the list of relocations in the obje...
Definition: ObjectFile.h:52
bool operator==(const SectionRef &Other) const
Definition: ObjectFile.h:414
static StringRef getName(Value *V)
bool isText() const
Whether this section contains instructions.
Definition: ObjectFile.h:464
virtual uint64_t getSectionIndex(DataRefImpl Sec) const =0
Tagged union holding either a T or a Error.
Definition: yaml2obj.h:21
bool operator!=(const DataRefImpl &a, const DataRefImpl &b)
Definition: SymbolicFile.h:58
bool isBitcode() const
Definition: ObjectFile.h:480
Expected< const typename ELFT::Shdr * > getSection(typename ELFT::ShdrRange Sections, uint32_t Index)
Definition: ELF.h:310
virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const =0
#define UINT64_MAX
Definition: DataTypes.h:83
uint64_t getIndex() const
Definition: ObjectFile.h:440
bool isCompressed() const
Definition: ObjectFile.h:460
uint64_t getCommonSize() const
Definition: ObjectFile.h:391
bool operator<(const SectionedAddress &LHS, const SectionedAddress &RHS)
Definition: ObjectFile.h:146
const ObjectFile * getObject() const
Definition: ObjectFile.h:403
virtual uint64_t getSectionAlignment(DataRefImpl Sec) const =0
section_iterator_range sections() const
Definition: ObjectFile.h:310
virtual Expected< uint64_t > getStartAddress() const
Definition: ObjectFile.h:322
static unsigned getHashValue(const object::SectionRef &Sec)
Definition: ObjectFile.h:569
virtual bool isSectionBitcode(DataRefImpl Sec) const
Definition: ObjectFile.cpp:69
const ObjectFile * getObject() const
Definition: ObjectFile.h:512
std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type cast(const Y &Val)
Definition: Casting.h:249
Expected< section_iterator > getSection() const
Get section this symbol is defined in reference to.
Definition: ObjectFile.h:395
virtual StringRef mapDebugSectionName(StringRef Name) const
Maps a debug section name to a standard DWARF section name.
Definition: ObjectFile.h:330
static object::SectionRef getEmptyKey()
Definition: ObjectFile.h:561
virtual Expected< SymbolRef::Type > getSymbolType(DataRefImpl Symb) const =0
#define P(N)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static FeatureBitset getFeatures(StringRef CPU, StringRef FS, ArrayRef< SubtargetSubTypeKV > ProcDesc, ArrayRef< SubtargetFeatureKV > ProcFeatures)
virtual void moveRelocationNext(DataRefImpl &Rel) const =0
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
bool isVirtual() const
Definition: ObjectFile.h:476
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
Definition: Error.cpp:87
symbol_iterator(const basic_symbol_iterator &B)
Definition: ObjectFile.h:203
virtual std::vector< SectionRef > dynamic_relocation_sections() const
Definition: ObjectFile.h:297
static bool isEqual(const object::SectionRef &A, const object::SectionRef &B)
Definition: ObjectFile.h:557
uint64_t getSize() const
Definition: ObjectFile.h:444
relocation_iterator relocation_begin() const
Definition: ObjectFile.h:496
static Expected< std::unique_ptr< ObjectFile > > createObjectFile(MemoryBufferRef Object)
Definition: ObjectFile.h:345
virtual Expected< StringRef > getSectionName(DataRefImpl Sec) const =0
bool operator<(const SectionRef &Other) const
Definition: ObjectFile.h:423
section_iterator getRelocatedSection() const
Definition: ObjectFile.h:504
Expected< uint64_t > getAddress() const
Returns the symbol virtual address (i.e.
Definition: ObjectFile.h:379
DataRefImpl getRawDataRefImpl() const
Definition: ObjectFile.h:508
bool isData() const
Whether this section contains data, not instructions.
Definition: ObjectFile.h:468
uint64_t getType() const
Definition: ObjectFile.h:538
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
struct llvm::object::DataRefImpl::@297 d
SymbolRef(const BasicSymbolRef &B)
Definition: ObjectFile.h:175
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool isBerkeleyText() const
Whether this section will be placed in the text segment, according to the Berkeley size format...
Definition: ObjectFile.h:488
virtual Expected< uint64_t > getSymbolAddress(DataRefImpl Symb) const =0
FileType
Defines the file type this file represents.
Definition: InterfaceFile.h:65
bool isBSS() const
Whether this section contains BSS uninitialized data.
Definition: ObjectFile.h:472
Expected< SymbolRef::Type > getType() const
Definition: ObjectFile.h:399
bool isBitcode(const unsigned char *BufPtr, const unsigned char *BufEnd)
isBitcode - Return true if the given bytes are the magic bytes for LLVM IR bitcode, either with or without a wrapper.
const SymbolicFile * getObject() const
Definition: SymbolicFile.h:207
virtual void setARMSubArch(Triple &TheTriple) const
Definition: ObjectFile.h:321
const SymbolRef & operator*() const
Definition: ObjectFile.h:212
virtual uint64_t getSectionAddress(DataRefImpl Sec) const =0
uint64_t getSymbolValue(DataRefImpl Symb) const
Definition: ObjectFile.cpp:50
virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const =0
bool isObject() const
Definition: Binary.h:102
Expected< StringRef > getName() const
Definition: ObjectFile.h:432
A range adaptor for a pair of iterators.
Manages the enabling and disabling of subtarget specific features.
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Definition: Hashing.h:600
virtual bool isSectionText(DataRefImpl Sec) const =0
This is a value type class that represents a single symbol in the list of symbols in the object file...
Definition: ObjectFile.h:160
static std::unique_ptr< PDBSymbol > getSymbolType(const PDBSymbol &Symbol)
Definition: UDTLayout.cpp:33
static bool classof(const Binary *v)
Definition: ObjectFile.h:349
symbol_iterator getSymbol() const
Definition: ObjectFile.h:534
symbol_iterator_range symbols() const
Definition: ObjectFile.h:302
virtual void moveSectionNext(DataRefImpl &Sec) const =0
iterator_range< relocation_iterator > relocations() const
Definition: ObjectFile.h:130
virtual bool isBerkeleyText(DataRefImpl Sec) const
Definition: ObjectFile.cpp:79
virtual bool isSectionData(DataRefImpl Sec) const =0
uint64_t getCommonSymbolSize(DataRefImpl Symb) const
Definition: ObjectFile.h:292
This is a value type class that represents a single symbol in the list of symbols in the object file...
Definition: SymbolicFile.h:98
virtual section_iterator getRelocatedSection(DataRefImpl Sec) const
Definition: ObjectFile.cpp:87
uint64_t getAlignment() const
Get the alignment of this section as the actual value (not log 2).
Definition: ObjectFile.h:456
const SymbolRef * operator->() const
Definition: ObjectFile.h:207
virtual bool isSectionCompressed(DataRefImpl Sec) const =0
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
virtual Expected< section_iterator > getSymbolSection(DataRefImpl Symb) const =0
virtual bool isSectionVirtual(DataRefImpl Sec) const =0
virtual uint64_t getSectionSize(DataRefImpl Sec) const =0
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
virtual void getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl< char > &Result) const =0
symbol_iterator(SymbolRef Sym)
Definition: ObjectFile.h:202
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
static object::SectionRef getTombstoneKey()
Definition: ObjectFile.h:564
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
bool isBerkeleyData() const
Whether this section will be placed in the data segment, according to the Berkeley size format...
Definition: ObjectFile.h:492
virtual uint64_t getRelocationType(DataRefImpl Rel) const =0
Unrecognized file.
Definition: Magic.h:22
DataRefImpl getRawDataRefImpl() const
Definition: ObjectFile.h:546
This is a value type class that represents a single section in the list of sections in the object fil...
Definition: ObjectFile.h:81
file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...
Definition: Magic.h:20