LLVM  16.0.0git
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/ArrayRef.h"
17 #include "llvm/ADT/Hashing.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/ADT/Triple.h"
23 #include "llvm/Object/Binary.h"
24 #include "llvm/Object/Error.h"
26 #include "llvm/Support/Casting.h"
27 #include "llvm/Support/Error.h"
29 #include <cassert>
30 #include <cstdint>
31 #include <memory>
32 
33 namespace llvm {
34 
35 class SubtargetFeatures;
36 
37 namespace object {
38 
39 class COFFObjectFile;
40 class MachOObjectFile;
41 class ObjectFile;
42 class SectionRef;
43 class SymbolRef;
44 class symbol_iterator;
45 class WasmObjectFile;
46 
48 
49 /// This is a value type class that represents a single relocation in the list
50 /// of relocations in the object file.
52  DataRefImpl RelocationPimpl;
53  const ObjectFile *OwningObject = nullptr;
54 
55 public:
56  RelocationRef() = default;
57  RelocationRef(DataRefImpl RelocationP, const ObjectFile *Owner);
58 
59  bool operator==(const RelocationRef &Other) const;
60 
61  void moveNext();
62 
63  uint64_t getOffset() const;
64  symbol_iterator getSymbol() const;
65  uint64_t getType() const;
66 
67  /// Get a string that represents the type of this relocation.
68  ///
69  /// This is for display purposes only.
70  void getTypeName(SmallVectorImpl<char> &Result) const;
71 
73  const ObjectFile *getObject() const;
74 };
75 
77 
78 /// This is a value type class that represents a single section in the list of
79 /// sections in the object file.
80 class SectionRef {
81  friend class SymbolRef;
82 
83  DataRefImpl SectionPimpl;
84  const ObjectFile *OwningObject = nullptr;
85 
86 public:
87  SectionRef() = default;
88  SectionRef(DataRefImpl SectionP, const ObjectFile *Owner);
89 
90  bool operator==(const SectionRef &Other) const;
91  bool operator!=(const SectionRef &Other) const;
92  bool operator<(const SectionRef &Other) const;
93 
94  void moveNext();
95 
97  uint64_t getAddress() const;
98  uint64_t getIndex() const;
99  uint64_t getSize() const;
101 
102  /// Get the alignment of this section as the actual value (not log 2).
103  uint64_t getAlignment() const;
104 
105  bool isCompressed() const;
106  /// Whether this section contains instructions.
107  bool isText() const;
108  /// Whether this section contains data, not instructions.
109  bool isData() const;
110  /// Whether this section contains BSS uninitialized data.
111  bool isBSS() const;
112  bool isVirtual() const;
113  bool isBitcode() const;
114  bool isStripped() const;
115 
116  /// Whether this section will be placed in the text segment, according to the
117  /// Berkeley size format. This is true if the section is allocatable, and
118  /// contains either code or readonly data.
119  bool isBerkeleyText() const;
120  /// Whether this section will be placed in the data segment, according to the
121  /// Berkeley size format. This is true if the section is allocatable and
122  /// contains data (e.g. PROGBITS), but is not text.
123  bool isBerkeleyData() const;
124 
125  /// Whether this section is a debug section.
126  bool isDebugSection() const;
127 
128  bool containsSymbol(SymbolRef S) const;
129 
134  }
135 
136  /// Returns the related section if this section contains relocations. The
137  /// returned section may or may not have applied its relocations.
139 
141  const ObjectFile *getObject() const;
142 };
143 
146 
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 raw_ostream &operator<<(raw_ostream &OS, const SectionedAddress &Addr);
164 
165 /// This is a value type class that represents a single symbol in the list of
166 /// symbols in the object file.
167 class SymbolRef : public BasicSymbolRef {
168  friend class SectionRef;
169 
170 public:
171  enum Type {
172  ST_Unknown, // Type not specified
178  };
179 
180  SymbolRef() = default;
181  SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner);
183  assert(isa<ObjectFile>(BasicSymbolRef::getObject()));
184  }
185 
187  /// Returns the symbol virtual address (i.e. address at which it will be
188  /// mapped).
190 
191  /// Return the value of the symbol depending on the object this can be an
192  /// offset or a virtual address.
194 
195  /// Get the alignment of this symbol as the actual value (not log 2).
196  uint32_t getAlignment() const;
197  uint64_t getCommonSize() const;
199 
200  /// Get section this symbol is defined in reference to. Result is
201  /// end_sections() if it is undefined or is an absolute symbol.
203 
204  const ObjectFile *getObject() const;
205 };
206 
208 public:
211  : basic_symbol_iterator(SymbolRef(B->getRawDataRefImpl(),
212  cast<ObjectFile>(B->getObject()))) {}
213 
214  const SymbolRef *operator->() const {
216  return static_cast<const SymbolRef*>(&P);
217  }
218 
219  const SymbolRef &operator*() const {
221  return static_cast<const SymbolRef&>(P);
222  }
223 };
224 
225 /// This class is the base class for all object file types. Concrete instances
226 /// of this object are created by createObjectFile, which figures out which type
227 /// to create.
228 class ObjectFile : public SymbolicFile {
229  virtual void anchor();
230 
231 protected:
232  ObjectFile(unsigned int Type, MemoryBufferRef Source);
233 
234  const uint8_t *base() const {
235  return reinterpret_cast<const uint8_t *>(Data.getBufferStart());
236  }
237 
238  // These functions are for SymbolRef to call internally. The main goal of
239  // this is to allow SymbolRef::SymbolPimpl to point directly to the symbol
240  // entry in the memory mapped object file. SymbolPimpl cannot contain any
241  // virtual functions because then it could not point into the memory mapped
242  // file.
243  //
244  // Implementations assume that the DataRefImpl is valid and has not been
245  // modified externally. It's UB otherwise.
246  friend class SymbolRef;
247 
248  virtual Expected<StringRef> getSymbolName(DataRefImpl Symb) const = 0;
250  DataRefImpl Symb) const override;
251  virtual Expected<uint64_t> getSymbolAddress(DataRefImpl Symb) const = 0;
252  virtual uint64_t getSymbolValueImpl(DataRefImpl Symb) const = 0;
253  virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const;
254  virtual uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const = 0;
255  virtual Expected<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const = 0;
257  getSymbolSection(DataRefImpl Symb) const = 0;
258 
259  // Same as above for SectionRef.
260  friend class SectionRef;
261 
262  virtual void moveSectionNext(DataRefImpl &Sec) const = 0;
263  virtual Expected<StringRef> getSectionName(DataRefImpl Sec) const = 0;
264  virtual uint64_t getSectionAddress(DataRefImpl Sec) const = 0;
265  virtual uint64_t getSectionIndex(DataRefImpl Sec) const = 0;
266  virtual uint64_t getSectionSize(DataRefImpl Sec) const = 0;
268  getSectionContents(DataRefImpl Sec) const = 0;
269  virtual uint64_t getSectionAlignment(DataRefImpl Sec) const = 0;
270  virtual bool isSectionCompressed(DataRefImpl Sec) const = 0;
271  virtual bool isSectionText(DataRefImpl Sec) const = 0;
272  virtual bool isSectionData(DataRefImpl Sec) const = 0;
273  virtual bool isSectionBSS(DataRefImpl Sec) const = 0;
274  // A section is 'virtual' if its contents aren't present in the object image.
275  virtual bool isSectionVirtual(DataRefImpl Sec) const = 0;
276  virtual bool isSectionBitcode(DataRefImpl Sec) const;
277  virtual bool isSectionStripped(DataRefImpl Sec) const;
278  virtual bool isBerkeleyText(DataRefImpl Sec) const;
279  virtual bool isBerkeleyData(DataRefImpl Sec) const;
280  virtual bool isDebugSection(DataRefImpl Sec) const;
281  virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const = 0;
282  virtual relocation_iterator section_rel_end(DataRefImpl Sec) const = 0;
284 
285  // Same as above for RelocationRef.
286  friend class RelocationRef;
287  virtual void moveRelocationNext(DataRefImpl &Rel) const = 0;
288  virtual uint64_t getRelocationOffset(DataRefImpl Rel) const = 0;
289  virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const = 0;
290  virtual uint64_t getRelocationType(DataRefImpl Rel) const = 0;
291  virtual void getRelocationTypeName(DataRefImpl Rel,
292  SmallVectorImpl<char> &Result) const = 0;
293 
297  };
298 
300 
301 public:
302  ObjectFile() = delete;
303  ObjectFile(const ObjectFile &other) = delete;
304 
306  Expected<uint32_t> SymbolFlagsOrErr = getSymbolFlags(Symb);
307  if (!SymbolFlagsOrErr)
308  // TODO: Actually report errors helpfully.
309  report_fatal_error(SymbolFlagsOrErr.takeError());
310  assert(*SymbolFlagsOrErr & SymbolRef::SF_Common);
311  return getCommonSymbolSizeImpl(Symb);
312  }
313 
314  virtual std::vector<SectionRef> dynamic_relocation_sections() const {
315  return std::vector<SectionRef>();
316  }
317 
321  }
322 
323  virtual section_iterator section_begin() const = 0;
324  virtual section_iterator section_end() const = 0;
325 
329  }
330 
331  virtual bool hasDebugInfo() const;
332 
333  /// The number of bytes used to represent an address in this object
334  /// file format.
335  virtual uint8_t getBytesInAddress() const = 0;
336 
337  virtual StringRef getFileFormatName() const = 0;
338  virtual Triple::ArchType getArch() const = 0;
339  virtual SubtargetFeatures getFeatures() const = 0;
340  virtual Optional<StringRef> tryGetCPUName() const { return None; };
341  virtual void setARMSubArch(Triple &TheTriple) const { }
344  };
345 
346  /// Create a triple from the data in this object file.
347  Triple makeTriple() const;
348 
349  /// Maps a debug section name to a standard DWARF section name.
350  virtual StringRef mapDebugSectionName(StringRef Name) const { return Name; }
351 
352  /// True if this is a relocatable object (.o/.obj).
353  virtual bool isRelocatableObject() const = 0;
354 
355  /// True if the reflection section can be stripped by the linker.
358  const;
359 
360  /// @returns Pointer to ObjectFile subclass to handle this type of object.
361  /// @param ObjectPath The path to the object file. ObjectPath.isObject must
362  /// return true.
363  /// Create ObjectFile from path.
365  createObjectFile(StringRef ObjectPath);
366 
369  bool InitContent = true);
373  }
374 
375  static bool classof(const Binary *v) {
376  return v->isObject();
377  }
378 
381 
384 
386  createELFObjectFile(MemoryBufferRef Object, bool InitContent = true);
387 
390  uint32_t UniversalCputype = 0,
391  uint32_t UniversalIndex = 0);
392 
395 };
396 
397 // Inline function definitions.
398 inline SymbolRef::SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner)
399  : BasicSymbolRef(SymbolP, Owner) {}
400 
403 }
404 
407 }
408 
411 }
412 
415 }
416 
419 }
420 
423 }
424 
427 }
428 
429 inline const ObjectFile *SymbolRef::getObject() const {
431  return cast<ObjectFile>(O);
432 }
433 
434 /// SectionRef
436  const ObjectFile *Owner)
437  : SectionPimpl(SectionP)
438  , OwningObject(Owner) {}
439 
440 inline bool SectionRef::operator==(const SectionRef &Other) const {
441  return OwningObject == Other.OwningObject &&
442  SectionPimpl == Other.SectionPimpl;
443 }
444 
445 inline bool SectionRef::operator!=(const SectionRef &Other) const {
446  return !(*this == Other);
447 }
448 
449 inline bool SectionRef::operator<(const SectionRef &Other) const {
450  assert(OwningObject == Other.OwningObject);
451  return SectionPimpl < Other.SectionPimpl;
452 }
453 
454 inline void SectionRef::moveNext() {
455  return OwningObject->moveSectionNext(SectionPimpl);
456 }
457 
459  return OwningObject->getSectionName(SectionPimpl);
460 }
461 
463  return OwningObject->getSectionAddress(SectionPimpl);
464 }
465 
467  return OwningObject->getSectionIndex(SectionPimpl);
468 }
469 
471  return OwningObject->getSectionSize(SectionPimpl);
472 }
473 
476  OwningObject->getSectionContents(SectionPimpl);
477  if (!Res)
478  return Res.takeError();
479  return StringRef(reinterpret_cast<const char *>(Res->data()), Res->size());
480 }
481 
483  return OwningObject->getSectionAlignment(SectionPimpl);
484 }
485 
486 inline bool SectionRef::isCompressed() const {
487  return OwningObject->isSectionCompressed(SectionPimpl);
488 }
489 
490 inline bool SectionRef::isText() const {
491  return OwningObject->isSectionText(SectionPimpl);
492 }
493 
494 inline bool SectionRef::isData() const {
495  return OwningObject->isSectionData(SectionPimpl);
496 }
497 
498 inline bool SectionRef::isBSS() const {
499  return OwningObject->isSectionBSS(SectionPimpl);
500 }
501 
502 inline bool SectionRef::isVirtual() const {
503  return OwningObject->isSectionVirtual(SectionPimpl);
504 }
505 
506 inline bool SectionRef::isBitcode() const {
507  return OwningObject->isSectionBitcode(SectionPimpl);
508 }
509 
510 inline bool SectionRef::isStripped() const {
511  return OwningObject->isSectionStripped(SectionPimpl);
512 }
513 
514 inline bool SectionRef::isBerkeleyText() const {
515  return OwningObject->isBerkeleyText(SectionPimpl);
516 }
517 
518 inline bool SectionRef::isBerkeleyData() const {
519  return OwningObject->isBerkeleyData(SectionPimpl);
520 }
521 
522 inline bool SectionRef::isDebugSection() const {
523  return OwningObject->isDebugSection(SectionPimpl);
524 }
525 
527  return OwningObject->section_rel_begin(SectionPimpl);
528 }
529 
531  return OwningObject->section_rel_end(SectionPimpl);
532 }
533 
535  return OwningObject->getRelocatedSection(SectionPimpl);
536 }
537 
539  return SectionPimpl;
540 }
541 
542 inline const ObjectFile *SectionRef::getObject() const {
543  return OwningObject;
544 }
545 
546 /// RelocationRef
548  const ObjectFile *Owner)
549  : RelocationPimpl(RelocationP)
550  , OwningObject(Owner) {}
551 
552 inline bool RelocationRef::operator==(const RelocationRef &Other) const {
553  return RelocationPimpl == Other.RelocationPimpl;
554 }
555 
556 inline void RelocationRef::moveNext() {
557  return OwningObject->moveRelocationNext(RelocationPimpl);
558 }
559 
561  return OwningObject->getRelocationOffset(RelocationPimpl);
562 }
563 
565  return OwningObject->getRelocationSymbol(RelocationPimpl);
566 }
567 
569  return OwningObject->getRelocationType(RelocationPimpl);
570 }
571 
573  return OwningObject->getRelocationTypeName(RelocationPimpl, Result);
574 }
575 
577  return RelocationPimpl;
578 }
579 
580 inline const ObjectFile *RelocationRef::getObject() const {
581  return OwningObject;
582 }
583 
584 } // end namespace object
585 
586 template <> struct DenseMapInfo<object::SectionRef> {
587  static bool isEqual(const object::SectionRef &A,
588  const object::SectionRef &B) {
589  return A == B;
590  }
592  return object::SectionRef({}, nullptr);
593  }
596  TS.p = (uintptr_t)-1;
597  return object::SectionRef(TS, nullptr);
598  }
599  static unsigned getHashValue(const object::SectionRef &Sec) {
601  return hash_combine(Raw.p, Raw.d.a, Raw.d.b);
602  }
603 };
604 
605 } // end namespace llvm
606 
607 #endif // LLVM_OBJECT_OBJECTFILE_H
llvm::object::SectionRef::operator<
bool operator<(const SectionRef &Other) const
Definition: ObjectFile.h:449
llvm::object::RelocationRef::getSymbol
symbol_iterator getSymbol() const
Definition: ObjectFile.h:564
llvm::object::RelocationRef::getTypeName
void getTypeName(SmallVectorImpl< char > &Result) const
Get a string that represents the type of this relocation.
Definition: ObjectFile.h:572
llvm::object::SectionRef::isVirtual
bool isVirtual() const
Definition: ObjectFile.h:502
llvm::file_magic::unknown
@ unknown
Unrecognized file.
Definition: Magic.h:22
llvm::MemoryBufferRef::getBufferStart
const char * getBufferStart() const
Definition: MemoryBufferRef.h:35
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::object::ObjectFile::getBytesInAddress
virtual uint8_t getBytesInAddress() const =0
The number of bytes used to represent an address in this object file format.
llvm::object::SymbolRef::getValue
Expected< 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:409
llvm::object::ObjectFile::getSectionName
virtual Expected< StringRef > getSectionName(DataRefImpl Sec) const =0
llvm::object::SectionRef::isData
bool isData() const
Whether this section contains data, not instructions.
Definition: ObjectFile.h:494
llvm::make_range
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Definition: iterator_range.h:53
llvm::object::SectionRef::containsSymbol
bool containsSymbol(SymbolRef S) const
Definition: ObjectFile.cpp:46
llvm::object::DataRefImpl::a
uint32_t a
Definition: SymbolicFile.h:39
llvm::file_magic
file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...
Definition: Magic.h:20
llvm::object::SectionRef::getSize
uint64_t getSize() const
Definition: ObjectFile.h:470
StringRef.h
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::object::BasicSymbolRef::SF_Common
@ SF_Common
Definition: SymbolicFile.h:114
llvm::object::ObjectFile::getSectionAddress
virtual uint64_t getSectionAddress(DataRefImpl Sec) const =0
llvm::object::ObjectFile::createWasmObjectFile
static Expected< std::unique_ptr< WasmObjectFile > > createWasmObjectFile(MemoryBufferRef Object)
Definition: WasmObjectFile.cpp:56
llvm::object::ObjectFile::getRelocationSymbol
virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const =0
llvm::object::SectionedAddress::Address
uint64_t Address
Definition: ObjectFile.h:147
llvm::object::SectionRef::getRawDataRefImpl
DataRefImpl getRawDataRefImpl() const
Definition: ObjectFile.h:538
llvm::object::ObjectFile::getSymbolAddress
virtual Expected< uint64_t > getSymbolAddress(DataRefImpl Symb) const =0
llvm::object::ObjectFile::createMachOObjectFile
static Expected< std::unique_ptr< MachOObjectFile > > createMachOObjectFile(MemoryBufferRef Object, uint32_t UniversalCputype=0, uint32_t UniversalIndex=0)
Definition: MachOObjectFile.cpp:5301
Error.h
llvm::object::SectionRef::getName
Expected< StringRef > getName() const
Definition: ObjectFile.h:458
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
llvm::object::ObjectFile::getSymbolValue
Expected< uint64_t > getSymbolValue(DataRefImpl Symb) const
Definition: ObjectFile.cpp:56
MemoryBufferRef.h
llvm::object::ObjectFile::setARMSubArch
virtual void setARMSubArch(Triple &TheTriple) const
Definition: ObjectFile.h:341
Swift.h
llvm::object::SectionRef::isBerkeleyText
bool isBerkeleyText() const
Whether this section will be placed in the text segment, according to the Berkeley size format.
Definition: ObjectFile.h:514
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::object::symbol_iterator::operator->
const SymbolRef * operator->() const
Definition: ObjectFile.h:214
llvm::object::SymbolRef::SymbolRef
SymbolRef(const BasicSymbolRef &B)
Definition: ObjectFile.h:182
llvm::object::SymbolRef::ST_Unknown
@ ST_Unknown
Definition: ObjectFile.h:172
llvm::object::Binary::Data
MemoryBufferRef Data
Definition: Binary.h:37
llvm::object::getObject
static Expected< const T * > getObject(MemoryBufferRef M, const void *Ptr, const uint64_t Size=sizeof(T))
Definition: XCOFFObjectFile.cpp:33
llvm::object::ObjectFile::createCOFFObjectFile
static Expected< std::unique_ptr< COFFObjectFile > > createCOFFObjectFile(MemoryBufferRef Object)
Definition: COFFObjectFile.cpp:1718
llvm::object::SectionRef::isBSS
bool isBSS() const
Whether this section contains BSS uninitialized data.
Definition: ObjectFile.h:498
llvm::object::ObjectFile::getArch
virtual Triple::ArchType getArch() const =0
llvm::object::ObjectFile::classof
static bool classof(const Binary *v)
Definition: ObjectFile.h:375
llvm::Optional
Definition: APInt.h:33
llvm::object::ObjectFile::tryGetCPUName
virtual Optional< StringRef > tryGetCPUName() const
Definition: ObjectFile.h:340
Hashing.h
llvm::object::SymbolRef::ST_Data
@ ST_Data
Definition: ObjectFile.h:174
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:41
RHS
Value * RHS
Definition: X86PartialReduction.cpp:76
llvm::object::SymbolRef::ST_File
@ ST_File
Definition: ObjectFile.h:176
llvm::object::ObjectFile::section_begin
virtual section_iterator section_begin() const =0
llvm::object::SymbolRef::getCommonSize
uint64_t getCommonSize() const
Definition: ObjectFile.h:417
llvm::object::ObjectFile::mapReflectionSectionNameToEnumValue
virtual llvm::binaryformat::Swift5ReflectionSectionKind mapReflectionSectionNameToEnumValue(StringRef SectionName) const
Definition: ObjectFile.h:295
SymbolicFile.h
llvm::object::SymbolRef::getAlignment
uint32_t getAlignment() const
Get the alignment of this symbol as the actual value (not log 2).
Definition: ObjectFile.h:413
llvm::MemoryBufferRef
Definition: MemoryBufferRef.h:22
llvm::object::SectionedAddress::SectionIndex
uint64_t SectionIndex
Definition: ObjectFile.h:148
llvm::DenseMapInfo< object::SectionRef >::getEmptyKey
static object::SectionRef getEmptyKey()
Definition: ObjectFile.h:591
llvm::object::SectionRef::moveNext
void moveNext()
Definition: ObjectFile.h:454
llvm::object::RelocationRef::RelocationRef
RelocationRef()=default
llvm::object::ObjectFile::symbols
symbol_iterator_range symbols() const
Definition: ObjectFile.h:319
llvm::object::ObjectFile::getCommonSymbolSize
uint64_t getCommonSymbolSize(DataRefImpl Symb) const
Definition: ObjectFile.h:305
llvm::object::ObjectFile::isDebugSection
virtual bool isDebugSection(DataRefImpl Sec) const
Definition: ObjectFile.cpp:97
llvm::object::RelocationRef::getType
uint64_t getType() const
Definition: ObjectFile.h:568
llvm::object::SymbolicFile::symbol_end
virtual basic_symbol_iterator symbol_end() const =0
llvm::cast
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition: Casting.h:565
LHS
Value * LHS
Definition: X86PartialReduction.cpp:75
llvm::object::SymbolicFile::getSymbolFlags
virtual Expected< uint32_t > getSymbolFlags(DataRefImpl Symb) const =0
llvm::DenseMapInfo
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition: APInt.h:34
llvm::object::ObjectFile::isSectionText
virtual bool isSectionText(DataRefImpl Sec) const =0
llvm::object::ObjectFile::getFeatures
virtual SubtargetFeatures getFeatures() const =0
llvm::object::ObjectFile::isSectionData
virtual bool isSectionData(DataRefImpl Sec) const =0
llvm::object::ObjectFile::isBerkeleyText
virtual bool isBerkeleyText(DataRefImpl Sec) const
Definition: ObjectFile.cpp:89
Error.h
llvm::object::ObjectFile::getRelocationTypeName
virtual void getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl< char > &Result) const =0
llvm::object::ObjectFile::isRelocatableObject
virtual bool isRelocatableObject() const =0
True if this is a relocatable object (.o/.obj).
Magic.h
llvm::object::symbol_iterator::operator*
const SymbolRef & operator*() const
Definition: ObjectFile.h:219
llvm::Triple::ArchType
ArchType
Definition: Triple.h:46
llvm::object::ObjectFile::section_end
virtual section_iterator section_end() const =0
llvm::object::BasicSymbolRef::getRawDataRefImpl
DataRefImpl getRawDataRefImpl() const
Definition: SymbolicFile.h:208
llvm::object::SectionRef::relocations
iterator_range< relocation_iterator > relocations() const
Definition: ObjectFile.h:132
llvm::object::ObjectFile::moveSectionNext
virtual void moveSectionNext(DataRefImpl &Sec) const =0
llvm::object::ObjectFile::isSectionCompressed
virtual bool isSectionCompressed(DataRefImpl Sec) const =0
llvm::errorCodeToError
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
Definition: Error.cpp:92
llvm::object::BasicSymbolRef
This is a value type class that represents a single symbol in the list of symbols in the object file.
Definition: SymbolicFile.h:103
llvm::object::ObjectFile::getFileFormatName
virtual StringRef getFileFormatName() const =0
llvm::SubtargetFeatures
Manages the enabling and disabling of subtarget specific features.
Definition: SubtargetFeature.h:180
UINT64_MAX
#define UINT64_MAX
Definition: DataTypes.h:77
llvm::object::content_iterator::operator*
const content_type & operator*() const
Definition: SymbolicFile.h:83
llvm::object::SectionRef::getAlignment
uint64_t getAlignment() const
Get the alignment of this section as the actual value (not log 2).
Definition: ObjectFile.h:482
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:145
llvm::object::ObjectFile::ObjectFile
ObjectFile()=delete
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::object::ObjectFile::getSymbolValueImpl
virtual uint64_t getSymbolValueImpl(DataRefImpl Symb) const =0
llvm::object::ObjectFile::getSymbolSection
virtual Expected< section_iterator > getSymbolSection(DataRefImpl Symb) const =0
llvm::object::object_error::parse_failed
@ parse_failed
llvm::object::DataRefImpl::p
uintptr_t p
Definition: SymbolicFile.h:41
llvm::object::SectionRef::isBerkeleyData
bool isBerkeleyData() const
Whether this section will be placed in the data segment, according to the Berkeley size format.
Definition: ObjectFile.h:518
DebugLocVerifyLevel::None
@ None
llvm::object::ObjectFile::createELFObjectFile
static Expected< std::unique_ptr< ObjectFile > > createELFObjectFile(MemoryBufferRef Object, bool InitContent=true)
Definition: ELFObjectFile.cpp:71
llvm::object::ObjectFile::getSectionSize
virtual uint64_t getSectionSize(DataRefImpl Sec) const =0
llvm::object::ObjectFile::section_iterator_range
iterator_range< section_iterator > section_iterator_range
Definition: ObjectFile.h:326
llvm::object::SymbolRef::getObject
const ObjectFile * getObject() const
Definition: ObjectFile.h:429
llvm::object::ObjectFile::isSectionVirtual
virtual bool isSectionVirtual(DataRefImpl Sec) const =0
llvm::object::RelocationRef::getRawDataRefImpl
DataRefImpl getRawDataRefImpl() const
Definition: ObjectFile.h:576
llvm::object::ObjectFile::getRelocationType
virtual uint64_t getRelocationType(DataRefImpl Rel) const =0
llvm::MachO::FileType
FileType
Defines the file type this file represents.
Definition: InterfaceFile.h:53
llvm::object::BasicSymbolRef::getObject
const SymbolicFile * getObject() const
Definition: SymbolicFile.h:212
llvm::OutputFileType::Object
@ Object
llvm::object::SectionRef
This is a value type class that represents a single section in the list of sections in the object fil...
Definition: ObjectFile.h:80
llvm::object::SectionRef::SectionRef
SectionRef()=default
llvm::object::operator<<
raw_ostream & operator<<(raw_ostream &OS, const SectionedAddress &Addr)
Definition: ObjectFile.cpp:34
llvm::binaryformat::Swift5ReflectionSectionKind
Swift5ReflectionSectionKind
Definition: Swift.h:14
llvm::object::ObjectFile::isBerkeleyData
virtual bool isBerkeleyData(DataRefImpl Sec) const
Definition: ObjectFile.cpp:93
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:264
llvm::object::DataRefImpl::d
struct llvm::object::DataRefImpl::@340 d
llvm::object::SymbolRef::getSection
Expected< section_iterator > getSection() const
Get section this symbol is defined in reference to.
Definition: ObjectFile.h:421
object
bar al al movzbl eax ret Missed when stored in a memory object
Definition: README.txt:1411
uint64_t
llvm::object::symbol_iterator
Definition: ObjectFile.h:207
llvm::object::SymbolRef::ST_Function
@ ST_Function
Definition: ObjectFile.h:177
Addr
uint64_t Addr
Definition: ELFObjHandler.cpp:79
llvm::object::SectionedAddress::UndefSection
const static uint64_t UndefSection
Definition: ObjectFile.h:145
llvm::object::SectionRef::isStripped
bool isStripped() const
Definition: ObjectFile.h:510
ArrayRef.h
llvm::object::SectionRef::isDebugSection
bool isDebugSection() const
Whether this section is a debug section.
Definition: ObjectFile.h:522
llvm::object::ObjectFile::createObjectFile
static Expected< OwningBinary< ObjectFile > > createObjectFile(StringRef ObjectPath)
Definition: ObjectFile.cpp:194
llvm::object::SymbolRef::ST_Debug
@ ST_Debug
Definition: ObjectFile.h:175
llvm::object::ObjectFile::printSymbolName
Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override
Definition: ObjectFile.cpp:69
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::object::ObjectFile::getSymbolName
virtual Expected< StringRef > getSymbolName(DataRefImpl Symb) const =0
llvm::object::SectionRef::getRelocatedSection
Expected< section_iterator > getRelocatedSection() const
Returns the related section if this section contains relocations.
Definition: ObjectFile.h:534
llvm::object::content_iterator
Definition: SymbolicFile.h:69
llvm::object::ObjectFile::base
const uint8_t * base() const
Definition: ObjectFile.h:234
iterator_range.h
llvm::codeview::CodeViewContainer::ObjectFile
@ ObjectFile
llvm::object::SectionRef::getContents
Expected< StringRef > getContents() const
Definition: ObjectFile.h:474
llvm::object::ObjectFile::createXCOFFObjectFile
static Expected< std::unique_ptr< ObjectFile > > createXCOFFObjectFile(MemoryBufferRef Object, unsigned FileType)
Definition: XCOFFObjectFile.cpp:1215
llvm::object::ObjectFile::makeTriple
Triple makeTriple() const
Create a triple from the data in this object file.
Definition: ObjectFile.cpp:109
Triple.h
llvm::object::RelocationRef::getOffset
uint64_t getOffset() const
Definition: ObjectFile.h:560
llvm::object::SectionRef::operator!=
bool operator!=(const SectionRef &Other) const
Definition: ObjectFile.h:445
llvm::Sched::Source
@ Source
Definition: TargetLowering.h:99
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::object::ObjectFile
This class is the base class for all object file types.
Definition: ObjectFile.h:228
llvm::object::ObjectFile::getRelocationOffset
virtual uint64_t getRelocationOffset(DataRefImpl Rel) const =0
llvm::object::Binary
Definition: Binary.h:32
llvm::object::ObjectFile::getRelocatedSection
virtual Expected< section_iterator > getRelocatedSection(DataRefImpl Sec) const
Definition: ObjectFile.cpp:105
uint32_t
llvm::binaryformat::unknown
@ unknown
Definition: Swift.h:18
llvm::object::ObjectFile::getSectionContents
virtual Expected< ArrayRef< uint8_t > > getSectionContents(DataRefImpl Sec) const =0
llvm::object::RelocationRef::getObject
const ObjectFile * getObject() const
Definition: ObjectFile.h:580
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::object::SymbolicFile::symbol_begin
virtual basic_symbol_iterator symbol_begin() const =0
llvm::object::DataRefImpl
Definition: SymbolicFile.h:35
llvm::object::ObjectFile::isSectionBSS
virtual bool isSectionBSS(DataRefImpl Sec) const =0
llvm::object::ObjectFile::symbol_iterator_range
iterator_range< symbol_iterator > symbol_iterator_range
Definition: ObjectFile.h:318
llvm::object::SectionRef::getAddress
uint64_t getAddress() const
Definition: ObjectFile.h:462
llvm::object::ObjectFile::section_rel_end
virtual relocation_iterator section_rel_end(DataRefImpl Sec) const =0
llvm::object::operator<
bool operator<(const SectionedAddress &LHS, const SectionedAddress &RHS)
Definition: ObjectFile.h:151
llvm::object::ObjectFile::getSymbolAlignment
virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const
Definition: ObjectFile.cpp:77
llvm::object::SectionRef::isText
bool isText() const
Whether this section contains instructions.
Definition: ObjectFile.h:490
llvm::object::ObjectFile::isSectionStripped
virtual bool isSectionStripped(DataRefImpl Sec) const
Definition: ObjectFile.cpp:87
llvm::object::ObjectFile::section_rel_begin
virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const =0
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
llvm::object::SymbolRef::Type
Type
Definition: ObjectFile.h:171
llvm::object::SectionRef::relocation_end
relocation_iterator relocation_end() const
Definition: ObjectFile.h:530
llvm::SectionName
Definition: DWARFSection.h:21
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
llvm::object::symbol_iterator::symbol_iterator
symbol_iterator(SymbolRef Sym)
Definition: ObjectFile.h:209
Casting.h
llvm::object::operator==
bool operator==(const SectionedAddress &LHS, const SectionedAddress &RHS)
Definition: ObjectFile.h:157
llvm::object::ObjectFile::getSectionIndex
virtual uint64_t getSectionIndex(DataRefImpl Sec) const =0
llvm::object::SymbolRef::ST_Other
@ ST_Other
Definition: ObjectFile.h:173
llvm::object::SectionRef::operator==
bool operator==(const SectionRef &Other) const
Definition: ObjectFile.h:440
llvm::object::RelocationRef::moveNext
void moveNext()
Definition: ObjectFile.h:556
llvm::object::ObjectFile::mapDebugSectionName
virtual StringRef mapDebugSectionName(StringRef Name) const
Maps a debug section name to a standard DWARF section name.
Definition: ObjectFile.h:350
llvm::Expected::takeError
Error takeError()
Take ownership of the stored error.
Definition: Error.h:596
llvm::object::SectionRef::isBitcode
bool isBitcode() const
Definition: ObjectFile.h:506
Binary.h
llvm::object::ObjectFile::getCommonSymbolSizeImpl
virtual uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const =0
llvm::hash_combine
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Definition: Hashing.h:605
llvm::object::ObjectFile::getSymbolType
virtual Expected< SymbolRef::Type > getSymbolType(DataRefImpl Symb) const =0
llvm::object::ObjectFile::isReflectionSectionStrippable
bool isReflectionSectionStrippable(llvm::binaryformat::Swift5ReflectionSectionKind ReflectionSectionKind) const
True if the reflection section can be stripped by the linker.
Definition: ObjectFile.cpp:210
llvm::object::SymbolRef::getType
Expected< SymbolRef::Type > getType() const
Definition: ObjectFile.h:425
llvm::object::SectionedAddress
Definition: ObjectFile.h:144
llvm::object::SectionRef::getIndex
uint64_t getIndex() const
Definition: ObjectFile.h:466
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition: iterator_range.h:30
llvm::object::ObjectFile::sections
section_iterator_range sections() const
Definition: ObjectFile.h:327
llvm::object::SectionRef::isCompressed
bool isCompressed() const
Definition: ObjectFile.h:486
llvm::object::RelocationRef::operator==
bool operator==(const RelocationRef &Other) const
Definition: ObjectFile.h:552
llvm::DenseMapInfo< object::SectionRef >::getTombstoneKey
static object::SectionRef getTombstoneKey()
Definition: ObjectFile.h:594
llvm::SmallVectorImpl< char >
llvm::object::SymbolRef
This is a value type class that represents a single symbol in the list of symbols in the object file.
Definition: ObjectFile.h:167
llvm::object::ObjectFile::hasDebugInfo
virtual bool hasDebugInfo() const
Definition: ObjectFile.cpp:99
llvm::object::DataRefImpl::b
uint32_t b
Definition: SymbolicFile.h:39
llvm::object::ObjectFile::isSectionBitcode
virtual bool isSectionBitcode(DataRefImpl Sec) const
Definition: ObjectFile.cpp:79
llvm::object::RelocationRef
This is a value type class that represents a single relocation in the list of relocations in the obje...
Definition: ObjectFile.h:51
llvm::object::SymbolRef::getName
Expected< StringRef > getName() const
Definition: ObjectFile.h:401
llvm::object::ObjectFile::moveRelocationNext
virtual void moveRelocationNext(DataRefImpl &Rel) const =0
llvm::object::ObjectFile::getStartAddress
virtual Expected< uint64_t > getStartAddress() const
Definition: ObjectFile.h:342
llvm::object::SymbolicFile
Definition: SymbolicFile.h:145
llvm::object::SymbolRef::SymbolRef
SymbolRef()=default
llvm::object::SectionRef::getObject
const ObjectFile * getObject() const
Definition: ObjectFile.h:542
llvm::object::ObjectFile::dynamic_relocation_sections
virtual std::vector< SectionRef > dynamic_relocation_sections() const
Definition: ObjectFile.h:314
llvm::DenseMapInfo< object::SectionRef >::getHashValue
static unsigned getHashValue(const object::SectionRef &Sec)
Definition: ObjectFile.h:599
llvm::object::symbol_iterator::symbol_iterator
symbol_iterator(const basic_symbol_iterator &B)
Definition: ObjectFile.h:210
llvm::object::SymbolRef::getAddress
Expected< uint64_t > getAddress() const
Returns the symbol virtual address (i.e.
Definition: ObjectFile.h:405
llvm::object::ObjectFile::getSectionAlignment
virtual uint64_t getSectionAlignment(DataRefImpl Sec) const =0
llvm::object::ObjectFile::createObjectFile
static Expected< std::unique_ptr< ObjectFile > > createObjectFile(MemoryBufferRef Object)
Definition: ObjectFile.h:371
llvm::object::Binary::isObject
bool isObject() const
Definition: Binary.h:106
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1251
llvm::object::SectionRef::relocation_begin
relocation_iterator relocation_begin() const
Definition: ObjectFile.h:526
llvm::DenseMapInfo< object::SectionRef >::isEqual
static bool isEqual(const object::SectionRef &A, const object::SectionRef &B)
Definition: ObjectFile.h:587