LLVM 17.0.0git
ObjectFile.h
Go to the documentation of this file.
1//===- ObjectFile.h - File format independent object file -------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file declares a file format independent ObjectFile class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_OBJECT_OBJECTFILE_H
14#define LLVM_OBJECT_OBJECTFILE_H
15
16#include "llvm/ADT/ArrayRef.h"
17#include "llvm/ADT/Hashing.h"
18#include "llvm/ADT/StringRef.h"
22#include "llvm/Object/Binary.h"
23#include "llvm/Object/Error.h"
26#include "llvm/Support/Error.h"
29#include <cassert>
30#include <cstdint>
31#include <memory>
32
33namespace llvm {
34
35class SubtargetFeatures;
36
37namespace object {
38
39class COFFObjectFile;
40class MachOObjectFile;
41class ObjectFile;
42class SectionRef;
43class SymbolRef;
44class symbol_iterator;
45class 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
55public:
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;
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.
81 friend class SymbolRef;
82
83 DataRefImpl SectionPimpl;
84 const ObjectFile *OwningObject = nullptr;
85
86public:
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.
103 Align getAlignment() const;
104
105 bool isCompressed() const;
106 /// Whether this section contains instructions.
107 bool isText() const;
108 /// Whether this section contains data, not instructions.
109 bool isData() const;
110 /// Whether this section contains BSS uninitialized data.
111 bool isBSS() const;
112 bool isVirtual() const;
113 bool isBitcode() const;
114 bool isStripped() const;
115
116 /// Whether this section will be placed in the text segment, according to the
117 /// Berkeley size format. This is true if the section is allocatable, and
118 /// contains either code or readonly data.
119 bool isBerkeleyText() const;
120 /// Whether this section will be placed in the data segment, according to the
121 /// Berkeley size format. This is true if the section is allocatable and
122 /// contains data (e.g. PROGBITS), but is not text.
123 bool isBerkeleyData() const;
124
125 /// Whether this section is a debug section.
126 bool isDebugSection() const;
127
128 bool containsSymbol(SymbolRef S) const;
129
134 }
135
136 /// Returns the related section if this section contains relocations. The
137 /// returned section may or may not have applied its relocations.
139
141 const ObjectFile *getObject() const;
142};
143
146
149};
150
151inline 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
157inline 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
163raw_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.
167class SymbolRef : public BasicSymbolRef {
168 friend class SectionRef;
169
170public:
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
208public:
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.
228class ObjectFile : public SymbolicFile {
229 virtual void anchor();
230
231protected:
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
250 DataRefImpl Symb) const override;
252 virtual uint64_t getSymbolValueImpl(DataRefImpl Symb) const = 0;
253 virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const;
258
259 // Same as above for SectionRef.
260 friend class SectionRef;
261
262 virtual void moveSectionNext(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;
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;
284
285 // Same as above for RelocationRef.
286 friend class RelocationRef;
287 virtual void moveRelocationNext(DataRefImpl &Rel) const = 0;
290 virtual uint64_t getRelocationType(DataRefImpl Rel) const = 0;
292 SmallVectorImpl<char> &Result) const = 0;
293
297 };
298
300
301public:
302 ObjectFile() = delete;
303 ObjectFile(const ObjectFile &other) = delete;
304
306 Expected<uint32_t> SymbolFlagsOrErr = getSymbolFlags(Symb);
307 if (!SymbolFlagsOrErr)
308 // TODO: Actually report errors helpfully.
309 report_fatal_error(SymbolFlagsOrErr.takeError());
310 assert(*SymbolFlagsOrErr & SymbolRef::SF_Common);
311 return getCommonSymbolSizeImpl(Symb);
312 }
313
314 virtual std::vector<SectionRef> dynamic_relocation_sections() const {
315 return std::vector<SectionRef>();
316 }
317
321 }
322
323 virtual section_iterator section_begin() const = 0;
324 virtual section_iterator section_end() const = 0;
325
329 }
330
331 virtual bool hasDebugInfo() const;
332
333 /// The number of bytes used to represent an address in this object
334 /// file format.
335 virtual uint8_t getBytesInAddress() const = 0;
336
337 virtual StringRef getFileFormatName() const = 0;
338 virtual Triple::ArchType getArch() const = 0;
340 virtual std::optional<StringRef> tryGetCPUName() const {
341 return std::nullopt;
342 };
343 virtual void setARMSubArch(Triple &TheTriple) const { }
346 };
347
348 /// Create a triple from the data in this object file.
349 Triple makeTriple() const;
350
351 /// Maps a debug section name to a standard DWARF section name.
353
354 /// True if this is a relocatable object (.o/.obj).
355 virtual bool isRelocatableObject() const = 0;
356
357 /// True if the reflection section can be stripped by the linker.
360 const;
361
362 /// @returns Pointer to ObjectFile subclass to handle this type of object.
363 /// @param ObjectPath The path to the object file. ObjectPath.isObject must
364 /// return true.
365 /// Create ObjectFile from path.
367 createObjectFile(StringRef ObjectPath);
368
371 bool InitContent = true);
375 }
376
377 static bool classof(const Binary *v) {
378 return v->isObject();
379 }
380
383
385 createXCOFFObjectFile(MemoryBufferRef Object, unsigned FileType);
386
388 createELFObjectFile(MemoryBufferRef Object, bool InitContent = true);
389
392 uint32_t UniversalCputype = 0,
393 uint32_t UniversalIndex = 0);
394
397
400};
401
402// Inline function definitions.
403inline SymbolRef::SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner)
404 : BasicSymbolRef(SymbolP, Owner) {}
405
408}
409
412}
413
416}
417
420}
421
424}
425
428}
429
432}
433
434inline const ObjectFile *SymbolRef::getObject() const {
436 return cast<ObjectFile>(O);
437}
438
439/// SectionRef
441 const ObjectFile *Owner)
442 : SectionPimpl(SectionP)
443 , OwningObject(Owner) {}
444
445inline bool SectionRef::operator==(const SectionRef &Other) const {
446 return OwningObject == Other.OwningObject &&
447 SectionPimpl == Other.SectionPimpl;
448}
449
450inline bool SectionRef::operator!=(const SectionRef &Other) const {
451 return !(*this == Other);
452}
453
454inline bool SectionRef::operator<(const SectionRef &Other) const {
455 assert(OwningObject == Other.OwningObject);
456 return SectionPimpl < Other.SectionPimpl;
457}
458
459inline void SectionRef::moveNext() {
460 return OwningObject->moveSectionNext(SectionPimpl);
461}
462
464 return OwningObject->getSectionName(SectionPimpl);
465}
466
468 return OwningObject->getSectionAddress(SectionPimpl);
469}
470
472 return OwningObject->getSectionIndex(SectionPimpl);
473}
474
476 return OwningObject->getSectionSize(SectionPimpl);
477}
478
481 OwningObject->getSectionContents(SectionPimpl);
482 if (!Res)
483 return Res.takeError();
484 return StringRef(reinterpret_cast<const char *>(Res->data()), Res->size());
485}
486
488 return MaybeAlign(OwningObject->getSectionAlignment(SectionPimpl))
489 .valueOrOne();
490}
491
492inline bool SectionRef::isCompressed() const {
493 return OwningObject->isSectionCompressed(SectionPimpl);
494}
495
496inline bool SectionRef::isText() const {
497 return OwningObject->isSectionText(SectionPimpl);
498}
499
500inline bool SectionRef::isData() const {
501 return OwningObject->isSectionData(SectionPimpl);
502}
503
504inline bool SectionRef::isBSS() const {
505 return OwningObject->isSectionBSS(SectionPimpl);
506}
507
508inline bool SectionRef::isVirtual() const {
509 return OwningObject->isSectionVirtual(SectionPimpl);
510}
511
512inline bool SectionRef::isBitcode() const {
513 return OwningObject->isSectionBitcode(SectionPimpl);
514}
515
516inline bool SectionRef::isStripped() const {
517 return OwningObject->isSectionStripped(SectionPimpl);
518}
519
520inline bool SectionRef::isBerkeleyText() const {
521 return OwningObject->isBerkeleyText(SectionPimpl);
522}
523
524inline bool SectionRef::isBerkeleyData() const {
525 return OwningObject->isBerkeleyData(SectionPimpl);
526}
527
528inline bool SectionRef::isDebugSection() const {
529 return OwningObject->isDebugSection(SectionPimpl);
530}
531
533 return OwningObject->section_rel_begin(SectionPimpl);
534}
535
537 return OwningObject->section_rel_end(SectionPimpl);
538}
539
541 return OwningObject->getRelocatedSection(SectionPimpl);
542}
543
545 return SectionPimpl;
546}
547
548inline const ObjectFile *SectionRef::getObject() const {
549 return OwningObject;
550}
551
552/// RelocationRef
554 const ObjectFile *Owner)
555 : RelocationPimpl(RelocationP)
556 , OwningObject(Owner) {}
557
559 return RelocationPimpl == Other.RelocationPimpl;
560}
561
563 return OwningObject->moveRelocationNext(RelocationPimpl);
564}
565
567 return OwningObject->getRelocationOffset(RelocationPimpl);
568}
569
571 return OwningObject->getRelocationSymbol(RelocationPimpl);
572}
573
575 return OwningObject->getRelocationType(RelocationPimpl);
576}
577
579 return OwningObject->getRelocationTypeName(RelocationPimpl, Result);
580}
581
583 return RelocationPimpl;
584}
585
587 return OwningObject;
588}
589
590} // end namespace object
591
592template <> struct DenseMapInfo<object::SectionRef> {
593 static bool isEqual(const object::SectionRef &A,
594 const object::SectionRef &B) {
595 return A == B;
596 }
598 return object::SectionRef({}, nullptr);
599 }
602 TS.p = (uintptr_t)-1;
603 return object::SectionRef(TS, nullptr);
604 }
605 static unsigned getHashValue(const object::SectionRef &Sec) {
607 return hash_combine(Raw.p, Raw.d.a, Raw.d.b);
608 }
609};
610
611} // end namespace llvm
612
613#endif // LLVM_OBJECT_OBJECTFILE_H
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
uint64_t Addr
std::string Name
Symbol * Sym
Definition: ELF_riscv.cpp:463
#define P(N)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
Value * RHS
Value * LHS
Lightweight error class with error context and mandatory checking.
Definition: Error.h:156
Tagged union holding either a T or a Error.
Definition: Error.h:470
Error takeError()
Take ownership of the stored error.
Definition: Error.h:597
const char * getBufferStart() const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:577
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
A range adaptor for a pair of iterators.
This is a value type class that represents a single symbol in the list of symbols in the object file.
Definition: SymbolicFile.h:103
const SymbolicFile * getObject() const
Definition: SymbolicFile.h:214
DataRefImpl getRawDataRefImpl() const
Definition: SymbolicFile.h:210
MemoryBufferRef Data
Definition: Binary.h:37
This class is the base class for all object file types.
Definition: ObjectFile.h:228
virtual bool isBerkeleyText(DataRefImpl Sec) const
Definition: ObjectFile.cpp:89
virtual Expected< section_iterator > getRelocatedSection(DataRefImpl Sec) const
Definition: ObjectFile.cpp:105
uint64_t getCommonSymbolSize(DataRefImpl Symb) const
Definition: ObjectFile.h:305
virtual uint64_t getSectionIndex(DataRefImpl Sec) const =0
virtual Expected< StringRef > getSectionName(DataRefImpl Sec) const =0
virtual uint64_t getSectionAlignment(DataRefImpl Sec) const =0
virtual bool isBerkeleyData(DataRefImpl Sec) const
Definition: ObjectFile.cpp:93
virtual bool isSectionBSS(DataRefImpl Sec) const =0
virtual Expected< StringRef > getSymbolName(DataRefImpl Symb) const =0
virtual void getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl< char > &Result) const =0
virtual std::vector< SectionRef > dynamic_relocation_sections() const
Definition: ObjectFile.h:314
static Expected< std::unique_ptr< COFFObjectFile > > createCOFFObjectFile(MemoryBufferRef Object)
virtual section_iterator section_end() const =0
virtual llvm::binaryformat::Swift5ReflectionSectionKind mapReflectionSectionNameToEnumValue(StringRef SectionName) const
Definition: ObjectFile.h:295
virtual uint8_t getBytesInAddress() const =0
The number of bytes used to represent an address in this object file format.
Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override
Definition: ObjectFile.cpp:69
virtual Expected< uint64_t > getSymbolAddress(DataRefImpl Symb) const =0
virtual Expected< ArrayRef< uint8_t > > getSectionContents(DataRefImpl Sec) const =0
virtual bool isSectionVirtual(DataRefImpl Sec) const =0
virtual uint64_t getRelocationType(DataRefImpl Rel) const =0
static Expected< std::unique_ptr< ObjectFile > > createELFObjectFile(MemoryBufferRef Object, bool InitContent=true)
virtual uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const =0
virtual Expected< SubtargetFeatures > getFeatures() const =0
virtual bool isSectionCompressed(DataRefImpl Sec) const =0
virtual uint64_t getSectionSize(DataRefImpl Sec) const =0
Triple makeTriple() const
Create a triple from the data in this object file.
Definition: ObjectFile.cpp:109
virtual bool isSectionText(DataRefImpl Sec) const =0
virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const =0
section_iterator_range sections() const
Definition: ObjectFile.h:327
virtual StringRef getFileFormatName() const =0
virtual uint64_t getSymbolValueImpl(DataRefImpl Symb) const =0
virtual void moveSectionNext(DataRefImpl &Sec) const =0
virtual bool isDebugSection(DataRefImpl Sec) const
Definition: ObjectFile.cpp:97
virtual void setARMSubArch(Triple &TheTriple) const
Definition: ObjectFile.h:343
virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const =0
virtual uint64_t getSectionAddress(DataRefImpl Sec) const =0
static Expected< std::unique_ptr< WasmObjectFile > > createWasmObjectFile(MemoryBufferRef Object)
static Expected< OwningBinary< ObjectFile > > createObjectFile(StringRef ObjectPath)
Definition: ObjectFile.cpp:198
virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const
Definition: ObjectFile.cpp:77
ObjectFile(const ObjectFile &other)=delete
virtual StringRef mapDebugSectionName(StringRef Name) const
Maps a debug section name to a standard DWARF section name.
Definition: ObjectFile.h:352
symbol_iterator_range symbols() const
Definition: ObjectFile.h:319
virtual bool isSectionData(DataRefImpl Sec) const =0
Expected< uint64_t > getSymbolValue(DataRefImpl Symb) const
Definition: ObjectFile.cpp:56
iterator_range< section_iterator > section_iterator_range
Definition: ObjectFile.h:326
virtual void moveRelocationNext(DataRefImpl &Rel) const =0
const uint8_t * base() const
Definition: ObjectFile.h:234
virtual Expected< section_iterator > getSymbolSection(DataRefImpl Symb) const =0
virtual bool isRelocatableObject() const =0
True if this is a relocatable object (.o/.obj).
bool isReflectionSectionStrippable(llvm::binaryformat::Swift5ReflectionSectionKind ReflectionSectionKind) const
True if the reflection section can be stripped by the linker.
Definition: ObjectFile.cpp:214
virtual bool hasDebugInfo() const
Definition: ObjectFile.cpp:99
static Expected< std::unique_ptr< ObjectFile > > createGOFFObjectFile(MemoryBufferRef Object)
static bool classof(const Binary *v)
Definition: ObjectFile.h:377
static Expected< std::unique_ptr< ObjectFile > > createXCOFFObjectFile(MemoryBufferRef Object, unsigned FileType)
static Expected< std::unique_ptr< MachOObjectFile > > createMachOObjectFile(MemoryBufferRef Object, uint32_t UniversalCputype=0, uint32_t UniversalIndex=0)
virtual Expected< uint64_t > getStartAddress() const
Definition: ObjectFile.h:344
virtual relocation_iterator section_rel_end(DataRefImpl Sec) const =0
virtual Triple::ArchType getArch() const =0
virtual bool isSectionStripped(DataRefImpl Sec) const
Definition: ObjectFile.cpp:87
virtual std::optional< StringRef > tryGetCPUName() const
Definition: ObjectFile.h:340
virtual bool isSectionBitcode(DataRefImpl Sec) const
Definition: ObjectFile.cpp:79
iterator_range< symbol_iterator > symbol_iterator_range
Definition: ObjectFile.h:318
virtual uint64_t getRelocationOffset(DataRefImpl Rel) const =0
static Expected< std::unique_ptr< ObjectFile > > createObjectFile(MemoryBufferRef Object)
Definition: ObjectFile.h:373
virtual Expected< SymbolRef::Type > getSymbolType(DataRefImpl Symb) const =0
virtual section_iterator section_begin() const =0
This is a value type class that represents a single relocation in the list of relocations in the obje...
Definition: ObjectFile.h:51
uint64_t getType() const
Definition: ObjectFile.h:574
bool operator==(const RelocationRef &Other) const
Definition: ObjectFile.h:558
uint64_t getOffset() const
Definition: ObjectFile.h:566
symbol_iterator getSymbol() const
Definition: ObjectFile.h:570
const ObjectFile * getObject() const
Definition: ObjectFile.h:586
void getTypeName(SmallVectorImpl< char > &Result) const
Get a string that represents the type of this relocation.
Definition: ObjectFile.h:578
DataRefImpl getRawDataRefImpl() const
Definition: ObjectFile.h:582
This is a value type class that represents a single section in the list of sections in the object fil...
Definition: ObjectFile.h:80
uint64_t getIndex() const
Definition: ObjectFile.h:471
bool operator<(const SectionRef &Other) const
Definition: ObjectFile.h:454
DataRefImpl getRawDataRefImpl() const
Definition: ObjectFile.h:544
bool operator!=(const SectionRef &Other) const
Definition: ObjectFile.h:450
bool isDebugSection() const
Whether this section is a debug section.
Definition: ObjectFile.h:528
iterator_range< relocation_iterator > relocations() const
Definition: ObjectFile.h:132
bool isData() const
Whether this section contains data, not instructions.
Definition: ObjectFile.h:500
Expected< StringRef > getContents() const
Definition: ObjectFile.h:479
relocation_iterator relocation_end() const
Definition: ObjectFile.h:536
bool isCompressed() const
Definition: ObjectFile.h:492
bool isStripped() const
Definition: ObjectFile.h:516
bool isBSS() const
Whether this section contains BSS uninitialized data.
Definition: ObjectFile.h:504
uint64_t getSize() const
Definition: ObjectFile.h:475
bool containsSymbol(SymbolRef S) const
Definition: ObjectFile.cpp:46
bool operator==(const SectionRef &Other) const
Definition: ObjectFile.h:445
uint64_t getAddress() const
Definition: ObjectFile.h:467
bool isBerkeleyText() const
Whether this section will be placed in the text segment, according to the Berkeley size format.
Definition: ObjectFile.h:520
bool isVirtual() const
Definition: ObjectFile.h:508
bool isText() const
Whether this section contains instructions.
Definition: ObjectFile.h:496
relocation_iterator relocation_begin() const
Definition: ObjectFile.h:532
Align getAlignment() const
Get the alignment of this section.
Definition: ObjectFile.h:487
bool isBerkeleyData() const
Whether this section will be placed in the data segment, according to the Berkeley size format.
Definition: ObjectFile.h:524
const ObjectFile * getObject() const
Definition: ObjectFile.h:548
bool isBitcode() const
Definition: ObjectFile.h:512
Expected< StringRef > getName() const
Definition: ObjectFile.h:463
Expected< section_iterator > getRelocatedSection() const
Returns the related section if this section contains relocations.
Definition: ObjectFile.h:540
This is a value type class that represents a single symbol in the list of symbols in the object file.
Definition: ObjectFile.h:167
Expected< SymbolRef::Type > getType() const
Definition: ObjectFile.h:430
SymbolRef(const BasicSymbolRef &B)
Definition: ObjectFile.h:182
Expected< StringRef > getName() const
Definition: ObjectFile.h:406
uint32_t getAlignment() const
Get the alignment of this symbol as the actual value (not log 2).
Definition: ObjectFile.h:418
const ObjectFile * getObject() const
Definition: ObjectFile.h:434
Expected< uint64_t > getAddress() const
Returns the symbol virtual address (i.e.
Definition: ObjectFile.h:410
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:414
Expected< section_iterator > getSection() const
Get section this symbol is defined in reference to.
Definition: ObjectFile.h:426
uint64_t getCommonSize() const
Definition: ObjectFile.h:422
virtual basic_symbol_iterator symbol_begin() const =0
virtual basic_symbol_iterator symbol_end() const =0
virtual Expected< uint32_t > getSymbolFlags(DataRefImpl Symb) const =0
const content_type & operator*() const
Definition: SymbolicFile.h:83
const SymbolRef * operator->() const
Definition: ObjectFile.h:214
symbol_iterator(const basic_symbol_iterator &B)
Definition: ObjectFile.h:210
const SymbolRef & operator*() const
Definition: ObjectFile.h:219
symbol_iterator(SymbolRef Sym)
Definition: ObjectFile.h:209
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
#define UINT64_MAX
Definition: DataTypes.h:77
Swift5ReflectionSectionKind
Definition: Swift.h:14
static Expected< const T * > getObject(MemoryBufferRef M, const void *Ptr, const uint64_t Size=sizeof(T))
bool operator==(const SectionedAddress &LHS, const SectionedAddress &RHS)
Definition: ObjectFile.h:157
bool operator<(const SectionedAddress &LHS, const SectionedAddress &RHS)
Definition: ObjectFile.h:151
raw_ostream & operator<<(raw_ostream &OS, const SectionedAddress &Addr)
Definition: ObjectFile.cpp:34
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:145
StringRef getTypeName()
We provide a function which tries to compute the (demangled) name of a type statically.
Definition: TypeName.h:27
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition: Casting.h:565
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
Definition: Error.cpp:92
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Definition: Hashing.h:613
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
static unsigned getHashValue(const object::SectionRef &Sec)
Definition: ObjectFile.h:605
static object::SectionRef getEmptyKey()
Definition: ObjectFile.h:597
static object::SectionRef getTombstoneKey()
Definition: ObjectFile.h:600
static bool isEqual(const object::SectionRef &A, const object::SectionRef &B)
Definition: ObjectFile.h:593
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition: DenseMapInfo.h:51
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:117
Align valueOrOne() const
For convenience, returns a valid alignment or 1 if undefined.
Definition: Alignment.h:141
file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...
Definition: Magic.h:20
@ unknown
Unrecognized file.
Definition: Magic.h:22
static const uint64_t UndefSection
Definition: ObjectFile.h:145
struct llvm::object::DataRefImpl::@339 d