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