Coverage Report

Created: 2018-07-19 03:59

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/Object/ELFObjectFile.h
Line
Count
Source (jump to first uncovered line)
1
//===- ELFObjectFile.h - ELF object file implementation ---------*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This file declares the ELFObjectFile template class.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_OBJECT_ELFOBJECTFILE_H
15
#define LLVM_OBJECT_ELFOBJECTFILE_H
16
17
#include "llvm/ADT/ArrayRef.h"
18
#include "llvm/ADT/STLExtras.h"
19
#include "llvm/ADT/SmallVector.h"
20
#include "llvm/ADT/StringRef.h"
21
#include "llvm/ADT/Triple.h"
22
#include "llvm/ADT/iterator_range.h"
23
#include "llvm/BinaryFormat/ELF.h"
24
#include "llvm/MC/SubtargetFeature.h"
25
#include "llvm/Object/Binary.h"
26
#include "llvm/Object/ELF.h"
27
#include "llvm/Object/ELFTypes.h"
28
#include "llvm/Object/Error.h"
29
#include "llvm/Object/ObjectFile.h"
30
#include "llvm/Object/SymbolicFile.h"
31
#include "llvm/Support/ARMAttributeParser.h"
32
#include "llvm/Support/ARMBuildAttributes.h"
33
#include "llvm/Support/Casting.h"
34
#include "llvm/Support/Endian.h"
35
#include "llvm/Support/Error.h"
36
#include "llvm/Support/ErrorHandling.h"
37
#include "llvm/Support/MemoryBuffer.h"
38
#include <cassert>
39
#include <cstdint>
40
#include <system_error>
41
42
namespace llvm {
43
namespace object {
44
45
class elf_symbol_iterator;
46
47
class ELFObjectFileBase : public ObjectFile {
48
  friend class ELFRelocationRef;
49
  friend class ELFSectionRef;
50
  friend class ELFSymbolRef;
51
52
protected:
53
  ELFObjectFileBase(unsigned int Type, MemoryBufferRef Source);
54
55
  virtual uint16_t getEMachine() const = 0;
56
  virtual uint64_t getSymbolSize(DataRefImpl Symb) const = 0;
57
  virtual uint8_t getSymbolOther(DataRefImpl Symb) const = 0;
58
  virtual uint8_t getSymbolELFType(DataRefImpl Symb) const = 0;
59
60
  virtual uint32_t getSectionType(DataRefImpl Sec) const = 0;
61
  virtual uint64_t getSectionFlags(DataRefImpl Sec) const = 0;
62
  virtual uint64_t getSectionOffset(DataRefImpl Sec) const = 0;
63
64
  virtual Expected<int64_t> getRelocationAddend(DataRefImpl Rel) const = 0;
65
66
public:
67
  using elf_symbol_iterator_range = iterator_range<elf_symbol_iterator>;
68
69
  virtual elf_symbol_iterator_range getDynamicSymbolIterators() const = 0;
70
71
  /// Returns platform-specific object flags, if any.
72
  virtual unsigned getPlatformFlags() const = 0;
73
74
  elf_symbol_iterator_range symbols() const;
75
76
  static bool classof(const Binary *v) { return v->isELF(); }
77
78
  SubtargetFeatures getFeatures() const override;
79
80
  SubtargetFeatures getMIPSFeatures() const;
81
82
  SubtargetFeatures getARMFeatures() const;
83
84
  SubtargetFeatures getRISCVFeatures() const;
85
86
  void setARMSubArch(Triple &TheTriple) const override;
87
88
  virtual uint16_t getEType() const = 0;
89
};
90
91
class ELFSectionRef : public SectionRef {
92
public:
93
  ELFSectionRef(const SectionRef &B) : SectionRef(B) {
94
    assert(isa<ELFObjectFileBase>(SectionRef::getObject()));
95
  }
96
97
  const ELFObjectFileBase *getObject() const {
98
    return cast<ELFObjectFileBase>(SectionRef::getObject());
99
  }
100
101
  uint32_t getType() const {
102
    return getObject()->getSectionType(getRawDataRefImpl());
103
  }
104
105
  uint64_t getFlags() const {
106
    return getObject()->getSectionFlags(getRawDataRefImpl());
107
  }
108
109
  uint64_t getOffset() const {
110
    return getObject()->getSectionOffset(getRawDataRefImpl());
111
  }
112
};
113
114
class elf_section_iterator : public section_iterator {
115
public:
116
  elf_section_iterator(const section_iterator &B) : section_iterator(B) {
117
    assert(isa<ELFObjectFileBase>(B->getObject()));
118
  }
119
120
  const ELFSectionRef *operator->() const {
121
    return static_cast<const ELFSectionRef *>(section_iterator::operator->());
122
  }
123
124
  const ELFSectionRef &operator*() const {
125
    return static_cast<const ELFSectionRef &>(section_iterator::operator*());
126
  }
127
};
128
129
class ELFSymbolRef : public SymbolRef {
130
public:
131
  ELFSymbolRef(const SymbolRef &B) : SymbolRef(B) {
132
    assert(isa<ELFObjectFileBase>(SymbolRef::getObject()));
133
  }
134
135
  const ELFObjectFileBase *getObject() const {
136
    return cast<ELFObjectFileBase>(BasicSymbolRef::getObject());
137
  }
138
139
  uint64_t getSize() const {
140
    return getObject()->getSymbolSize(getRawDataRefImpl());
141
  }
142
143
  uint8_t getOther() const {
144
    return getObject()->getSymbolOther(getRawDataRefImpl());
145
  }
146
147
  uint8_t getELFType() const {
148
    return getObject()->getSymbolELFType(getRawDataRefImpl());
149
  }
150
};
151
152
class elf_symbol_iterator : public symbol_iterator {
153
public:
154
  elf_symbol_iterator(const basic_symbol_iterator &B)
155
      : symbol_iterator(SymbolRef(B->getRawDataRefImpl(),
156
1.24k
                                  cast<ELFObjectFileBase>(B->getObject()))) {}
157
158
  const ELFSymbolRef *operator->() const {
159
    return static_cast<const ELFSymbolRef *>(symbol_iterator::operator->());
160
  }
161
162
  const ELFSymbolRef &operator*() const {
163
    return static_cast<const ELFSymbolRef &>(symbol_iterator::operator*());
164
  }
165
};
166
167
class ELFRelocationRef : public RelocationRef {
168
public:
169
  ELFRelocationRef(const RelocationRef &B) : RelocationRef(B) {
170
    assert(isa<ELFObjectFileBase>(RelocationRef::getObject()));
171
  }
172
173
  const ELFObjectFileBase *getObject() const {
174
    return cast<ELFObjectFileBase>(RelocationRef::getObject());
175
  }
176
177
  Expected<int64_t> getAddend() const {
178
    return getObject()->getRelocationAddend(getRawDataRefImpl());
179
  }
180
};
181
182
class elf_relocation_iterator : public relocation_iterator {
183
public:
184
  elf_relocation_iterator(const relocation_iterator &B)
185
      : relocation_iterator(RelocationRef(
186
            B->getRawDataRefImpl(), cast<ELFObjectFileBase>(B->getObject()))) {}
187
188
  const ELFRelocationRef *operator->() const {
189
    return static_cast<const ELFRelocationRef *>(
190
        relocation_iterator::operator->());
191
  }
192
193
  const ELFRelocationRef &operator*() const {
194
    return static_cast<const ELFRelocationRef &>(
195
        relocation_iterator::operator*());
196
  }
197
};
198
199
inline ELFObjectFileBase::elf_symbol_iterator_range
200
ELFObjectFileBase::symbols() const {
201
  return elf_symbol_iterator_range(symbol_begin(), symbol_end());
202
}
203
204
template <class ELFT> class ELFObjectFile : public ELFObjectFileBase {
205
  uint16_t getEMachine() const override;
206
  uint16_t getEType() const override;
207
  uint64_t getSymbolSize(DataRefImpl Sym) const override;
208
209
public:
210
  LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
211
212
  using uintX_t = typename ELFT::uint;
213
214
  using Elf_Sym = typename ELFT::Sym;
215
  using Elf_Shdr = typename ELFT::Shdr;
216
  using Elf_Ehdr = typename ELFT::Ehdr;
217
  using Elf_Rel = typename ELFT::Rel;
218
  using Elf_Rela = typename ELFT::Rela;
219
  using Elf_Dyn = typename ELFT::Dyn;
220
221
private:
222
  ELFObjectFile(MemoryBufferRef Object, ELFFile<ELFT> EF,
223
                const Elf_Shdr *DotDynSymSec, const Elf_Shdr *DotSymtabSec,
224
                ArrayRef<Elf_Word> ShndxTable);
225
226
protected:
227
  ELFFile<ELFT> EF;
228
229
  const Elf_Shdr *DotDynSymSec = nullptr; // Dynamic symbol table section.
230
  const Elf_Shdr *DotSymtabSec = nullptr; // Symbol table section.
231
  ArrayRef<Elf_Word> ShndxTable;
232
233
  void moveSymbolNext(DataRefImpl &Symb) const override;
234
  Expected<StringRef> getSymbolName(DataRefImpl Symb) const override;
235
  Expected<uint64_t> getSymbolAddress(DataRefImpl Symb) const override;
236
  uint64_t getSymbolValueImpl(DataRefImpl Symb) const override;
237
  uint32_t getSymbolAlignment(DataRefImpl Symb) const override;
238
  uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override;
239
  uint32_t getSymbolFlags(DataRefImpl Symb) const override;
240
  uint8_t getSymbolOther(DataRefImpl Symb) const override;
241
  uint8_t getSymbolELFType(DataRefImpl Symb) const override;
242
  Expected<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const override;
243
  Expected<section_iterator> getSymbolSection(const Elf_Sym *Symb,
244
                                              const Elf_Shdr *SymTab) const;
245
  Expected<section_iterator> getSymbolSection(DataRefImpl Symb) const override;
246
247
  void moveSectionNext(DataRefImpl &Sec) const override;
248
  std::error_code getSectionName(DataRefImpl Sec,
249
                                 StringRef &Res) const override;
250
  uint64_t getSectionAddress(DataRefImpl Sec) const override;
251
  uint64_t getSectionIndex(DataRefImpl Sec) const override;
252
  uint64_t getSectionSize(DataRefImpl Sec) const override;
253
  std::error_code getSectionContents(DataRefImpl Sec,
254
                                     StringRef &Res) const override;
255
  uint64_t getSectionAlignment(DataRefImpl Sec) const override;
256
  bool isSectionCompressed(DataRefImpl Sec) const override;
257
  bool isSectionText(DataRefImpl Sec) const override;
258
  bool isSectionData(DataRefImpl Sec) const override;
259
  bool isSectionBSS(DataRefImpl Sec) const override;
260
  bool isSectionVirtual(DataRefImpl Sec) const override;
261
  relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
262
  relocation_iterator section_rel_end(DataRefImpl Sec) const override;
263
  std::vector<SectionRef> dynamic_relocation_sections() const override;
264
  section_iterator getRelocatedSection(DataRefImpl Sec) const override;
265
266
  void moveRelocationNext(DataRefImpl &Rel) const override;
267
  uint64_t getRelocationOffset(DataRefImpl Rel) const override;
268
  symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
269
  uint64_t getRelocationType(DataRefImpl Rel) const override;
270
  void getRelocationTypeName(DataRefImpl Rel,
271
                             SmallVectorImpl<char> &Result) const override;
272
273
  uint32_t getSectionType(DataRefImpl Sec) const override;
274
  uint64_t getSectionFlags(DataRefImpl Sec) const override;
275
  uint64_t getSectionOffset(DataRefImpl Sec) const override;
276
  StringRef getRelocationTypeName(uint32_t Type) const;
277
278
  /// Get the relocation section that contains \a Rel.
279
20.6k
  const Elf_Shdr *getRelSection(DataRefImpl Rel) const {
280
20.6k
    auto RelSecOrErr = EF.getSection(Rel.d.a);
281
20.6k
    if (!RelSecOrErr)
282
0
      report_fatal_error(errorToErrorCode(RelSecOrErr.takeError()).message());
283
20.6k
    return *RelSecOrErr;
284
20.6k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelSection(llvm::object::DataRefImpl) const
Line
Count
Source
279
2.35k
  const Elf_Shdr *getRelSection(DataRefImpl Rel) const {
280
2.35k
    auto RelSecOrErr = EF.getSection(Rel.d.a);
281
2.35k
    if (!RelSecOrErr)
282
0
      report_fatal_error(errorToErrorCode(RelSecOrErr.takeError()).message());
283
2.35k
    return *RelSecOrErr;
284
2.35k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelSection(llvm::object::DataRefImpl) const
Line
Count
Source
279
881
  const Elf_Shdr *getRelSection(DataRefImpl Rel) const {
280
881
    auto RelSecOrErr = EF.getSection(Rel.d.a);
281
881
    if (!RelSecOrErr)
282
0
      report_fatal_error(errorToErrorCode(RelSecOrErr.takeError()).message());
283
881
    return *RelSecOrErr;
284
881
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelSection(llvm::object::DataRefImpl) const
Line
Count
Source
279
16.5k
  const Elf_Shdr *getRelSection(DataRefImpl Rel) const {
280
16.5k
    auto RelSecOrErr = EF.getSection(Rel.d.a);
281
16.5k
    if (!RelSecOrErr)
282
0
      report_fatal_error(errorToErrorCode(RelSecOrErr.takeError()).message());
283
16.5k
    return *RelSecOrErr;
284
16.5k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelSection(llvm::object::DataRefImpl) const
Line
Count
Source
279
828
  const Elf_Shdr *getRelSection(DataRefImpl Rel) const {
280
828
    auto RelSecOrErr = EF.getSection(Rel.d.a);
281
828
    if (!RelSecOrErr)
282
0
      report_fatal_error(errorToErrorCode(RelSecOrErr.takeError()).message());
283
828
    return *RelSecOrErr;
284
828
  }
285
286
8.53k
  DataRefImpl toDRI(const Elf_Shdr *SymTable, unsigned SymbolNum) const {
287
8.53k
    DataRefImpl DRI;
288
8.53k
    if (!SymTable) {
289
242
      DRI.d.a = 0;
290
242
      DRI.d.b = 0;
291
242
      return DRI;
292
242
    }
293
8.28k
    assert(SymTable->sh_type == ELF::SHT_SYMTAB ||
294
8.28k
           SymTable->sh_type == ELF::SHT_DYNSYM);
295
8.28k
296
8.28k
    auto SectionsOrErr = EF.sections();
297
8.28k
    if (!SectionsOrErr) {
298
0
      DRI.d.a = 0;
299
0
      DRI.d.b = 0;
300
0
      return DRI;
301
0
    }
302
8.28k
    uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
303
8.28k
    unsigned SymTableIndex =
304
8.28k
        (reinterpret_cast<uintptr_t>(SymTable) - SHT) / sizeof(Elf_Shdr);
305
8.28k
306
8.28k
    DRI.d.a = SymTableIndex;
307
8.28k
    DRI.d.b = SymbolNum;
308
8.28k
    return DRI;
309
8.28k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::toDRI(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*, unsigned int) const
Line
Count
Source
286
1.46k
  DataRefImpl toDRI(const Elf_Shdr *SymTable, unsigned SymbolNum) const {
287
1.46k
    DataRefImpl DRI;
288
1.46k
    if (!SymTable) {
289
196
      DRI.d.a = 0;
290
196
      DRI.d.b = 0;
291
196
      return DRI;
292
196
    }
293
1.27k
    assert(SymTable->sh_type == ELF::SHT_SYMTAB ||
294
1.27k
           SymTable->sh_type == ELF::SHT_DYNSYM);
295
1.27k
296
1.27k
    auto SectionsOrErr = EF.sections();
297
1.27k
    if (!SectionsOrErr) {
298
0
      DRI.d.a = 0;
299
0
      DRI.d.b = 0;
300
0
      return DRI;
301
0
    }
302
1.27k
    uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
303
1.27k
    unsigned SymTableIndex =
304
1.27k
        (reinterpret_cast<uintptr_t>(SymTable) - SHT) / sizeof(Elf_Shdr);
305
1.27k
306
1.27k
    DRI.d.a = SymTableIndex;
307
1.27k
    DRI.d.b = SymbolNum;
308
1.27k
    return DRI;
309
1.27k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::toDRI(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*, unsigned int) const
Line
Count
Source
286
397
  DataRefImpl toDRI(const Elf_Shdr *SymTable, unsigned SymbolNum) const {
287
397
    DataRefImpl DRI;
288
397
    if (!SymTable) {
289
8
      DRI.d.a = 0;
290
8
      DRI.d.b = 0;
291
8
      return DRI;
292
8
    }
293
389
    assert(SymTable->sh_type == ELF::SHT_SYMTAB ||
294
389
           SymTable->sh_type == ELF::SHT_DYNSYM);
295
389
296
389
    auto SectionsOrErr = EF.sections();
297
389
    if (!SectionsOrErr) {
298
0
      DRI.d.a = 0;
299
0
      DRI.d.b = 0;
300
0
      return DRI;
301
0
    }
302
389
    uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
303
389
    unsigned SymTableIndex =
304
389
        (reinterpret_cast<uintptr_t>(SymTable) - SHT) / sizeof(Elf_Shdr);
305
389
306
389
    DRI.d.a = SymTableIndex;
307
389
    DRI.d.b = SymbolNum;
308
389
    return DRI;
309
389
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::toDRI(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*, unsigned int) const
Line
Count
Source
286
6.34k
  DataRefImpl toDRI(const Elf_Shdr *SymTable, unsigned SymbolNum) const {
287
6.34k
    DataRefImpl DRI;
288
6.34k
    if (!SymTable) {
289
36
      DRI.d.a = 0;
290
36
      DRI.d.b = 0;
291
36
      return DRI;
292
36
    }
293
6.30k
    assert(SymTable->sh_type == ELF::SHT_SYMTAB ||
294
6.30k
           SymTable->sh_type == ELF::SHT_DYNSYM);
295
6.30k
296
6.30k
    auto SectionsOrErr = EF.sections();
297
6.30k
    if (!SectionsOrErr) {
298
0
      DRI.d.a = 0;
299
0
      DRI.d.b = 0;
300
0
      return DRI;
301
0
    }
302
6.30k
    uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
303
6.30k
    unsigned SymTableIndex =
304
6.30k
        (reinterpret_cast<uintptr_t>(SymTable) - SHT) / sizeof(Elf_Shdr);
305
6.30k
306
6.30k
    DRI.d.a = SymTableIndex;
307
6.30k
    DRI.d.b = SymbolNum;
308
6.30k
    return DRI;
309
6.30k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::toDRI(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*, unsigned int) const
Line
Count
Source
286
321
  DataRefImpl toDRI(const Elf_Shdr *SymTable, unsigned SymbolNum) const {
287
321
    DataRefImpl DRI;
288
321
    if (!SymTable) {
289
2
      DRI.d.a = 0;
290
2
      DRI.d.b = 0;
291
2
      return DRI;
292
2
    }
293
319
    assert(SymTable->sh_type == ELF::SHT_SYMTAB ||
294
319
           SymTable->sh_type == ELF::SHT_DYNSYM);
295
319
296
319
    auto SectionsOrErr = EF.sections();
297
319
    if (!SectionsOrErr) {
298
0
      DRI.d.a = 0;
299
0
      DRI.d.b = 0;
300
0
      return DRI;
301
0
    }
302
319
    uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
303
319
    unsigned SymTableIndex =
304
319
        (reinterpret_cast<uintptr_t>(SymTable) - SHT) / sizeof(Elf_Shdr);
305
319
306
319
    DRI.d.a = SymTableIndex;
307
319
    DRI.d.b = SymbolNum;
308
319
    return DRI;
309
319
  }
310
311
  const Elf_Shdr *toELFShdrIter(DataRefImpl Sec) const {
312
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
313
  }
314
315
246k
  DataRefImpl toDRI(const Elf_Shdr *Sec) const {
316
246k
    DataRefImpl DRI;
317
246k
    DRI.p = reinterpret_cast<uintptr_t>(Sec);
318
246k
    return DRI;
319
246k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::toDRI(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*) const
Line
Count
Source
315
29.8k
  DataRefImpl toDRI(const Elf_Shdr *Sec) const {
316
29.8k
    DataRefImpl DRI;
317
29.8k
    DRI.p = reinterpret_cast<uintptr_t>(Sec);
318
29.8k
    return DRI;
319
29.8k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::toDRI(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*) const
Line
Count
Source
315
7.55k
  DataRefImpl toDRI(const Elf_Shdr *Sec) const {
316
7.55k
    DataRefImpl DRI;
317
7.55k
    DRI.p = reinterpret_cast<uintptr_t>(Sec);
318
7.55k
    return DRI;
319
7.55k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::toDRI(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*) const
Line
Count
Source
315
203k
  DataRefImpl toDRI(const Elf_Shdr *Sec) const {
316
203k
    DataRefImpl DRI;
317
203k
    DRI.p = reinterpret_cast<uintptr_t>(Sec);
318
203k
    return DRI;
319
203k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::toDRI(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*) const
Line
Count
Source
315
5.19k
  DataRefImpl toDRI(const Elf_Shdr *Sec) const {
316
5.19k
    DataRefImpl DRI;
317
5.19k
    DRI.p = reinterpret_cast<uintptr_t>(Sec);
318
5.19k
    return DRI;
319
5.19k
  }
320
321
  DataRefImpl toDRI(const Elf_Dyn *Dyn) const {
322
    DataRefImpl DRI;
323
    DRI.p = reinterpret_cast<uintptr_t>(Dyn);
324
    return DRI;
325
  }
326
327
39.7k
  bool isExportedToOtherDSO(const Elf_Sym *ESym) const {
328
39.7k
    unsigned char Binding = ESym->getBinding();
329
39.7k
    unsigned char Visibility = ESym->getVisibility();
330
39.7k
331
39.7k
    // A symbol is exported if its binding is either GLOBAL or WEAK, and its
332
39.7k
    // visibility is either DEFAULT or PROTECTED. All other symbols are not
333
39.7k
    // exported.
334
39.7k
    return ((Binding == ELF::STB_GLOBAL || 
Binding == ELF::STB_WEAK23.3k
) &&
335
39.7k
            
(20.3k
Visibility == ELF::STV_DEFAULT20.3k
||
336
20.3k
             
Visibility == ELF::STV_PROTECTED8.65k
));
337
39.7k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isExportedToOtherDSO(llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*) const
Line
Count
Source
327
8.67k
  bool isExportedToOtherDSO(const Elf_Sym *ESym) const {
328
8.67k
    unsigned char Binding = ESym->getBinding();
329
8.67k
    unsigned char Visibility = ESym->getVisibility();
330
8.67k
331
8.67k
    // A symbol is exported if its binding is either GLOBAL or WEAK, and its
332
8.67k
    // visibility is either DEFAULT or PROTECTED. All other symbols are not
333
8.67k
    // exported.
334
8.67k
    return ((Binding == ELF::STB_GLOBAL || 
Binding == ELF::STB_WEAK5.38k
) &&
335
8.67k
            
(3.29k
Visibility == ELF::STV_DEFAULT3.29k
||
336
3.29k
             
Visibility == ELF::STV_PROTECTED4
));
337
8.67k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isExportedToOtherDSO(llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*) const
Line
Count
Source
327
1.14k
  bool isExportedToOtherDSO(const Elf_Sym *ESym) const {
328
1.14k
    unsigned char Binding = ESym->getBinding();
329
1.14k
    unsigned char Visibility = ESym->getVisibility();
330
1.14k
331
1.14k
    // A symbol is exported if its binding is either GLOBAL or WEAK, and its
332
1.14k
    // visibility is either DEFAULT or PROTECTED. All other symbols are not
333
1.14k
    // exported.
334
1.14k
    return ((Binding == ELF::STB_GLOBAL || 
Binding == ELF::STB_WEAK772
) &&
335
1.14k
            
(377
Visibility == ELF::STV_DEFAULT377
||
336
377
             
Visibility == ELF::STV_PROTECTED0
));
337
1.14k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isExportedToOtherDSO(llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*) const
Line
Count
Source
327
29.1k
  bool isExportedToOtherDSO(const Elf_Sym *ESym) const {
328
29.1k
    unsigned char Binding = ESym->getBinding();
329
29.1k
    unsigned char Visibility = ESym->getVisibility();
330
29.1k
331
29.1k
    // A symbol is exported if its binding is either GLOBAL or WEAK, and its
332
29.1k
    // visibility is either DEFAULT or PROTECTED. All other symbols are not
333
29.1k
    // exported.
334
29.1k
    return ((Binding == ELF::STB_GLOBAL || 
Binding == ELF::STB_WEAK16.7k
) &&
335
29.1k
            
(16.4k
Visibility == ELF::STV_DEFAULT16.4k
||
336
16.4k
             
Visibility == ELF::STV_PROTECTED8.64k
));
337
29.1k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isExportedToOtherDSO(llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*) const
Line
Count
Source
327
753
  bool isExportedToOtherDSO(const Elf_Sym *ESym) const {
328
753
    unsigned char Binding = ESym->getBinding();
329
753
    unsigned char Visibility = ESym->getVisibility();
330
753
331
753
    // A symbol is exported if its binding is either GLOBAL or WEAK, and its
332
753
    // visibility is either DEFAULT or PROTECTED. All other symbols are not
333
753
    // exported.
334
753
    return ((Binding == ELF::STB_GLOBAL || 
Binding == ELF::STB_WEAK486
) &&
335
753
            
(270
Visibility == ELF::STV_DEFAULT270
||
336
270
             
Visibility == ELF::STV_PROTECTED0
));
337
753
  }
338
339
  // This flag is used for classof, to distinguish ELFObjectFile from
340
  // its subclass. If more subclasses will be created, this flag will
341
  // have to become an enum.
342
  bool isDyldELFObject;
343
344
public:
345
  ELFObjectFile(ELFObjectFile<ELFT> &&Other);
346
  static Expected<ELFObjectFile<ELFT>> create(MemoryBufferRef Object);
347
348
  const Elf_Rel *getRel(DataRefImpl Rel) const;
349
  const Elf_Rela *getRela(DataRefImpl Rela) const;
350
351
159k
  const Elf_Sym *getSymbol(DataRefImpl Sym) const {
352
159k
    auto Ret = EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
353
159k
    if (!Ret)
354
0
      report_fatal_error(errorToErrorCode(Ret.takeError()).message());
355
159k
    return *Ret;
356
159k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
351
52.6k
  const Elf_Sym *getSymbol(DataRefImpl Sym) const {
352
52.6k
    auto Ret = EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
353
52.6k
    if (!Ret)
354
0
      report_fatal_error(errorToErrorCode(Ret.takeError()).message());
355
52.6k
    return *Ret;
356
52.6k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
351
4.60k
  const Elf_Sym *getSymbol(DataRefImpl Sym) const {
352
4.60k
    auto Ret = EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
353
4.60k
    if (!Ret)
354
0
      report_fatal_error(errorToErrorCode(Ret.takeError()).message());
355
4.60k
    return *Ret;
356
4.60k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
351
99.0k
  const Elf_Sym *getSymbol(DataRefImpl Sym) const {
352
99.0k
    auto Ret = EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
353
99.0k
    if (!Ret)
354
0
      report_fatal_error(errorToErrorCode(Ret.takeError()).message());
355
99.0k
    return *Ret;
356
99.0k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
351
2.71k
  const Elf_Sym *getSymbol(DataRefImpl Sym) const {
352
2.71k
    auto Ret = EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
353
2.71k
    if (!Ret)
354
0
      report_fatal_error(errorToErrorCode(Ret.takeError()).message());
355
2.71k
    return *Ret;
356
2.71k
  }
357
358
620k
  const Elf_Shdr *getSection(DataRefImpl Sec) const {
359
620k
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
360
620k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSection(llvm::object::DataRefImpl) const
Line
Count
Source
358
30.9k
  const Elf_Shdr *getSection(DataRefImpl Sec) const {
359
30.9k
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
360
30.9k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSection(llvm::object::DataRefImpl) const
Line
Count
Source
358
9.95k
  const Elf_Shdr *getSection(DataRefImpl Sec) const {
359
9.95k
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
360
9.95k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSection(llvm::object::DataRefImpl) const
Line
Count
Source
358
571k
  const Elf_Shdr *getSection(DataRefImpl Sec) const {
359
571k
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
360
571k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSection(llvm::object::DataRefImpl) const
Line
Count
Source
358
8.20k
  const Elf_Shdr *getSection(DataRefImpl Sec) const {
359
8.20k
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
360
8.20k
  }
361
362
  basic_symbol_iterator symbol_begin() const override;
363
  basic_symbol_iterator symbol_end() const override;
364
365
  elf_symbol_iterator dynamic_symbol_begin() const;
366
  elf_symbol_iterator dynamic_symbol_end() const;
367
368
  section_iterator section_begin() const override;
369
  section_iterator section_end() const override;
370
371
  Expected<int64_t> getRelocationAddend(DataRefImpl Rel) const override;
372
373
  uint8_t getBytesInAddress() const override;
374
  StringRef getFileFormatName() const override;
375
  Triple::ArchType getArch() const override;
376
  Expected<uint64_t> getStartAddress() const override;
377
378
144
  unsigned getPlatformFlags() const override { return EF.getHeader()->e_flags; }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getPlatformFlags() const
Line
Count
Source
378
32
  unsigned getPlatformFlags() const override { return EF.getHeader()->e_flags; }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getPlatformFlags() const
Line
Count
Source
378
72
  unsigned getPlatformFlags() const override { return EF.getHeader()->e_flags; }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getPlatformFlags() const
Line
Count
Source
378
19
  unsigned getPlatformFlags() const override { return EF.getHeader()->e_flags; }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getPlatformFlags() const
Line
Count
Source
378
21
  unsigned getPlatformFlags() const override { return EF.getHeader()->e_flags; }
379
380
202
  std::error_code getBuildAttributes(ARMAttributeParser &Attributes) const override {
381
202
    auto SectionsOrErr = EF.sections();
382
202
    if (!SectionsOrErr)
383
0
      return errorToErrorCode(SectionsOrErr.takeError());
384
202
385
1.48k
    
for (const Elf_Shdr &Sec : *SectionsOrErr)202
{
386
1.48k
      if (Sec.sh_type == ELF::SHT_ARM_ATTRIBUTES) {
387
61
        auto ErrorOrContents = EF.getSectionContents(&Sec);
388
61
        if (!ErrorOrContents)
389
0
          return errorToErrorCode(ErrorOrContents.takeError());
390
61
391
61
        auto Contents = ErrorOrContents.get();
392
61
        if (Contents[0] != ARMBuildAttrs::Format_Version || Contents.size() == 1)
393
0
          return std::error_code();
394
61
395
61
        Attributes.Parse(Contents, ELFT::TargetEndianness == support::little);
396
61
        break;
397
61
      }
398
1.48k
    }
399
202
    return std::error_code();
400
202
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getBuildAttributes(llvm::ARMAttributeParser&) const
Line
Count
Source
380
202
  std::error_code getBuildAttributes(ARMAttributeParser &Attributes) const override {
381
202
    auto SectionsOrErr = EF.sections();
382
202
    if (!SectionsOrErr)
383
0
      return errorToErrorCode(SectionsOrErr.takeError());
384
202
385
1.48k
    
for (const Elf_Shdr &Sec : *SectionsOrErr)202
{
386
1.48k
      if (Sec.sh_type == ELF::SHT_ARM_ATTRIBUTES) {
387
61
        auto ErrorOrContents = EF.getSectionContents(&Sec);
388
61
        if (!ErrorOrContents)
389
0
          return errorToErrorCode(ErrorOrContents.takeError());
390
61
391
61
        auto Contents = ErrorOrContents.get();
392
61
        if (Contents[0] != ARMBuildAttrs::Format_Version || Contents.size() == 1)
393
0
          return std::error_code();
394
61
395
61
        Attributes.Parse(Contents, ELFT::TargetEndianness == support::little);
396
61
        break;
397
61
      }
398
1.48k
    }
399
202
    return std::error_code();
400
202
  }
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getBuildAttributes(llvm::ARMAttributeParser&) const
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getBuildAttributes(llvm::ARMAttributeParser&) const
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getBuildAttributes(llvm::ARMAttributeParser&) const
401
402
  const ELFFile<ELFT> *getELFFile() const { return &EF; }
403
404
  bool isDyldType() const { return isDyldELFObject; }
405
  static bool classof(const Binary *v) {
406
    return v->getType() == getELFType(ELFT::TargetEndianness == support::little,
407
                                      ELFT::Is64Bits);
408
  }
409
410
  elf_symbol_iterator_range getDynamicSymbolIterators() const override;
411
412
  bool isRelocatableObject() const override;
413
};
414
415
using ELF32LEObjectFile = ELFObjectFile<ELF32LE>;
416
using ELF64LEObjectFile = ELFObjectFile<ELF64LE>;
417
using ELF32BEObjectFile = ELFObjectFile<ELF32BE>;
418
using ELF64BEObjectFile = ELFObjectFile<ELF64BE>;
419
420
template <class ELFT>
421
28.6k
void ELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Sym) const {
422
28.6k
  ++Sym.d.b;
423
28.6k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::moveSymbolNext(llvm::object::DataRefImpl&) const
Line
Count
Source
421
7.96k
void ELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Sym) const {
422
7.96k
  ++Sym.d.b;
423
7.96k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::moveSymbolNext(llvm::object::DataRefImpl&) const
Line
Count
Source
421
710
void ELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Sym) const {
422
710
  ++Sym.d.b;
423
710
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::moveSymbolNext(llvm::object::DataRefImpl&) const
Line
Count
Source
421
19.4k
void ELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Sym) const {
422
19.4k
  ++Sym.d.b;
423
19.4k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::moveSymbolNext(llvm::object::DataRefImpl&) const
Line
Count
Source
421
460
void ELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Sym) const {
422
460
  ++Sym.d.b;
423
460
}
424
425
template <class ELFT>
426
31.6k
Expected<StringRef> ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Sym) const {
427
31.6k
  const Elf_Sym *ESym = getSymbol(Sym);
428
31.6k
  auto SymTabOrErr = EF.getSection(Sym.d.a);
429
31.6k
  if (!SymTabOrErr)
430
0
    return SymTabOrErr.takeError();
431
31.6k
  const Elf_Shdr *SymTableSec = *SymTabOrErr;
432
31.6k
  auto StrTabOrErr = EF.getSection(SymTableSec->sh_link);
433
31.6k
  if (!StrTabOrErr)
434
0
    return StrTabOrErr.takeError();
435
31.6k
  const Elf_Shdr *StringTableSec = *StrTabOrErr;
436
31.6k
  auto SymStrTabOrErr = EF.getStringTable(StringTableSec);
437
31.6k
  if (!SymStrTabOrErr)
438
0
    return SymStrTabOrErr.takeError();
439
31.6k
  return ESym->getName(*SymStrTabOrErr);
440
31.6k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolName(llvm::object::DataRefImpl) const
Line
Count
Source
426
14.0k
Expected<StringRef> ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Sym) const {
427
14.0k
  const Elf_Sym *ESym = getSymbol(Sym);
428
14.0k
  auto SymTabOrErr = EF.getSection(Sym.d.a);
429
14.0k
  if (!SymTabOrErr)
430
0
    return SymTabOrErr.takeError();
431
14.0k
  const Elf_Shdr *SymTableSec = *SymTabOrErr;
432
14.0k
  auto StrTabOrErr = EF.getSection(SymTableSec->sh_link);
433
14.0k
  if (!StrTabOrErr)
434
0
    return StrTabOrErr.takeError();
435
14.0k
  const Elf_Shdr *StringTableSec = *StrTabOrErr;
436
14.0k
  auto SymStrTabOrErr = EF.getStringTable(StringTableSec);
437
14.0k
  if (!SymStrTabOrErr)
438
0
    return SymStrTabOrErr.takeError();
439
14.0k
  return ESym->getName(*SymStrTabOrErr);
440
14.0k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolName(llvm::object::DataRefImpl) const
Line
Count
Source
426
697
Expected<StringRef> ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Sym) const {
427
697
  const Elf_Sym *ESym = getSymbol(Sym);
428
697
  auto SymTabOrErr = EF.getSection(Sym.d.a);
429
697
  if (!SymTabOrErr)
430
0
    return SymTabOrErr.takeError();
431
697
  const Elf_Shdr *SymTableSec = *SymTabOrErr;
432
697
  auto StrTabOrErr = EF.getSection(SymTableSec->sh_link);
433
697
  if (!StrTabOrErr)
434
0
    return StrTabOrErr.takeError();
435
697
  const Elf_Shdr *StringTableSec = *StrTabOrErr;
436
697
  auto SymStrTabOrErr = EF.getStringTable(StringTableSec);
437
697
  if (!SymStrTabOrErr)
438
0
    return SymStrTabOrErr.takeError();
439
697
  return ESym->getName(*SymStrTabOrErr);
440
697
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolName(llvm::object::DataRefImpl) const
Line
Count
Source
426
16.5k
Expected<StringRef> ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Sym) const {
427
16.5k
  const Elf_Sym *ESym = getSymbol(Sym);
428
16.5k
  auto SymTabOrErr = EF.getSection(Sym.d.a);
429
16.5k
  if (!SymTabOrErr)
430
0
    return SymTabOrErr.takeError();
431
16.5k
  const Elf_Shdr *SymTableSec = *SymTabOrErr;
432
16.5k
  auto StrTabOrErr = EF.getSection(SymTableSec->sh_link);
433
16.5k
  if (!StrTabOrErr)
434
0
    return StrTabOrErr.takeError();
435
16.5k
  const Elf_Shdr *StringTableSec = *StrTabOrErr;
436
16.5k
  auto SymStrTabOrErr = EF.getStringTable(StringTableSec);
437
16.5k
  if (!SymStrTabOrErr)
438
0
    return SymStrTabOrErr.takeError();
439
16.5k
  return ESym->getName(*SymStrTabOrErr);
440
16.5k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolName(llvm::object::DataRefImpl) const
Line
Count
Source
426
405
Expected<StringRef> ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Sym) const {
427
405
  const Elf_Sym *ESym = getSymbol(Sym);
428
405
  auto SymTabOrErr = EF.getSection(Sym.d.a);
429
405
  if (!SymTabOrErr)
430
0
    return SymTabOrErr.takeError();
431
405
  const Elf_Shdr *SymTableSec = *SymTabOrErr;
432
405
  auto StrTabOrErr = EF.getSection(SymTableSec->sh_link);
433
405
  if (!StrTabOrErr)
434
0
    return StrTabOrErr.takeError();
435
405
  const Elf_Shdr *StringTableSec = *StrTabOrErr;
436
405
  auto SymStrTabOrErr = EF.getStringTable(StringTableSec);
437
405
  if (!SymStrTabOrErr)
438
0
    return SymStrTabOrErr.takeError();
439
405
  return ESym->getName(*SymStrTabOrErr);
440
405
}
441
442
template <class ELFT>
443
797
uint64_t ELFObjectFile<ELFT>::getSectionFlags(DataRefImpl Sec) const {
444
797
  return getSection(Sec)->sh_flags;
445
797
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionFlags(llvm::object::DataRefImpl) const
Line
Count
Source
443
71
uint64_t ELFObjectFile<ELFT>::getSectionFlags(DataRefImpl Sec) const {
444
71
  return getSection(Sec)->sh_flags;
445
71
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionFlags(llvm::object::DataRefImpl) const
Line
Count
Source
443
36
uint64_t ELFObjectFile<ELFT>::getSectionFlags(DataRefImpl Sec) const {
444
36
  return getSection(Sec)->sh_flags;
445
36
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionFlags(llvm::object::DataRefImpl) const
Line
Count
Source
443
646
uint64_t ELFObjectFile<ELFT>::getSectionFlags(DataRefImpl Sec) const {
444
646
  return getSection(Sec)->sh_flags;
445
646
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionFlags(llvm::object::DataRefImpl) const
Line
Count
Source
443
44
uint64_t ELFObjectFile<ELFT>::getSectionFlags(DataRefImpl Sec) const {
444
44
  return getSection(Sec)->sh_flags;
445
44
}
446
447
template <class ELFT>
448
543
uint32_t ELFObjectFile<ELFT>::getSectionType(DataRefImpl Sec) const {
449
543
  return getSection(Sec)->sh_type;
450
543
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionType(llvm::object::DataRefImpl) const
Line
Count
Source
448
54
uint32_t ELFObjectFile<ELFT>::getSectionType(DataRefImpl Sec) const {
449
54
  return getSection(Sec)->sh_type;
450
54
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionType(llvm::object::DataRefImpl) const
Line
Count
Source
448
18
uint32_t ELFObjectFile<ELFT>::getSectionType(DataRefImpl Sec) const {
449
18
  return getSection(Sec)->sh_type;
450
18
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionType(llvm::object::DataRefImpl) const
Line
Count
Source
448
449
uint32_t ELFObjectFile<ELFT>::getSectionType(DataRefImpl Sec) const {
449
449
  return getSection(Sec)->sh_type;
450
449
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionType(llvm::object::DataRefImpl) const
Line
Count
Source
448
22
uint32_t ELFObjectFile<ELFT>::getSectionType(DataRefImpl Sec) const {
449
22
  return getSection(Sec)->sh_type;
450
22
}
451
452
template <class ELFT>
453
0
uint64_t ELFObjectFile<ELFT>::getSectionOffset(DataRefImpl Sec) const {
454
0
  return getSection(Sec)->sh_offset;
455
0
}
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionOffset(llvm::object::DataRefImpl) const
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionOffset(llvm::object::DataRefImpl) const
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionOffset(llvm::object::DataRefImpl) const
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionOffset(llvm::object::DataRefImpl) const
456
457
template <class ELFT>
458
23.8k
uint64_t ELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const {
459
23.8k
  const Elf_Sym *ESym = getSymbol(Symb);
460
23.8k
  uint64_t Ret = ESym->st_value;
461
23.8k
  if (ESym->st_shndx == ELF::SHN_ABS)
462
531
    return Ret;
463
23.3k
464
23.3k
  const Elf_Ehdr *Header = EF.getHeader();
465
23.3k
  // Clear the ARM/Thumb or microMIPS indicator flag.
466
23.3k
  if ((Header->e_machine == ELF::EM_ARM || 
Header->e_machine == ELF::EM_MIPS17.4k
) &&
467
23.3k
      
ESym->getType() == ELF::STT_FUNC6.80k
)
468
2.97k
    Ret &= ~1;
469
23.3k
470
23.3k
  return Ret;
471
23.3k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolValueImpl(llvm::object::DataRefImpl) const
Line
Count
Source
458
7.18k
uint64_t ELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const {
459
7.18k
  const Elf_Sym *ESym = getSymbol(Symb);
460
7.18k
  uint64_t Ret = ESym->st_value;
461
7.18k
  if (ESym->st_shndx == ELF::SHN_ABS)
462
142
    return Ret;
463
7.03k
464
7.03k
  const Elf_Ehdr *Header = EF.getHeader();
465
7.03k
  // Clear the ARM/Thumb or microMIPS indicator flag.
466
7.03k
  if ((Header->e_machine == ELF::EM_ARM || 
Header->e_machine == ELF::EM_MIPS1.11k
) &&
467
7.03k
      
ESym->getType() == ELF::STT_FUNC6.09k
)
468
2.80k
    Ret &= ~1;
469
7.03k
470
7.03k
  return Ret;
471
7.03k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolValueImpl(llvm::object::DataRefImpl) const
Line
Count
Source
458
578
uint64_t ELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const {
459
578
  const Elf_Sym *ESym = getSymbol(Symb);
460
578
  uint64_t Ret = ESym->st_value;
461
578
  if (ESym->st_shndx == ELF::SHN_ABS)
462
29
    return Ret;
463
549
464
549
  const Elf_Ehdr *Header = EF.getHeader();
465
549
  // Clear the ARM/Thumb or microMIPS indicator flag.
466
549
  if ((Header->e_machine == ELF::EM_ARM || 
Header->e_machine == ELF::EM_MIPS535
) &&
467
549
      
ESym->getType() == ELF::STT_FUNC527
)
468
137
    Ret &= ~1;
469
549
470
549
  return Ret;
471
549
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolValueImpl(llvm::object::DataRefImpl) const
Line
Count
Source
458
15.8k
uint64_t ELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const {
459
15.8k
  const Elf_Sym *ESym = getSymbol(Symb);
460
15.8k
  uint64_t Ret = ESym->st_value;
461
15.8k
  if (ESym->st_shndx == ELF::SHN_ABS)
462
358
    return Ret;
463
15.4k
464
15.4k
  const Elf_Ehdr *Header = EF.getHeader();
465
15.4k
  // Clear the ARM/Thumb or microMIPS indicator flag.
466
15.4k
  if ((Header->e_machine == ELF::EM_ARM || Header->e_machine == ELF::EM_MIPS) &&
467
15.4k
      
ESym->getType() == ELF::STT_FUNC60
)
468
30
    Ret &= ~1;
469
15.4k
470
15.4k
  return Ret;
471
15.4k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolValueImpl(llvm::object::DataRefImpl) const
Line
Count
Source
458
320
uint64_t ELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const {
459
320
  const Elf_Sym *ESym = getSymbol(Symb);
460
320
  uint64_t Ret = ESym->st_value;
461
320
  if (ESym->st_shndx == ELF::SHN_ABS)
462
2
    return Ret;
463
318
464
318
  const Elf_Ehdr *Header = EF.getHeader();
465
318
  // Clear the ARM/Thumb or microMIPS indicator flag.
466
318
  if ((Header->e_machine == ELF::EM_ARM || Header->e_machine == ELF::EM_MIPS) &&
467
318
      
ESym->getType() == ELF::STT_FUNC123
)
468
11
    Ret &= ~1;
469
318
470
318
  return Ret;
471
318
}
472
473
template <class ELFT>
474
Expected<uint64_t>
475
26.1k
ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb) const {
476
26.1k
  uint64_t Result = getSymbolValue(Symb);
477
26.1k
  const Elf_Sym *ESym = getSymbol(Symb);
478
26.1k
  switch (ESym->st_shndx) {
479
26.1k
  case ELF::SHN_COMMON:
480
2.77k
  case ELF::SHN_UNDEF:
481
2.77k
  case ELF::SHN_ABS:
482
2.77k
    return Result;
483
23.3k
  }
484
23.3k
485
23.3k
  const Elf_Ehdr *Header = EF.getHeader();
486
23.3k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
487
23.3k
  if (!SymTabOrErr)
488
0
    return SymTabOrErr.takeError();
489
23.3k
  const Elf_Shdr *SymTab = *SymTabOrErr;
490
23.3k
491
23.3k
  if (Header->e_type == ELF::ET_REL) {
492
4.51k
    auto SectionOrErr = EF.getSection(ESym, SymTab, ShndxTable);
493
4.51k
    if (!SectionOrErr)
494
0
      return SectionOrErr.takeError();
495
4.51k
    const Elf_Shdr *Section = *SectionOrErr;
496
4.51k
    if (Section)
497
4.51k
      Result += Section->sh_addr;
498
4.51k
  }
499
23.3k
500
23.3k
  return Result;
501
23.3k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolAddress(llvm::object::DataRefImpl) const
Line
Count
Source
475
7.79k
ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb) const {
476
7.79k
  uint64_t Result = getSymbolValue(Symb);
477
7.79k
  const Elf_Sym *ESym = getSymbol(Symb);
478
7.79k
  switch (ESym->st_shndx) {
479
7.79k
  case ELF::SHN_COMMON:
480
760
  case ELF::SHN_UNDEF:
481
760
  case ELF::SHN_ABS:
482
760
    return Result;
483
7.03k
  }
484
7.03k
485
7.03k
  const Elf_Ehdr *Header = EF.getHeader();
486
7.03k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
487
7.03k
  if (!SymTabOrErr)
488
0
    return SymTabOrErr.takeError();
489
7.03k
  const Elf_Shdr *SymTab = *SymTabOrErr;
490
7.03k
491
7.03k
  if (Header->e_type == ELF::ET_REL) {
492
1.64k
    auto SectionOrErr = EF.getSection(ESym, SymTab, ShndxTable);
493
1.64k
    if (!SectionOrErr)
494
0
      return SectionOrErr.takeError();
495
1.64k
    const Elf_Shdr *Section = *SectionOrErr;
496
1.64k
    if (Section)
497
1.64k
      Result += Section->sh_addr;
498
1.64k
  }
499
7.03k
500
7.03k
  return Result;
501
7.03k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolAddress(llvm::object::DataRefImpl) const
Line
Count
Source
475
708
ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb) const {
476
708
  uint64_t Result = getSymbolValue(Symb);
477
708
  const Elf_Sym *ESym = getSymbol(Symb);
478
708
  switch (ESym->st_shndx) {
479
708
  case ELF::SHN_COMMON:
480
159
  case ELF::SHN_UNDEF:
481
159
  case ELF::SHN_ABS:
482
159
    return Result;
483
549
  }
484
549
485
549
  const Elf_Ehdr *Header = EF.getHeader();
486
549
  auto SymTabOrErr = EF.getSection(Symb.d.a);
487
549
  if (!SymTabOrErr)
488
0
    return SymTabOrErr.takeError();
489
549
  const Elf_Shdr *SymTab = *SymTabOrErr;
490
549
491
549
  if (Header->e_type == ELF::ET_REL) {
492
208
    auto SectionOrErr = EF.getSection(ESym, SymTab, ShndxTable);
493
208
    if (!SectionOrErr)
494
0
      return SectionOrErr.takeError();
495
208
    const Elf_Shdr *Section = *SectionOrErr;
496
208
    if (Section)
497
208
      Result += Section->sh_addr;
498
208
  }
499
549
500
549
  return Result;
501
549
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolAddress(llvm::object::DataRefImpl) const
Line
Count
Source
475
17.2k
ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb) const {
476
17.2k
  uint64_t Result = getSymbolValue(Symb);
477
17.2k
  const Elf_Sym *ESym = getSymbol(Symb);
478
17.2k
  switch (ESym->st_shndx) {
479
17.2k
  case ELF::SHN_COMMON:
480
1.77k
  case ELF::SHN_UNDEF:
481
1.77k
  case ELF::SHN_ABS:
482
1.77k
    return Result;
483
15.4k
  }
484
15.4k
485
15.4k
  const Elf_Ehdr *Header = EF.getHeader();
486
15.4k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
487
15.4k
  if (!SymTabOrErr)
488
0
    return SymTabOrErr.takeError();
489
15.4k
  const Elf_Shdr *SymTab = *SymTabOrErr;
490
15.4k
491
15.4k
  if (Header->e_type == ELF::ET_REL) {
492
2.53k
    auto SectionOrErr = EF.getSection(ESym, SymTab, ShndxTable);
493
2.53k
    if (!SectionOrErr)
494
0
      return SectionOrErr.takeError();
495
2.53k
    const Elf_Shdr *Section = *SectionOrErr;
496
2.53k
    if (Section)
497
2.53k
      Result += Section->sh_addr;
498
2.53k
  }
499
15.4k
500
15.4k
  return Result;
501
15.4k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolAddress(llvm::object::DataRefImpl) const
Line
Count
Source
475
401
ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb) const {
476
401
  uint64_t Result = getSymbolValue(Symb);
477
401
  const Elf_Sym *ESym = getSymbol(Symb);
478
401
  switch (ESym->st_shndx) {
479
401
  case ELF::SHN_COMMON:
480
83
  case ELF::SHN_UNDEF:
481
83
  case ELF::SHN_ABS:
482
83
    return Result;
483
318
  }
484
318
485
318
  const Elf_Ehdr *Header = EF.getHeader();
486
318
  auto SymTabOrErr = EF.getSection(Symb.d.a);
487
318
  if (!SymTabOrErr)
488
0
    return SymTabOrErr.takeError();
489
318
  const Elf_Shdr *SymTab = *SymTabOrErr;
490
318
491
318
  if (Header->e_type == ELF::ET_REL) {
492
121
    auto SectionOrErr = EF.getSection(ESym, SymTab, ShndxTable);
493
121
    if (!SectionOrErr)
494
0
      return SectionOrErr.takeError();
495
121
    const Elf_Shdr *Section = *SectionOrErr;
496
121
    if (Section)
497
121
      Result += Section->sh_addr;
498
121
  }
499
318
500
318
  return Result;
501
318
}
502
503
template <class ELFT>
504
15
uint32_t ELFObjectFile<ELFT>::getSymbolAlignment(DataRefImpl Symb) const {
505
15
  const Elf_Sym *Sym = getSymbol(Symb);
506
15
  if (Sym->st_shndx == ELF::SHN_COMMON)
507
15
    return Sym->st_value;
508
0
  return 0;
509
0
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
504
6
uint32_t ELFObjectFile<ELFT>::getSymbolAlignment(DataRefImpl Symb) const {
505
6
  const Elf_Sym *Sym = getSymbol(Symb);
506
6
  if (Sym->st_shndx == ELF::SHN_COMMON)
507
6
    return Sym->st_value;
508
0
  return 0;
509
0
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
504
4
uint32_t ELFObjectFile<ELFT>::getSymbolAlignment(DataRefImpl Symb) const {
505
4
  const Elf_Sym *Sym = getSymbol(Symb);
506
4
  if (Sym->st_shndx == ELF::SHN_COMMON)
507
4
    return Sym->st_value;
508
0
  return 0;
509
0
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
504
3
uint32_t ELFObjectFile<ELFT>::getSymbolAlignment(DataRefImpl Symb) const {
505
3
  const Elf_Sym *Sym = getSymbol(Symb);
506
3
  if (Sym->st_shndx == ELF::SHN_COMMON)
507
3
    return Sym->st_value;
508
0
  return 0;
509
0
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
504
2
uint32_t ELFObjectFile<ELFT>::getSymbolAlignment(DataRefImpl Symb) const {
505
2
  const Elf_Sym *Sym = getSymbol(Symb);
506
2
  if (Sym->st_shndx == ELF::SHN_COMMON)
507
2
    return Sym->st_value;
508
0
  return 0;
509
0
}
510
511
template <class ELFT>
512
1.27k
uint16_t ELFObjectFile<ELFT>::getEMachine() const {
513
1.27k
  return EF.getHeader()->e_machine;
514
1.27k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getEMachine() const
Line
Count
Source
512
365
uint16_t ELFObjectFile<ELFT>::getEMachine() const {
513
365
  return EF.getHeader()->e_machine;
514
365
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getEMachine() const
Line
Count
Source
512
66
uint16_t ELFObjectFile<ELFT>::getEMachine() const {
513
66
  return EF.getHeader()->e_machine;
514
66
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getEMachine() const
Line
Count
Source
512
806
uint16_t ELFObjectFile<ELFT>::getEMachine() const {
513
806
  return EF.getHeader()->e_machine;
514
806
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getEMachine() const
Line
Count
Source
512
37
uint16_t ELFObjectFile<ELFT>::getEMachine() const {
513
37
  return EF.getHeader()->e_machine;
514
37
}
515
516
0
template <class ELFT> uint16_t ELFObjectFile<ELFT>::getEType() const {
517
0
  return EF.getHeader()->e_type;
518
0
}
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getEType() const
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getEType() const
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getEType() const
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getEType() const
519
520
template <class ELFT>
521
6.97k
uint64_t ELFObjectFile<ELFT>::getSymbolSize(DataRefImpl Sym) const {
522
6.97k
  return getSymbol(Sym)->st_size;
523
6.97k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolSize(llvm::object::DataRefImpl) const
Line
Count
Source
521
197
uint64_t ELFObjectFile<ELFT>::getSymbolSize(DataRefImpl Sym) const {
522
197
  return getSymbol(Sym)->st_size;
523
197
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolSize(llvm::object::DataRefImpl) const
Line
Count
Source
521
175
uint64_t ELFObjectFile<ELFT>::getSymbolSize(DataRefImpl Sym) const {
522
175
  return getSymbol(Sym)->st_size;
523
175
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolSize(llvm::object::DataRefImpl) const
Line
Count
Source
521
6.53k
uint64_t ELFObjectFile<ELFT>::getSymbolSize(DataRefImpl Sym) const {
522
6.53k
  return getSymbol(Sym)->st_size;
523
6.53k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolSize(llvm::object::DataRefImpl) const
Line
Count
Source
521
64
uint64_t ELFObjectFile<ELFT>::getSymbolSize(DataRefImpl Sym) const {
522
64
  return getSymbol(Sym)->st_size;
523
64
}
524
525
template <class ELFT>
526
56
uint64_t ELFObjectFile<ELFT>::getCommonSymbolSizeImpl(DataRefImpl Symb) const {
527
56
  return getSymbol(Symb)->st_size;
528
56
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getCommonSymbolSizeImpl(llvm::object::DataRefImpl) const
Line
Count
Source
526
13
uint64_t ELFObjectFile<ELFT>::getCommonSymbolSizeImpl(DataRefImpl Symb) const {
527
13
  return getSymbol(Symb)->st_size;
528
13
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getCommonSymbolSizeImpl(llvm::object::DataRefImpl) const
Line
Count
Source
526
5
uint64_t ELFObjectFile<ELFT>::getCommonSymbolSizeImpl(DataRefImpl Symb) const {
527
5
  return getSymbol(Symb)->st_size;
528
5
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getCommonSymbolSizeImpl(llvm::object::DataRefImpl) const
Line
Count
Source
526
35
uint64_t ELFObjectFile<ELFT>::getCommonSymbolSizeImpl(DataRefImpl Symb) const {
527
35
  return getSymbol(Symb)->st_size;
528
35
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getCommonSymbolSizeImpl(llvm::object::DataRefImpl) const
Line
Count
Source
526
3
uint64_t ELFObjectFile<ELFT>::getCommonSymbolSizeImpl(DataRefImpl Symb) const {
527
3
  return getSymbol(Symb)->st_size;
528
3
}
529
530
template <class ELFT>
531
0
uint8_t ELFObjectFile<ELFT>::getSymbolOther(DataRefImpl Symb) const {
532
0
  return getSymbol(Symb)->st_other;
533
0
}
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolOther(llvm::object::DataRefImpl) const
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolOther(llvm::object::DataRefImpl) const
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolOther(llvm::object::DataRefImpl) const
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolOther(llvm::object::DataRefImpl) const
534
535
template <class ELFT>
536
62
uint8_t ELFObjectFile<ELFT>::getSymbolELFType(DataRefImpl Symb) const {
537
62
  return getSymbol(Symb)->getType();
538
62
}
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolELFType(llvm::object::DataRefImpl) const
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolELFType(llvm::object::DataRefImpl) const
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolELFType(llvm::object::DataRefImpl) const
Line
Count
Source
536
62
uint8_t ELFObjectFile<ELFT>::getSymbolELFType(DataRefImpl Symb) const {
537
62
  return getSymbol(Symb)->getType();
538
62
}
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolELFType(llvm::object::DataRefImpl) const
539
540
template <class ELFT>
541
Expected<SymbolRef::Type>
542
7.70k
ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const {
543
7.70k
  const Elf_Sym *ESym = getSymbol(Symb);
544
7.70k
545
7.70k
  switch (ESym->getType()) {
546
7.70k
  case ELF::STT_NOTYPE:
547
1.41k
    return SymbolRef::ST_Unknown;
548
7.70k
  case ELF::STT_SECTION:
549
1.77k
    return SymbolRef::ST_Debug;
550
7.70k
  case ELF::STT_FILE:
551
363
    return SymbolRef::ST_File;
552
7.70k
  case ELF::STT_FUNC:
553
2.12k
    return SymbolRef::ST_Function;
554
7.70k
  case ELF::STT_OBJECT:
555
2.02k
  case ELF::STT_COMMON:
556
2.02k
  case ELF::STT_TLS:
557
2.02k
    return SymbolRef::ST_Data;
558
2.02k
  default:
559
2
    return SymbolRef::ST_Other;
560
7.70k
  }
561
7.70k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolType(llvm::object::DataRefImpl) const
Line
Count
Source
542
258
ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const {
543
258
  const Elf_Sym *ESym = getSymbol(Symb);
544
258
545
258
  switch (ESym->getType()) {
546
258
  case ELF::STT_NOTYPE:
547
134
    return SymbolRef::ST_Unknown;
548
258
  case ELF::STT_SECTION:
549
54
    return SymbolRef::ST_Debug;
550
258
  case ELF::STT_FILE:
551
13
    return SymbolRef::ST_File;
552
258
  case ELF::STT_FUNC:
553
30
    return SymbolRef::ST_Function;
554
258
  case ELF::STT_OBJECT:
555
27
  case ELF::STT_COMMON:
556
27
  case ELF::STT_TLS:
557
27
    return SymbolRef::ST_Data;
558
27
  default:
559
0
    return SymbolRef::ST_Other;
560
258
  }
561
258
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolType(llvm::object::DataRefImpl) const
Line
Count
Source
542
255
ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const {
543
255
  const Elf_Sym *ESym = getSymbol(Symb);
544
255
545
255
  switch (ESym->getType()) {
546
255
  case ELF::STT_NOTYPE:
547
175
    return SymbolRef::ST_Unknown;
548
255
  case ELF::STT_SECTION:
549
13
    return SymbolRef::ST_Debug;
550
255
  case ELF::STT_FILE:
551
5
    return SymbolRef::ST_File;
552
255
  case ELF::STT_FUNC:
553
28
    return SymbolRef::ST_Function;
554
255
  case ELF::STT_OBJECT:
555
34
  case ELF::STT_COMMON:
556
34
  case ELF::STT_TLS:
557
34
    return SymbolRef::ST_Data;
558
34
  default:
559
0
    return SymbolRef::ST_Other;
560
255
  }
561
255
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolType(llvm::object::DataRefImpl) const
Line
Count
Source
542
7.03k
ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const {
543
7.03k
  const Elf_Sym *ESym = getSymbol(Symb);
544
7.03k
545
7.03k
  switch (ESym->getType()) {
546
7.03k
  case ELF::STT_NOTYPE:
547
1.01k
    return SymbolRef::ST_Unknown;
548
7.03k
  case ELF::STT_SECTION:
549
1.68k
    return SymbolRef::ST_Debug;
550
7.03k
  case ELF::STT_FILE:
551
337
    return SymbolRef::ST_File;
552
7.03k
  case ELF::STT_FUNC:
553
2.04k
    return SymbolRef::ST_Function;
554
7.03k
  case ELF::STT_OBJECT:
555
1.95k
  case ELF::STT_COMMON:
556
1.95k
  case ELF::STT_TLS:
557
1.95k
    return SymbolRef::ST_Data;
558
1.95k
  default:
559
2
    return SymbolRef::ST_Other;
560
7.03k
  }
561
7.03k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolType(llvm::object::DataRefImpl) const
Line
Count
Source
542
157
ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const {
543
157
  const Elf_Sym *ESym = getSymbol(Symb);
544
157
545
157
  switch (ESym->getType()) {
546
157
  case ELF::STT_NOTYPE:
547
93
    return SymbolRef::ST_Unknown;
548
157
  case ELF::STT_SECTION:
549
21
    return SymbolRef::ST_Debug;
550
157
  case ELF::STT_FILE:
551
8
    return SymbolRef::ST_File;
552
157
  case ELF::STT_FUNC:
553
21
    return SymbolRef::ST_Function;
554
157
  case ELF::STT_OBJECT:
555
14
  case ELF::STT_COMMON:
556
14
  case ELF::STT_TLS:
557
14
    return SymbolRef::ST_Data;
558
14
  default:
559
0
    return SymbolRef::ST_Other;
560
157
  }
561
157
}
562
563
template <class ELFT>
564
39.7k
uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
565
39.7k
  const Elf_Sym *ESym = getSymbol(Sym);
566
39.7k
567
39.7k
  uint32_t Result = SymbolRef::SF_None;
568
39.7k
569
39.7k
  if (ESym->getBinding() != ELF::STB_LOCAL)
570
20.3k
    Result |= SymbolRef::SF_Global;
571
39.7k
572
39.7k
  if (ESym->getBinding() == ELF::STB_WEAK)
573
4.02k
    Result |= SymbolRef::SF_Weak;
574
39.7k
575
39.7k
  if (ESym->st_shndx == ELF::SHN_ABS)
576
1.20k
    Result |= SymbolRef::SF_Absolute;
577
39.7k
578
39.7k
  if (ESym->getType() == ELF::STT_FILE || 
ESym->getType() == ELF::STT_SECTION38.9k
)
579
3.65k
    Result |= SymbolRef::SF_FormatSpecific;
580
39.7k
581
39.7k
  auto DotSymtabSecSyms = EF.symbols(DotSymtabSec);
582
39.7k
  if (DotSymtabSecSyms && ESym == (*DotSymtabSecSyms).begin())
583
1.89k
    Result |= SymbolRef::SF_FormatSpecific;
584
39.7k
  auto DotDynSymSecSyms = EF.symbols(DotDynSymSec);
585
39.7k
  if (DotDynSymSecSyms && ESym == (*DotDynSymSecSyms).begin())
586
5
    Result |= SymbolRef::SF_FormatSpecific;
587
39.7k
588
39.7k
  if (EF.getHeader()->e_machine == ELF::EM_ARM) {
589
6.45k
    if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
590
6.45k
      StringRef Name = *NameOrErr;
591
6.45k
      if (Name.startswith("$d") || 
Name.startswith("$t")6.30k
||
592
6.45k
          
Name.startswith("$a")4.30k
)
593
2.82k
        Result |= SymbolRef::SF_FormatSpecific;
594
6.45k
    } else {
595
0
      // TODO: Actually report errors helpfully.
596
0
      consumeError(NameOrErr.takeError());
597
0
    }
598
6.45k
    if (ESym->getType() == ELF::STT_FUNC && 
(ESym->st_value & 1) == 12.81k
)
599
2.14k
      Result |= SymbolRef::SF_Thumb;
600
6.45k
  }
601
39.7k
602
39.7k
  if (ESym->st_shndx == ELF::SHN_UNDEF)
603
3.24k
    Result |= SymbolRef::SF_Undefined;
604
39.7k
605
39.7k
  if (ESym->getType() == ELF::STT_COMMON || ESym->st_shndx == ELF::SHN_COMMON)
606
117
    Result |= SymbolRef::SF_Common;
607
39.7k
608
39.7k
  if (isExportedToOtherDSO(ESym))
609
11.7k
    Result |= SymbolRef::SF_Exported;
610
39.7k
611
39.7k
  if (ESym->getVisibility() == ELF::STV_HIDDEN)
612
9.30k
    Result |= SymbolRef::SF_Hidden;
613
39.7k
614
39.7k
  return Result;
615
39.7k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolFlags(llvm::object::DataRefImpl) const
Line
Count
Source
564
8.67k
uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
565
8.67k
  const Elf_Sym *ESym = getSymbol(Sym);
566
8.67k
567
8.67k
  uint32_t Result = SymbolRef::SF_None;
568
8.67k
569
8.67k
  if (ESym->getBinding() != ELF::STB_LOCAL)
570
3.29k
    Result |= SymbolRef::SF_Global;
571
8.67k
572
8.67k
  if (ESym->getBinding() == ELF::STB_WEAK)
573
6
    Result |= SymbolRef::SF_Weak;
574
8.67k
575
8.67k
  if (ESym->st_shndx == ELF::SHN_ABS)
576
214
    Result |= SymbolRef::SF_Absolute;
577
8.67k
578
8.67k
  if (ESym->getType() == ELF::STT_FILE || 
ESym->getType() == ELF::STT_SECTION8.55k
)
579
655
    Result |= SymbolRef::SF_FormatSpecific;
580
8.67k
581
8.67k
  auto DotSymtabSecSyms = EF.symbols(DotSymtabSec);
582
8.67k
  if (DotSymtabSecSyms && ESym == (*DotSymtabSecSyms).begin())
583
459
    Result |= SymbolRef::SF_FormatSpecific;
584
8.67k
  auto DotDynSymSecSyms = EF.symbols(DotDynSymSec);
585
8.67k
  if (DotDynSymSecSyms && ESym == (*DotDynSymSecSyms).begin())
586
1
    Result |= SymbolRef::SF_FormatSpecific;
587
8.67k
588
8.67k
  if (EF.getHeader()->e_machine == ELF::EM_ARM) {
589
6.43k
    if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
590
6.43k
      StringRef Name = *NameOrErr;
591
6.43k
      if (Name.startswith("$d") || 
Name.startswith("$t")6.28k
||
592
6.43k
          
Name.startswith("$a")4.28k
)
593
2.82k
        Result |= SymbolRef::SF_FormatSpecific;
594
6.43k
    } else {
595
0
      // TODO: Actually report errors helpfully.
596
0
      consumeError(NameOrErr.takeError());
597
0
    }
598
6.43k
    if (ESym->getType() == ELF::STT_FUNC && 
(ESym->st_value & 1) == 12.81k
)
599
2.14k
      Result |= SymbolRef::SF_Thumb;
600
6.43k
  }
601
8.67k
602
8.67k
  if (ESym->st_shndx == ELF::SHN_UNDEF)
603
760
    Result |= SymbolRef::SF_Undefined;
604
8.67k
605
8.67k
  if (ESym->getType() == ELF::STT_COMMON || ESym->st_shndx == ELF::SHN_COMMON)
606
27
    Result |= SymbolRef::SF_Common;
607
8.67k
608
8.67k
  if (isExportedToOtherDSO(ESym))
609
3.28k
    Result |= SymbolRef::SF_Exported;
610
8.67k
611
8.67k
  if (ESym->getVisibility() == ELF::STV_HIDDEN)
612
111
    Result |= SymbolRef::SF_Hidden;
613
8.67k
614
8.67k
  return Result;
615
8.67k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolFlags(llvm::object::DataRefImpl) const
Line
Count
Source
564
1.14k
uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
565
1.14k
  const Elf_Sym *ESym = getSymbol(Sym);
566
1.14k
567
1.14k
  uint32_t Result = SymbolRef::SF_None;
568
1.14k
569
1.14k
  if (ESym->getBinding() != ELF::STB_LOCAL)
570
377
    Result |= SymbolRef::SF_Global;
571
1.14k
572
1.14k
  if (ESym->getBinding() == ELF::STB_WEAK)
573
5
    Result |= SymbolRef::SF_Weak;
574
1.14k
575
1.14k
  if (ESym->st_shndx == ELF::SHN_ABS)
576
67
    Result |= SymbolRef::SF_Absolute;
577
1.14k
578
1.14k
  if (ESym->getType() == ELF::STT_FILE || 
ESym->getType() == ELF::STT_SECTION1.11k
)
579
102
    Result |= SymbolRef::SF_FormatSpecific;
580
1.14k
581
1.14k
  auto DotSymtabSecSyms = EF.symbols(DotSymtabSec);
582
1.14k
  if (DotSymtabSecSyms && ESym == (*DotSymtabSecSyms).begin())
583
138
    Result |= SymbolRef::SF_FormatSpecific;
584
1.14k
  auto DotDynSymSecSyms = EF.symbols(DotDynSymSec);
585
1.14k
  if (DotDynSymSecSyms && ESym == (*DotDynSymSecSyms).begin())
586
0
    Result |= SymbolRef::SF_FormatSpecific;
587
1.14k
588
1.14k
  if (EF.getHeader()->e_machine == ELF::EM_ARM) {
589
21
    if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
590
21
      StringRef Name = *NameOrErr;
591
21
      if (Name.startswith("$d") || Name.startswith("$t") ||
592
21
          
Name.startswith("$a")19
)
593
4
        Result |= SymbolRef::SF_FormatSpecific;
594
21
    } else {
595
0
      // TODO: Actually report errors helpfully.
596
0
      consumeError(NameOrErr.takeError());
597
0
    }
598
21
    if (ESym->getType() == ELF::STT_FUNC && 
(ESym->st_value & 1) == 10
)
599
0
      Result |= SymbolRef::SF_Thumb;
600
21
  }
601
1.14k
602
1.14k
  if (ESym->st_shndx == ELF::SHN_UNDEF)
603
185
    Result |= SymbolRef::SF_Undefined;
604
1.14k
605
1.14k
  if (ESym->getType() == ELF::STT_COMMON || ESym->st_shndx == ELF::SHN_COMMON)
606
17
    Result |= SymbolRef::SF_Common;
607
1.14k
608
1.14k
  if (isExportedToOtherDSO(ESym))
609
377
    Result |= SymbolRef::SF_Exported;
610
1.14k
611
1.14k
  if (ESym->getVisibility() == ELF::STV_HIDDEN)
612
162
    Result |= SymbolRef::SF_Hidden;
613
1.14k
614
1.14k
  return Result;
615
1.14k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolFlags(llvm::object::DataRefImpl) const
Line
Count
Source
564
29.1k
uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
565
29.1k
  const Elf_Sym *ESym = getSymbol(Sym);
566
29.1k
567
29.1k
  uint32_t Result = SymbolRef::SF_None;
568
29.1k
569
29.1k
  if (ESym->getBinding() != ELF::STB_LOCAL)
570
16.4k
    Result |= SymbolRef::SF_Global;
571
29.1k
572
29.1k
  if (ESym->getBinding() == ELF::STB_WEAK)
573
4.01k
    Result |= SymbolRef::SF_Weak;
574
29.1k
575
29.1k
  if (ESym->st_shndx == ELF::SHN_ABS)
576
887
    Result |= SymbolRef::SF_Absolute;
577
29.1k
578
29.1k
  if (ESym->getType() == ELF::STT_FILE || 
ESym->getType() == ELF::STT_SECTION28.5k
)
579
2.77k
    Result |= SymbolRef::SF_FormatSpecific;
580
29.1k
581
29.1k
  auto DotSymtabSecSyms = EF.symbols(DotSymtabSec);
582
29.1k
  if (DotSymtabSecSyms && ESym == (*DotSymtabSecSyms).begin())
583
1.22k
    Result |= SymbolRef::SF_FormatSpecific;
584
29.1k
  auto DotDynSymSecSyms = EF.symbols(DotDynSymSec);
585
29.1k
  if (DotDynSymSecSyms && ESym == (*DotDynSymSecSyms).begin())
586
4
    Result |= SymbolRef::SF_FormatSpecific;
587
29.1k
588
29.1k
  if (EF.getHeader()->e_machine == ELF::EM_ARM) {
589
0
    if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
590
0
      StringRef Name = *NameOrErr;
591
0
      if (Name.startswith("$d") || Name.startswith("$t") ||
592
0
          Name.startswith("$a"))
593
0
        Result |= SymbolRef::SF_FormatSpecific;
594
0
    } else {
595
0
      // TODO: Actually report errors helpfully.
596
0
      consumeError(NameOrErr.takeError());
597
0
    }
598
0
    if (ESym->getType() == ELF::STT_FUNC && (ESym->st_value & 1) == 1)
599
0
      Result |= SymbolRef::SF_Thumb;
600
0
  }
601
29.1k
602
29.1k
  if (ESym->st_shndx == ELF::SHN_UNDEF)
603
2.17k
    Result |= SymbolRef::SF_Undefined;
604
29.1k
605
29.1k
  if (ESym->getType() == ELF::STT_COMMON || ESym->st_shndx == ELF::SHN_COMMON)
606
64
    Result |= SymbolRef::SF_Common;
607
29.1k
608
29.1k
  if (isExportedToOtherDSO(ESym))
609
7.79k
    Result |= SymbolRef::SF_Exported;
610
29.1k
611
29.1k
  if (ESym->getVisibility() == ELF::STV_HIDDEN)
612
8.96k
    Result |= SymbolRef::SF_Hidden;
613
29.1k
614
29.1k
  return Result;
615
29.1k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolFlags(llvm::object::DataRefImpl) const
Line
Count
Source
564
753
uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
565
753
  const Elf_Sym *ESym = getSymbol(Sym);
566
753
567
753
  uint32_t Result = SymbolRef::SF_None;
568
753
569
753
  if (ESym->getBinding() != ELF::STB_LOCAL)
570
270
    Result |= SymbolRef::SF_Global;
571
753
572
753
  if (ESym->getBinding() == ELF::STB_WEAK)
573
3
    Result |= SymbolRef::SF_Weak;
574
753
575
753
  if (ESym->st_shndx == ELF::SHN_ABS)
576
32
    Result |= SymbolRef::SF_Absolute;
577
753
578
753
  if (ESym->getType() == ELF::STT_FILE || 
ESym->getType() == ELF::STT_SECTION722
)
579
114
    Result |= SymbolRef::SF_FormatSpecific;
580
753
581
753
  auto DotSymtabSecSyms = EF.symbols(DotSymtabSec);
582
753
  if (DotSymtabSecSyms && ESym == (*DotSymtabSecSyms).begin())
583
74
    Result |= SymbolRef::SF_FormatSpecific;
584
753
  auto DotDynSymSecSyms = EF.symbols(DotDynSymSec);
585
753
  if (DotDynSymSecSyms && ESym == (*DotDynSymSecSyms).begin())
586
0
    Result |= SymbolRef::SF_FormatSpecific;
587
753
588
753
  if (EF.getHeader()->e_machine == ELF::EM_ARM) {
589
0
    if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
590
0
      StringRef Name = *NameOrErr;
591
0
      if (Name.startswith("$d") || Name.startswith("$t") ||
592
0
          Name.startswith("$a"))
593
0
        Result |= SymbolRef::SF_FormatSpecific;
594
0
    } else {
595
0
      // TODO: Actually report errors helpfully.
596
0
      consumeError(NameOrErr.takeError());
597
0
    }
598
0
    if (ESym->getType() == ELF::STT_FUNC && (ESym->st_value & 1) == 1)
599
0
      Result |= SymbolRef::SF_Thumb;
600
0
  }
601
753
602
753
  if (ESym->st_shndx == ELF::SHN_UNDEF)
603
126
    Result |= SymbolRef::SF_Undefined;
604
753
605
753
  if (ESym->getType() == ELF::STT_COMMON || ESym->st_shndx == ELF::SHN_COMMON)
606
9
    Result |= SymbolRef::SF_Common;
607
753
608
753
  if (isExportedToOtherDSO(ESym))
609
270
    Result |= SymbolRef::SF_Exported;
610
753
611
753
  if (ESym->getVisibility() == ELF::STV_HIDDEN)
612
68
    Result |= SymbolRef::SF_Hidden;
613
753
614
753
  return Result;
615
753
}
616
617
template <class ELFT>
618
Expected<section_iterator>
619
ELFObjectFile<ELFT>::getSymbolSection(const Elf_Sym *ESym,
620
12.7k
                                      const Elf_Shdr *SymTab) const {
621
12.7k
  auto ESecOrErr = EF.getSection(ESym, SymTab, ShndxTable);
622
12.7k
  if (!ESecOrErr)
623
0
    return ESecOrErr.takeError();
624
12.7k
625
12.7k
  const Elf_Shdr *ESec = *ESecOrErr;
626
12.7k
  if (!ESec)
627
934
    return section_end();
628
11.8k
629
11.8k
  DataRefImpl Sec;
630
11.8k
  Sec.p = reinterpret_cast<intptr_t>(ESec);
631
11.8k
  return section_iterator(SectionRef(Sec, this));
632
11.8k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolSection(llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*, llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*) const
Line
Count
Source
620
7.38k
                                      const Elf_Shdr *SymTab) const {
621
7.38k
  auto ESecOrErr = EF.getSection(ESym, SymTab, ShndxTable);
622
7.38k
  if (!ESecOrErr)
623
0
    return ESecOrErr.takeError();
624
7.38k
625
7.38k
  const Elf_Shdr *ESec = *ESecOrErr;
626
7.38k
  if (!ESec)
627
382
    return section_end();
628
6.99k
629
6.99k
  DataRefImpl Sec;
630
6.99k
  Sec.p = reinterpret_cast<intptr_t>(ESec);
631
6.99k
  return section_iterator(SectionRef(Sec, this));
632
6.99k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolSection(llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*, llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*) const
Line
Count
Source
620
651
                                      const Elf_Shdr *SymTab) const {
621
651
  auto ESecOrErr = EF.getSection(ESym, SymTab, ShndxTable);
622
651
  if (!ESecOrErr)
623
0
    return ESecOrErr.takeError();
624
651
625
651
  const Elf_Shdr *ESec = *ESecOrErr;
626
651
  if (!ESec)
627
95
    return section_end();
628
556
629
556
  DataRefImpl Sec;
630
556
  Sec.p = reinterpret_cast<intptr_t>(ESec);
631
556
  return section_iterator(SectionRef(Sec, this));
632
556
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolSection(llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*, llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*) const
Line
Count
Source
620
4.35k
                                      const Elf_Shdr *SymTab) const {
621
4.35k
  auto ESecOrErr = EF.getSection(ESym, SymTab, ShndxTable);
622
4.35k
  if (!ESecOrErr)
623
0
    return ESecOrErr.takeError();
624
4.35k
625
4.35k
  const Elf_Shdr *ESec = *ESecOrErr;
626
4.35k
  if (!ESec)
627
410
    return section_end();
628
3.94k
629
3.94k
  DataRefImpl Sec;
630
3.94k
  Sec.p = reinterpret_cast<intptr_t>(ESec);
631
3.94k
  return section_iterator(SectionRef(Sec, this));
632
3.94k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolSection(llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*, llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*) const
Line
Count
Source
620
372
                                      const Elf_Shdr *SymTab) const {
621
372
  auto ESecOrErr = EF.getSection(ESym, SymTab, ShndxTable);
622
372
  if (!ESecOrErr)
623
0
    return ESecOrErr.takeError();
624
372
625
372
  const Elf_Shdr *ESec = *ESecOrErr;
626
372
  if (!ESec)
627
47
    return section_end();
628
325
629
325
  DataRefImpl Sec;
630
325
  Sec.p = reinterpret_cast<intptr_t>(ESec);
631
325
  return section_iterator(SectionRef(Sec, this));
632
325
}
633
634
template <class ELFT>
635
Expected<section_iterator>
636
12.7k
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb) const {
637
12.7k
  const Elf_Sym *Sym = getSymbol(Symb);
638
12.7k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
639
12.7k
  if (!SymTabOrErr)
640
0
    return SymTabOrErr.takeError();
641
12.7k
  const Elf_Shdr *SymTab = *SymTabOrErr;
642
12.7k
  return getSymbolSection(Sym, SymTab);
643
12.7k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolSection(llvm::object::DataRefImpl) const
Line
Count
Source
636
7.38k
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb) const {
637
7.38k
  const Elf_Sym *Sym = getSymbol(Symb);
638
7.38k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
639
7.38k
  if (!SymTabOrErr)
640
0
    return SymTabOrErr.takeError();
641
7.38k
  const Elf_Shdr *SymTab = *SymTabOrErr;
642
7.38k
  return getSymbolSection(Sym, SymTab);
643
7.38k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolSection(llvm::object::DataRefImpl) const
Line
Count
Source
636
651
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb) const {
637
651
  const Elf_Sym *Sym = getSymbol(Symb);
638
651
  auto SymTabOrErr = EF.getSection(Symb.d.a);
639
651
  if (!SymTabOrErr)
640
0
    return SymTabOrErr.takeError();
641
651
  const Elf_Shdr *SymTab = *SymTabOrErr;
642
651
  return getSymbolSection(Sym, SymTab);
643
651
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolSection(llvm::object::DataRefImpl) const
Line
Count
Source
636
4.35k
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb) const {
637
4.35k
  const Elf_Sym *Sym = getSymbol(Symb);
638
4.35k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
639
4.35k
  if (!SymTabOrErr)
640
0
    return SymTabOrErr.takeError();
641
4.35k
  const Elf_Shdr *SymTab = *SymTabOrErr;
642
4.35k
  return getSymbolSection(Sym, SymTab);
643
4.35k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolSection(llvm::object::DataRefImpl) const
Line
Count
Source
636
372
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb) const {
637
372
  const Elf_Sym *Sym = getSymbol(Symb);
638
372
  auto SymTabOrErr = EF.getSection(Symb.d.a);
639
372
  if (!SymTabOrErr)
640
0
    return SymTabOrErr.takeError();
641
372
  const Elf_Shdr *SymTab = *SymTabOrErr;
642
372
  return getSymbolSection(Sym, SymTab);
643
372
}
644
645
template <class ELFT>
646
176k
void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {
647
176k
  const Elf_Shdr *ESec = getSection(Sec);
648
176k
  Sec = toDRI(++ESec);
649
176k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::moveSectionNext(llvm::object::DataRefImpl&) const
Line
Count
Source
646
10.5k
void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {
647
10.5k
  const Elf_Shdr *ESec = getSection(Sec);
648
10.5k
  Sec = toDRI(++ESec);
649
10.5k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::moveSectionNext(llvm::object::DataRefImpl&) const
Line
Count
Source
646
3.43k
void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {
647
3.43k
  const Elf_Shdr *ESec = getSection(Sec);
648
3.43k
  Sec = toDRI(++ESec);
649
3.43k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::moveSectionNext(llvm::object::DataRefImpl&) const
Line
Count
Source
646
160k
void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {
647
160k
  const Elf_Shdr *ESec = getSection(Sec);
648
160k
  Sec = toDRI(++ESec);
649
160k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::moveSectionNext(llvm::object::DataRefImpl&) const
Line
Count
Source
646
2.27k
void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {
647
2.27k
  const Elf_Shdr *ESec = getSection(Sec);
648
2.27k
  Sec = toDRI(++ESec);
649
2.27k
}
650
651
template <class ELFT>
652
std::error_code ELFObjectFile<ELFT>::getSectionName(DataRefImpl Sec,
653
159k
                                                    StringRef &Result) const {
654
159k
  auto Name = EF.getSectionName(&*getSection(Sec));
655
159k
  if (!Name)
656
32
    return errorToErrorCode(Name.takeError());
657
159k
  Result = *Name;
658
159k
  return std::error_code();
659
159k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionName(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
653
3.24k
                                                    StringRef &Result) const {
654
3.24k
  auto Name = EF.getSectionName(&*getSection(Sec));
655
3.24k
  if (!Name)
656
28
    return errorToErrorCode(Name.takeError());
657
3.21k
  Result = *Name;
658
3.21k
  return std::error_code();
659
3.21k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionName(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
653
1.07k
                                                    StringRef &Result) const {
654
1.07k
  auto Name = EF.getSectionName(&*getSection(Sec));
655
1.07k
  if (!Name)
656
0
    return errorToErrorCode(Name.takeError());
657
1.07k
  Result = *Name;
658
1.07k
  return std::error_code();
659
1.07k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionName(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
653
154k
                                                    StringRef &Result) const {
654
154k
  auto Name = EF.getSectionName(&*getSection(Sec));
655
154k
  if (!Name)
656
4
    return errorToErrorCode(Name.takeError());
657
154k
  Result = *Name;
658
154k
  return std::error_code();
659
154k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionName(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
653
1.12k
                                                    StringRef &Result) const {
654
1.12k
  auto Name = EF.getSectionName(&*getSection(Sec));
655
1.12k
  if (!Name)
656
0
    return errorToErrorCode(Name.takeError());
657
1.12k
  Result = *Name;
658
1.12k
  return std::error_code();
659
1.12k
}
660
661
template <class ELFT>
662
13.9k
uint64_t ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec) const {
663
13.9k
  return getSection(Sec)->sh_addr;
664
13.9k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionAddress(llvm::object::DataRefImpl) const
Line
Count
Source
662
3.88k
uint64_t ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec) const {
663
3.88k
  return getSection(Sec)->sh_addr;
664
3.88k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionAddress(llvm::object::DataRefImpl) const
Line
Count
Source
662
1.27k
uint64_t ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec) const {
663
1.27k
  return getSection(Sec)->sh_addr;
664
1.27k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionAddress(llvm::object::DataRefImpl) const
Line
Count
Source
662
7.88k
uint64_t ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec) const {
663
7.88k
  return getSection(Sec)->sh_addr;
664
7.88k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionAddress(llvm::object::DataRefImpl) const
Line
Count
Source
662
921
uint64_t ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec) const {
663
921
  return getSection(Sec)->sh_addr;
664
921
}
665
666
template <class ELFT>
667
2.89k
uint64_t ELFObjectFile<ELFT>::getSectionIndex(DataRefImpl Sec) const {
668
2.89k
  auto SectionsOrErr = EF.sections();
669
2.89k
  handleAllErrors(std::move(SectionsOrErr.takeError()),
670
2.89k
                  [](const ErrorInfoBase &) {
671
0
                    llvm_unreachable("unable to get section index");
672
0
                  });
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionIndex(llvm::object::DataRefImpl) const::'lambda'(llvm::ErrorInfoBase const&)::operator()(llvm::ErrorInfoBase const&) const
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionIndex(llvm::object::DataRefImpl) const::'lambda'(llvm::ErrorInfoBase const&)::operator()(llvm::ErrorInfoBase const&) const
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionIndex(llvm::object::DataRefImpl) const::'lambda'(llvm::ErrorInfoBase const&)::operator()(llvm::ErrorInfoBase const&) const
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionIndex(llvm::object::DataRefImpl) const::'lambda'(llvm::ErrorInfoBase const&)::operator()(llvm::ErrorInfoBase const&) const
673
2.89k
  const Elf_Shdr *First = SectionsOrErr->begin();
674
2.89k
  return getSection(Sec) - First;
675
2.89k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionIndex(llvm::object::DataRefImpl) const
Line
Count
Source
667
288
uint64_t ELFObjectFile<ELFT>::getSectionIndex(DataRefImpl Sec) const {
668
288
  auto SectionsOrErr = EF.sections();
669
288
  handleAllErrors(std::move(SectionsOrErr.takeError()),
670
288
                  [](const ErrorInfoBase &) {
671
288
                    llvm_unreachable("unable to get section index");
672
288
                  });
673
288
  const Elf_Shdr *First = SectionsOrErr->begin();
674
288
  return getSection(Sec) - First;
675
288
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionIndex(llvm::object::DataRefImpl) const
Line
Count
Source
667
101
uint64_t ELFObjectFile<ELFT>::getSectionIndex(DataRefImpl Sec) const {
668
101
  auto SectionsOrErr = EF.sections();
669
101
  handleAllErrors(std::move(SectionsOrErr.takeError()),
670
101
                  [](const ErrorInfoBase &) {
671
101
                    llvm_unreachable("unable to get section index");
672
101
                  });
673
101
  const Elf_Shdr *First = SectionsOrErr->begin();
674
101
  return getSection(Sec) - First;
675
101
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionIndex(llvm::object::DataRefImpl) const
Line
Count
Source
667
2.37k
uint64_t ELFObjectFile<ELFT>::getSectionIndex(DataRefImpl Sec) const {
668
2.37k
  auto SectionsOrErr = EF.sections();
669
2.37k
  handleAllErrors(std::move(SectionsOrErr.takeError()),
670
2.37k
                  [](const ErrorInfoBase &) {
671
2.37k
                    llvm_unreachable("unable to get section index");
672
2.37k
                  });
673
2.37k
  const Elf_Shdr *First = SectionsOrErr->begin();
674
2.37k
  return getSection(Sec) - First;
675
2.37k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionIndex(llvm::object::DataRefImpl) const
Line
Count
Source
667
128
uint64_t ELFObjectFile<ELFT>::getSectionIndex(DataRefImpl Sec) const {
668
128
  auto SectionsOrErr = EF.sections();
669
128
  handleAllErrors(std::move(SectionsOrErr.takeError()),
670
128
                  [](const ErrorInfoBase &) {
671
128
                    llvm_unreachable("unable to get section index");
672
128
                  });
673
128
  const Elf_Shdr *First = SectionsOrErr->begin();
674
128
  return getSection(Sec) - First;
675
128
}
676
677
template <class ELFT>
678
195k
uint64_t ELFObjectFile<ELFT>::getSectionSize(DataRefImpl Sec) const {
679
195k
  return getSection(Sec)->sh_size;
680
195k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionSize(llvm::object::DataRefImpl) const
Line
Count
Source
678
1.13k
uint64_t ELFObjectFile<ELFT>::getSectionSize(DataRefImpl Sec) const {
679
1.13k
  return getSection(Sec)->sh_size;
680
1.13k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionSize(llvm::object::DataRefImpl) const
Line
Count
Source
678
425
uint64_t ELFObjectFile<ELFT>::getSectionSize(DataRefImpl Sec) const {
679
425
  return getSection(Sec)->sh_size;
680
425
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionSize(llvm::object::DataRefImpl) const
Line
Count
Source
678
193k
uint64_t ELFObjectFile<ELFT>::getSectionSize(DataRefImpl Sec) const {
679
193k
  return getSection(Sec)->sh_size;
680
193k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionSize(llvm::object::DataRefImpl) const
Line
Count
Source
678
455
uint64_t ELFObjectFile<ELFT>::getSectionSize(DataRefImpl Sec) const {
679
455
  return getSection(Sec)->sh_size;
680
455
}
681
682
template <class ELFT>
683
std::error_code
684
ELFObjectFile<ELFT>::getSectionContents(DataRefImpl Sec,
685
11.9k
                                        StringRef &Result) const {
686
11.9k
  const Elf_Shdr *EShdr = getSection(Sec);
687
11.9k
  if (std::error_code EC =
688
16
          checkOffset(getMemoryBufferRef(),
689
16
                      (uintptr_t)base() + EShdr->sh_offset, EShdr->sh_size))
690
16
    return EC;
691
11.9k
  Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
692
11.9k
  return std::error_code();
693
11.9k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionContents(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
685
1.58k
                                        StringRef &Result) const {
686
1.58k
  const Elf_Shdr *EShdr = getSection(Sec);
687
1.58k
  if (std::error_code EC =
688
16
          checkOffset(getMemoryBufferRef(),
689
16
                      (uintptr_t)base() + EShdr->sh_offset, EShdr->sh_size))
690
16
    return EC;
691
1.57k
  Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
692
1.57k
  return std::error_code();
693
1.57k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionContents(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
685
541
                                        StringRef &Result) const {
686
541
  const Elf_Shdr *EShdr = getSection(Sec);
687
541
  if (std::error_code EC =
688
0
          checkOffset(getMemoryBufferRef(),
689
0
                      (uintptr_t)base() + EShdr->sh_offset, EShdr->sh_size))
690
0
    return EC;
691
541
  Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
692
541
  return std::error_code();
693
541
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionContents(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
685
9.21k
                                        StringRef &Result) const {
686
9.21k
  const Elf_Shdr *EShdr = getSection(Sec);
687
9.21k
  if (std::error_code EC =
688
0
          checkOffset(getMemoryBufferRef(),
689
0
                      (uintptr_t)base() + EShdr->sh_offset, EShdr->sh_size))
690
0
    return EC;
691
9.21k
  Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
692
9.21k
  return std::error_code();
693
9.21k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionContents(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
685
586
                                        StringRef &Result) const {
686
586
  const Elf_Shdr *EShdr = getSection(Sec);
687
586
  if (std::error_code EC =
688
0
          checkOffset(getMemoryBufferRef(),
689
0
                      (uintptr_t)base() + EShdr->sh_offset, EShdr->sh_size))
690
0
    return EC;
691
586
  Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
692
586
  return std::error_code();
693
586
}
694
695
template <class ELFT>
696
294
uint64_t ELFObjectFile<ELFT>::getSectionAlignment(DataRefImpl Sec) const {
697
294
  return getSection(Sec)->sh_addralign;
698
294
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
696
36
uint64_t ELFObjectFile<ELFT>::getSectionAlignment(DataRefImpl Sec) const {
697
36
  return getSection(Sec)->sh_addralign;
698
36
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
696
34
uint64_t ELFObjectFile<ELFT>::getSectionAlignment(DataRefImpl Sec) const {
697
34
  return getSection(Sec)->sh_addralign;
698
34
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
696
180
uint64_t ELFObjectFile<ELFT>::getSectionAlignment(DataRefImpl Sec) const {
697
180
  return getSection(Sec)->sh_addralign;
698
180
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
696
44
uint64_t ELFObjectFile<ELFT>::getSectionAlignment(DataRefImpl Sec) const {
697
44
  return getSection(Sec)->sh_addralign;
698
44
}
699
700
template <class ELFT>
701
7.92k
bool ELFObjectFile<ELFT>::isSectionCompressed(DataRefImpl Sec) const {
702
7.92k
  return getSection(Sec)->sh_flags & ELF::SHF_COMPRESSED;
703
7.92k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isSectionCompressed(llvm::object::DataRefImpl) const
Line
Count
Source
701
601
bool ELFObjectFile<ELFT>::isSectionCompressed(DataRefImpl Sec) const {
702
601
  return getSection(Sec)->sh_flags & ELF::SHF_COMPRESSED;
703
601
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isSectionCompressed(llvm::object::DataRefImpl) const
Line
Count
Source
701
210
bool ELFObjectFile<ELFT>::isSectionCompressed(DataRefImpl Sec) const {
702
210
  return getSection(Sec)->sh_flags & ELF::SHF_COMPRESSED;
703
210
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isSectionCompressed(llvm::object::DataRefImpl) const
Line
Count
Source
701
6.84k
bool ELFObjectFile<ELFT>::isSectionCompressed(DataRefImpl Sec) const {
702
6.84k
  return getSection(Sec)->sh_flags & ELF::SHF_COMPRESSED;
703
6.84k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isSectionCompressed(llvm::object::DataRefImpl) const
Line
Count
Source
701
269
bool ELFObjectFile<ELFT>::isSectionCompressed(DataRefImpl Sec) const {
702
269
  return getSection(Sec)->sh_flags & ELF::SHF_COMPRESSED;
703
269
}
704
705
template <class ELFT>
706
11.1k
bool ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec) const {
707
11.1k
  return getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR;
708
11.1k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isSectionText(llvm::object::DataRefImpl) const
Line
Count
Source
706
3.22k
bool ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec) const {
707
3.22k
  return getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR;
708
3.22k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isSectionText(llvm::object::DataRefImpl) const
Line
Count
Source
706
989
bool ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec) const {
707
989
  return getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR;
708
989
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isSectionText(llvm::object::DataRefImpl) const
Line
Count
Source
706
6.32k
bool ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec) const {
707
6.32k
  return getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR;
708
6.32k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isSectionText(llvm::object::DataRefImpl) const
Line
Count
Source
706
606
bool ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec) const {
707
606
  return getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR;
708
606
}
709
710
template <class ELFT>
711
1.31k
bool ELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec) const {
712
1.31k
  const Elf_Shdr *EShdr = getSection(Sec);
713
1.31k
  return EShdr->sh_type == ELF::SHT_PROGBITS &&
714
1.31k
         
EShdr->sh_flags & ELF::SHF_ALLOC526
&&
715
1.31k
         
!(EShdr->sh_flags & ELF::SHF_EXECINSTR)338
;
716
1.31k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isSectionData(llvm::object::DataRefImpl) const
Line
Count
Source
711
56
bool ELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec) const {
712
56
  const Elf_Shdr *EShdr = getSection(Sec);
713
56
  return EShdr->sh_type == ELF::SHT_PROGBITS &&
714
56
         
EShdr->sh_flags & ELF::SHF_ALLOC19
&&
715
56
         
!(EShdr->sh_flags & ELF::SHF_EXECINSTR)14
;
716
56
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isSectionData(llvm::object::DataRefImpl) const
Line
Count
Source
711
26
bool ELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec) const {
712
26
  const Elf_Shdr *EShdr = getSection(Sec);
713
26
  return EShdr->sh_type == ELF::SHT_PROGBITS &&
714
26
         
EShdr->sh_flags & ELF::SHF_ALLOC8
&&
715
26
         
!(EShdr->sh_flags & ELF::SHF_EXECINSTR)6
;
716
26
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isSectionData(llvm::object::DataRefImpl) const
Line
Count
Source
711
1.15k
bool ELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec) const {
712
1.15k
  const Elf_Shdr *EShdr = getSection(Sec);
713
1.15k
  return EShdr->sh_type == ELF::SHT_PROGBITS &&
714
1.15k
         
EShdr->sh_flags & ELF::SHF_ALLOC479
&&
715
1.15k
         
!(EShdr->sh_flags & ELF::SHF_EXECINSTR)303
;
716
1.15k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isSectionData(llvm::object::DataRefImpl) const
Line
Count
Source
711
76
bool ELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec) const {
712
76
  const Elf_Shdr *EShdr = getSection(Sec);
713
76
  return EShdr->sh_type == ELF::SHT_PROGBITS &&
714
76
         
EShdr->sh_flags & ELF::SHF_ALLOC20
&&
715
76
         
!(EShdr->sh_flags & ELF::SHF_EXECINSTR)15
;
716
76
}
717
718
template <class ELFT>
719
11.2k
bool ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec) const {
720
11.2k
  const Elf_Shdr *EShdr = getSection(Sec);
721
11.2k
  return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
722
11.2k
         
EShdr->sh_type == ELF::SHT_NOBITS3.56k
;
723
11.2k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isSectionBSS(llvm::object::DataRefImpl) const
Line
Count
Source
719
1.13k
bool ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec) const {
720
1.13k
  const Elf_Shdr *EShdr = getSection(Sec);
721
1.13k
  return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
722
1.13k
         
EShdr->sh_type == ELF::SHT_NOBITS422
;
723
1.13k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isSectionBSS(llvm::object::DataRefImpl) const
Line
Count
Source
719
474
bool ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec) const {
720
474
  const Elf_Shdr *EShdr = getSection(Sec);
721
474
  return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
722
474
         
EShdr->sh_type == ELF::SHT_NOBITS212
;
723
474
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isSectionBSS(llvm::object::DataRefImpl) const
Line
Count
Source
719
9.25k
bool ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec) const {
720
9.25k
  const Elf_Shdr *EShdr = getSection(Sec);
721
9.25k
  return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
722
9.25k
         
EShdr->sh_type == ELF::SHT_NOBITS2.76k
;
723
9.25k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isSectionBSS(llvm::object::DataRefImpl) const
Line
Count
Source
719
430
bool ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec) const {
720
430
  const Elf_Shdr *EShdr = getSection(Sec);
721
430
  return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
722
430
         
EShdr->sh_type == ELF::SHT_NOBITS166
;
723
430
}
724
725
template <class ELFT>
726
std::vector<SectionRef>
727
0
ELFObjectFile<ELFT>::dynamic_relocation_sections() const {
728
0
  std::vector<SectionRef> Res;
729
0
  std::vector<uintptr_t> Offsets;
730
0
731
0
  auto SectionsOrErr = EF.sections();
732
0
  if (!SectionsOrErr)
733
0
    return Res;
734
0
735
0
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
736
0
    if (Sec.sh_type != ELF::SHT_DYNAMIC)
737
0
      continue;
738
0
    Elf_Dyn *Dynamic =
739
0
        reinterpret_cast<Elf_Dyn *>((uintptr_t)base() + Sec.sh_offset);
740
0
    for (; Dynamic->d_tag != ELF::DT_NULL; Dynamic++) {
741
0
      if (Dynamic->d_tag == ELF::DT_REL || Dynamic->d_tag == ELF::DT_RELA ||
742
0
          Dynamic->d_tag == ELF::DT_JMPREL) {
743
0
        Offsets.push_back(Dynamic->d_un.d_val);
744
0
      }
745
0
    }
746
0
  }
747
0
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
748
0
    if (is_contained(Offsets, Sec.sh_offset))
749
0
      Res.emplace_back(toDRI(&Sec), this);
750
0
  }
751
0
  return Res;
752
0
}
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::dynamic_relocation_sections() const
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::dynamic_relocation_sections() const
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::dynamic_relocation_sections() const
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::dynamic_relocation_sections() const
753
754
template <class ELFT>
755
13.7k
bool ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec) const {
756
13.7k
  return getSection(Sec)->sh_type == ELF::SHT_NOBITS;
757
13.7k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isSectionVirtual(llvm::object::DataRefImpl) const
Line
Count
Source
755
2.95k
bool ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec) const {
756
2.95k
  return getSection(Sec)->sh_type == ELF::SHT_NOBITS;
757
2.95k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isSectionVirtual(llvm::object::DataRefImpl) const
Line
Count
Source
755
528
bool ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec) const {
756
528
  return getSection(Sec)->sh_type == ELF::SHT_NOBITS;
757
528
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isSectionVirtual(llvm::object::DataRefImpl) const
Line
Count
Source
755
9.67k
bool ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec) const {
756
9.67k
  return getSection(Sec)->sh_type == ELF::SHT_NOBITS;
757
9.67k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isSectionVirtual(llvm::object::DataRefImpl) const
Line
Count
Source
755
586
bool ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec) const {
756
586
  return getSection(Sec)->sh_type == ELF::SHT_NOBITS;
757
586
}
758
759
template <class ELFT>
760
relocation_iterator
761
3.79k
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
762
3.79k
  DataRefImpl RelData;
763
3.79k
  auto SectionsOrErr = EF.sections();
764
3.79k
  if (!SectionsOrErr)
765
0
    return relocation_iterator(RelocationRef());
766
3.79k
  uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
767
3.79k
  RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
768
3.79k
  RelData.d.b = 0;
769
3.79k
  return relocation_iterator(RelocationRef(RelData, this));
770
3.79k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::section_rel_begin(llvm::object::DataRefImpl) const
Line
Count
Source
761
718
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
762
718
  DataRefImpl RelData;
763
718
  auto SectionsOrErr = EF.sections();
764
718
  if (!SectionsOrErr)
765
0
    return relocation_iterator(RelocationRef());
766
718
  uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
767
718
  RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
768
718
  RelData.d.b = 0;
769
718
  return relocation_iterator(RelocationRef(RelData, this));
770
718
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::section_rel_begin(llvm::object::DataRefImpl) const
Line
Count
Source
761
156
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
762
156
  DataRefImpl RelData;
763
156
  auto SectionsOrErr = EF.sections();
764
156
  if (!SectionsOrErr)
765
0
    return relocation_iterator(RelocationRef());
766
156
  uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
767
156
  RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
768
156
  RelData.d.b = 0;
769
156
  return relocation_iterator(RelocationRef(RelData, this));
770
156
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::section_rel_begin(llvm::object::DataRefImpl) const
Line
Count
Source
761
2.74k
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
762
2.74k
  DataRefImpl RelData;
763
2.74k
  auto SectionsOrErr = EF.sections();
764
2.74k
  if (!SectionsOrErr)
765
0
    return relocation_iterator(RelocationRef());
766
2.74k
  uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
767
2.74k
  RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
768
2.74k
  RelData.d.b = 0;
769
2.74k
  return relocation_iterator(RelocationRef(RelData, this));
770
2.74k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::section_rel_begin(llvm::object::DataRefImpl) const
Line
Count
Source
761
168
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
762
168
  DataRefImpl RelData;
763
168
  auto SectionsOrErr = EF.sections();
764
168
  if (!SectionsOrErr)
765
0
    return relocation_iterator(RelocationRef());
766
168
  uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
767
168
  RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
768
168
  RelData.d.b = 0;
769
168
  return relocation_iterator(RelocationRef(RelData, this));
770
168
}
771
772
template <class ELFT>
773
relocation_iterator
774
1.89k
ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
775
1.89k
  const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
776
1.89k
  relocation_iterator Begin = section_rel_begin(Sec);
777
1.89k
  if (S->sh_type != ELF::SHT_RELA && 
S->sh_type != ELF::SHT_REL601
)
778
357
    return Begin;
779
1.53k
  DataRefImpl RelData = Begin->getRawDataRefImpl();
780
1.53k
  const Elf_Shdr *RelSec = getRelSection(RelData);
781
1.53k
782
1.53k
  // Error check sh_link here so that getRelocationSymbol can just use it.
783
1.53k
  auto SymSecOrErr = EF.getSection(RelSec->sh_link);
784
1.53k
  if (!SymSecOrErr)
785
0
    report_fatal_error(errorToErrorCode(SymSecOrErr.takeError()).message());
786
1.53k
787
1.53k
  RelData.d.b += S->sh_size / S->sh_entsize;
788
1.53k
  return relocation_iterator(RelocationRef(RelData, this));
789
1.53k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::section_rel_end(llvm::object::DataRefImpl) const
Line
Count
Source
774
359
ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
775
359
  const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
776
359
  relocation_iterator Begin = section_rel_begin(Sec);
777
359
  if (S->sh_type != ELF::SHT_RELA && 
S->sh_type != ELF::SHT_REL318
)
778
131
    return Begin;
779
228
  DataRefImpl RelData = Begin->getRawDataRefImpl();
780
228
  const Elf_Shdr *RelSec = getRelSection(RelData);
781
228
782
228
  // Error check sh_link here so that getRelocationSymbol can just use it.
783
228
  auto SymSecOrErr = EF.getSection(RelSec->sh_link);
784
228
  if (!SymSecOrErr)
785
0
    report_fatal_error(errorToErrorCode(SymSecOrErr.takeError()).message());
786
228
787
228
  RelData.d.b += S->sh_size / S->sh_entsize;
788
228
  return relocation_iterator(RelocationRef(RelData, this));
789
228
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::section_rel_end(llvm::object::DataRefImpl) const
Line
Count
Source
774
78
ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
775
78
  const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
776
78
  relocation_iterator Begin = section_rel_begin(Sec);
777
78
  if (S->sh_type != ELF::SHT_RELA && 
S->sh_type != ELF::SHT_REL55
)
778
12
    return Begin;
779
66
  DataRefImpl RelData = Begin->getRawDataRefImpl();
780
66
  const Elf_Shdr *RelSec = getRelSection(RelData);
781
66
782
66
  // Error check sh_link here so that getRelocationSymbol can just use it.
783
66
  auto SymSecOrErr = EF.getSection(RelSec->sh_link);
784
66
  if (!SymSecOrErr)
785
0
    report_fatal_error(errorToErrorCode(SymSecOrErr.takeError()).message());
786
66
787
66
  RelData.d.b += S->sh_size / S->sh_entsize;
788
66
  return relocation_iterator(RelocationRef(RelData, this));
789
66
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::section_rel_end(llvm::object::DataRefImpl) const
Line
Count
Source
774
1.37k
ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
775
1.37k
  const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
776
1.37k
  relocation_iterator Begin = section_rel_begin(Sec);
777
1.37k
  if (S->sh_type != ELF::SHT_RELA && 
S->sh_type != ELF::SHT_REL212
)
778
202
    return Begin;
779
1.17k
  DataRefImpl RelData = Begin->getRawDataRefImpl();
780
1.17k
  const Elf_Shdr *RelSec = getRelSection(RelData);
781
1.17k
782
1.17k
  // Error check sh_link here so that getRelocationSymbol can just use it.
783
1.17k
  auto SymSecOrErr = EF.getSection(RelSec->sh_link);
784
1.17k
  if (!SymSecOrErr)
785
0
    report_fatal_error(errorToErrorCode(SymSecOrErr.takeError()).message());
786
1.17k
787
1.17k
  RelData.d.b += S->sh_size / S->sh_entsize;
788
1.17k
  return relocation_iterator(RelocationRef(RelData, this));
789
1.17k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::section_rel_end(llvm::object::DataRefImpl) const
Line
Count
Source
774
84
ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
775
84
  const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
776
84
  relocation_iterator Begin = section_rel_begin(Sec);
777
84
  if (S->sh_type != ELF::SHT_RELA && 
S->sh_type != ELF::SHT_REL16
)
778
12
    return Begin;
779
72
  DataRefImpl RelData = Begin->getRawDataRefImpl();
780
72
  const Elf_Shdr *RelSec = getRelSection(RelData);
781
72
782
72
  // Error check sh_link here so that getRelocationSymbol can just use it.
783
72
  auto SymSecOrErr = EF.getSection(RelSec->sh_link);
784
72
  if (!SymSecOrErr)
785
0
    report_fatal_error(errorToErrorCode(SymSecOrErr.takeError()).message());
786
72
787
72
  RelData.d.b += S->sh_size / S->sh_entsize;
788
72
  return relocation_iterator(RelocationRef(RelData, this));
789
72
}
790
791
template <class ELFT>
792
section_iterator
793
19.2k
ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const {
794
19.2k
  if (EF.getHeader()->e_type != ELF::ET_REL)
795
6.62k
    return section_end();
796
12.5k
797
12.5k
  const Elf_Shdr *EShdr = getSection(Sec);
798
12.5k
  uintX_t Type = EShdr->sh_type;
799
12.5k
  if (Type != ELF::SHT_REL && 
Type != ELF::SHT_RELA12.2k
)
800
10.6k
    return section_end();
801
1.90k
802
1.90k
  auto R = EF.getSection(EShdr->sh_info);
803
1.90k
  if (!R)
804
0
    report_fatal_error(errorToErrorCode(R.takeError()).message());
805
1.90k
  return section_iterator(SectionRef(toDRI(*R), this));
806
1.90k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocatedSection(llvm::object::DataRefImpl) const
Line
Count
Source
793
3.68k
ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const {
794
3.68k
  if (EF.getHeader()->e_type != ELF::ET_REL)
795
1.55k
    return section_end();
796
2.12k
797
2.12k
  const Elf_Shdr *EShdr = getSection(Sec);
798
2.12k
  uintX_t Type = EShdr->sh_type;
799
2.12k
  if (Type != ELF::SHT_REL && 
Type != ELF::SHT_RELA1.90k
)
800
1.82k
    return section_end();
801
302
802
302
  auto R = EF.getSection(EShdr->sh_info);
803
302
  if (!R)
804
0
    report_fatal_error(errorToErrorCode(R.takeError()).message());
805
302
  return section_iterator(SectionRef(toDRI(*R), this));
806
302
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocatedSection(llvm::object::DataRefImpl) const
Line
Count
Source
793
1.35k
ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const {
794
1.35k
  if (EF.getHeader()->e_type != ELF::ET_REL)
795
591
    return section_end();
796
767
797
767
  const Elf_Shdr *EShdr = getSection(Sec);
798
767
  uintX_t Type = EShdr->sh_type;
799
767
  if (Type != ELF::SHT_REL && 
Type != ELF::SHT_RELA689
)
800
648
    return section_end();
801
119
802
119
  auto R = EF.getSection(EShdr->sh_info);
803
119
  if (!R)
804
0
    report_fatal_error(errorToErrorCode(R.takeError()).message());
805
119
  return section_iterator(SectionRef(toDRI(*R), this));
806
119
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocatedSection(llvm::object::DataRefImpl) const
Line
Count
Source
793
13.0k
ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const {
794
13.0k
  if (EF.getHeader()->e_type != ELF::ET_REL)
795
4.02k
    return section_end();
796
9.06k
797
9.06k
  const Elf_Shdr *EShdr = getSection(Sec);
798
9.06k
  uintX_t Type = EShdr->sh_type;
799
9.06k
  if (Type != ELF::SHT_REL && 
Type != ELF::SHT_RELA9.04k
)
800
7.69k
    return section_end();
801
1.37k
802
1.37k
  auto R = EF.getSection(EShdr->sh_info);
803
1.37k
  if (!R)
804
0
    report_fatal_error(errorToErrorCode(R.takeError()).message());
805
1.37k
  return section_iterator(SectionRef(toDRI(*R), this));
806
1.37k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocatedSection(llvm::object::DataRefImpl) const
Line
Count
Source
793
1.07k
ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const {
794
1.07k
  if (EF.getHeader()->e_type != ELF::ET_REL)
795
450
    return section_end();
796
624
797
624
  const Elf_Shdr *EShdr = getSection(Sec);
798
624
  uintX_t Type = EShdr->sh_type;
799
624
  if (Type != ELF::SHT_REL && 
Type != ELF::SHT_RELA617
)
800
510
    return section_end();
801
114
802
114
  auto R = EF.getSection(EShdr->sh_info);
803
114
  if (!R)
804
0
    report_fatal_error(errorToErrorCode(R.takeError()).message());
805
114
  return section_iterator(SectionRef(toDRI(*R), this));
806
114
}
807
808
// Relocations
809
template <class ELFT>
810
5.28k
void ELFObjectFile<ELFT>::moveRelocationNext(DataRefImpl &Rel) const {
811
5.28k
  ++Rel.d.b;
812
5.28k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::moveRelocationNext(llvm::object::DataRefImpl&) const
Line
Count
Source
810
656
void ELFObjectFile<ELFT>::moveRelocationNext(DataRefImpl &Rel) const {
811
656
  ++Rel.d.b;
812
656
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::moveRelocationNext(llvm::object::DataRefImpl&) const
Line
Count
Source
810
224
void ELFObjectFile<ELFT>::moveRelocationNext(DataRefImpl &Rel) const {
811
224
  ++Rel.d.b;
812
224
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::moveRelocationNext(llvm::object::DataRefImpl&) const
Line
Count
Source
810
4.18k
void ELFObjectFile<ELFT>::moveRelocationNext(DataRefImpl &Rel) const {
811
4.18k
  ++Rel.d.b;
812
4.18k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::moveRelocationNext(llvm::object::DataRefImpl&) const
Line
Count
Source
810
214
void ELFObjectFile<ELFT>::moveRelocationNext(DataRefImpl &Rel) const {
811
214
  ++Rel.d.b;
812
214
}
813
814
template <class ELFT>
815
symbol_iterator
816
4.87k
ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
817
4.87k
  uint32_t symbolIdx;
818
4.87k
  const Elf_Shdr *sec = getRelSection(Rel);
819
4.87k
  if (sec->sh_type == ELF::SHT_REL)
820
636
    symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL());
821
4.23k
  else
822
4.23k
    symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL());
823
4.87k
  if (!symbolIdx)
824
27
    return symbol_end();
825
4.84k
826
4.84k
  // FIXME: error check symbolIdx
827
4.84k
  DataRefImpl SymbolData;
828
4.84k
  SymbolData.d.a = sec->sh_link;
829
4.84k
  SymbolData.d.b = symbolIdx;
830
4.84k
  return symbol_iterator(SymbolRef(SymbolData, this));
831
4.84k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
816
623
ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
817
623
  uint32_t symbolIdx;
818
623
  const Elf_Shdr *sec = getRelSection(Rel);
819
623
  if (sec->sh_type == ELF::SHT_REL)
820
457
    symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL());
821
166
  else
822
166
    symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL());
823
623
  if (!symbolIdx)
824
0
    return symbol_end();
825
623
826
623
  // FIXME: error check symbolIdx
827
623
  DataRefImpl SymbolData;
828
623
  SymbolData.d.a = sec->sh_link;
829
623
  SymbolData.d.b = symbolIdx;
830
623
  return symbol_iterator(SymbolRef(SymbolData, this));
831
623
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
816
193
ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
817
193
  uint32_t symbolIdx;
818
193
  const Elf_Shdr *sec = getRelSection(Rel);
819
193
  if (sec->sh_type == ELF::SHT_REL)
820
143
    symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL());
821
50
  else
822
50
    symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL());
823
193
  if (!symbolIdx)
824
0
    return symbol_end();
825
193
826
193
  // FIXME: error check symbolIdx
827
193
  DataRefImpl SymbolData;
828
193
  SymbolData.d.a = sec->sh_link;
829
193
  SymbolData.d.b = symbolIdx;
830
193
  return symbol_iterator(SymbolRef(SymbolData, this));
831
193
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
816
3.88k
ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
817
3.88k
  uint32_t symbolIdx;
818
3.88k
  const Elf_Shdr *sec = getRelSection(Rel);
819
3.88k
  if (sec->sh_type == ELF::SHT_REL)
820
20
    symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL());
821
3.86k
  else
822
3.86k
    symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL());
823
3.88k
  if (!symbolIdx)
824
27
    return symbol_end();
825
3.85k
826
3.85k
  // FIXME: error check symbolIdx
827
3.85k
  DataRefImpl SymbolData;
828
3.85k
  SymbolData.d.a = sec->sh_link;
829
3.85k
  SymbolData.d.b = symbolIdx;
830
3.85k
  return symbol_iterator(SymbolRef(SymbolData, this));
831
3.85k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
816
174
ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
817
174
  uint32_t symbolIdx;
818
174
  const Elf_Shdr *sec = getRelSection(Rel);
819
174
  if (sec->sh_type == ELF::SHT_REL)
820
16
    symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL());
821
158
  else
822
158
    symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL());
823
174
  if (!symbolIdx)
824
0
    return symbol_end();
825
174
826
174
  // FIXME: error check symbolIdx
827
174
  DataRefImpl SymbolData;
828
174
  SymbolData.d.a = sec->sh_link;
829
174
  SymbolData.d.b = symbolIdx;
830
174
  return symbol_iterator(SymbolRef(SymbolData, this));
831
174
}
832
833
template <class ELFT>
834
5.38k
uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const {
835
5.38k
  const Elf_Shdr *sec = getRelSection(Rel);
836
5.38k
  if (sec->sh_type == ELF::SHT_REL)
837
891
    return getRel(Rel)->r_offset;
838
4.49k
839
4.49k
  return getRela(Rel)->r_offset;
840
4.49k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationOffset(llvm::object::DataRefImpl) const
Line
Count
Source
834
816
uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const {
835
816
  const Elf_Shdr *sec = getRelSection(Rel);
836
816
  if (sec->sh_type == ELF::SHT_REL)
837
601
    return getRel(Rel)->r_offset;
838
215
839
215
  return getRela(Rel)->r_offset;
840
215
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationOffset(llvm::object::DataRefImpl) const
Line
Count
Source
834
386
uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const {
835
386
  const Elf_Shdr *sec = getRelSection(Rel);
836
386
  if (sec->sh_type == ELF::SHT_REL)
837
237
    return getRel(Rel)->r_offset;
838
149
839
149
  return getRela(Rel)->r_offset;
840
149
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationOffset(llvm::object::DataRefImpl) const
Line
Count
Source
834
3.91k
uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const {
835
3.91k
  const Elf_Shdr *sec = getRelSection(Rel);
836
3.91k
  if (sec->sh_type == ELF::SHT_REL)
837
37
    return getRel(Rel)->r_offset;
838
3.87k
839
3.87k
  return getRela(Rel)->r_offset;
840
3.87k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationOffset(llvm::object::DataRefImpl) const
Line
Count
Source
834
277
uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const {
835
277
  const Elf_Shdr *sec = getRelSection(Rel);
836
277
  if (sec->sh_type == ELF::SHT_REL)
837
16
    return getRel(Rel)->r_offset;
838
261
839
261
  return getRela(Rel)->r_offset;
840
261
}
841
842
template <class ELFT>
843
5.12k
uint64_t ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel) const {
844
5.12k
  const Elf_Shdr *sec = getRelSection(Rel);
845
5.12k
  if (sec->sh_type == ELF::SHT_REL)
846
633
    return getRel(Rel)->getType(EF.isMips64EL());
847
4.49k
  else
848
4.49k
    return getRela(Rel)->getType(EF.isMips64EL());
849
5.12k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationType(llvm::object::DataRefImpl) const
Line
Count
Source
843
629
uint64_t ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel) const {
844
629
  const Elf_Shdr *sec = getRelSection(Rel);
845
629
  if (sec->sh_type == ELF::SHT_REL)
846
454
    return getRel(Rel)->getType(EF.isMips64EL());
847
175
  else
848
175
    return getRela(Rel)->getType(EF.isMips64EL());
849
629
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationType(llvm::object::DataRefImpl) const
Line
Count
Source
843
193
uint64_t ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel) const {
844
193
  const Elf_Shdr *sec = getRelSection(Rel);
845
193
  if (sec->sh_type == ELF::SHT_REL)
846
143
    return getRel(Rel)->getType(EF.isMips64EL());
847
50
  else
848
50
    return getRela(Rel)->getType(EF.isMips64EL());
849
193
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationType(llvm::object::DataRefImpl) const
Line
Count
Source
843
4.13k
uint64_t ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel) const {
844
4.13k
  const Elf_Shdr *sec = getRelSection(Rel);
845
4.13k
  if (sec->sh_type == ELF::SHT_REL)
846
20
    return getRel(Rel)->getType(EF.isMips64EL());
847
4.11k
  else
848
4.11k
    return getRela(Rel)->getType(EF.isMips64EL());
849
4.13k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationType(llvm::object::DataRefImpl) const
Line
Count
Source
843
174
uint64_t ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel) const {
844
174
  const Elf_Shdr *sec = getRelSection(Rel);
845
174
  if (sec->sh_type == ELF::SHT_REL)
846
16
    return getRel(Rel)->getType(EF.isMips64EL());
847
158
  else
848
158
    return getRela(Rel)->getType(EF.isMips64EL());
849
174
}
850
851
template <class ELFT>
852
StringRef ELFObjectFile<ELFT>::getRelocationTypeName(uint32_t Type) const {
853
  return getELFRelocationTypeName(EF.getHeader()->e_machine, Type);
854
}
855
856
template <class ELFT>
857
void ELFObjectFile<ELFT>::getRelocationTypeName(
858
761
    DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
859
761
  uint32_t type = getRelocationType(Rel);
860
761
  EF.getRelocationTypeName(type, Result);
861
761
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationTypeName(llvm::object::DataRefImpl, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
858
274
    DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
859
274
  uint32_t type = getRelocationType(Rel);
860
274
  EF.getRelocationTypeName(type, Result);
861
274
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationTypeName(llvm::object::DataRefImpl, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
858
55
    DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
859
55
  uint32_t type = getRelocationType(Rel);
860
55
  EF.getRelocationTypeName(type, Result);
861
55
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationTypeName(llvm::object::DataRefImpl, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
858
405
    DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
859
405
  uint32_t type = getRelocationType(Rel);
860
405
  EF.getRelocationTypeName(type, Result);
861
405
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationTypeName(llvm::object::DataRefImpl, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
858
27
    DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
859
27
  uint32_t type = getRelocationType(Rel);
860
27
  EF.getRelocationTypeName(type, Result);
861
27
}
862
863
template <class ELFT>
864
Expected<int64_t>
865
3.69k
ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel) const {
866
3.69k
  if (getRelSection(Rel)->sh_type != ELF::SHT_RELA)
867
41
    return createError("Section is not SHT_RELA");
868
3.65k
  return (int64_t)getRela(Rel)->r_addend;
869
3.65k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationAddend(llvm::object::DataRefImpl) const
Line
Count
Source
865
63
ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel) const {
866
63
  if (getRelSection(Rel)->sh_type != ELF::SHT_RELA)
867
21
    return createError("Section is not SHT_RELA");
868
42
  return (int64_t)getRela(Rel)->r_addend;
869
42
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationAddend(llvm::object::DataRefImpl) const
Line
Count
Source
865
43
ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel) const {
866
43
  if (getRelSection(Rel)->sh_type != ELF::SHT_RELA)
867
19
    return createError("Section is not SHT_RELA");
868
24
  return (int64_t)getRela(Rel)->r_addend;
869
24
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationAddend(llvm::object::DataRefImpl) const
Line
Count
Source
865
3.46k
ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel) const {
866
3.46k
  if (getRelSection(Rel)->sh_type != ELF::SHT_RELA)
867
1
    return createError("Section is not SHT_RELA");
868
3.45k
  return (int64_t)getRela(Rel)->r_addend;
869
3.45k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationAddend(llvm::object::DataRefImpl) const
Line
Count
Source
865
131
ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel) const {
866
131
  if (getRelSection(Rel)->sh_type != ELF::SHT_RELA)
867
0
    return createError("Section is not SHT_RELA");
868
131
  return (int64_t)getRela(Rel)->r_addend;
869
131
}
870
871
template <class ELFT>
872
const typename ELFObjectFile<ELFT>::Elf_Rel *
873
2.16k
ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const {
874
2.16k
  assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
875
2.16k
  auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
876
2.16k
  if (!Ret)
877
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
878
2.16k
  return *Ret;
879
2.16k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRel(llvm::object::DataRefImpl) const
Line
Count
Source
873
1.51k
ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const {
874
1.51k
  assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
875
1.51k
  auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
876
1.51k
  if (!Ret)
877
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
878
1.51k
  return *Ret;
879
1.51k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRel(llvm::object::DataRefImpl) const
Line
Count
Source
873
523
ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const {
874
523
  assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
875
523
  auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
876
523
  if (!Ret)
877
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
878
523
  return *Ret;
879
523
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRel(llvm::object::DataRefImpl) const
Line
Count
Source
873
77
ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const {
874
77
  assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
875
77
  auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
876
77
  if (!Ret)
877
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
878
77
  return *Ret;
879
77
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRel(llvm::object::DataRefImpl) const
Line
Count
Source
873
48
ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const {
874
48
  assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
875
48
  auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
876
48
  if (!Ret)
877
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
878
48
  return *Ret;
879
48
}
880
881
template <class ELFT>
882
const typename ELFObjectFile<ELFT>::Elf_Rela *
883
17.4k
ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
884
17.4k
  assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
885
17.4k
  auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
886
17.4k
  if (!Ret)
887
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
888
17.4k
  return *Ret;
889
17.4k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRela(llvm::object::DataRefImpl) const
Line
Count
Source
883
713
ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
884
713
  assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
885
713
  auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
886
713
  if (!Ret)
887
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
888
713
  return *Ret;
889
713
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRela(llvm::object::DataRefImpl) const
Line
Count
Source
883
299
ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
884
299
  assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
885
299
  auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
886
299
  if (!Ret)
887
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
888
299
  return *Ret;
889
299
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRela(llvm::object::DataRefImpl) const
Line
Count
Source
883
15.7k
ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
884
15.7k
  assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
885
15.7k
  auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
886
15.7k
  if (!Ret)
887
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
888
15.7k
  return *Ret;
889
15.7k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRela(llvm::object::DataRefImpl) const
Line
Count
Source
883
735
ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
884
735
  assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
885
735
  auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
886
735
  if (!Ret)
887
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
888
735
  return *Ret;
889
735
}
890
891
template <class ELFT>
892
Expected<ELFObjectFile<ELFT>>
893
4.96k
ELFObjectFile<ELFT>::create(MemoryBufferRef Object) {
894
4.96k
  auto EFOrErr = ELFFile<ELFT>::create(Object.getBuffer());
895
4.96k
  if (Error E = EFOrErr.takeError())
896
1
    return std::move(E);
897
4.95k
  auto EF = std::move(*EFOrErr);
898
4.95k
899
4.95k
  auto SectionsOrErr = EF.sections();
900
4.95k
  if (!SectionsOrErr)
901
3
    return SectionsOrErr.takeError();
902
4.95k
903
4.95k
  const Elf_Shdr *DotDynSymSec = nullptr;
904
4.95k
  const Elf_Shdr *DotSymtabSec = nullptr;
905
4.95k
  ArrayRef<Elf_Word> ShndxTable;
906
1.54M
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
907
1.54M
    switch (Sec.sh_type) {
908
1.54M
    case ELF::SHT_DYNSYM: {
909
1.00k
      if (DotDynSymSec)
910
0
        return createError("More than one dynamic symbol table!");
911
1.00k
      DotDynSymSec = &Sec;
912
1.00k
      break;
913
1.00k
    }
914
4.89k
    case ELF::SHT_SYMTAB: {
915
4.89k
      if (DotSymtabSec)
916
0
        return createError("More than one static symbol table!");
917
4.89k
      DotSymtabSec = &Sec;
918
4.89k
      break;
919
4.89k
    }
920
4.89k
    case ELF::SHT_SYMTAB_SHNDX: {
921
15
      auto TableOrErr = EF.getSHNDXTable(Sec);
922
15
      if (!TableOrErr)
923
1
        return TableOrErr.takeError();
924
14
      ShndxTable = *TableOrErr;
925
14
      break;
926
14
    }
927
1.54M
    }
928
1.54M
  }
929
4.95k
  return ELFObjectFile<ELFT>(Object, EF, DotDynSymSec, DotSymtabSec,
930
4.95k
                             ShndxTable);
931
4.95k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::create(llvm::MemoryBufferRef)
Line
Count
Source
893
1.06k
ELFObjectFile<ELFT>::create(MemoryBufferRef Object) {
894
1.06k
  auto EFOrErr = ELFFile<ELFT>::create(Object.getBuffer());
895
1.06k
  if (Error E = EFOrErr.takeError())
896
1
    return std::move(E);
897
1.06k
  auto EF = std::move(*EFOrErr);
898
1.06k
899
1.06k
  auto SectionsOrErr = EF.sections();
900
1.06k
  if (!SectionsOrErr)
901
0
    return SectionsOrErr.takeError();
902
1.06k
903
1.06k
  const Elf_Shdr *DotDynSymSec = nullptr;
904
1.06k
  const Elf_Shdr *DotSymtabSec = nullptr;
905
1.06k
  ArrayRef<Elf_Word> ShndxTable;
906
9.47k
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
907
9.47k
    switch (Sec.sh_type) {
908
9.47k
    case ELF::SHT_DYNSYM: {
909
178
      if (DotDynSymSec)
910
0
        return createError("More than one dynamic symbol table!");
911
178
      DotDynSymSec = &Sec;
912
178
      break;
913
178
    }
914
1.05k
    case ELF::SHT_SYMTAB: {
915
1.05k
      if (DotSymtabSec)
916
0
        return createError("More than one static symbol table!");
917
1.05k
      DotSymtabSec = &Sec;
918
1.05k
      break;
919
1.05k
    }
920
1.05k
    case ELF::SHT_SYMTAB_SHNDX: {
921
0
      auto TableOrErr = EF.getSHNDXTable(Sec);
922
0
      if (!TableOrErr)
923
0
        return TableOrErr.takeError();
924
0
      ShndxTable = *TableOrErr;
925
0
      break;
926
0
    }
927
9.47k
    }
928
9.47k
  }
929
1.06k
  return ELFObjectFile<ELFT>(Object, EF, DotDynSymSec, DotSymtabSec,
930
1.06k
                             ShndxTable);
931
1.06k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::create(llvm::MemoryBufferRef)
Line
Count
Source
893
275
ELFObjectFile<ELFT>::create(MemoryBufferRef Object) {
894
275
  auto EFOrErr = ELFFile<ELFT>::create(Object.getBuffer());
895
275
  if (Error E = EFOrErr.takeError())
896
0
    return std::move(E);
897
275
  auto EF = std::move(*EFOrErr);
898
275
899
275
  auto SectionsOrErr = EF.sections();
900
275
  if (!SectionsOrErr)
901
0
    return SectionsOrErr.takeError();
902
275
903
275
  const Elf_Shdr *DotDynSymSec = nullptr;
904
275
  const Elf_Shdr *DotSymtabSec = nullptr;
905
275
  ArrayRef<Elf_Word> ShndxTable;
906
3.20k
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
907
3.20k
    switch (Sec.sh_type) {
908
3.20k
    case ELF::SHT_DYNSYM: {
909
74
      if (DotDynSymSec)
910
0
        return createError("More than one dynamic symbol table!");
911
74
      DotDynSymSec = &Sec;
912
74
      break;
913
74
    }
914
275
    case ELF::SHT_SYMTAB: {
915
275
      if (DotSymtabSec)
916
0
        return createError("More than one static symbol table!");
917
275
      DotSymtabSec = &Sec;
918
275
      break;
919
275
    }
920
275
    case ELF::SHT_SYMTAB_SHNDX: {
921
0
      auto TableOrErr = EF.getSHNDXTable(Sec);
922
0
      if (!TableOrErr)
923
0
        return TableOrErr.takeError();
924
0
      ShndxTable = *TableOrErr;
925
0
      break;
926
0
    }
927
3.20k
    }
928
3.20k
  }
929
275
  return ELFObjectFile<ELFT>(Object, EF, DotDynSymSec, DotSymtabSec,
930
275
                             ShndxTable);
931
275
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::create(llvm::MemoryBufferRef)
Line
Count
Source
893
3.40k
ELFObjectFile<ELFT>::create(MemoryBufferRef Object) {
894
3.40k
  auto EFOrErr = ELFFile<ELFT>::create(Object.getBuffer());
895
3.40k
  if (Error E = EFOrErr.takeError())
896
0
    return std::move(E);
897
3.40k
  auto EF = std::move(*EFOrErr);
898
3.40k
899
3.40k
  auto SectionsOrErr = EF.sections();
900
3.40k
  if (!SectionsOrErr)
901
3
    return SectionsOrErr.takeError();
902
3.40k
903
3.40k
  const Elf_Shdr *DotDynSymSec = nullptr;
904
3.40k
  const Elf_Shdr *DotSymtabSec = nullptr;
905
3.40k
  ArrayRef<Elf_Word> ShndxTable;
906
1.53M
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
907
1.53M
    switch (Sec.sh_type) {
908
1.53M
    case ELF::SHT_DYNSYM: {
909
699
      if (DotDynSymSec)
910
0
        return createError("More than one dynamic symbol table!");
911
699
      DotDynSymSec = &Sec;
912
699
      break;
913
699
    }
914
3.35k
    case ELF::SHT_SYMTAB: {
915
3.35k
      if (DotSymtabSec)
916
0
        return createError("More than one static symbol table!");
917
3.35k
      DotSymtabSec = &Sec;
918
3.35k
      break;
919
3.35k
    }
920
3.35k
    case ELF::SHT_SYMTAB_SHNDX: {
921
15
      auto TableOrErr = EF.getSHNDXTable(Sec);
922
15
      if (!TableOrErr)
923
1
        return TableOrErr.takeError();
924
14
      ShndxTable = *TableOrErr;
925
14
      break;
926
14
    }
927
1.53M
    }
928
1.53M
  }
929
3.40k
  return ELFObjectFile<ELFT>(Object, EF, DotDynSymSec, DotSymtabSec,
930
3.40k
                             ShndxTable);
931
3.40k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::create(llvm::MemoryBufferRef)
Line
Count
Source
893
214
ELFObjectFile<ELFT>::create(MemoryBufferRef Object) {
894
214
  auto EFOrErr = ELFFile<ELFT>::create(Object.getBuffer());
895
214
  if (Error E = EFOrErr.takeError())
896
0
    return std::move(E);
897
214
  auto EF = std::move(*EFOrErr);
898
214
899
214
  auto SectionsOrErr = EF.sections();
900
214
  if (!SectionsOrErr)
901
0
    return SectionsOrErr.takeError();
902
214
903
214
  const Elf_Shdr *DotDynSymSec = nullptr;
904
214
  const Elf_Shdr *DotSymtabSec = nullptr;
905
214
  ArrayRef<Elf_Word> ShndxTable;
906
2.33k
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
907
2.33k
    switch (Sec.sh_type) {
908
2.33k
    case ELF::SHT_DYNSYM: {
909
53
      if (DotDynSymSec)
910
0
        return createError("More than one dynamic symbol table!");
911
53
      DotDynSymSec = &Sec;
912
53
      break;
913
53
    }
914
213
    case ELF::SHT_SYMTAB: {
915
213
      if (DotSymtabSec)
916
0
        return createError("More than one static symbol table!");
917
213
      DotSymtabSec = &Sec;
918
213
      break;
919
213
    }
920
213
    case ELF::SHT_SYMTAB_SHNDX: {
921
0
      auto TableOrErr = EF.getSHNDXTable(Sec);
922
0
      if (!TableOrErr)
923
0
        return TableOrErr.takeError();
924
0
      ShndxTable = *TableOrErr;
925
0
      break;
926
0
    }
927
2.33k
    }
928
2.33k
  }
929
214
  return ELFObjectFile<ELFT>(Object, EF, DotDynSymSec, DotSymtabSec,
930
214
                             ShndxTable);
931
214
}
932
933
template <class ELFT>
934
ELFObjectFile<ELFT>::ELFObjectFile(MemoryBufferRef Object, ELFFile<ELFT> EF,
935
                                   const Elf_Shdr *DotDynSymSec,
936
                                   const Elf_Shdr *DotSymtabSec,
937
                                   ArrayRef<Elf_Word> ShndxTable)
938
    : ELFObjectFileBase(
939
          getELFType(ELFT::TargetEndianness == support::little, ELFT::Is64Bits),
940
          Object),
941
      EF(EF), DotDynSymSec(DotDynSymSec), DotSymtabSec(DotSymtabSec),
942
14.8k
      ShndxTable(ShndxTable) {}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::ELFObjectFile(llvm::MemoryBufferRef, llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >, llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*, llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*, llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)1, 1ul> >)
Line
Count
Source
942
3.18k
      ShndxTable(ShndxTable) {}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::ELFObjectFile(llvm::MemoryBufferRef, llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >, llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*, llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*, llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)0, 1ul> >)
Line
Count
Source
942
825
      ShndxTable(ShndxTable) {}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::ELFObjectFile(llvm::MemoryBufferRef, llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >, llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*, llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*, llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)1, 1ul> >)
Line
Count
Source
942
10.2k
      ShndxTable(ShndxTable) {}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::ELFObjectFile(llvm::MemoryBufferRef, llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >, llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*, llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*, llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)0, 1ul> >)
Line
Count
Source
942
642
      ShndxTable(ShndxTable) {}
943
944
template <class ELFT>
945
ELFObjectFile<ELFT>::ELFObjectFile(ELFObjectFile<ELFT> &&Other)
946
    : ELFObjectFile(Other.Data, Other.EF, Other.DotDynSymSec,
947
9.90k
                    Other.DotSymtabSec, Other.ShndxTable) {}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::ELFObjectFile(llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >&&)
Line
Count
Source
947
2.12k
                    Other.DotSymtabSec, Other.ShndxTable) {}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::ELFObjectFile(llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >&&)
Line
Count
Source
947
550
                    Other.DotSymtabSec, Other.ShndxTable) {}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::ELFObjectFile(llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >&&)
Line
Count
Source
947
6.80k
                    Other.DotSymtabSec, Other.ShndxTable) {}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::ELFObjectFile(llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >&&)
Line
Count
Source
947
428
                    Other.DotSymtabSec, Other.ShndxTable) {}
948
949
template <class ELFT>
950
1.86k
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin() const {
951
1.86k
  DataRefImpl Sym = toDRI(DotSymtabSec, 0);
952
1.86k
  return basic_symbol_iterator(SymbolRef(Sym, this));
953
1.86k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::symbol_begin() const
Line
Count
Source
950
440
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin() const {
951
440
  DataRefImpl Sym = toDRI(DotSymtabSec, 0);
952
440
  return basic_symbol_iterator(SymbolRef(Sym, this));
953
440
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::symbol_begin() const
Line
Count
Source
950
109
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin() const {
951
109
  DataRefImpl Sym = toDRI(DotSymtabSec, 0);
952
109
  return basic_symbol_iterator(SymbolRef(Sym, this));
953
109
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::symbol_begin() const
Line
Count
Source
950
1.24k
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin() const {
951
1.24k
  DataRefImpl Sym = toDRI(DotSymtabSec, 0);
952
1.24k
  return basic_symbol_iterator(SymbolRef(Sym, this));
953
1.24k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::symbol_begin() const
Line
Count
Source
950
66
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin() const {
951
66
  DataRefImpl Sym = toDRI(DotSymtabSec, 0);
952
66
  return basic_symbol_iterator(SymbolRef(Sym, this));
953
66
}
954
955
template <class ELFT>
956
6.42k
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
957
6.42k
  const Elf_Shdr *SymTab = DotSymtabSec;
958
6.42k
  if (!SymTab)
959
3
    return symbol_begin();
960
6.41k
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
961
6.41k
  return basic_symbol_iterator(SymbolRef(Sym, this));
962
6.41k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::symbol_end() const
Line
Count
Source
956
831
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
957
831
  const Elf_Shdr *SymTab = DotSymtabSec;
958
831
  if (!SymTab)
959
1
    return symbol_begin();
960
830
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
961
830
  return basic_symbol_iterator(SymbolRef(Sym, this));
962
830
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::symbol_end() const
Line
Count
Source
956
280
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
957
280
  const Elf_Shdr *SymTab = DotSymtabSec;
958
280
  if (!SymTab)
959
0
    return symbol_begin();
960
280
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
961
280
  return basic_symbol_iterator(SymbolRef(Sym, this));
962
280
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::symbol_end() const
Line
Count
Source
956
5.05k
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
957
5.05k
  const Elf_Shdr *SymTab = DotSymtabSec;
958
5.05k
  if (!SymTab)
959
2
    return symbol_begin();
960
5.05k
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
961
5.05k
  return basic_symbol_iterator(SymbolRef(Sym, this));
962
5.05k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::symbol_end() const
Line
Count
Source
956
253
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
957
253
  const Elf_Shdr *SymTab = DotSymtabSec;
958
253
  if (!SymTab)
959
0
    return symbol_begin();
960
253
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
961
253
  return basic_symbol_iterator(SymbolRef(Sym, this));
962
253
}
963
964
template <class ELFT>
965
243
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_begin() const {
966
243
  DataRefImpl Sym = toDRI(DotDynSymSec, 0);
967
243
  return symbol_iterator(SymbolRef(Sym, this));
968
243
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::dynamic_symbol_begin() const
Line
Count
Source
965
196
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_begin() const {
966
196
  DataRefImpl Sym = toDRI(DotDynSymSec, 0);
967
196
  return symbol_iterator(SymbolRef(Sym, this));
968
196
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::dynamic_symbol_begin() const
Line
Count
Source
965
8
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_begin() const {
966
8
  DataRefImpl Sym = toDRI(DotDynSymSec, 0);
967
8
  return symbol_iterator(SymbolRef(Sym, this));
968
8
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::dynamic_symbol_begin() const
Line
Count
Source
965
37
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_begin() const {
966
37
  DataRefImpl Sym = toDRI(DotDynSymSec, 0);
967
37
  return symbol_iterator(SymbolRef(Sym, this));
968
37
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::dynamic_symbol_begin() const
Line
Count
Source
965
2
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_begin() const {
966
2
  DataRefImpl Sym = toDRI(DotDynSymSec, 0);
967
2
  return symbol_iterator(SymbolRef(Sym, this));
968
2
}
969
970
template <class ELFT>
971
125
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_end() const {
972
125
  const Elf_Shdr *SymTab = DotDynSymSec;
973
125
  if (!SymTab)
974
118
    return dynamic_symbol_begin();
975
7
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
976
7
  return basic_symbol_iterator(SymbolRef(Sym, this));
977
7
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::dynamic_symbol_end() const
Line
Count
Source
971
99
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_end() const {
972
99
  const Elf_Shdr *SymTab = DotDynSymSec;
973
99
  if (!SymTab)
974
97
    return dynamic_symbol_begin();
975
2
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
976
2
  return basic_symbol_iterator(SymbolRef(Sym, this));
977
2
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::dynamic_symbol_end() const
Line
Count
Source
971
4
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_end() const {
972
4
  const Elf_Shdr *SymTab = DotDynSymSec;
973
4
  if (!SymTab)
974
4
    return dynamic_symbol_begin();
975
0
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
976
0
  return basic_symbol_iterator(SymbolRef(Sym, this));
977
0
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::dynamic_symbol_end() const
Line
Count
Source
971
21
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_end() const {
972
21
  const Elf_Shdr *SymTab = DotDynSymSec;
973
21
  if (!SymTab)
974
16
    return dynamic_symbol_begin();
975
5
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
976
5
  return basic_symbol_iterator(SymbolRef(Sym, this));
977
5
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::dynamic_symbol_end() const
Line
Count
Source
971
1
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_end() const {
972
1
  const Elf_Shdr *SymTab = DotDynSymSec;
973
1
  if (!SymTab)
974
1
    return dynamic_symbol_begin();
975
0
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
976
0
  return basic_symbol_iterator(SymbolRef(Sym, this));
977
0
}
978
979
template <class ELFT>
980
5.24k
section_iterator ELFObjectFile<ELFT>::section_begin() const {
981
5.24k
  auto SectionsOrErr = EF.sections();
982
5.24k
  if (!SectionsOrErr)
983
0
    return section_iterator(SectionRef());
984
5.24k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).begin()), this));
985
5.24k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::section_begin() const
Line
Count
Source
980
1.28k
section_iterator ELFObjectFile<ELFT>::section_begin() const {
981
1.28k
  auto SectionsOrErr = EF.sections();
982
1.28k
  if (!SectionsOrErr)
983
0
    return section_iterator(SectionRef());
984
1.28k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).begin()), this));
985
1.28k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::section_begin() const
Line
Count
Source
980
263
section_iterator ELFObjectFile<ELFT>::section_begin() const {
981
263
  auto SectionsOrErr = EF.sections();
982
263
  if (!SectionsOrErr)
983
0
    return section_iterator(SectionRef());
984
263
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).begin()), this));
985
263
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::section_begin() const
Line
Count
Source
980
3.52k
section_iterator ELFObjectFile<ELFT>::section_begin() const {
981
3.52k
  auto SectionsOrErr = EF.sections();
982
3.52k
  if (!SectionsOrErr)
983
0
    return section_iterator(SectionRef());
984
3.52k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).begin()), this));
985
3.52k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::section_begin() const
Line
Count
Source
980
183
section_iterator ELFObjectFile<ELFT>::section_begin() const {
981
183
  auto SectionsOrErr = EF.sections();
982
183
  if (!SectionsOrErr)
983
0
    return section_iterator(SectionRef());
984
183
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).begin()), this));
985
183
}
986
987
template <class ELFT>
988
62.2k
section_iterator ELFObjectFile<ELFT>::section_end() const {
989
62.2k
  auto SectionsOrErr = EF.sections();
990
62.2k
  if (!SectionsOrErr)
991
0
    return section_iterator(SectionRef());
992
62.2k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).end()), this));
993
62.2k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::section_end() const
Line
Count
Source
988
17.7k
section_iterator ELFObjectFile<ELFT>::section_end() const {
989
17.7k
  auto SectionsOrErr = EF.sections();
990
17.7k
  if (!SectionsOrErr)
991
0
    return section_iterator(SectionRef());
992
17.7k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).end()), this));
993
17.7k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::section_end() const
Line
Count
Source
988
3.73k
section_iterator ELFObjectFile<ELFT>::section_end() const {
989
3.73k
  auto SectionsOrErr = EF.sections();
990
3.73k
  if (!SectionsOrErr)
991
0
    return section_iterator(SectionRef());
992
3.73k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).end()), this));
993
3.73k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::section_end() const
Line
Count
Source
988
38.2k
section_iterator ELFObjectFile<ELFT>::section_end() const {
989
38.2k
  auto SectionsOrErr = EF.sections();
990
38.2k
  if (!SectionsOrErr)
991
0
    return section_iterator(SectionRef());
992
38.2k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).end()), this));
993
38.2k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::section_end() const
Line
Count
Source
988
2.62k
section_iterator ELFObjectFile<ELFT>::section_end() const {
989
2.62k
  auto SectionsOrErr = EF.sections();
990
2.62k
  if (!SectionsOrErr)
991
0
    return section_iterator(SectionRef());
992
2.62k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).end()), this));
993
2.62k
}
994
995
template <class ELFT>
996
8.24k
uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
997
8.24k
  return ELFT::Is64Bits ? 
86.35k
:
41.89k
;
998
8.24k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getBytesInAddress() const
Line
Count
Source
996
1.37k
uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
997
1.37k
  return ELFT::Is64Bits ? 
80
: 4;
998
1.37k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getBytesInAddress() const
Line
Count
Source
996
520
uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
997
520
  return ELFT::Is64Bits ? 
80
: 4;
998
520
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getBytesInAddress() const
Line
Count
Source
996
6.02k
uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
997
6.02k
  return ELFT::Is64Bits ? 8 : 
40
;
998
6.02k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getBytesInAddress() const
Line
Count
Source
996
326
uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
997
326
  return ELFT::Is64Bits ? 8 : 
40
;
998
326
}
999
1000
template <class ELFT>
1001
3.99k
StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
1002
3.99k
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1003
3.99k
  switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1004
3.99k
  case ELF::ELFCLASS32:
1005
1.23k
    switch (EF.getHeader()->e_machine) {
1006
1.23k
    case ELF::EM_386:
1007
224
      return "ELF32-i386";
1008
1.23k
    case ELF::EM_IAMCU:
1009
3
      return "ELF32-iamcu";
1010
1.23k
    case ELF::EM_X86_64:
1011
6
      return "ELF32-x86-64";
1012
1.23k
    case ELF::EM_ARM:
1013
426
      return (IsLittleEndian ? 
"ELF32-arm-little"415
:
"ELF32-arm-big"11
);
1014
1.23k
    case ELF::EM_AVR:
1015
0
      return "ELF32-avr";
1016
1.23k
    case ELF::EM_HEXAGON:
1017
114
      return "ELF32-hexagon";
1018
1.23k
    case ELF::EM_LANAI:
1019
4
      return "ELF32-lanai";
1020
1.23k
    case ELF::EM_MIPS:
1021
398
      return "ELF32-mips";
1022
1.23k
    case ELF::EM_PPC:
1023
11
      return "ELF32-ppc";
1024
1.23k
    case ELF::EM_RISCV:
1025
0
      return "ELF32-riscv";
1026
1.23k
    case ELF::EM_SPARC:
1027
8
    case ELF::EM_SPARC32PLUS:
1028
8
      return "ELF32-sparc";
1029
36
    case ELF::EM_AMDGPU:
1030
36
      return "ELF32-amdgpu";
1031
8
    default:
1032
2
      return "ELF32-unknown";
1033
0
    }
1034
2.76k
  case ELF::ELFCLASS64:
1035
2.76k
    switch (EF.getHeader()->e_machine) {
1036
2.76k
    case ELF::EM_386:
1037
0
      return "ELF64-i386";
1038
2.76k
    case ELF::EM_X86_64:
1039
1.64k
      return "ELF64-x86-64";
1040
2.76k
    case ELF::EM_AARCH64:
1041
701
      return (IsLittleEndian ? 
"ELF64-aarch64-little"694
:
"ELF64-aarch64-big"7
);
1042
2.76k
    case ELF::EM_PPC64:
1043
118
      return "ELF64-ppc64";
1044
2.76k
    case ELF::EM_RISCV:
1045
0
      return "ELF64-riscv";
1046
2.76k
    case ELF::EM_S390:
1047
10
      return "ELF64-s390";
1048
2.76k
    case ELF::EM_SPARCV9:
1049
14
      return "ELF64-sparc";
1050
2.76k
    case ELF::EM_MIPS:
1051
149
      return "ELF64-mips";
1052
2.76k
    case ELF::EM_AMDGPU:
1053
109
      return "ELF64-amdgpu";
1054
2.76k
    case ELF::EM_BPF:
1055
17
      return "ELF64-BPF";
1056
2.76k
    default:
1057
1
      return "ELF64-unknown";
1058
0
    }
1059
0
  default:
1060
0
    // FIXME: Proper error handling.
1061
0
    report_fatal_error("Invalid ELFCLASS!");
1062
3.99k
  }
1063
3.99k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getFileFormatName() const
Line
Count
Source
1001
963
StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
1002
963
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1003
963
  switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1004
963
  case ELF::ELFCLASS32:
1005
963
    switch (EF.getHeader()->e_machine) {
1006
963
    case ELF::EM_386:
1007
224
      return "ELF32-i386";
1008
963
    case ELF::EM_IAMCU:
1009
3
      return "ELF32-iamcu";
1010
963
    case ELF::EM_X86_64:
1011
5
      return "ELF32-x86-64";
1012
963
    case ELF::EM_ARM:
1013
415
      return (IsLittleEndian ? "ELF32-arm-little" : 
"ELF32-arm-big"0
);
1014
963
    case ELF::EM_AVR:
1015
0
      return "ELF32-avr";
1016
963
    case ELF::EM_HEXAGON:
1017
114
      return "ELF32-hexagon";
1018
963
    case ELF::EM_LANAI:
1019
1
      return "ELF32-lanai";
1020
963
    case ELF::EM_MIPS:
1021
162
      return "ELF32-mips";
1022
963
    case ELF::EM_PPC:
1023
0
      return "ELF32-ppc";
1024
963
    case ELF::EM_RISCV:
1025
0
      return "ELF32-riscv";
1026
963
    case ELF::EM_SPARC:
1027
1
    case ELF::EM_SPARC32PLUS:
1028
1
      return "ELF32-sparc";
1029
36
    case ELF::EM_AMDGPU:
1030
36
      return "ELF32-amdgpu";
1031
2
    default:
1032
2
      return "ELF32-unknown";
1033
0
    }
1034
0
  case ELF::ELFCLASS64:
1035
0
    switch (EF.getHeader()->e_machine) {
1036
0
    case ELF::EM_386:
1037
0
      return "ELF64-i386";
1038
0
    case ELF::EM_X86_64:
1039
0
      return "ELF64-x86-64";
1040
0
    case ELF::EM_AARCH64:
1041
0
      return (IsLittleEndian ? "ELF64-aarch64-little" : "ELF64-aarch64-big");
1042
0
    case ELF::EM_PPC64:
1043
0
      return "ELF64-ppc64";
1044
0
    case ELF::EM_RISCV:
1045
0
      return "ELF64-riscv";
1046
0
    case ELF::EM_S390:
1047
0
      return "ELF64-s390";
1048
0
    case ELF::EM_SPARCV9:
1049
0
      return "ELF64-sparc";
1050
0
    case ELF::EM_MIPS:
1051
0
      return "ELF64-mips";
1052
0
    case ELF::EM_AMDGPU:
1053
0
      return "ELF64-amdgpu";
1054
0
    case ELF::EM_BPF:
1055
0
      return "ELF64-BPF";
1056
0
    default:
1057
0
      return "ELF64-unknown";
1058
0
    }
1059
0
  default:
1060
0
    // FIXME: Proper error handling.
1061
0
    report_fatal_error("Invalid ELFCLASS!");
1062
963
  }
1063
963
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getFileFormatName() const
Line
Count
Source
1001
269
StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
1002
269
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1003
269
  switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1004
269
  case ELF::ELFCLASS32:
1005
269
    switch (EF.getHeader()->e_machine) {
1006
269
    case ELF::EM_386:
1007
0
      return "ELF32-i386";
1008
269
    case ELF::EM_IAMCU:
1009
0
      return "ELF32-iamcu";
1010
269
    case ELF::EM_X86_64:
1011
1
      return "ELF32-x86-64";
1012
269
    case ELF::EM_ARM:
1013
11
      return (IsLittleEndian ? 
"ELF32-arm-little"0
: "ELF32-arm-big");
1014
269
    case ELF::EM_AVR:
1015
0
      return "ELF32-avr";
1016
269
    case ELF::EM_HEXAGON:
1017
0
      return "ELF32-hexagon";
1018
269
    case ELF::EM_LANAI:
1019
3
      return "ELF32-lanai";
1020
269
    case ELF::EM_MIPS:
1021
236
      return "ELF32-mips";
1022
269
    case ELF::EM_PPC:
1023
11
      return "ELF32-ppc";
1024
269
    case ELF::EM_RISCV:
1025
0
      return "ELF32-riscv";
1026
269
    case ELF::EM_SPARC:
1027
7
    case ELF::EM_SPARC32PLUS:
1028
7
      return "ELF32-sparc";
1029
7
    case ELF::EM_AMDGPU:
1030
0
      return "ELF32-amdgpu";
1031
7
    default:
1032
0
      return "ELF32-unknown";
1033
0
    }
1034
0
  case ELF::ELFCLASS64:
1035
0
    switch (EF.getHeader()->e_machine) {
1036
0
    case ELF::EM_386:
1037
0
      return "ELF64-i386";
1038
0
    case ELF::EM_X86_64:
1039
0
      return "ELF64-x86-64";
1040
0
    case ELF::EM_AARCH64:
1041
0
      return (IsLittleEndian ? "ELF64-aarch64-little" : "ELF64-aarch64-big");
1042
0
    case ELF::EM_PPC64:
1043
0
      return "ELF64-ppc64";
1044
0
    case ELF::EM_RISCV:
1045
0
      return "ELF64-riscv";
1046
0
    case ELF::EM_S390:
1047
0
      return "ELF64-s390";
1048
0
    case ELF::EM_SPARCV9:
1049
0
      return "ELF64-sparc";
1050
0
    case ELF::EM_MIPS:
1051
0
      return "ELF64-mips";
1052
0
    case ELF::EM_AMDGPU:
1053
0
      return "ELF64-amdgpu";
1054
0
    case ELF::EM_BPF:
1055
0
      return "ELF64-BPF";
1056
0
    default:
1057
0
      return "ELF64-unknown";
1058
0
    }
1059
0
  default:
1060
0
    // FIXME: Proper error handling.
1061
0
    report_fatal_error("Invalid ELFCLASS!");
1062
269
  }
1063
269
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getFileFormatName() const
Line
Count
Source
1001
2.58k
StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
1002
2.58k
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1003
2.58k
  switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1004
2.58k
  case ELF::ELFCLASS32:
1005
0
    switch (EF.getHeader()->e_machine) {
1006
0
    case ELF::EM_386:
1007
0
      return "ELF32-i386";
1008
0
    case ELF::EM_IAMCU:
1009
0
      return "ELF32-iamcu";
1010
0
    case ELF::EM_X86_64:
1011
0
      return "ELF32-x86-64";
1012
0
    case ELF::EM_ARM:
1013
0
      return (IsLittleEndian ? "ELF32-arm-little" : "ELF32-arm-big");
1014
0
    case ELF::EM_AVR:
1015
0
      return "ELF32-avr";
1016
0
    case ELF::EM_HEXAGON:
1017
0
      return "ELF32-hexagon";
1018
0
    case ELF::EM_LANAI:
1019
0
      return "ELF32-lanai";
1020
0
    case ELF::EM_MIPS:
1021
0
      return "ELF32-mips";
1022
0
    case ELF::EM_PPC:
1023
0
      return "ELF32-ppc";
1024
0
    case ELF::EM_RISCV:
1025
0
      return "ELF32-riscv";
1026
0
    case ELF::EM_SPARC:
1027
0
    case ELF::EM_SPARC32PLUS:
1028
0
      return "ELF32-sparc";
1029
0
    case ELF::EM_AMDGPU:
1030
0
      return "ELF32-amdgpu";
1031
0
    default:
1032
0
      return "ELF32-unknown";
1033
0
    }
1034
2.58k
  case ELF::ELFCLASS64:
1035
2.58k
    switch (EF.getHeader()->e_machine) {
1036
2.58k
    case ELF::EM_386:
1037
0
      return "ELF64-i386";
1038
2.58k
    case ELF::EM_X86_64:
1039
1.64k
      return "ELF64-x86-64";
1040
2.58k
    case ELF::EM_AARCH64:
1041
694
      return (IsLittleEndian ? "ELF64-aarch64-little" : 
"ELF64-aarch64-big"0
);
1042
2.58k
    case ELF::EM_PPC64:
1043
53
      return "ELF64-ppc64";
1044
2.58k
    case ELF::EM_RISCV:
1045
0
      return "ELF64-riscv";
1046
2.58k
    case ELF::EM_S390:
1047
0
      return "ELF64-s390";
1048
2.58k
    case ELF::EM_SPARCV9:
1049
0
      return "ELF64-sparc";
1050
2.58k
    case ELF::EM_MIPS:
1051
65
      return "ELF64-mips";
1052
2.58k
    case ELF::EM_AMDGPU:
1053
109
      return "ELF64-amdgpu";
1054
2.58k
    case ELF::EM_BPF:
1055
15
      return "ELF64-BPF";
1056
2.58k
    default:
1057
1
      return "ELF64-unknown";
1058
0
    }
1059
0
  default:
1060
0
    // FIXME: Proper error handling.
1061
0
    report_fatal_error("Invalid ELFCLASS!");
1062
2.58k
  }
1063
2.58k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getFileFormatName() const
Line
Count
Source
1001
184
StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
1002
184
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1003
184
  switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1004
184
  case ELF::ELFCLASS32:
1005
0
    switch (EF.getHeader()->e_machine) {
1006
0
    case ELF::EM_386:
1007
0
      return "ELF32-i386";
1008
0
    case ELF::EM_IAMCU:
1009
0
      return "ELF32-iamcu";
1010
0
    case ELF::EM_X86_64:
1011
0
      return "ELF32-x86-64";
1012
0
    case ELF::EM_ARM:
1013
0
      return (IsLittleEndian ? "ELF32-arm-little" : "ELF32-arm-big");
1014
0
    case ELF::EM_AVR:
1015
0
      return "ELF32-avr";
1016
0
    case ELF::EM_HEXAGON:
1017
0
      return "ELF32-hexagon";
1018
0
    case ELF::EM_LANAI:
1019
0
      return "ELF32-lanai";
1020
0
    case ELF::EM_MIPS:
1021
0
      return "ELF32-mips";
1022
0
    case ELF::EM_PPC:
1023
0
      return "ELF32-ppc";
1024
0
    case ELF::EM_RISCV:
1025
0
      return "ELF32-riscv";
1026
0
    case ELF::EM_SPARC:
1027
0
    case ELF::EM_SPARC32PLUS:
1028
0
      return "ELF32-sparc";
1029
0
    case ELF::EM_AMDGPU:
1030
0
      return "ELF32-amdgpu";
1031
0
    default:
1032
0
      return "ELF32-unknown";
1033
0
    }
1034
184
  case ELF::ELFCLASS64:
1035
184
    switch (EF.getHeader()->e_machine) {
1036
184
    case ELF::EM_386:
1037
0
      return "ELF64-i386";
1038
184
    case ELF::EM_X86_64:
1039
2
      return "ELF64-x86-64";
1040
184
    case ELF::EM_AARCH64:
1041
7
      return (IsLittleEndian ? 
"ELF64-aarch64-little"0
: "ELF64-aarch64-big");
1042
184
    case ELF::EM_PPC64:
1043
65
      return "ELF64-ppc64";
1044
184
    case ELF::EM_RISCV:
1045
0
      return "ELF64-riscv";
1046
184
    case ELF::EM_S390:
1047
10
      return "ELF64-s390";
1048
184
    case ELF::EM_SPARCV9:
1049
14
      return "ELF64-sparc";
1050
184
    case ELF::EM_MIPS:
1051
84
      return "ELF64-mips";
1052
184
    case ELF::EM_AMDGPU:
1053
0
      return "ELF64-amdgpu";
1054
184
    case ELF::EM_BPF:
1055
2
      return "ELF64-BPF";
1056
184
    default:
1057
0
      return "ELF64-unknown";
1058
0
    }
1059
0
  default:
1060
0
    // FIXME: Proper error handling.
1061
0
    report_fatal_error("Invalid ELFCLASS!");
1062
184
  }
1063
184
}
1064
1065
31.1M
template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::getArch() const {
1066
31.1M
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1067
31.1M
  switch (EF.getHeader()->e_machine) {
1068
31.1M
  case ELF::EM_386:
1069
123k
  case ELF::EM_IAMCU:
1070
123k
    return Triple::x86;
1071
123k
  case ELF::EM_X86_64:
1072
27.1k
    return Triple::x86_64;
1073
243k
  case ELF::EM_AARCH64:
1074
243k
    return IsLittleEndian ? 
Triple::aarch64243k
:
Triple::aarch64_be31
;
1075
123k
  case ELF::EM_ARM:
1076
51.5k
    return Triple::arm;
1077
123k
  case ELF::EM_AVR:
1078
0
    return Triple::avr;
1079
123k
  case ELF::EM_HEXAGON:
1080
22.2k
    return Triple::hexagon;
1081
123k
  case ELF::EM_LANAI:
1082
10
    return Triple::lanai;
1083
358k
  case ELF::EM_MIPS:
1084
358k
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1085
358k
    case ELF::ELFCLASS32:
1086
356k
      return IsLittleEndian ? 
Triple::mipsel347k
:
Triple::mips8.69k
;
1087
358k
    case ELF::ELFCLASS64:
1088
2.44k
      return IsLittleEndian ? 
Triple::mips64el1.10k
:
Triple::mips641.33k
;
1089
358k
    default:
1090
0
      report_fatal_error("Invalid ELFCLASS!");
1091
0
    }
1092
167
  case ELF::EM_PPC:
1093
167
    return Triple::ppc;
1094
30.3M
  case ELF::EM_PPC64:
1095
30.3M
    return IsLittleEndian ? 
Triple::ppc64le15.1M
:
Triple::ppc6415.1M
;
1096
0
  case ELF::EM_RISCV:
1097
0
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1098
0
    case ELF::ELFCLASS32:
1099
0
      return Triple::riscv32;
1100
0
    case ELF::ELFCLASS64:
1101
0
      return Triple::riscv64;
1102
0
    default:
1103
0
      report_fatal_error("Invalid ELFCLASS!");
1104
0
    }
1105
264
  case ELF::EM_S390:
1106
264
    return Triple::systemz;
1107
0
1108
98
  case ELF::EM_SPARC:
1109
98
  case ELF::EM_SPARC32PLUS:
1110
98
    return IsLittleEndian ? 
Triple::sparcel23
:
Triple::sparc75
;
1111
106
  case ELF::EM_SPARCV9:
1112
106
    return Triple::sparcv9;
1113
98
1114
2.82k
  case ELF::EM_AMDGPU: {
1115
2.82k
    if (!IsLittleEndian)
1116
0
      return Triple::UnknownArch;
1117
2.82k
1118
2.82k
    unsigned MACH = EF.getHeader()->e_flags & ELF::EF_AMDGPU_MACH;
1119
2.82k
    if (MACH >= ELF::EF_AMDGPU_MACH_R600_FIRST &&
1120
2.82k
        
MACH <= ELF::EF_AMDGPU_MACH_R600_LAST2.78k
)
1121
105
      return Triple::r600;
1122
2.71k
    if (MACH >= ELF::EF_AMDGPU_MACH_AMDGCN_FIRST &&
1123
2.71k
        
MACH <= ELF::EF_AMDGPU_MACH_AMDGCN_LAST2.67k
)
1124
2.67k
      return Triple::amdgcn;
1125
44
1126
44
    return Triple::UnknownArch;
1127
44
  }
1128
44
1129
2.90k
  case ELF::EM_BPF:
1130
2.90k
    return IsLittleEndian ? 
Triple::bpfel2.51k
:
Triple::bpfeb394
;
1131
44
1132
44
  default:
1133
2
    return Triple::UnknownArch;
1134
31.1M
  }
1135
31.1M
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getArch() const
Line
Count
Source
1065
545k
template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::getArch() const {
1066
545k
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1067
545k
  switch (EF.getHeader()->e_machine) {
1068
545k
  case ELF::EM_386:
1069
123k
  case ELF::EM_IAMCU:
1070
123k
    return Triple::x86;
1071
123k
  case ELF::EM_X86_64:
1072
22
    return Triple::x86_64;
1073
123k
  case ELF::EM_AARCH64:
1074
0
    return IsLittleEndian ? Triple::aarch64 : Triple::aarch64_be;
1075
123k
  case ELF::EM_ARM:
1076
51.5k
    return Triple::arm;
1077
123k
  case ELF::EM_AVR:
1078
0
    return Triple::avr;
1079
123k
  case ELF::EM_HEXAGON:
1080
22.2k
    return Triple::hexagon;
1081
123k
  case ELF::EM_LANAI:
1082
3
    return Triple::lanai;
1083
347k
  case ELF::EM_MIPS:
1084
347k
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1085
347k
    case ELF::ELFCLASS32:
1086
347k
      return IsLittleEndian ? Triple::mipsel : 
Triple::mips0
;
1087
347k
    case ELF::ELFCLASS64:
1088
0
      return IsLittleEndian ? Triple::mips64el : Triple::mips64;
1089
347k
    default:
1090
0
      report_fatal_error("Invalid ELFCLASS!");
1091
0
    }
1092
0
  case ELF::EM_PPC:
1093
0
    return Triple::ppc;
1094
0
  case ELF::EM_PPC64:
1095
0
    return IsLittleEndian ? Triple::ppc64le : Triple::ppc64;
1096
0
  case ELF::EM_RISCV:
1097
0
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1098
0
    case ELF::ELFCLASS32:
1099
0
      return Triple::riscv32;
1100
0
    case ELF::ELFCLASS64:
1101
0
      return Triple::riscv64;
1102
0
    default:
1103
0
      report_fatal_error("Invalid ELFCLASS!");
1104
0
    }
1105
0
  case ELF::EM_S390:
1106
0
    return Triple::systemz;
1107
0
1108
23
  case ELF::EM_SPARC:
1109
23
  case ELF::EM_SPARC32PLUS:
1110
23
    return IsLittleEndian ? Triple::sparcel : 
Triple::sparc0
;
1111
23
  case ELF::EM_SPARCV9:
1112
0
    return Triple::sparcv9;
1113
23
1114
108
  case ELF::EM_AMDGPU: {
1115
108
    if (!IsLittleEndian)
1116
0
      return Triple::UnknownArch;
1117
108
1118
108
    unsigned MACH = EF.getHeader()->e_flags & ELF::EF_AMDGPU_MACH;
1119
108
    if (MACH >= ELF::EF_AMDGPU_MACH_R600_FIRST &&
1120
108
        
MACH <= ELF::EF_AMDGPU_MACH_R600_LAST105
)
1121
105
      return Triple::r600;
1122
3
    if (MACH >= ELF::EF_AMDGPU_MACH_AMDGCN_FIRST &&
1123
3
        
MACH <= ELF::EF_AMDGPU_MACH_AMDGCN_LAST0
)
1124
0
      return Triple::amdgcn;
1125
3
1126
3
    return Triple::UnknownArch;
1127
3
  }
1128
3
1129
3
  case ELF::EM_BPF:
1130
0
    return IsLittleEndian ? Triple::bpfel : Triple::bpfeb;
1131
3
1132
3
  default:
1133
2
    return Triple::UnknownArch;
1134
545k
  }
1135
545k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getArch() const
Line
Count
Source
1065
8.96k
template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::getArch() const {
1066
8.96k
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1067
8.96k
  switch (EF.getHeader()->e_machine) {
1068
8.96k
  case ELF::EM_386:
1069
0
  case ELF::EM_IAMCU:
1070
0
    return Triple::x86;
1071
3
  case ELF::EM_X86_64:
1072
3
    return Triple::x86_64;
1073
0
  case ELF::EM_AARCH64:
1074
0
    return IsLittleEndian ? Triple::aarch64 : Triple::aarch64_be;
1075
21
  case ELF::EM_ARM:
1076
21
    return Triple::arm;
1077
0
  case ELF::EM_AVR:
1078
0
    return Triple::avr;
1079
0
  case ELF::EM_HEXAGON:
1080
0
    return Triple::hexagon;
1081
7
  case ELF::EM_LANAI:
1082
7
    return Triple::lanai;
1083
8.69k
  case ELF::EM_MIPS:
1084
8.69k
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1085
8.69k
    case ELF::ELFCLASS32:
1086
8.69k
      return IsLittleEndian ? 
Triple::mipsel0
: Triple::mips;
1087
8.69k
    case ELF::ELFCLASS64:
1088
0
      return IsLittleEndian ? Triple::mips64el : Triple::mips64;
1089
8.69k
    default:
1090
0
      report_fatal_error("Invalid ELFCLASS!");
1091
0
    }
1092
167
  case ELF::EM_PPC:
1093
167
    return Triple::ppc;
1094
0
  case ELF::EM_PPC64:
1095
0
    return IsLittleEndian ? Triple::ppc64le : Triple::ppc64;
1096
0
  case ELF::EM_RISCV:
1097
0
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1098
0
    case ELF::ELFCLASS32:
1099
0
      return Triple::riscv32;
1100
0
    case ELF::ELFCLASS64:
1101
0
      return Triple::riscv64;
1102
0
    default:
1103
0
      report_fatal_error("Invalid ELFCLASS!");
1104
0
    }
1105
0
  case ELF::EM_S390:
1106
0
    return Triple::systemz;
1107
0
1108
75
  case ELF::EM_SPARC:
1109
75
  case ELF::EM_SPARC32PLUS:
1110
75
    return IsLittleEndian ? 
Triple::sparcel0
: Triple::sparc;
1111
75
  case ELF::EM_SPARCV9:
1112
0
    return Triple::sparcv9;
1113
75
1114
75
  case ELF::EM_AMDGPU: {
1115
0
    if (!IsLittleEndian)
1116
0
      return Triple::UnknownArch;
1117
0
1118
0
    unsigned MACH = EF.getHeader()->e_flags & ELF::EF_AMDGPU_MACH;
1119
0
    if (MACH >= ELF::EF_AMDGPU_MACH_R600_FIRST &&
1120
0
        MACH <= ELF::EF_AMDGPU_MACH_R600_LAST)
1121
0
      return Triple::r600;
1122
0
    if (MACH >= ELF::EF_AMDGPU_MACH_AMDGCN_FIRST &&
1123
0
        MACH <= ELF::EF_AMDGPU_MACH_AMDGCN_LAST)
1124
0
      return Triple::amdgcn;
1125
0
1126
0
    return Triple::UnknownArch;
1127
0
  }
1128
0
1129
0
  case ELF::EM_BPF:
1130
0
    return IsLittleEndian ? Triple::bpfel : Triple::bpfeb;
1131
0
1132
0
  default:
1133
0
    return Triple::UnknownArch;
1134
8.96k
  }
1135
8.96k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getArch() const
Line
Count
Source
1065
15.4M
template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::getArch() const {
1066
15.4M
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1067
15.4M
  switch (EF.getHeader()->e_machine) {
1068
15.4M
  case ELF::EM_386:
1069
0
  case ELF::EM_IAMCU:
1070
0
    return Triple::x86;
1071
27.1k
  case ELF::EM_X86_64:
1072
27.1k
    return Triple::x86_64;
1073
243k
  case ELF::EM_AARCH64:
1074
243k
    return IsLittleEndian ? Triple::aarch64 : 
Triple::aarch64_be0
;
1075
0
  case ELF::EM_ARM:
1076
0
    return Triple::arm;
1077
0
  case ELF::EM_AVR:
1078
0
    return Triple::avr;
1079
3
  case ELF::EM_HEXAGON:
1080
3
    return Triple::hexagon;
1081
0
  case ELF::EM_LANAI:
1082
0
    return Triple::lanai;
1083
1.10k
  case ELF::EM_MIPS:
1084
1.10k
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1085
1.10k
    case ELF::ELFCLASS32:
1086
0
      return IsLittleEndian ? Triple::mipsel : Triple::mips;
1087
1.10k
    case ELF::ELFCLASS64:
1088
1.10k
      return IsLittleEndian ? Triple::mips64el : 
Triple::mips640
;
1089
1.10k
    default:
1090
0
      report_fatal_error("Invalid ELFCLASS!");
1091
0
    }
1092
0
  case ELF::EM_PPC:
1093
0
    return Triple::ppc;
1094
15.1M
  case ELF::EM_PPC64:
1095
15.1M
    return IsLittleEndian ? Triple::ppc64le : 
Triple::ppc640
;
1096
0
  case ELF::EM_RISCV:
1097
0
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1098
0
    case ELF::ELFCLASS32:
1099
0
      return Triple::riscv32;
1100
0
    case ELF::ELFCLASS64:
1101
0
      return Triple::riscv64;
1102
0
    default:
1103
0
      report_fatal_error("Invalid ELFCLASS!");
1104
0
    }
1105
0
  case ELF::EM_S390:
1106
0
    return Triple::systemz;
1107
0
1108
0
  case ELF::EM_SPARC:
1109
0
  case ELF::EM_SPARC32PLUS:
1110
0
    return IsLittleEndian ? Triple::sparcel : Triple::sparc;
1111
0
  case ELF::EM_SPARCV9:
1112
0
    return Triple::sparcv9;
1113
0
1114
2.71k
  case ELF::EM_AMDGPU: {
1115
2.71k
    if (!IsLittleEndian)
1116
0
      return Triple::UnknownArch;
1117
2.71k
1118
2.71k
    unsigned MACH = EF.getHeader()->e_flags & ELF::EF_AMDGPU_MACH;
1119
2.71k
    if (MACH >= ELF::EF_AMDGPU_MACH_R600_FIRST &&
1120
2.71k
        
MACH <= ELF::EF_AMDGPU_MACH_R600_LAST2.67k
)
1121
0
      return Triple::r600;
1122
2.71k
    if (MACH >= ELF::EF_AMDGPU_MACH_AMDGCN_FIRST &&
1123
2.71k
        
MACH <= ELF::EF_AMDGPU_MACH_AMDGCN_LAST2.67k
)
1124
2.67k
      return Triple::amdgcn;
1125
41
1126
41
    return Triple::UnknownArch;
1127
41
  }
1128
41
1129
2.51k
  case ELF::EM_BPF:
1130
2.51k
    return IsLittleEndian ? Triple::bpfel : 
Triple::bpfeb0
;
1131
41
1132
41
  default:
1133
0
    return Triple::UnknownArch;
1134
15.4M
  }
1135
15.4M
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getArch() const
Line
Count
Source
1065
15.1M
template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::getArch() const {
1066
15.1M
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1067
15.1M
  switch (EF.getHeader()->e_machine) {
1068
15.1M
  case ELF::EM_386:
1069
0
  case ELF::EM_IAMCU:
1070
0
    return Triple::x86;
1071
6
  case ELF::EM_X86_64:
1072
6
    return Triple::x86_64;
1073
31
  case ELF::EM_AARCH64:
1074
31
    return IsLittleEndian ? 
Triple::aarch640
: Triple::aarch64_be;
1075
0
  case ELF::EM_ARM:
1076
0
    return Triple::arm;
1077
0
  case ELF::EM_AVR:
1078
0
    return Triple::avr;
1079
0
  case ELF::EM_HEXAGON:
1080
0
    return Triple::hexagon;
1081
0
  case ELF::EM_LANAI:
1082
0
    return Triple::lanai;
1083
1.33k
  case ELF::EM_MIPS:
1084
1.33k
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1085
1.33k
    case ELF::ELFCLASS32:
1086
0
      return IsLittleEndian ? Triple::mipsel : Triple::mips;
1087
1.33k
    case ELF::ELFCLASS64:
1088
1.33k
      return IsLittleEndian ? 
Triple::mips64el0
: Triple::mips64;
1089
1.33k
    default:
1090
0
      report_fatal_error("Invalid ELFCLASS!");
1091
0
    }
1092
0
  case ELF::EM_PPC:
1093
0
    return Triple::ppc;
1094
15.1M
  case ELF::EM_PPC64:
1095
15.1M
    return IsLittleEndian ? 
Triple::ppc64le0
: Triple::ppc64;
1096
0
  case ELF::EM_RISCV:
1097
0
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1098
0
    case ELF::ELFCLASS32:
1099
0
      return Triple::riscv32;
1100
0
    case ELF::ELFCLASS64:
1101
0
      return Triple::riscv64;
1102
0
    default:
1103
0
      report_fatal_error("Invalid ELFCLASS!");
1104
0
    }
1105
264
  case ELF::EM_S390:
1106
264
    return Triple::systemz;
1107
0
1108
0
  case ELF::EM_SPARC:
1109
0
  case ELF::EM_SPARC32PLUS:
1110
0
    return IsLittleEndian ? Triple::sparcel : Triple::sparc;
1111
106
  case ELF::EM_SPARCV9:
1112
106
    return Triple::sparcv9;
1113
0
1114
0
  case ELF::EM_AMDGPU: {
1115
0
    if (!IsLittleEndian)
1116
0
      return Triple::UnknownArch;
1117
0
1118
0
    unsigned MACH = EF.getHeader()->e_flags & ELF::EF_AMDGPU_MACH;
1119
0
    if (MACH >= ELF::EF_AMDGPU_MACH_R600_FIRST &&
1120
0
        MACH <= ELF::EF_AMDGPU_MACH_R600_LAST)
1121
0
      return Triple::r600;
1122
0
    if (MACH >= ELF::EF_AMDGPU_MACH_AMDGCN_FIRST &&
1123
0
        MACH <= ELF::EF_AMDGPU_MACH_AMDGCN_LAST)
1124
0
      return Triple::amdgcn;
1125
0
1126
0
    return Triple::UnknownArch;
1127
0
  }
1128
0
1129
394
  case ELF::EM_BPF:
1130
394
    return IsLittleEndian ? 
Triple::bpfel0
: Triple::bpfeb;
1131
0
1132
0
  default:
1133
0
    return Triple::UnknownArch;
1134
15.1M
  }
1135
15.1M
}
1136
1137
template <class ELFT>
1138
2
Expected<uint64_t> ELFObjectFile<ELFT>::getStartAddress() const {
1139
2
  return EF.getHeader()->e_entry;
1140
2
}
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getStartAddress() const
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getStartAddress() const
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getStartAddress() const
Line
Count
Source
1138
2
Expected<uint64_t> ELFObjectFile<ELFT>::getStartAddress() const {
1139
2
  return EF.getHeader()->e_entry;
1140
2
}
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getStartAddress() const
1141
1142
template <class ELFT>
1143
ELFObjectFileBase::elf_symbol_iterator_range
1144
125
ELFObjectFile<ELFT>::getDynamicSymbolIterators() const {
1145
125
  return make_range(dynamic_symbol_begin(), dynamic_symbol_end());
1146
125
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getDynamicSymbolIterators() const
Line
Count
Source
1144
99
ELFObjectFile<ELFT>::getDynamicSymbolIterators() const {
1145
99
  return make_range(dynamic_symbol_begin(), dynamic_symbol_end());
1146
99
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getDynamicSymbolIterators() const
Line
Count
Source
1144
4
ELFObjectFile<ELFT>::getDynamicSymbolIterators() const {
1145
4
  return make_range(dynamic_symbol_begin(), dynamic_symbol_end());
1146
4
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getDynamicSymbolIterators() const
Line
Count
Source
1144
21
ELFObjectFile<ELFT>::getDynamicSymbolIterators() const {
1145
21
  return make_range(dynamic_symbol_begin(), dynamic_symbol_end());
1146
21
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getDynamicSymbolIterators() const
Line
Count
Source
1144
1
ELFObjectFile<ELFT>::getDynamicSymbolIterators() const {
1145
1
  return make_range(dynamic_symbol_begin(), dynamic_symbol_end());
1146
1
}
1147
1148
1.41k
template <class ELFT> bool ELFObjectFile<ELFT>::isRelocatableObject() const {
1149
1.41k
  return EF.getHeader()->e_type == ELF::ET_REL;
1150
1.41k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isRelocatableObject() const
Line
Count
Source
1148
686
template <class ELFT> bool ELFObjectFile<ELFT>::isRelocatableObject() const {
1149
686
  return EF.getHeader()->e_type == ELF::ET_REL;
1150
686
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isRelocatableObject() const
Line
Count
Source
1148
140
template <class ELFT> bool ELFObjectFile<ELFT>::isRelocatableObject() const {
1149
140
  return EF.getHeader()->e_type == ELF::ET_REL;
1150
140
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isRelocatableObject() const
Line
Count
Source
1148
574
template <class ELFT> bool ELFObjectFile<ELFT>::isRelocatableObject() const {
1149
574
  return EF.getHeader()->e_type == ELF::ET_REL;
1150
574
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isRelocatableObject() const
Line
Count
Source
1148
12
template <class ELFT> bool ELFObjectFile<ELFT>::isRelocatableObject() const {
1149
12
  return EF.getHeader()->e_type == ELF::ET_REL;
1150
12
}
1151
1152
} // end namespace object
1153
} // end namespace llvm
1154
1155
#endif // LLVM_OBJECT_ELFOBJECTFILE_H