LLVM  14.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/DenseMapInfo.h"
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/ADT/Triple.h"
21 #include "llvm/Object/Binary.h"
22 #include "llvm/Object/Error.h"
24 #include "llvm/Support/Casting.h"
25 #include "llvm/Support/Error.h"
27 #include <cassert>
28 #include <cstdint>
29 #include <memory>
30 #include <system_error>
31 
32 namespace llvm {
33 
34 class ARMAttributeParser;
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 
145  const static uint64_t UndefSection = UINT64_MAX;
146 
147  uint64_t Address = 0;
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 
295 
296 public:
297  ObjectFile() = delete;
298  ObjectFile(const ObjectFile &other) = delete;
299 
300  uint64_t getCommonSymbolSize(DataRefImpl Symb) const {
301  Expected<uint32_t> SymbolFlagsOrErr = getSymbolFlags(Symb);
302  if (!SymbolFlagsOrErr)
303  // TODO: Actually report errors helpfully.
304  report_fatal_error(SymbolFlagsOrErr.takeError());
305  assert(*SymbolFlagsOrErr & SymbolRef::SF_Common);
306  return getCommonSymbolSizeImpl(Symb);
307  }
308 
309  virtual std::vector<SectionRef> dynamic_relocation_sections() const {
310  return std::vector<SectionRef>();
311  }
312 
316  }
317 
318  virtual section_iterator section_begin() const = 0;
319  virtual section_iterator section_end() const = 0;
320 
324  }
325 
326  /// The number of bytes used to represent an address in this object
327  /// file format.
328  virtual uint8_t getBytesInAddress() const = 0;
329 
330  virtual StringRef getFileFormatName() const = 0;
331  virtual Triple::ArchType getArch() const = 0;
332  virtual SubtargetFeatures getFeatures() const = 0;
333  virtual Optional<StringRef> tryGetCPUName() const { return None; };
334  virtual void setARMSubArch(Triple &TheTriple) const { }
337  };
338 
339  /// Create a triple from the data in this object file.
340  Triple makeTriple() const;
341 
342  /// Maps a debug section name to a standard DWARF section name.
343  virtual StringRef mapDebugSectionName(StringRef Name) const { return Name; }
344 
345  /// True if this is a relocatable object (.o/.obj).
346  virtual bool isRelocatableObject() const = 0;
347 
348  /// @returns Pointer to ObjectFile subclass to handle this type of object.
349  /// @param ObjectPath The path to the object file. ObjectPath.isObject must
350  /// return true.
351  /// Create ObjectFile from path.
353  createObjectFile(StringRef ObjectPath);
354 
357  bool InitContent = true);
361  }
362 
363  static bool classof(const Binary *v) {
364  return v->isObject();
365  }
366 
369 
372 
374  createELFObjectFile(MemoryBufferRef Object, bool InitContent = true);
375 
378  uint32_t UniversalCputype = 0,
379  uint32_t UniversalIndex = 0);
380 
383 };
384 
385 // Inline function definitions.
386 inline SymbolRef::SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner)
387  : BasicSymbolRef(SymbolP, Owner) {}
388 
391 }
392 
395 }
396 
399 }
400 
403 }
404 
405 inline uint64_t SymbolRef::getCommonSize() const {
407 }
408 
411 }
412 
415 }
416 
417 inline const ObjectFile *SymbolRef::getObject() const {
419  return cast<ObjectFile>(O);
420 }
421 
422 /// SectionRef
424  const ObjectFile *Owner)
425  : SectionPimpl(SectionP)
426  , OwningObject(Owner) {}
427 
428 inline bool SectionRef::operator==(const SectionRef &Other) const {
429  return OwningObject == Other.OwningObject &&
430  SectionPimpl == Other.SectionPimpl;
431 }
432 
433 inline bool SectionRef::operator!=(const SectionRef &Other) const {
434  return !(*this == Other);
435 }
436 
437 inline bool SectionRef::operator<(const SectionRef &Other) const {
438  assert(OwningObject == Other.OwningObject);
439  return SectionPimpl < Other.SectionPimpl;
440 }
441 
442 inline void SectionRef::moveNext() {
443  return OwningObject->moveSectionNext(SectionPimpl);
444 }
445 
447  return OwningObject->getSectionName(SectionPimpl);
448 }
449 
450 inline uint64_t SectionRef::getAddress() const {
451  return OwningObject->getSectionAddress(SectionPimpl);
452 }
453 
454 inline uint64_t SectionRef::getIndex() const {
455  return OwningObject->getSectionIndex(SectionPimpl);
456 }
457 
458 inline uint64_t SectionRef::getSize() const {
459  return OwningObject->getSectionSize(SectionPimpl);
460 }
461 
464  OwningObject->getSectionContents(SectionPimpl);
465  if (!Res)
466  return Res.takeError();
467  return StringRef(reinterpret_cast<const char *>(Res->data()), Res->size());
468 }
469 
470 inline uint64_t SectionRef::getAlignment() const {
471  return OwningObject->getSectionAlignment(SectionPimpl);
472 }
473 
474 inline bool SectionRef::isCompressed() const {
475  return OwningObject->isSectionCompressed(SectionPimpl);
476 }
477 
478 inline bool SectionRef::isText() const {
479  return OwningObject->isSectionText(SectionPimpl);
480 }
481 
482 inline bool SectionRef::isData() const {
483  return OwningObject->isSectionData(SectionPimpl);
484 }
485 
486 inline bool SectionRef::isBSS() const {
487  return OwningObject->isSectionBSS(SectionPimpl);
488 }
489 
490 inline bool SectionRef::isVirtual() const {
491  return OwningObject->isSectionVirtual(SectionPimpl);
492 }
493 
494 inline bool SectionRef::isBitcode() const {
495  return OwningObject->isSectionBitcode(SectionPimpl);
496 }
497 
498 inline bool SectionRef::isStripped() const {
499  return OwningObject->isSectionStripped(SectionPimpl);
500 }
501 
502 inline bool SectionRef::isBerkeleyText() const {
503  return OwningObject->isBerkeleyText(SectionPimpl);
504 }
505 
506 inline bool SectionRef::isBerkeleyData() const {
507  return OwningObject->isBerkeleyData(SectionPimpl);
508 }
509 
510 inline bool SectionRef::isDebugSection() const {
511  return OwningObject->isDebugSection(SectionPimpl);
512 }
513 
515  return OwningObject->section_rel_begin(SectionPimpl);
516 }
517 
519  return OwningObject->section_rel_end(SectionPimpl);
520 }
521 
523  return OwningObject->getRelocatedSection(SectionPimpl);
524 }
525 
527  return SectionPimpl;
528 }
529 
530 inline const ObjectFile *SectionRef::getObject() const {
531  return OwningObject;
532 }
533 
534 /// RelocationRef
536  const ObjectFile *Owner)
537  : RelocationPimpl(RelocationP)
538  , OwningObject(Owner) {}
539 
540 inline bool RelocationRef::operator==(const RelocationRef &Other) const {
541  return RelocationPimpl == Other.RelocationPimpl;
542 }
543 
544 inline void RelocationRef::moveNext() {
545  return OwningObject->moveRelocationNext(RelocationPimpl);
546 }
547 
548 inline uint64_t RelocationRef::getOffset() const {
549  return OwningObject->getRelocationOffset(RelocationPimpl);
550 }
551 
553  return OwningObject->getRelocationSymbol(RelocationPimpl);
554 }
555 
556 inline uint64_t RelocationRef::getType() const {
557  return OwningObject->getRelocationType(RelocationPimpl);
558 }
559 
561  return OwningObject->getRelocationTypeName(RelocationPimpl, Result);
562 }
563 
565  return RelocationPimpl;
566 }
567 
568 inline const ObjectFile *RelocationRef::getObject() const {
569  return OwningObject;
570 }
571 
572 } // end namespace object
573 
574 template <> struct DenseMapInfo<object::SectionRef> {
575  static bool isEqual(const object::SectionRef &A,
576  const object::SectionRef &B) {
577  return A == B;
578  }
580  return object::SectionRef({}, nullptr);
581  }
584  TS.p = (uintptr_t)-1;
585  return object::SectionRef(TS, nullptr);
586  }
587  static unsigned getHashValue(const object::SectionRef &Sec) {
589  return hash_combine(Raw.p, Raw.d.a, Raw.d.b);
590  }
591 };
592 
593 } // end namespace llvm
594 
595 #endif // LLVM_OBJECT_OBJECTFILE_H
llvm::object::SectionRef::operator<
bool operator<(const SectionRef &Other) const
Definition: ObjectFile.h:437
MemoryBuffer.h
llvm::object::RelocationRef::getSymbol
symbol_iterator getSymbol() const
Definition: ObjectFile.h:552
llvm::object::RelocationRef::getTypeName
void getTypeName(SmallVectorImpl< char > &Result) const
Get a string that represents the type of this relocation.
Definition: ObjectFile.h:560
llvm::object::SectionRef::isVirtual
bool isVirtual() const
Definition: ObjectFile.h:490
llvm::cast
std::enable_if_t<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > cast(const Y &Val)
Definition: Casting.h:254
llvm::file_magic::unknown
@ unknown
Unrecognized file.
Definition: Magic.h:22
llvm::MemoryBufferRef::getBufferStart
const char * getBufferStart() const
Definition: MemoryBufferRef.h:35
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
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:397
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:482
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:47
llvm::object::DataRefImpl::a
uint32_t a
Definition: SymbolicFile.h:37
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:458
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:112
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:58
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:526
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:4657
Error.h
llvm::object::SectionRef::getName
Expected< StringRef > getName() const
Definition: ObjectFile.h:446
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
llvm::object::ObjectFile::getSymbolValue
Expected< uint64_t > getSymbolValue(DataRefImpl Symb) const
Definition: ObjectFile.cpp:57
llvm::object::ObjectFile::setARMSubArch
virtual void setARMSubArch(Triple &TheTriple) const
Definition: ObjectFile.h:334
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:502
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:1655
llvm::object::SectionRef::isBSS
bool isBSS() const
Whether this section contains BSS uninitialized data.
Definition: ObjectFile.h:486
llvm::object::ObjectFile::getArch
virtual Triple::ArchType getArch() const =0
llvm::object::ObjectFile::classof
static bool classof(const Binary *v)
Definition: ObjectFile.h:363
llvm::Optional
Definition: APInt.h:33
llvm::object::ObjectFile::tryGetCPUName
virtual Optional< StringRef > tryGetCPUName() const
Definition: ObjectFile.h:333
llvm::object::SymbolRef::ST_Data
@ ST_Data
Definition: ObjectFile.h:173
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
llvm::object::SymbolRef::ST_File
@ ST_File
Definition: ObjectFile.h:175
llvm::object::ObjectFile::section_begin
virtual section_iterator section_begin() const =0
llvm::object::SymbolRef::getCommonSize
uint64_t getCommonSize() const
Definition: ObjectFile.h:405
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:401
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:579
llvm::object::SectionRef::moveNext
void moveNext()
Definition: ObjectFile.h:442
llvm::object::RelocationRef::RelocationRef
RelocationRef()=default
llvm::object::ObjectFile::symbols
symbol_iterator_range symbols() const
Definition: ObjectFile.h:314
llvm::object::ObjectFile::getCommonSymbolSize
uint64_t getCommonSymbolSize(DataRefImpl Symb) const
Definition: ObjectFile.h:300
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:556
llvm::object::SymbolicFile::symbol_end
virtual basic_symbol_iterator symbol_end() const =0
llvm::object::SymbolicFile::getSymbolFlags
virtual Expected< uint32_t > getSymbolFlags(DataRefImpl Symb) const =0
llvm::DenseMapInfo
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:47
llvm::object::ObjectFile::section_end
virtual section_iterator section_end() const =0
llvm::object::BasicSymbolRef::getRawDataRefImpl
DataRefImpl getRawDataRefImpl() const
Definition: SymbolicFile.h:206
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:87
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:101
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:81
llvm::object::SectionRef::getAlignment
uint64_t getAlignment() const
Get the alignment of this section as the actual value (not log 2).
Definition: ObjectFile.h:470
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:140
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:39
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:506
DebugLocVerifyLevel::None
@ None
llvm::object::ObjectFile::createELFObjectFile
static Expected< std::unique_ptr< ObjectFile > > createELFObjectFile(MemoryBufferRef Object, bool InitContent=true)
Definition: ELFObjectFile.cpp:72
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:321
llvm::object::SymbolRef::getObject
const ObjectFile * getObject() const
Definition: ObjectFile.h:417
llvm::object::ObjectFile::isSectionVirtual
virtual bool isSectionVirtual(DataRefImpl Sec) const =0
llvm::object::RelocationRef::getRawDataRefImpl
DataRefImpl getRawDataRefImpl() const
Definition: ObjectFile.h:564
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:57
llvm::object::BasicSymbolRef::getObject
const SymbolicFile * getObject() const
Definition: SymbolicFile.h:210
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:35
llvm::object::ObjectFile::isBerkeleyData
virtual bool isBerkeleyData(DataRefImpl Sec) const
Definition: ObjectFile.cpp:93
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:179
llvm::object::SymbolRef::getSection
Expected< section_iterator > getSection() const
Get section this symbol is defined in reference to.
Definition: ObjectFile.h:409
object
bar al al movzbl eax ret Missed when stored in a memory object
Definition: README.txt:1411
llvm::object::symbol_iterator
Definition: ObjectFile.h:207
llvm::object::SymbolRef::ST_Function
@ ST_Function
Definition: ObjectFile.h:176
Addr
uint64_t Addr
Definition: ELFObjHandler.cpp:80
llvm::object::SectionedAddress::UndefSection
const static uint64_t UndefSection
Definition: ObjectFile.h:145
llvm::object::SectionRef::isStripped
bool isStripped() const
Definition: ObjectFile.h:498
llvm::object::SectionRef::isDebugSection
bool isDebugSection() const
Whether this section is a debug section.
Definition: ObjectFile.h:510
llvm::object::ObjectFile::createObjectFile
static Expected< OwningBinary< ObjectFile > > createObjectFile(StringRef ObjectPath)
Definition: ObjectFile.cpp:185
llvm::object::SymbolRef::ST_Debug
@ ST_Debug
Definition: ObjectFile.h:174
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:522
llvm::object::content_iterator
Definition: SymbolicFile.h:67
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:462
llvm::object::ObjectFile::createXCOFFObjectFile
static Expected< std::unique_ptr< ObjectFile > > createXCOFFObjectFile(MemoryBufferRef Object, unsigned FileType)
Definition: XCOFFObjectFile.cpp:792
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:548
llvm::object::SectionRef::operator!=
bool operator!=(const SectionRef &Other) const
Definition: ObjectFile.h:433
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::object::ObjectFile::getSectionContents
virtual Expected< ArrayRef< uint8_t > > getSectionContents(DataRefImpl Sec) const =0
llvm::object::RelocationRef::getObject
const ObjectFile * getObject() const
Definition: ObjectFile.h:568
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:33
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:313
llvm::object::SectionRef::getAddress
uint64_t getAddress() const
Definition: ObjectFile.h:450
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:478
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:52
llvm::object::SymbolRef::Type
Type
Definition: ObjectFile.h:171
llvm::object::SectionRef::relocation_end
relocation_iterator relocation_end() const
Definition: ObjectFile.h:518
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
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:177
llvm::object::SectionRef::operator==
bool operator==(const SectionRef &Other) const
Definition: ObjectFile.h:428
llvm::object::RelocationRef::moveNext
void moveNext()
Definition: ObjectFile.h:544
llvm::object::ObjectFile::mapDebugSectionName
virtual StringRef mapDebugSectionName(StringRef Name) const
Maps a debug section name to a standard DWARF section name.
Definition: ObjectFile.h:343
llvm::Expected::takeError
Error takeError()
Take ownership of the stored error.
Definition: Error.h:589
llvm::object::SectionRef::isBitcode
bool isBitcode() const
Definition: ObjectFile.h:494
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:604
llvm::object::ObjectFile::getSymbolType
virtual Expected< SymbolRef::Type > getSymbolType(DataRefImpl Symb) const =0
llvm::object::SymbolRef::getType
Expected< SymbolRef::Type > getType() const
Definition: ObjectFile.h:413
llvm::object::SectionedAddress
Definition: ObjectFile.h:144
llvm::object::SectionRef::getIndex
uint64_t getIndex() const
Definition: ObjectFile.h:454
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:322
llvm::object::SectionRef::isCompressed
bool isCompressed() const
Definition: ObjectFile.h:474
llvm::object::RelocationRef::operator==
bool operator==(const RelocationRef &Other) const
Definition: ObjectFile.h:540
llvm::DenseMapInfo< object::SectionRef >::getTombstoneKey
static object::SectionRef getTombstoneKey()
Definition: ObjectFile.h:582
llvm::SmallVectorImpl< char >
DenseMapInfo.h
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:37
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:389
llvm::object::ObjectFile::moveRelocationNext
virtual void moveRelocationNext(DataRefImpl &Rel) const =0
llvm::object::ObjectFile::getStartAddress
virtual Expected< uint64_t > getStartAddress() const
Definition: ObjectFile.h:335
llvm::object::SymbolicFile
Definition: SymbolicFile.h:143
llvm::object::SymbolRef::SymbolRef
SymbolRef()=default
llvm::object::SectionRef::getObject
const ObjectFile * getObject() const
Definition: ObjectFile.h:530
llvm::object::ObjectFile::dynamic_relocation_sections
virtual std::vector< SectionRef > dynamic_relocation_sections() const
Definition: ObjectFile.h:309
llvm::object::DataRefImpl::d
struct llvm::object::DataRefImpl::@317 d
llvm::DenseMapInfo< object::SectionRef >::getHashValue
static unsigned getHashValue(const object::SectionRef &Sec)
Definition: ObjectFile.h:587
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:393
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:359
llvm::object::Binary::isObject
bool isObject() const
Definition: Binary.h:104
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1172
llvm::object::SectionRef::relocation_begin
relocation_iterator relocation_begin() const
Definition: ObjectFile.h:514
llvm::DenseMapInfo< object::SectionRef >::isEqual
static bool isEqual(const object::SectionRef &A, const object::SectionRef &B)
Definition: ObjectFile.h:575