LLVM  15.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  /// The number of bytes used to represent an address in this object
332  /// file format.
333  virtual uint8_t getBytesInAddress() const = 0;
334 
335  virtual StringRef getFileFormatName() const = 0;
336  virtual Triple::ArchType getArch() const = 0;
337  virtual SubtargetFeatures getFeatures() const = 0;
338  virtual Optional<StringRef> tryGetCPUName() const { return None; };
339  virtual void setARMSubArch(Triple &TheTriple) const { }
342  };
343 
344  /// Create a triple from the data in this object file.
345  Triple makeTriple() const;
346 
347  /// Maps a debug section name to a standard DWARF section name.
348  virtual StringRef mapDebugSectionName(StringRef Name) const { return Name; }
349 
350  /// True if this is a relocatable object (.o/.obj).
351  virtual bool isRelocatableObject() const = 0;
352 
353  /// True if the reflection section can be stripped by the linker.
356  const;
357 
358  /// @returns Pointer to ObjectFile subclass to handle this type of object.
359  /// @param ObjectPath The path to the object file. ObjectPath.isObject must
360  /// return true.
361  /// Create ObjectFile from path.
363  createObjectFile(StringRef ObjectPath);
364 
367  bool InitContent = true);
371  }
372 
373  static bool classof(const Binary *v) {
374  return v->isObject();
375  }
376 
379 
382 
384  createELFObjectFile(MemoryBufferRef Object, bool InitContent = true);
385 
388  uint32_t UniversalCputype = 0,
389  uint32_t UniversalIndex = 0);
390 
393 };
394 
395 // Inline function definitions.
396 inline SymbolRef::SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner)
397  : BasicSymbolRef(SymbolP, Owner) {}
398 
401 }
402 
405 }
406 
409 }
410 
413 }
414 
417 }
418 
421 }
422 
425 }
426 
427 inline const ObjectFile *SymbolRef::getObject() const {
429  return cast<ObjectFile>(O);
430 }
431 
432 /// SectionRef
434  const ObjectFile *Owner)
435  : SectionPimpl(SectionP)
436  , OwningObject(Owner) {}
437 
438 inline bool SectionRef::operator==(const SectionRef &Other) const {
439  return OwningObject == Other.OwningObject &&
440  SectionPimpl == Other.SectionPimpl;
441 }
442 
443 inline bool SectionRef::operator!=(const SectionRef &Other) const {
444  return !(*this == Other);
445 }
446 
447 inline bool SectionRef::operator<(const SectionRef &Other) const {
448  assert(OwningObject == Other.OwningObject);
449  return SectionPimpl < Other.SectionPimpl;
450 }
451 
452 inline void SectionRef::moveNext() {
453  return OwningObject->moveSectionNext(SectionPimpl);
454 }
455 
457  return OwningObject->getSectionName(SectionPimpl);
458 }
459 
461  return OwningObject->getSectionAddress(SectionPimpl);
462 }
463 
465  return OwningObject->getSectionIndex(SectionPimpl);
466 }
467 
469  return OwningObject->getSectionSize(SectionPimpl);
470 }
471 
474  OwningObject->getSectionContents(SectionPimpl);
475  if (!Res)
476  return Res.takeError();
477  return StringRef(reinterpret_cast<const char *>(Res->data()), Res->size());
478 }
479 
481  return OwningObject->getSectionAlignment(SectionPimpl);
482 }
483 
484 inline bool SectionRef::isCompressed() const {
485  return OwningObject->isSectionCompressed(SectionPimpl);
486 }
487 
488 inline bool SectionRef::isText() const {
489  return OwningObject->isSectionText(SectionPimpl);
490 }
491 
492 inline bool SectionRef::isData() const {
493  return OwningObject->isSectionData(SectionPimpl);
494 }
495 
496 inline bool SectionRef::isBSS() const {
497  return OwningObject->isSectionBSS(SectionPimpl);
498 }
499 
500 inline bool SectionRef::isVirtual() const {
501  return OwningObject->isSectionVirtual(SectionPimpl);
502 }
503 
504 inline bool SectionRef::isBitcode() const {
505  return OwningObject->isSectionBitcode(SectionPimpl);
506 }
507 
508 inline bool SectionRef::isStripped() const {
509  return OwningObject->isSectionStripped(SectionPimpl);
510 }
511 
512 inline bool SectionRef::isBerkeleyText() const {
513  return OwningObject->isBerkeleyText(SectionPimpl);
514 }
515 
516 inline bool SectionRef::isBerkeleyData() const {
517  return OwningObject->isBerkeleyData(SectionPimpl);
518 }
519 
520 inline bool SectionRef::isDebugSection() const {
521  return OwningObject->isDebugSection(SectionPimpl);
522 }
523 
525  return OwningObject->section_rel_begin(SectionPimpl);
526 }
527 
529  return OwningObject->section_rel_end(SectionPimpl);
530 }
531 
533  return OwningObject->getRelocatedSection(SectionPimpl);
534 }
535 
537  return SectionPimpl;
538 }
539 
540 inline const ObjectFile *SectionRef::getObject() const {
541  return OwningObject;
542 }
543 
544 /// RelocationRef
546  const ObjectFile *Owner)
547  : RelocationPimpl(RelocationP)
548  , OwningObject(Owner) {}
549 
550 inline bool RelocationRef::operator==(const RelocationRef &Other) const {
551  return RelocationPimpl == Other.RelocationPimpl;
552 }
553 
554 inline void RelocationRef::moveNext() {
555  return OwningObject->moveRelocationNext(RelocationPimpl);
556 }
557 
559  return OwningObject->getRelocationOffset(RelocationPimpl);
560 }
561 
563  return OwningObject->getRelocationSymbol(RelocationPimpl);
564 }
565 
567  return OwningObject->getRelocationType(RelocationPimpl);
568 }
569 
571  return OwningObject->getRelocationTypeName(RelocationPimpl, Result);
572 }
573 
575  return RelocationPimpl;
576 }
577 
578 inline const ObjectFile *RelocationRef::getObject() const {
579  return OwningObject;
580 }
581 
582 } // end namespace object
583 
584 template <> struct DenseMapInfo<object::SectionRef> {
585  static bool isEqual(const object::SectionRef &A,
586  const object::SectionRef &B) {
587  return A == B;
588  }
590  return object::SectionRef({}, nullptr);
591  }
594  TS.p = (uintptr_t)-1;
595  return object::SectionRef(TS, nullptr);
596  }
597  static unsigned getHashValue(const object::SectionRef &Sec) {
599  return hash_combine(Raw.p, Raw.d.a, Raw.d.b);
600  }
601 };
602 
603 } // end namespace llvm
604 
605 #endif // LLVM_OBJECT_OBJECTFILE_H
llvm::object::SectionRef::operator<
bool operator<(const SectionRef &Other) const
Definition: ObjectFile.h:447
llvm::object::RelocationRef::getSymbol
symbol_iterator getSymbol() const
Definition: ObjectFile.h:562
llvm::object::RelocationRef::getTypeName
void getTypeName(SmallVectorImpl< char > &Result) const
Get a string that represents the type of this relocation.
Definition: ObjectFile.h:570
llvm::object::SectionRef::isVirtual
bool isVirtual() const
Definition: ObjectFile.h:500
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:17
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:407
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:492
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:468
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::cast
decltype(auto) LLVM_NODISCARD cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition: Casting.h:565
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:536
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:4898
Error.h
llvm::object::SectionRef::getName
Expected< StringRef > getName() const
Definition: ObjectFile.h:456
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:339
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:512
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:1714
llvm::object::SectionRef::isBSS
bool isBSS() const
Whether this section contains BSS uninitialized data.
Definition: ObjectFile.h:496
llvm::object::ObjectFile::getArch
virtual Triple::ArchType getArch() const =0
llvm::object::ObjectFile::classof
static bool classof(const Binary *v)
Definition: ObjectFile.h:373
llvm::Optional
Definition: APInt.h:33
llvm::object::ObjectFile::tryGetCPUName
virtual Optional< StringRef > tryGetCPUName() const
Definition: ObjectFile.h:338
llvm::object::DataRefImpl::d
struct llvm::object::DataRefImpl::@332 d
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:415
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:411
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:589
llvm::object::SectionRef::moveNext
void moveNext()
Definition: ObjectFile.h:452
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:566
llvm::object::SymbolicFile::symbol_end
virtual basic_symbol_iterator symbol_end() const =0
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:90
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:183
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:480
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:143
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:54
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:516
DebugLocVerifyLevel::None
@ None
llvm::object::ObjectFile::createELFObjectFile
static Expected< std::unique_ptr< ObjectFile > > createELFObjectFile(MemoryBufferRef Object, bool InitContent=true)
Definition: ELFObjectFile.cpp:70
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:427
llvm::object::ObjectFile::isSectionVirtual
virtual bool isSectionVirtual(DataRefImpl Sec) const =0
llvm::object::RelocationRef::getRawDataRefImpl
DataRefImpl getRawDataRefImpl() const
Definition: ObjectFile.h:574
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:240
llvm::object::SymbolRef::getSection
Expected< section_iterator > getSection() const
Get section this symbol is defined in reference to.
Definition: ObjectFile.h:419
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:78
llvm::object::SectionedAddress::UndefSection
const static uint64_t UndefSection
Definition: ObjectFile.h:145
llvm::object::SectionRef::isStripped
bool isStripped() const
Definition: ObjectFile.h:508
ArrayRef.h
llvm::object::SectionRef::isDebugSection
bool isDebugSection() const
Whether this section is a debug section.
Definition: ObjectFile.h:520
llvm::object::ObjectFile::createObjectFile
static Expected< OwningBinary< ObjectFile > > createObjectFile(StringRef ObjectPath)
Definition: ObjectFile.cpp:188
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:532
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:472
llvm::object::ObjectFile::createXCOFFObjectFile
static Expected< std::unique_ptr< ObjectFile > > createXCOFFObjectFile(MemoryBufferRef Object, unsigned FileType)
Definition: XCOFFObjectFile.cpp:1125
llvm::object::ObjectFile::makeTriple
Triple makeTriple() const
Create a triple from the data in this object file.
Definition: ObjectFile.cpp:104
Triple.h
llvm::object::RelocationRef::getOffset
uint64_t getOffset() const
Definition: ObjectFile.h:558
llvm::object::SectionRef::operator!=
bool operator!=(const SectionRef &Other) const
Definition: ObjectFile.h:443
llvm::Sched::Source
@ Source
Definition: TargetLowering.h:99
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
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:100
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:578
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:460
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:488
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:528
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:438
llvm::object::RelocationRef::moveNext
void moveNext()
Definition: ObjectFile.h:554
llvm::object::ObjectFile::mapDebugSectionName
virtual StringRef mapDebugSectionName(StringRef Name) const
Maps a debug section name to a standard DWARF section name.
Definition: ObjectFile.h:348
llvm::Expected::takeError
Error takeError()
Take ownership of the stored error.
Definition: Error.h:597
llvm::object::SectionRef::isBitcode
bool isBitcode() const
Definition: ObjectFile.h:504
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:204
llvm::object::SymbolRef::getType
Expected< SymbolRef::Type > getType() const
Definition: ObjectFile.h:423
llvm::object::SectionedAddress
Definition: ObjectFile.h:144
llvm::object::SectionRef::getIndex
uint64_t getIndex() const
Definition: ObjectFile.h:464
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:484
llvm::object::RelocationRef::operator==
bool operator==(const RelocationRef &Other) const
Definition: ObjectFile.h:550
llvm::DenseMapInfo< object::SectionRef >::getTombstoneKey
static object::SectionRef getTombstoneKey()
Definition: ObjectFile.h:592
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::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:399
llvm::object::ObjectFile::moveRelocationNext
virtual void moveRelocationNext(DataRefImpl &Rel) const =0
llvm::object::ObjectFile::getStartAddress
virtual Expected< uint64_t > getStartAddress() const
Definition: ObjectFile.h:340
llvm::object::SymbolicFile
Definition: SymbolicFile.h:145
llvm::object::SymbolRef::SymbolRef
SymbolRef()=default
llvm::object::SectionRef::getObject
const ObjectFile * getObject() const
Definition: ObjectFile.h:540
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:597
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:403
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:369
llvm::object::Binary::isObject
bool isObject() const
Definition: Binary.h:106
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1237
llvm::object::SectionRef::relocation_begin
relocation_iterator relocation_begin() const
Definition: ObjectFile.h:524
llvm::DenseMapInfo< object::SectionRef >::isEqual
static bool isEqual(const object::SectionRef &A, const object::SectionRef &B)
Definition: ObjectFile.h:585