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 SubtargetFeatures;
35 
36 namespace object {
37 
38 class COFFObjectFile;
39 class MachOObjectFile;
40 class ObjectFile;
41 class SectionRef;
42 class SymbolRef;
43 class symbol_iterator;
44 class WasmObjectFile;
45 
47 
48 /// This is a value type class that represents a single relocation in the list
49 /// of relocations in the object file.
51  DataRefImpl RelocationPimpl;
52  const ObjectFile *OwningObject = nullptr;
53 
54 public:
55  RelocationRef() = default;
56  RelocationRef(DataRefImpl RelocationP, const ObjectFile *Owner);
57 
58  bool operator==(const RelocationRef &Other) const;
59 
60  void moveNext();
61 
62  uint64_t getOffset() const;
63  symbol_iterator getSymbol() const;
64  uint64_t getType() const;
65 
66  /// Get a string that represents the type of this relocation.
67  ///
68  /// This is for display purposes only.
69  void getTypeName(SmallVectorImpl<char> &Result) const;
70 
72  const ObjectFile *getObject() const;
73 };
74 
76 
77 /// This is a value type class that represents a single section in the list of
78 /// sections in the object file.
79 class SectionRef {
80  friend class SymbolRef;
81 
82  DataRefImpl SectionPimpl;
83  const ObjectFile *OwningObject = nullptr;
84 
85 public:
86  SectionRef() = default;
87  SectionRef(DataRefImpl SectionP, const ObjectFile *Owner);
88 
89  bool operator==(const SectionRef &Other) const;
90  bool operator!=(const SectionRef &Other) const;
91  bool operator<(const SectionRef &Other) const;
92 
93  void moveNext();
94 
96  uint64_t getAddress() const;
97  uint64_t getIndex() const;
98  uint64_t getSize() const;
100 
101  /// Get the alignment of this section as the actual value (not log 2).
102  uint64_t getAlignment() const;
103 
104  bool isCompressed() const;
105  /// Whether this section contains instructions.
106  bool isText() const;
107  /// Whether this section contains data, not instructions.
108  bool isData() const;
109  /// Whether this section contains BSS uninitialized data.
110  bool isBSS() const;
111  bool isVirtual() const;
112  bool isBitcode() const;
113  bool isStripped() const;
114 
115  /// Whether this section will be placed in the text segment, according to the
116  /// Berkeley size format. This is true if the section is allocatable, and
117  /// contains either code or readonly data.
118  bool isBerkeleyText() const;
119  /// Whether this section will be placed in the data segment, according to the
120  /// Berkeley size format. This is true if the section is allocatable and
121  /// contains data (e.g. PROGBITS), but is not text.
122  bool isBerkeleyData() const;
123 
124  /// Whether this section is a debug section.
125  bool isDebugSection() const;
126 
127  bool containsSymbol(SymbolRef S) const;
128 
133  }
134 
135  /// Returns the related section if this section contains relocations. The
136  /// returned section may or may not have applied its relocations.
138 
140  const ObjectFile *getObject() const;
141 };
142 
145 
148 };
149 
150 inline bool operator<(const SectionedAddress &LHS,
151  const SectionedAddress &RHS) {
152  return std::tie(LHS.SectionIndex, LHS.Address) <
153  std::tie(RHS.SectionIndex, RHS.Address);
154 }
155 
156 inline bool operator==(const SectionedAddress &LHS,
157  const SectionedAddress &RHS) {
158  return std::tie(LHS.SectionIndex, LHS.Address) ==
159  std::tie(RHS.SectionIndex, RHS.Address);
160 }
161 
162 raw_ostream &operator<<(raw_ostream &OS, const SectionedAddress &Addr);
163 
164 /// This is a value type class that represents a single symbol in the list of
165 /// symbols in the object file.
166 class SymbolRef : public BasicSymbolRef {
167  friend class SectionRef;
168 
169 public:
170  enum Type {
171  ST_Unknown, // Type not specified
177  };
178 
179  SymbolRef() = default;
180  SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner);
182  assert(isa<ObjectFile>(BasicSymbolRef::getObject()));
183  }
184 
186  /// Returns the symbol virtual address (i.e. address at which it will be
187  /// mapped).
189 
190  /// Return the value of the symbol depending on the object this can be an
191  /// offset or a virtual address.
193 
194  /// Get the alignment of this symbol as the actual value (not log 2).
195  uint32_t getAlignment() const;
196  uint64_t getCommonSize() const;
198 
199  /// Get section this symbol is defined in reference to. Result is
200  /// end_sections() if it is undefined or is an absolute symbol.
202 
203  const ObjectFile *getObject() const;
204 };
205 
207 public:
210  : basic_symbol_iterator(SymbolRef(B->getRawDataRefImpl(),
211  cast<ObjectFile>(B->getObject()))) {}
212 
213  const SymbolRef *operator->() const {
215  return static_cast<const SymbolRef*>(&P);
216  }
217 
218  const SymbolRef &operator*() const {
220  return static_cast<const SymbolRef&>(P);
221  }
222 };
223 
224 /// This class is the base class for all object file types. Concrete instances
225 /// of this object are created by createObjectFile, which figures out which type
226 /// to create.
227 class ObjectFile : public SymbolicFile {
228  virtual void anchor();
229 
230 protected:
231  ObjectFile(unsigned int Type, MemoryBufferRef Source);
232 
233  const uint8_t *base() const {
234  return reinterpret_cast<const uint8_t *>(Data.getBufferStart());
235  }
236 
237  // These functions are for SymbolRef to call internally. The main goal of
238  // this is to allow SymbolRef::SymbolPimpl to point directly to the symbol
239  // entry in the memory mapped object file. SymbolPimpl cannot contain any
240  // virtual functions because then it could not point into the memory mapped
241  // file.
242  //
243  // Implementations assume that the DataRefImpl is valid and has not been
244  // modified externally. It's UB otherwise.
245  friend class SymbolRef;
246 
247  virtual Expected<StringRef> getSymbolName(DataRefImpl Symb) const = 0;
249  DataRefImpl Symb) const override;
250  virtual Expected<uint64_t> getSymbolAddress(DataRefImpl Symb) const = 0;
251  virtual uint64_t getSymbolValueImpl(DataRefImpl Symb) const = 0;
252  virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const;
253  virtual uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const = 0;
254  virtual Expected<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const = 0;
256  getSymbolSection(DataRefImpl Symb) const = 0;
257 
258  // Same as above for SectionRef.
259  friend class SectionRef;
260 
261  virtual void moveSectionNext(DataRefImpl &Sec) const = 0;
262  virtual Expected<StringRef> getSectionName(DataRefImpl Sec) const = 0;
263  virtual uint64_t getSectionAddress(DataRefImpl Sec) const = 0;
264  virtual uint64_t getSectionIndex(DataRefImpl Sec) const = 0;
265  virtual uint64_t getSectionSize(DataRefImpl Sec) const = 0;
267  getSectionContents(DataRefImpl Sec) const = 0;
268  virtual uint64_t getSectionAlignment(DataRefImpl Sec) const = 0;
269  virtual bool isSectionCompressed(DataRefImpl Sec) const = 0;
270  virtual bool isSectionText(DataRefImpl Sec) const = 0;
271  virtual bool isSectionData(DataRefImpl Sec) const = 0;
272  virtual bool isSectionBSS(DataRefImpl Sec) const = 0;
273  // A section is 'virtual' if its contents aren't present in the object image.
274  virtual bool isSectionVirtual(DataRefImpl Sec) const = 0;
275  virtual bool isSectionBitcode(DataRefImpl Sec) const;
276  virtual bool isSectionStripped(DataRefImpl Sec) const;
277  virtual bool isBerkeleyText(DataRefImpl Sec) const;
278  virtual bool isBerkeleyData(DataRefImpl Sec) const;
279  virtual bool isDebugSection(DataRefImpl Sec) const;
280  virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const = 0;
281  virtual relocation_iterator section_rel_end(DataRefImpl Sec) const = 0;
283 
284  // Same as above for RelocationRef.
285  friend class RelocationRef;
286  virtual void moveRelocationNext(DataRefImpl &Rel) const = 0;
287  virtual uint64_t getRelocationOffset(DataRefImpl Rel) const = 0;
288  virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const = 0;
289  virtual uint64_t getRelocationType(DataRefImpl Rel) const = 0;
290  virtual void getRelocationTypeName(DataRefImpl Rel,
291  SmallVectorImpl<char> &Result) const = 0;
292 
294 
295 public:
296  ObjectFile() = delete;
297  ObjectFile(const ObjectFile &other) = delete;
298 
300  Expected<uint32_t> SymbolFlagsOrErr = getSymbolFlags(Symb);
301  if (!SymbolFlagsOrErr)
302  // TODO: Actually report errors helpfully.
303  report_fatal_error(SymbolFlagsOrErr.takeError());
304  assert(*SymbolFlagsOrErr & SymbolRef::SF_Common);
305  return getCommonSymbolSizeImpl(Symb);
306  }
307 
308  virtual std::vector<SectionRef> dynamic_relocation_sections() const {
309  return std::vector<SectionRef>();
310  }
311 
315  }
316 
317  virtual section_iterator section_begin() const = 0;
318  virtual section_iterator section_end() const = 0;
319 
323  }
324 
325  /// The number of bytes used to represent an address in this object
326  /// file format.
327  virtual uint8_t getBytesInAddress() const = 0;
328 
329  virtual StringRef getFileFormatName() const = 0;
330  virtual Triple::ArchType getArch() const = 0;
331  virtual SubtargetFeatures getFeatures() const = 0;
332  virtual Optional<StringRef> tryGetCPUName() const { return None; };
333  virtual void setARMSubArch(Triple &TheTriple) const { }
336  };
337 
338  /// Create a triple from the data in this object file.
339  Triple makeTriple() const;
340 
341  /// Maps a debug section name to a standard DWARF section name.
342  virtual StringRef mapDebugSectionName(StringRef Name) const { return Name; }
343 
344  /// True if this is a relocatable object (.o/.obj).
345  virtual bool isRelocatableObject() const = 0;
346 
347  /// @returns Pointer to ObjectFile subclass to handle this type of object.
348  /// @param ObjectPath The path to the object file. ObjectPath.isObject must
349  /// return true.
350  /// Create ObjectFile from path.
352  createObjectFile(StringRef ObjectPath);
353 
356  bool InitContent = true);
360  }
361 
362  static bool classof(const Binary *v) {
363  return v->isObject();
364  }
365 
368 
371 
373  createELFObjectFile(MemoryBufferRef Object, bool InitContent = true);
374 
377  uint32_t UniversalCputype = 0,
378  uint32_t UniversalIndex = 0);
379 
382 };
383 
384 // Inline function definitions.
385 inline SymbolRef::SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner)
386  : BasicSymbolRef(SymbolP, Owner) {}
387 
390 }
391 
394 }
395 
398 }
399 
402 }
403 
406 }
407 
410 }
411 
414 }
415 
416 inline const ObjectFile *SymbolRef::getObject() const {
418  return cast<ObjectFile>(O);
419 }
420 
421 /// SectionRef
423  const ObjectFile *Owner)
424  : SectionPimpl(SectionP)
425  , OwningObject(Owner) {}
426 
427 inline bool SectionRef::operator==(const SectionRef &Other) const {
428  return OwningObject == Other.OwningObject &&
429  SectionPimpl == Other.SectionPimpl;
430 }
431 
432 inline bool SectionRef::operator!=(const SectionRef &Other) const {
433  return !(*this == Other);
434 }
435 
436 inline bool SectionRef::operator<(const SectionRef &Other) const {
437  assert(OwningObject == Other.OwningObject);
438  return SectionPimpl < Other.SectionPimpl;
439 }
440 
441 inline void SectionRef::moveNext() {
442  return OwningObject->moveSectionNext(SectionPimpl);
443 }
444 
446  return OwningObject->getSectionName(SectionPimpl);
447 }
448 
450  return OwningObject->getSectionAddress(SectionPimpl);
451 }
452 
454  return OwningObject->getSectionIndex(SectionPimpl);
455 }
456 
458  return OwningObject->getSectionSize(SectionPimpl);
459 }
460 
463  OwningObject->getSectionContents(SectionPimpl);
464  if (!Res)
465  return Res.takeError();
466  return StringRef(reinterpret_cast<const char *>(Res->data()), Res->size());
467 }
468 
470  return OwningObject->getSectionAlignment(SectionPimpl);
471 }
472 
473 inline bool SectionRef::isCompressed() const {
474  return OwningObject->isSectionCompressed(SectionPimpl);
475 }
476 
477 inline bool SectionRef::isText() const {
478  return OwningObject->isSectionText(SectionPimpl);
479 }
480 
481 inline bool SectionRef::isData() const {
482  return OwningObject->isSectionData(SectionPimpl);
483 }
484 
485 inline bool SectionRef::isBSS() const {
486  return OwningObject->isSectionBSS(SectionPimpl);
487 }
488 
489 inline bool SectionRef::isVirtual() const {
490  return OwningObject->isSectionVirtual(SectionPimpl);
491 }
492 
493 inline bool SectionRef::isBitcode() const {
494  return OwningObject->isSectionBitcode(SectionPimpl);
495 }
496 
497 inline bool SectionRef::isStripped() const {
498  return OwningObject->isSectionStripped(SectionPimpl);
499 }
500 
501 inline bool SectionRef::isBerkeleyText() const {
502  return OwningObject->isBerkeleyText(SectionPimpl);
503 }
504 
505 inline bool SectionRef::isBerkeleyData() const {
506  return OwningObject->isBerkeleyData(SectionPimpl);
507 }
508 
509 inline bool SectionRef::isDebugSection() const {
510  return OwningObject->isDebugSection(SectionPimpl);
511 }
512 
514  return OwningObject->section_rel_begin(SectionPimpl);
515 }
516 
518  return OwningObject->section_rel_end(SectionPimpl);
519 }
520 
522  return OwningObject->getRelocatedSection(SectionPimpl);
523 }
524 
526  return SectionPimpl;
527 }
528 
529 inline const ObjectFile *SectionRef::getObject() const {
530  return OwningObject;
531 }
532 
533 /// RelocationRef
535  const ObjectFile *Owner)
536  : RelocationPimpl(RelocationP)
537  , OwningObject(Owner) {}
538 
539 inline bool RelocationRef::operator==(const RelocationRef &Other) const {
540  return RelocationPimpl == Other.RelocationPimpl;
541 }
542 
543 inline void RelocationRef::moveNext() {
544  return OwningObject->moveRelocationNext(RelocationPimpl);
545 }
546 
548  return OwningObject->getRelocationOffset(RelocationPimpl);
549 }
550 
552  return OwningObject->getRelocationSymbol(RelocationPimpl);
553 }
554 
556  return OwningObject->getRelocationType(RelocationPimpl);
557 }
558 
560  return OwningObject->getRelocationTypeName(RelocationPimpl, Result);
561 }
562 
564  return RelocationPimpl;
565 }
566 
567 inline const ObjectFile *RelocationRef::getObject() const {
568  return OwningObject;
569 }
570 
571 } // end namespace object
572 
573 template <> struct DenseMapInfo<object::SectionRef> {
574  static bool isEqual(const object::SectionRef &A,
575  const object::SectionRef &B) {
576  return A == B;
577  }
579  return object::SectionRef({}, nullptr);
580  }
583  TS.p = (uintptr_t)-1;
584  return object::SectionRef(TS, nullptr);
585  }
586  static unsigned getHashValue(const object::SectionRef &Sec) {
588  return hash_combine(Raw.p, Raw.d.a, Raw.d.b);
589  }
590 };
591 
592 } // end namespace llvm
593 
594 #endif // LLVM_OBJECT_OBJECTFILE_H
llvm::object::SectionRef::operator<
bool operator<(const SectionRef &Other) const
Definition: ObjectFile.h:436
MemoryBuffer.h
llvm::object::RelocationRef::getSymbol
symbol_iterator getSymbol() const
Definition: ObjectFile.h:551
llvm::object::RelocationRef::getTypeName
void getTypeName(SmallVectorImpl< char > &Result) const
Get a string that represents the type of this relocation.
Definition: ObjectFile.h:559
llvm::object::SectionRef::isVirtual
bool isVirtual() const
Definition: ObjectFile.h:489
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
This is an optimization pass for GlobalISel generic memory operations.
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:396
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:481
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:457
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:146
llvm::object::SectionRef::getRawDataRefImpl
DataRefImpl getRawDataRefImpl() const
Definition: ObjectFile.h:525
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:4700
Error.h
llvm::object::SectionRef::getName
Expected< StringRef > getName() const
Definition: ObjectFile.h:445
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:57
llvm::object::ObjectFile::setARMSubArch
virtual void setARMSubArch(Triple &TheTriple) const
Definition: ObjectFile.h:333
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:501
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:213
llvm::object::SymbolRef::SymbolRef
SymbolRef(const BasicSymbolRef &B)
Definition: ObjectFile.h:181
llvm::object::SymbolRef::ST_Unknown
@ ST_Unknown
Definition: ObjectFile.h:171
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:485
llvm::object::ObjectFile::getArch
virtual Triple::ArchType getArch() const =0
llvm::object::ObjectFile::classof
static bool classof(const Binary *v)
Definition: ObjectFile.h:362
llvm::Optional
Definition: APInt.h:33
llvm::object::ObjectFile::tryGetCPUName
virtual Optional< StringRef > tryGetCPUName() const
Definition: ObjectFile.h:332
llvm::object::SymbolRef::ST_Data
@ ST_Data
Definition: ObjectFile.h:172
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
RHS
Value * RHS
Definition: X86PartialReduction.cpp:74
llvm::object::SymbolRef::ST_File
@ ST_File
Definition: ObjectFile.h:174
llvm::object::ObjectFile::section_begin
virtual section_iterator section_begin() const =0
llvm::object::SymbolRef::getCommonSize
uint64_t getCommonSize() const
Definition: ObjectFile.h:404
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:400
llvm::MemoryBufferRef
Definition: MemoryBufferRef.h:22
llvm::object::SectionedAddress::SectionIndex
uint64_t SectionIndex
Definition: ObjectFile.h:147
llvm::DenseMapInfo< object::SectionRef >::getEmptyKey
static object::SectionRef getEmptyKey()
Definition: ObjectFile.h:578
llvm::object::SectionRef::moveNext
void moveNext()
Definition: ObjectFile.h:441
llvm::object::RelocationRef::RelocationRef
RelocationRef()=default
llvm::object::ObjectFile::symbols
symbol_iterator_range symbols() const
Definition: ObjectFile.h:313
llvm::object::ObjectFile::getCommonSymbolSize
uint64_t getCommonSymbolSize(DataRefImpl Symb) const
Definition: ObjectFile.h:299
llvm::object::ObjectFile::isDebugSection
virtual bool isDebugSection(DataRefImpl Sec) const
Definition: ObjectFile.cpp:98
llvm::object::RelocationRef::getType
uint64_t getType() const
Definition: ObjectFile.h:555
llvm::object::SymbolicFile::symbol_end
virtual basic_symbol_iterator symbol_end() const =0
LHS
Value * LHS
Definition: X86PartialReduction.cpp:73
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:90
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:218
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:206
llvm::object::SectionRef::relocations
iterator_range< relocation_iterator > relocations() const
Definition: ObjectFile.h:131
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: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:469
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: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:505
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:320
llvm::object::SymbolRef::getObject
const ObjectFile * getObject() const
Definition: ObjectFile.h:416
llvm::object::ObjectFile::isSectionVirtual
virtual bool isSectionVirtual(DataRefImpl Sec) const =0
llvm::object::RelocationRef::getRawDataRefImpl
DataRefImpl getRawDataRefImpl() const
Definition: ObjectFile.h:563
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:79
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:94
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:206
llvm::object::SymbolRef::getSection
Expected< section_iterator > getSection() const
Get section this symbol is defined in reference to.
Definition: ObjectFile.h:408
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:206
llvm::object::SymbolRef::ST_Function
@ ST_Function
Definition: ObjectFile.h:175
Addr
uint64_t Addr
Definition: ELFObjHandler.cpp:79
llvm::object::SectionedAddress::UndefSection
const static uint64_t UndefSection
Definition: ObjectFile.h:144
llvm::object::SectionRef::isStripped
bool isStripped() const
Definition: ObjectFile.h:497
llvm::object::SectionRef::isDebugSection
bool isDebugSection() const
Whether this section is a debug section.
Definition: ObjectFile.h:509
llvm::object::ObjectFile::createObjectFile
static Expected< OwningBinary< ObjectFile > > createObjectFile(StringRef ObjectPath)
Definition: ObjectFile.cpp:186
llvm::object::SymbolRef::ST_Debug
@ ST_Debug
Definition: ObjectFile.h:173
llvm::object::ObjectFile::printSymbolName
Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override
Definition: ObjectFile.cpp:70
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:521
llvm::object::content_iterator
Definition: SymbolicFile.h:67
llvm::object::ObjectFile::base
const uint8_t * base() const
Definition: ObjectFile.h:233
iterator_range.h
llvm::codeview::CodeViewContainer::ObjectFile
@ ObjectFile
llvm::object::SectionRef::getContents
Expected< StringRef > getContents() const
Definition: ObjectFile.h:461
llvm::object::ObjectFile::createXCOFFObjectFile
static Expected< std::unique_ptr< ObjectFile > > createXCOFFObjectFile(MemoryBufferRef Object, unsigned FileType)
Definition: XCOFFObjectFile.cpp:1102
llvm::object::ObjectFile::makeTriple
Triple makeTriple() const
Create a triple from the data in this object file.
Definition: ObjectFile.cpp:105
Triple.h
llvm::object::RelocationRef::getOffset
uint64_t getOffset() const
Definition: ObjectFile.h:547
llvm::object::SectionRef::operator!=
bool operator!=(const SectionRef &Other) const
Definition: ObjectFile.h:432
llvm::Sched::Source
@ Source
Definition: TargetLowering.h:99
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
llvm::object::ObjectFile
This class is the base class for all object file types.
Definition: ObjectFile.h:227
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:101
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:567
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:312
llvm::object::SectionRef::getAddress
uint64_t getAddress() const
Definition: ObjectFile.h:449
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:150
llvm::object::ObjectFile::getSymbolAlignment
virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const
Definition: ObjectFile.cpp:78
llvm::object::SectionRef::isText
bool isText() const
Whether this section contains instructions.
Definition: ObjectFile.h:477
llvm::object::ObjectFile::isSectionStripped
virtual bool isSectionStripped(DataRefImpl Sec) const
Definition: ObjectFile.cpp:88
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:170
llvm::object::SectionRef::relocation_end
relocation_iterator relocation_end() const
Definition: ObjectFile.h:517
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:156
llvm::object::symbol_iterator::symbol_iterator
symbol_iterator(SymbolRef Sym)
Definition: ObjectFile.h:208
Casting.h
llvm::object::operator==
bool operator==(const SectionedAddress &LHS, const SectionedAddress &RHS)
Definition: ObjectFile.h:156
llvm::object::ObjectFile::getSectionIndex
virtual uint64_t getSectionIndex(DataRefImpl Sec) const =0
llvm::object::SymbolRef::ST_Other
@ ST_Other
Definition: ObjectFile.h:176
llvm::object::SectionRef::operator==
bool operator==(const SectionRef &Other) const
Definition: ObjectFile.h:427
llvm::object::RelocationRef::moveNext
void moveNext()
Definition: ObjectFile.h:543
llvm::object::ObjectFile::mapDebugSectionName
virtual StringRef mapDebugSectionName(StringRef Name) const
Maps a debug section name to a standard DWARF section name.
Definition: ObjectFile.h:342
llvm::Expected::takeError
Error takeError()
Take ownership of the stored error.
Definition: Error.h:598
llvm::object::SectionRef::isBitcode
bool isBitcode() const
Definition: ObjectFile.h:493
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::SymbolRef::getType
Expected< SymbolRef::Type > getType() const
Definition: ObjectFile.h:412
llvm::object::SectionedAddress
Definition: ObjectFile.h:143
llvm::object::SectionRef::getIndex
uint64_t getIndex() const
Definition: ObjectFile.h:453
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:321
llvm::object::SectionRef::isCompressed
bool isCompressed() const
Definition: ObjectFile.h:473
llvm::object::RelocationRef::operator==
bool operator==(const RelocationRef &Other) const
Definition: ObjectFile.h:539
llvm::DenseMapInfo< object::SectionRef >::getTombstoneKey
static object::SectionRef getTombstoneKey()
Definition: ObjectFile.h:581
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:166
llvm::object::DataRefImpl::d
struct llvm::object::DataRefImpl::@326 d
llvm::object::DataRefImpl::b
uint32_t b
Definition: SymbolicFile.h:37
llvm::object::ObjectFile::isSectionBitcode
virtual bool isSectionBitcode(DataRefImpl Sec) const
Definition: ObjectFile.cpp:80
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:50
llvm::object::SymbolRef::getName
Expected< StringRef > getName() const
Definition: ObjectFile.h:388
llvm::object::ObjectFile::moveRelocationNext
virtual void moveRelocationNext(DataRefImpl &Rel) const =0
llvm::object::ObjectFile::getStartAddress
virtual Expected< uint64_t > getStartAddress() const
Definition: ObjectFile.h:334
llvm::object::SymbolicFile
Definition: SymbolicFile.h:143
llvm::object::SymbolRef::SymbolRef
SymbolRef()=default
llvm::object::SectionRef::getObject
const ObjectFile * getObject() const
Definition: ObjectFile.h:529
llvm::object::ObjectFile::dynamic_relocation_sections
virtual std::vector< SectionRef > dynamic_relocation_sections() const
Definition: ObjectFile.h:308
llvm::DenseMapInfo< object::SectionRef >::getHashValue
static unsigned getHashValue(const object::SectionRef &Sec)
Definition: ObjectFile.h:586
llvm::object::symbol_iterator::symbol_iterator
symbol_iterator(const basic_symbol_iterator &B)
Definition: ObjectFile.h:209
llvm::object::SymbolRef::getAddress
Expected< uint64_t > getAddress() const
Returns the symbol virtual address (i.e.
Definition: ObjectFile.h:392
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:358
llvm::object::Binary::isObject
bool isObject() const
Definition: Binary.h:104
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1198
llvm::object::SectionRef::relocation_begin
relocation_iterator relocation_begin() const
Definition: ObjectFile.h:513
llvm::DenseMapInfo< object::SectionRef >::isEqual
static bool isEqual(const object::SectionRef &A, const object::SectionRef &B)
Definition: ObjectFile.h:574