LLVM  13.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.
127 
128  bool containsSymbol(SymbolRef S) const;
129 
134  }
136 
138  const ObjectFile *getObject() const;
139 };
140 
142  const static uint64_t UndefSection = UINT64_MAX;
143 
144  uint64_t Address = 0;
146 };
147 
148 inline bool operator<(const SectionedAddress &LHS,
149  const SectionedAddress &RHS) {
150  return std::tie(LHS.SectionIndex, LHS.Address) <
151  std::tie(RHS.SectionIndex, RHS.Address);
152 }
153 
154 inline bool operator==(const SectionedAddress &LHS,
155  const SectionedAddress &RHS) {
156  return std::tie(LHS.SectionIndex, LHS.Address) ==
157  std::tie(RHS.SectionIndex, RHS.Address);
158 }
159 
160 raw_ostream &operator<<(raw_ostream &OS, const SectionedAddress &Addr);
161 
162 /// This is a value type class that represents a single symbol in the list of
163 /// symbols in the object file.
164 class SymbolRef : public BasicSymbolRef {
165  friend class SectionRef;
166 
167 public:
168  enum Type {
169  ST_Unknown, // Type not specified
175  };
176 
177  SymbolRef() = default;
178  SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner);
180  assert(isa<ObjectFile>(BasicSymbolRef::getObject()));
181  }
182 
184  /// Returns the symbol virtual address (i.e. address at which it will be
185  /// mapped).
187 
188  /// Return the value of the symbol depending on the object this can be an
189  /// offset or a virtual address.
191 
192  /// Get the alignment of this symbol as the actual value (not log 2).
193  uint32_t getAlignment() const;
194  uint64_t getCommonSize() const;
196 
197  /// Get section this symbol is defined in reference to. Result is
198  /// end_sections() if it is undefined or is an absolute symbol.
200 
201  const ObjectFile *getObject() const;
202 };
203 
205 public:
208  : basic_symbol_iterator(SymbolRef(B->getRawDataRefImpl(),
209  cast<ObjectFile>(B->getObject()))) {}
210 
211  const SymbolRef *operator->() const {
213  return static_cast<const SymbolRef*>(&P);
214  }
215 
216  const SymbolRef &operator*() const {
218  return static_cast<const SymbolRef&>(P);
219  }
220 };
221 
222 /// This class is the base class for all object file types. Concrete instances
223 /// of this object are created by createObjectFile, which figures out which type
224 /// to create.
225 class ObjectFile : public SymbolicFile {
226  virtual void anchor();
227 
228 protected:
229  ObjectFile(unsigned int Type, MemoryBufferRef Source);
230 
231  const uint8_t *base() const {
232  return reinterpret_cast<const uint8_t *>(Data.getBufferStart());
233  }
234 
235  // These functions are for SymbolRef to call internally. The main goal of
236  // this is to allow SymbolRef::SymbolPimpl to point directly to the symbol
237  // entry in the memory mapped object file. SymbolPimpl cannot contain any
238  // virtual functions because then it could not point into the memory mapped
239  // file.
240  //
241  // Implementations assume that the DataRefImpl is valid and has not been
242  // modified externally. It's UB otherwise.
243  friend class SymbolRef;
244 
245  virtual Expected<StringRef> getSymbolName(DataRefImpl Symb) const = 0;
247  DataRefImpl Symb) const override;
248  virtual Expected<uint64_t> getSymbolAddress(DataRefImpl Symb) const = 0;
249  virtual uint64_t getSymbolValueImpl(DataRefImpl Symb) const = 0;
250  virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const;
251  virtual uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const = 0;
252  virtual Expected<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const = 0;
254  getSymbolSection(DataRefImpl Symb) const = 0;
255 
256  // Same as above for SectionRef.
257  friend class SectionRef;
258 
259  virtual void moveSectionNext(DataRefImpl &Sec) const = 0;
260  virtual Expected<StringRef> getSectionName(DataRefImpl Sec) const = 0;
261  virtual uint64_t getSectionAddress(DataRefImpl Sec) const = 0;
262  virtual uint64_t getSectionIndex(DataRefImpl Sec) const = 0;
263  virtual uint64_t getSectionSize(DataRefImpl Sec) const = 0;
265  getSectionContents(DataRefImpl Sec) const = 0;
266  virtual uint64_t getSectionAlignment(DataRefImpl Sec) const = 0;
267  virtual bool isSectionCompressed(DataRefImpl Sec) const = 0;
268  virtual bool isSectionText(DataRefImpl Sec) const = 0;
269  virtual bool isSectionData(DataRefImpl Sec) const = 0;
270  virtual bool isSectionBSS(DataRefImpl Sec) const = 0;
271  // A section is 'virtual' if its contents aren't present in the object image.
272  virtual bool isSectionVirtual(DataRefImpl Sec) const = 0;
273  virtual bool isSectionBitcode(DataRefImpl Sec) const;
274  virtual bool isSectionStripped(DataRefImpl Sec) const;
275  virtual bool isBerkeleyText(DataRefImpl Sec) const;
276  virtual bool isBerkeleyData(DataRefImpl Sec) const;
277  virtual bool isDebugSection(StringRef SectionName) const;
278  virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const = 0;
279  virtual relocation_iterator section_rel_end(DataRefImpl Sec) const = 0;
281 
282  // Same as above for RelocationRef.
283  friend class RelocationRef;
284  virtual void moveRelocationNext(DataRefImpl &Rel) const = 0;
285  virtual uint64_t getRelocationOffset(DataRefImpl Rel) const = 0;
286  virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const = 0;
287  virtual uint64_t getRelocationType(DataRefImpl Rel) const = 0;
288  virtual void getRelocationTypeName(DataRefImpl Rel,
289  SmallVectorImpl<char> &Result) const = 0;
290 
292 
293 public:
294  ObjectFile() = delete;
295  ObjectFile(const ObjectFile &other) = delete;
296 
297  uint64_t getCommonSymbolSize(DataRefImpl Symb) const {
298  Expected<uint32_t> SymbolFlagsOrErr = getSymbolFlags(Symb);
299  if (!SymbolFlagsOrErr)
300  // TODO: Actually report errors helpfully.
301  report_fatal_error(SymbolFlagsOrErr.takeError());
302  assert(*SymbolFlagsOrErr & SymbolRef::SF_Common);
303  return getCommonSymbolSizeImpl(Symb);
304  }
305 
306  virtual std::vector<SectionRef> dynamic_relocation_sections() const {
307  return std::vector<SectionRef>();
308  }
309 
313  }
314 
315  virtual section_iterator section_begin() const = 0;
316  virtual section_iterator section_end() const = 0;
317 
321  }
322 
323  /// The number of bytes used to represent an address in this object
324  /// file format.
325  virtual uint8_t getBytesInAddress() const = 0;
326 
327  virtual StringRef getFileFormatName() const = 0;
328  virtual Triple::ArchType getArch() const = 0;
329  virtual SubtargetFeatures getFeatures() const = 0;
330  virtual Optional<StringRef> tryGetCPUName() const { return None; };
331  virtual void setARMSubArch(Triple &TheTriple) const { }
334  };
335 
336  /// Create a triple from the data in this object file.
337  Triple makeTriple() const;
338 
339  /// Maps a debug section name to a standard DWARF section name.
340  virtual StringRef mapDebugSectionName(StringRef Name) const { return Name; }
341 
342  /// True if this is a relocatable object (.o/.obj).
343  virtual bool isRelocatableObject() const = 0;
344 
345  /// @returns Pointer to ObjectFile subclass to handle this type of object.
346  /// @param ObjectPath The path to the object file. ObjectPath.isObject must
347  /// return true.
348  /// Create ObjectFile from path.
350  createObjectFile(StringRef ObjectPath);
351 
354  bool InitContent = true);
358  }
359 
360  static bool classof(const Binary *v) {
361  return v->isObject();
362  }
363 
366 
369 
371  createELFObjectFile(MemoryBufferRef Object, bool InitContent = true);
372 
375  uint32_t UniversalCputype = 0,
376  uint32_t UniversalIndex = 0);
377 
380 };
381 
382 // Inline function definitions.
383 inline SymbolRef::SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner)
384  : BasicSymbolRef(SymbolP, Owner) {}
385 
388 }
389 
392 }
393 
396 }
397 
400 }
401 
402 inline uint64_t SymbolRef::getCommonSize() const {
404 }
405 
408 }
409 
412 }
413 
414 inline const ObjectFile *SymbolRef::getObject() const {
416  return cast<ObjectFile>(O);
417 }
418 
419 /// SectionRef
421  const ObjectFile *Owner)
422  : SectionPimpl(SectionP)
423  , OwningObject(Owner) {}
424 
425 inline bool SectionRef::operator==(const SectionRef &Other) const {
426  return OwningObject == Other.OwningObject &&
427  SectionPimpl == Other.SectionPimpl;
428 }
429 
430 inline bool SectionRef::operator!=(const SectionRef &Other) const {
431  return !(*this == Other);
432 }
433 
434 inline bool SectionRef::operator<(const SectionRef &Other) const {
435  assert(OwningObject == Other.OwningObject);
436  return SectionPimpl < Other.SectionPimpl;
437 }
438 
439 inline void SectionRef::moveNext() {
440  return OwningObject->moveSectionNext(SectionPimpl);
441 }
442 
444  return OwningObject->getSectionName(SectionPimpl);
445 }
446 
447 inline uint64_t SectionRef::getAddress() const {
448  return OwningObject->getSectionAddress(SectionPimpl);
449 }
450 
451 inline uint64_t SectionRef::getIndex() const {
452  return OwningObject->getSectionIndex(SectionPimpl);
453 }
454 
455 inline uint64_t SectionRef::getSize() const {
456  return OwningObject->getSectionSize(SectionPimpl);
457 }
458 
461  OwningObject->getSectionContents(SectionPimpl);
462  if (!Res)
463  return Res.takeError();
464  return StringRef(reinterpret_cast<const char *>(Res->data()), Res->size());
465 }
466 
467 inline uint64_t SectionRef::getAlignment() const {
468  return OwningObject->getSectionAlignment(SectionPimpl);
469 }
470 
471 inline bool SectionRef::isCompressed() const {
472  return OwningObject->isSectionCompressed(SectionPimpl);
473 }
474 
475 inline bool SectionRef::isText() const {
476  return OwningObject->isSectionText(SectionPimpl);
477 }
478 
479 inline bool SectionRef::isData() const {
480  return OwningObject->isSectionData(SectionPimpl);
481 }
482 
483 inline bool SectionRef::isBSS() const {
484  return OwningObject->isSectionBSS(SectionPimpl);
485 }
486 
487 inline bool SectionRef::isVirtual() const {
488  return OwningObject->isSectionVirtual(SectionPimpl);
489 }
490 
491 inline bool SectionRef::isBitcode() const {
492  return OwningObject->isSectionBitcode(SectionPimpl);
493 }
494 
495 inline bool SectionRef::isStripped() const {
496  return OwningObject->isSectionStripped(SectionPimpl);
497 }
498 
499 inline bool SectionRef::isBerkeleyText() const {
500  return OwningObject->isBerkeleyText(SectionPimpl);
501 }
502 
503 inline bool SectionRef::isBerkeleyData() const {
504  return OwningObject->isBerkeleyData(SectionPimpl);
505 }
506 
508  return OwningObject->isDebugSection(SectionName);
509 }
510 
512  return OwningObject->section_rel_begin(SectionPimpl);
513 }
514 
516  return OwningObject->section_rel_end(SectionPimpl);
517 }
518 
520  return OwningObject->getRelocatedSection(SectionPimpl);
521 }
522 
524  return SectionPimpl;
525 }
526 
527 inline const ObjectFile *SectionRef::getObject() const {
528  return OwningObject;
529 }
530 
531 /// RelocationRef
533  const ObjectFile *Owner)
534  : RelocationPimpl(RelocationP)
535  , OwningObject(Owner) {}
536 
537 inline bool RelocationRef::operator==(const RelocationRef &Other) const {
538  return RelocationPimpl == Other.RelocationPimpl;
539 }
540 
541 inline void RelocationRef::moveNext() {
542  return OwningObject->moveRelocationNext(RelocationPimpl);
543 }
544 
545 inline uint64_t RelocationRef::getOffset() const {
546  return OwningObject->getRelocationOffset(RelocationPimpl);
547 }
548 
550  return OwningObject->getRelocationSymbol(RelocationPimpl);
551 }
552 
553 inline uint64_t RelocationRef::getType() const {
554  return OwningObject->getRelocationType(RelocationPimpl);
555 }
556 
558  return OwningObject->getRelocationTypeName(RelocationPimpl, Result);
559 }
560 
562  return RelocationPimpl;
563 }
564 
565 inline const ObjectFile *RelocationRef::getObject() const {
566  return OwningObject;
567 }
568 
569 } // end namespace object
570 
571 template <> struct DenseMapInfo<object::SectionRef> {
572  static bool isEqual(const object::SectionRef &A,
573  const object::SectionRef &B) {
574  return A == B;
575  }
577  return object::SectionRef({}, nullptr);
578  }
581  TS.p = (uintptr_t)-1;
582  return object::SectionRef(TS, nullptr);
583  }
584  static unsigned getHashValue(const object::SectionRef &Sec) {
586  return hash_combine(Raw.p, Raw.d.a, Raw.d.b);
587  }
588 };
589 
590 } // end namespace llvm
591 
592 #endif // LLVM_OBJECT_OBJECTFILE_H
llvm::object::SectionRef::operator<
bool operator<(const SectionRef &Other) const
Definition: ObjectFile.h:434
MemoryBuffer.h
llvm::object::RelocationRef::getSymbol
symbol_iterator getSymbol() const
Definition: ObjectFile.h:549
llvm::object::RelocationRef::getTypeName
void getTypeName(SmallVectorImpl< char > &Result) const
Get a string that represents the type of this relocation.
Definition: ObjectFile.h:557
llvm::object::SectionRef::isVirtual
bool isVirtual() const
Definition: ObjectFile.h:487
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
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:394
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:479
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:455
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:144
llvm::object::SectionRef::getRawDataRefImpl
DataRefImpl getRawDataRefImpl() const
Definition: ObjectFile.h:523
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:4651
Error.h
llvm::object::SectionRef::getName
Expected< StringRef > getName() const
Definition: ObjectFile.h:443
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::SectionRef::isDebugSection
bool isDebugSection(StringRef SectionName) const
Whether this section is a debug section.
Definition: ObjectFile.h:507
llvm::object::ObjectFile::setARMSubArch
virtual void setARMSubArch(Triple &TheTriple) const
Definition: ObjectFile.h:331
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:499
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:46
llvm::object::symbol_iterator::operator->
const SymbolRef * operator->() const
Definition: ObjectFile.h:211
llvm::object::SymbolRef::SymbolRef
SymbolRef(const BasicSymbolRef &B)
Definition: ObjectFile.h:179
llvm::object::SymbolRef::ST_Unknown
@ ST_Unknown
Definition: ObjectFile.h:169
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:1648
llvm::object::SectionRef::isBSS
bool isBSS() const
Whether this section contains BSS uninitialized data.
Definition: ObjectFile.h:483
llvm::object::ObjectFile::getArch
virtual Triple::ArchType getArch() const =0
llvm::object::ObjectFile::classof
static bool classof(const Binary *v)
Definition: ObjectFile.h:360
llvm::Optional
Definition: APInt.h:33
llvm::object::ObjectFile::tryGetCPUName
virtual Optional< StringRef > tryGetCPUName() const
Definition: ObjectFile.h:330
llvm::object::SymbolRef::ST_Data
@ ST_Data
Definition: ObjectFile.h:170
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:172
llvm::object::ObjectFile::section_begin
virtual section_iterator section_begin() const =0
llvm::object::SymbolRef::getCommonSize
uint64_t getCommonSize() const
Definition: ObjectFile.h:402
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:398
llvm::MemoryBufferRef
Definition: MemoryBufferRef.h:22
llvm::object::SectionedAddress::SectionIndex
uint64_t SectionIndex
Definition: ObjectFile.h:145
llvm::DenseMapInfo< object::SectionRef >::getEmptyKey
static object::SectionRef getEmptyKey()
Definition: ObjectFile.h:576
llvm::object::SectionRef::moveNext
void moveNext()
Definition: ObjectFile.h:439
llvm::object::RelocationRef::RelocationRef
RelocationRef()=default
llvm::object::ObjectFile::symbols
symbol_iterator_range symbols() const
Definition: ObjectFile.h:311
llvm::object::ObjectFile::getCommonSymbolSize
uint64_t getCommonSymbolSize(DataRefImpl Symb) const
Definition: ObjectFile.h:297
llvm::object::RelocationRef::getType
uint64_t getType() const
Definition: ObjectFile.h:553
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:216
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:467
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::report_fatal_error
LLVM_ATTRIBUTE_NORETURN 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:50
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:503
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:318
llvm::object::SymbolRef::getObject
const ObjectFile * getObject() const
Definition: ObjectFile.h:414
llvm::object::ObjectFile::isSectionVirtual
virtual bool isSectionVirtual(DataRefImpl Sec) const =0
llvm::object::RelocationRef::getRawDataRefImpl
DataRefImpl getRawDataRefImpl() const
Definition: ObjectFile.h:561
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:406
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:204
llvm::object::SymbolRef::ST_Function
@ ST_Function
Definition: ObjectFile.h:173
Addr
uint64_t Addr
Definition: ELFObjHandler.cpp:80
llvm::object::SectionedAddress::UndefSection
const static uint64_t UndefSection
Definition: ObjectFile.h:142
llvm::object::SectionRef::isStripped
bool isStripped() const
Definition: ObjectFile.h:495
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:171
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
Definition: ObjectFile.h:519
llvm::object::content_iterator
Definition: SymbolicFile.h:67
llvm::object::ObjectFile::base
const uint8_t * base() const
Definition: ObjectFile.h:231
iterator_range.h
llvm::codeview::CodeViewContainer::ObjectFile
@ ObjectFile
llvm::object::SectionRef::getContents
Expected< StringRef > getContents() const
Definition: ObjectFile.h:459
llvm::object::DataRefImpl::d
struct llvm::object::DataRefImpl::@313 d
llvm::object::ObjectFile::createXCOFFObjectFile
static Expected< std::unique_ptr< ObjectFile > > createXCOFFObjectFile(MemoryBufferRef Object, unsigned FileType)
Definition: XCOFFObjectFile.cpp:778
llvm::object::ObjectFile::makeTriple
Triple makeTriple() const
Create a triple from the data in this object file.
Definition: ObjectFile.cpp:106
Triple.h
llvm::object::RelocationRef::getOffset
uint64_t getOffset() const
Definition: ObjectFile.h:545
llvm::object::SectionRef::operator!=
bool operator!=(const SectionRef &Other) const
Definition: ObjectFile.h:430
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:225
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:102
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:565
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:310
llvm::object::SectionRef::getAddress
uint64_t getAddress() const
Definition: ObjectFile.h:447
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:148
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:475
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:168
llvm::object::SectionRef::relocation_end
relocation_iterator relocation_end() const
Definition: ObjectFile.h:515
llvm::SectionName
Definition: DWARFSection.h:21
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:206
Casting.h
llvm::object::operator==
bool operator==(const SectionedAddress &LHS, const SectionedAddress &RHS)
Definition: ObjectFile.h:154
llvm::object::ObjectFile::getSectionIndex
virtual uint64_t getSectionIndex(DataRefImpl Sec) const =0
llvm::object::SymbolRef::ST_Other
@ ST_Other
Definition: ObjectFile.h:174
llvm::object::SectionRef::operator==
bool operator==(const SectionRef &Other) const
Definition: ObjectFile.h:425
llvm::object::RelocationRef::moveNext
void moveNext()
Definition: ObjectFile.h:541
llvm::object::ObjectFile::mapDebugSectionName
virtual StringRef mapDebugSectionName(StringRef Name) const
Maps a debug section name to a standard DWARF section name.
Definition: ObjectFile.h:340
llvm::Expected::takeError
Error takeError()
Take ownership of the stored error.
Definition: Error.h:557
llvm::object::SectionRef::isBitcode
bool isBitcode() const
Definition: ObjectFile.h:491
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:410
llvm::object::SectionedAddress
Definition: ObjectFile.h:141
llvm::object::SectionRef::getIndex
uint64_t getIndex() const
Definition: ObjectFile.h:451
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:319
llvm::object::SectionRef::isCompressed
bool isCompressed() const
Definition: ObjectFile.h:471
llvm::object::RelocationRef::operator==
bool operator==(const RelocationRef &Other) const
Definition: ObjectFile.h:537
llvm::DenseMapInfo< object::SectionRef >::getTombstoneKey
static object::SectionRef getTombstoneKey()
Definition: ObjectFile.h:579
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:164
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:386
llvm::object::ObjectFile::moveRelocationNext
virtual void moveRelocationNext(DataRefImpl &Rel) const =0
llvm::object::ObjectFile::getStartAddress
virtual Expected< uint64_t > getStartAddress() const
Definition: ObjectFile.h:332
llvm::object::SymbolicFile
Definition: SymbolicFile.h:143
llvm::object::SymbolRef::SymbolRef
SymbolRef()=default
llvm::object::SectionRef::getObject
const ObjectFile * getObject() const
Definition: ObjectFile.h:527
llvm::object::ObjectFile::dynamic_relocation_sections
virtual std::vector< SectionRef > dynamic_relocation_sections() const
Definition: ObjectFile.h:306
llvm::DenseMapInfo< object::SectionRef >::getHashValue
static unsigned getHashValue(const object::SectionRef &Sec)
Definition: ObjectFile.h:584
llvm::object::symbol_iterator::symbol_iterator
symbol_iterator(const basic_symbol_iterator &B)
Definition: ObjectFile.h:207
llvm::object::SymbolRef::getAddress
Expected< uint64_t > getAddress() const
Returns the symbol virtual address (i.e.
Definition: ObjectFile.h:390
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:356
llvm::object::ObjectFile::isDebugSection
virtual bool isDebugSection(StringRef SectionName) const
Definition: ObjectFile.cpp:97
llvm::object::Binary::isObject
bool isObject() const
Definition: Binary.h:104
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1168
llvm::object::SectionRef::relocation_begin
relocation_iterator relocation_begin() const
Definition: ObjectFile.h:511
llvm::DenseMapInfo< object::SectionRef >::isEqual
static bool isEqual(const object::SectionRef &A, const object::SectionRef &B)
Definition: ObjectFile.h:572