LLVM  10.0.0
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  Expected<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 
159 
160 /// This is a value type class that represents a single symbol in the list of
161 /// symbols in the object file.
162 class SymbolRef : public BasicSymbolRef {
163  friend class SectionRef;
164 
165 public:
166  enum Type {
167  ST_Unknown, // Type not specified
172  ST_Other
173  };
174 
175  SymbolRef() = default;
176  SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner);
178  assert(isa<ObjectFile>(BasicSymbolRef::getObject()));
179  }
180 
182  /// Returns the symbol virtual address (i.e. address at which it will be
183  /// mapped).
184  Expected<uint64_t> getAddress() const;
185 
186  /// Return the value of the symbol depending on the object this can be an
187  /// offset or a virtual address.
188  uint64_t getValue() const;
189 
190  /// Get the alignment of this symbol as the actual value (not log 2).
191  uint32_t getAlignment() const;
192  uint64_t getCommonSize() const;
194 
195  /// Get section this symbol is defined in reference to. Result is
196  /// end_sections() if it is undefined or is an absolute symbol.
198 
199  const ObjectFile *getObject() const;
200 };
201 
203 public:
207  cast<ObjectFile>(B->getObject()))) {}
208 
209  const SymbolRef *operator->() const {
211  return static_cast<const SymbolRef*>(&P);
212  }
213 
214  const SymbolRef &operator*() const {
216  return static_cast<const SymbolRef&>(P);
217  }
218 };
219 
220 /// This class is the base class for all object file types. Concrete instances
221 /// of this object are created by createObjectFile, which figures out which type
222 /// to create.
223 class ObjectFile : public SymbolicFile {
224  virtual void anchor();
225 
226 protected:
227  ObjectFile(unsigned int Type, MemoryBufferRef Source);
228 
229  const uint8_t *base() const {
230  return reinterpret_cast<const uint8_t *>(Data.getBufferStart());
231  }
232 
233  // These functions are for SymbolRef to call internally. The main goal of
234  // this is to allow SymbolRef::SymbolPimpl to point directly to the symbol
235  // entry in the memory mapped object file. SymbolPimpl cannot contain any
236  // virtual functions because then it could not point into the memory mapped
237  // file.
238  //
239  // Implementations assume that the DataRefImpl is valid and has not been
240  // modified externally. It's UB otherwise.
241  friend class SymbolRef;
242 
243  virtual Expected<StringRef> getSymbolName(DataRefImpl Symb) const = 0;
244  Error printSymbolName(raw_ostream &OS,
245  DataRefImpl Symb) const override;
246  virtual Expected<uint64_t> getSymbolAddress(DataRefImpl Symb) const = 0;
247  virtual uint64_t getSymbolValueImpl(DataRefImpl Symb) const = 0;
248  virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const;
249  virtual uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const = 0;
250  virtual Expected<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const = 0;
252  getSymbolSection(DataRefImpl Symb) const = 0;
253 
254  // Same as above for SectionRef.
255  friend class SectionRef;
256 
257  virtual void moveSectionNext(DataRefImpl &Sec) const = 0;
258  virtual Expected<StringRef> getSectionName(DataRefImpl Sec) const = 0;
259  virtual uint64_t getSectionAddress(DataRefImpl Sec) const = 0;
260  virtual uint64_t getSectionIndex(DataRefImpl Sec) const = 0;
261  virtual uint64_t getSectionSize(DataRefImpl Sec) const = 0;
263  getSectionContents(DataRefImpl Sec) const = 0;
264  virtual uint64_t getSectionAlignment(DataRefImpl Sec) const = 0;
265  virtual bool isSectionCompressed(DataRefImpl Sec) const = 0;
266  virtual bool isSectionText(DataRefImpl Sec) const = 0;
267  virtual bool isSectionData(DataRefImpl Sec) const = 0;
268  virtual bool isSectionBSS(DataRefImpl Sec) const = 0;
269  // A section is 'virtual' if its contents aren't present in the object image.
270  virtual bool isSectionVirtual(DataRefImpl Sec) const = 0;
271  virtual bool isSectionBitcode(DataRefImpl Sec) const;
272  virtual bool isSectionStripped(DataRefImpl Sec) const;
273  virtual bool isBerkeleyText(DataRefImpl Sec) const;
274  virtual bool isBerkeleyData(DataRefImpl Sec) const;
275  virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const = 0;
276  virtual relocation_iterator section_rel_end(DataRefImpl Sec) const = 0;
277  virtual Expected<section_iterator> getRelocatedSection(DataRefImpl Sec) const;
278 
279  // Same as above for RelocationRef.
280  friend class RelocationRef;
281  virtual void moveRelocationNext(DataRefImpl &Rel) const = 0;
282  virtual uint64_t getRelocationOffset(DataRefImpl Rel) const = 0;
283  virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const = 0;
284  virtual uint64_t getRelocationType(DataRefImpl Rel) const = 0;
285  virtual void getRelocationTypeName(DataRefImpl Rel,
286  SmallVectorImpl<char> &Result) const = 0;
287 
288  uint64_t getSymbolValue(DataRefImpl Symb) const;
289 
290 public:
291  ObjectFile() = delete;
292  ObjectFile(const ObjectFile &other) = delete;
293 
294  uint64_t getCommonSymbolSize(DataRefImpl Symb) const {
295  assert(getSymbolFlags(Symb) & SymbolRef::SF_Common);
296  return getCommonSymbolSizeImpl(Symb);
297  }
298 
299  virtual std::vector<SectionRef> dynamic_relocation_sections() const {
300  return std::vector<SectionRef>();
301  }
302 
305  return symbol_iterator_range(symbol_begin(), symbol_end());
306  }
307 
308  virtual section_iterator section_begin() const = 0;
309  virtual section_iterator section_end() const = 0;
310 
313  return section_iterator_range(section_begin(), section_end());
314  }
315 
316  /// The number of bytes used to represent an address in this object
317  /// file format.
318  virtual uint8_t getBytesInAddress() const = 0;
319 
320  virtual StringRef getFileFormatName() const = 0;
321  virtual Triple::ArchType getArch() const = 0;
322  virtual SubtargetFeatures getFeatures() const = 0;
323  virtual void setARMSubArch(Triple &TheTriple) const { }
326  };
327 
328  /// Create a triple from the data in this object file.
329  Triple makeTriple() const;
330 
331  /// Maps a debug section name to a standard DWARF section name.
332  virtual StringRef mapDebugSectionName(StringRef Name) const { return Name; }
333 
334  /// True if this is a relocatable object (.o/.obj).
335  virtual bool isRelocatableObject() const = 0;
336 
337  /// @returns Pointer to ObjectFile subclass to handle this type of object.
338  /// @param ObjectPath The path to the object file. ObjectPath.isObject must
339  /// return true.
340  /// Create ObjectFile from path.
342  createObjectFile(StringRef ObjectPath);
343 
345  createObjectFile(MemoryBufferRef Object, llvm::file_magic Type);
348  return createObjectFile(Object, llvm::file_magic::unknown);
349  }
350 
351  static bool classof(const Binary *v) {
352  return v->isObject();
353  }
354 
356  createCOFFObjectFile(MemoryBufferRef Object);
357 
359  createXCOFFObjectFile(MemoryBufferRef Object, unsigned FileType);
360 
362  createELFObjectFile(MemoryBufferRef Object);
363 
365  createMachOObjectFile(MemoryBufferRef Object,
366  uint32_t UniversalCputype = 0,
367  uint32_t UniversalIndex = 0);
368 
370  createWasmObjectFile(MemoryBufferRef Object);
371 };
372 
373 // Inline function definitions.
374 inline SymbolRef::SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner)
375  : BasicSymbolRef(SymbolP, Owner) {}
376 
379 }
380 
383 }
384 
385 inline uint64_t SymbolRef::getValue() const {
387 }
388 
391 }
392 
393 inline uint64_t SymbolRef::getCommonSize() const {
395 }
396 
399 }
400 
403 }
404 
405 inline const ObjectFile *SymbolRef::getObject() const {
407  return cast<ObjectFile>(O);
408 }
409 
410 /// SectionRef
412  const ObjectFile *Owner)
413  : SectionPimpl(SectionP)
414  , OwningObject(Owner) {}
415 
416 inline bool SectionRef::operator==(const SectionRef &Other) const {
417  return OwningObject == Other.OwningObject &&
418  SectionPimpl == Other.SectionPimpl;
419 }
420 
421 inline bool SectionRef::operator!=(const SectionRef &Other) const {
422  return !(*this == Other);
423 }
424 
425 inline bool SectionRef::operator<(const SectionRef &Other) const {
426  assert(OwningObject == Other.OwningObject);
427  return SectionPimpl < Other.SectionPimpl;
428 }
429 
430 inline void SectionRef::moveNext() {
431  return OwningObject->moveSectionNext(SectionPimpl);
432 }
433 
435  return OwningObject->getSectionName(SectionPimpl);
436 }
437 
438 inline uint64_t SectionRef::getAddress() const {
439  return OwningObject->getSectionAddress(SectionPimpl);
440 }
441 
442 inline uint64_t SectionRef::getIndex() const {
443  return OwningObject->getSectionIndex(SectionPimpl);
444 }
445 
446 inline uint64_t SectionRef::getSize() const {
447  return OwningObject->getSectionSize(SectionPimpl);
448 }
449 
452  OwningObject->getSectionContents(SectionPimpl);
453  if (!Res)
454  return Res.takeError();
455  return StringRef(reinterpret_cast<const char *>(Res->data()), Res->size());
456 }
457 
458 inline uint64_t SectionRef::getAlignment() const {
459  return OwningObject->getSectionAlignment(SectionPimpl);
460 }
461 
462 inline bool SectionRef::isCompressed() const {
463  return OwningObject->isSectionCompressed(SectionPimpl);
464 }
465 
466 inline bool SectionRef::isText() const {
467  return OwningObject->isSectionText(SectionPimpl);
468 }
469 
470 inline bool SectionRef::isData() const {
471  return OwningObject->isSectionData(SectionPimpl);
472 }
473 
474 inline bool SectionRef::isBSS() const {
475  return OwningObject->isSectionBSS(SectionPimpl);
476 }
477 
478 inline bool SectionRef::isVirtual() const {
479  return OwningObject->isSectionVirtual(SectionPimpl);
480 }
481 
482 inline bool SectionRef::isBitcode() const {
483  return OwningObject->isSectionBitcode(SectionPimpl);
484 }
485 
486 inline bool SectionRef::isStripped() const {
487  return OwningObject->isSectionStripped(SectionPimpl);
488 }
489 
490 inline bool SectionRef::isBerkeleyText() const {
491  return OwningObject->isBerkeleyText(SectionPimpl);
492 }
493 
494 inline bool SectionRef::isBerkeleyData() const {
495  return OwningObject->isBerkeleyData(SectionPimpl);
496 }
497 
499  return OwningObject->section_rel_begin(SectionPimpl);
500 }
501 
503  return OwningObject->section_rel_end(SectionPimpl);
504 }
505 
507  return OwningObject->getRelocatedSection(SectionPimpl);
508 }
509 
511  return SectionPimpl;
512 }
513 
514 inline const ObjectFile *SectionRef::getObject() const {
515  return OwningObject;
516 }
517 
518 /// RelocationRef
520  const ObjectFile *Owner)
521  : RelocationPimpl(RelocationP)
522  , OwningObject(Owner) {}
523 
524 inline bool RelocationRef::operator==(const RelocationRef &Other) const {
525  return RelocationPimpl == Other.RelocationPimpl;
526 }
527 
528 inline void RelocationRef::moveNext() {
529  return OwningObject->moveRelocationNext(RelocationPimpl);
530 }
531 
532 inline uint64_t RelocationRef::getOffset() const {
533  return OwningObject->getRelocationOffset(RelocationPimpl);
534 }
535 
537  return OwningObject->getRelocationSymbol(RelocationPimpl);
538 }
539 
540 inline uint64_t RelocationRef::getType() const {
541  return OwningObject->getRelocationType(RelocationPimpl);
542 }
543 
545  return OwningObject->getRelocationTypeName(RelocationPimpl, Result);
546 }
547 
549  return RelocationPimpl;
550 }
551 
552 inline const ObjectFile *RelocationRef::getObject() const {
553  return OwningObject;
554 }
555 
556 } // end namespace object
557 
558 template <> struct DenseMapInfo<object::SectionRef> {
559  static bool isEqual(const object::SectionRef &A,
560  const object::SectionRef &B) {
561  return A == B;
562  }
564  return object::SectionRef({}, nullptr);
565  }
568  TS.p = (uintptr_t)-1;
569  return object::SectionRef(TS, nullptr);
570  }
571  static unsigned getHashValue(const object::SectionRef &Sec) {
573  return hash_combine(Raw.p, Raw.d.a, Raw.d.b);
574  }
575 };
576 
577 } // end namespace llvm
578 
579 #endif // LLVM_OBJECT_OBJECTFILE_H
raw_ostream & operator<<(raw_ostream &OS, const SectionedAddress &Addr)
Definition: ObjectFile.cpp:35
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:90
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Expected< StringRef > getName() const
Definition: ObjectFile.h:377
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:385
uint64_t getOffset() const
Definition: ObjectFile.h:532
bool operator!=(const SectionRef &Other) const
Definition: ObjectFile.h:421
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
virtual Expected< section_iterator > getRelocatedSection(DataRefImpl Sec) const
Definition: ObjectFile.cpp:95
bool isStripped() const
Definition: ObjectFile.h:486
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:974
Expected< section_iterator > getRelocatedSection() const
Definition: ObjectFile.h:506
virtual bool isSectionBSS(DataRefImpl Sec) const =0
This class is the base class for all object file types.
Definition: ObjectFile.h:223
bool operator==(const RelocationRef &Other) const
Definition: ObjectFile.h:524
Expected< StringRef > getContents() const
Definition: ObjectFile.h:450
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:229
uint32_t getAlignment() const
Get the alignment of this symbol as the actual value (not log 2).
Definition: ObjectFile.h:389
Error takeError()
Take ownership of the stored error.
Definition: Error.h:552
const ObjectFile * getObject() const
Definition: ObjectFile.h:552
virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const
Definition: ObjectFile.cpp:74
virtual Expected< StringRef > getSymbolName(DataRefImpl Symb) const =0
virtual bool isSectionStripped(DataRefImpl Sec) const
Definition: ObjectFile.cpp:84
relocation_iterator relocation_end() const
Definition: ObjectFile.h:502
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:544
static uint32_t getAlignment(const MCSectionCOFF &Sec)
uint64_t getAddress() const
Definition: ObjectFile.h:438
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:416
static StringRef getName(Value *V)
bool isText() const
Whether this section contains instructions.
Definition: ObjectFile.h:466
virtual uint64_t getSectionIndex(DataRefImpl Sec) const =0
Tagged union holding either a T or a Error.
Definition: APFloat.h:41
bool operator!=(const DataRefImpl &a, const DataRefImpl &b)
Definition: SymbolicFile.h:58
bool isBitcode() const
Definition: ObjectFile.h:482
Expected< const typename ELFT::Shdr * > getSection(typename ELFT::ShdrRange Sections, uint32_t Index)
Definition: ELF.h:311
virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const =0
#define UINT64_MAX
Definition: DataTypes.h:83
uint64_t getIndex() const
Definition: ObjectFile.h:442
bool isCompressed() const
Definition: ObjectFile.h:462
uint64_t getCommonSize() const
Definition: ObjectFile.h:393
bool operator<(const SectionedAddress &LHS, const SectionedAddress &RHS)
Definition: ObjectFile.h:146
const ObjectFile * getObject() const
Definition: ObjectFile.h:405
virtual uint64_t getSectionAlignment(DataRefImpl Sec) const =0
section_iterator_range sections() const
Definition: ObjectFile.h:312
virtual Expected< uint64_t > getStartAddress() const
Definition: ObjectFile.h:324
static unsigned getHashValue(const object::SectionRef &Sec)
Definition: ObjectFile.h:571
virtual bool isSectionBitcode(DataRefImpl Sec) const
Definition: ObjectFile.cpp:76
const ObjectFile * getObject() const
Definition: ObjectFile.h:514
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:397
struct llvm::object::DataRefImpl::@292 d
virtual StringRef mapDebugSectionName(StringRef Name) const
Maps a debug section name to a standard DWARF section name.
Definition: ObjectFile.h:332
static object::SectionRef getEmptyKey()
Definition: ObjectFile.h:563
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:46
bool isVirtual() const
Definition: ObjectFile.h:478
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:205
virtual std::vector< SectionRef > dynamic_relocation_sections() const
Definition: ObjectFile.h:299
static bool isEqual(const object::SectionRef &A, const object::SectionRef &B)
Definition: ObjectFile.h:559
uint64_t getSize() const
Definition: ObjectFile.h:446
relocation_iterator relocation_begin() const
Definition: ObjectFile.h:498
static Expected< std::unique_ptr< ObjectFile > > createObjectFile(MemoryBufferRef Object)
Definition: ObjectFile.h:347
virtual Expected< StringRef > getSectionName(DataRefImpl Sec) const =0
bool operator<(const SectionRef &Other) const
Definition: ObjectFile.h:425
Expected< uint64_t > getAddress() const
Returns the symbol virtual address (i.e.
Definition: ObjectFile.h:381
DataRefImpl getRawDataRefImpl() const
Definition: ObjectFile.h:510
bool isData() const
Whether this section contains data, not instructions.
Definition: ObjectFile.h:470
uint64_t getType() const
Definition: ObjectFile.h:540
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
SymbolRef(const BasicSymbolRef &B)
Definition: ObjectFile.h:177
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:490
virtual Expected< uint64_t > getSymbolAddress(DataRefImpl Symb) const =0
FileType
Defines the file type this file represents.
Definition: InterfaceFile.h:57
bool isBSS() const
Whether this section contains BSS uninitialized data.
Definition: ObjectFile.h:474
Expected< SymbolRef::Type > getType() const
Definition: ObjectFile.h:401
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:323
const SymbolRef & operator*() const
Definition: ObjectFile.h:214
virtual uint64_t getSectionAddress(DataRefImpl Sec) const =0
uint64_t getSymbolValue(DataRefImpl Symb) const
Definition: ObjectFile.cpp:57
virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const =0
bool isObject() const
Definition: Binary.h:102
Expected< StringRef > getName() const
Definition: ObjectFile.h:434
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:162
static std::unique_ptr< PDBSymbol > getSymbolType(const PDBSymbol &Symbol)
Definition: UDTLayout.cpp:33
static bool classof(const Binary *v)
Definition: ObjectFile.h:351
symbol_iterator getSymbol() const
Definition: ObjectFile.h:536
symbol_iterator_range symbols() const
Definition: ObjectFile.h:304
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:86
virtual bool isSectionData(DataRefImpl Sec) const =0
uint64_t getCommonSymbolSize(DataRefImpl Symb) const
Definition: ObjectFile.h:294
This is a value type class that represents a single symbol in the list of symbols in the object file...
Definition: SymbolicFile.h:98
uint64_t getAlignment() const
Get the alignment of this section as the actual value (not log 2).
Definition: ObjectFile.h:458
const SymbolRef * operator->() const
Definition: ObjectFile.h:209
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:204
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
static object::SectionRef getTombstoneKey()
Definition: ObjectFile.h:566
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:54
bool isBerkeleyData() const
Whether this section will be placed in the data segment, according to the Berkeley size format...
Definition: ObjectFile.h:494
virtual uint64_t getRelocationType(DataRefImpl Rel) const =0
Unrecognized file.
Definition: Magic.h:22
DataRefImpl getRawDataRefImpl() const
Definition: ObjectFile.h:548
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