Coverage Report

Created: 2018-11-13 17:19

/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
  std::vector<std::pair<DataRefImpl, uint64_t>> getPltAddresses() const;
91
};
92
93
class ELFSectionRef : public SectionRef {
94
public:
95
  ELFSectionRef(const SectionRef &B) : SectionRef(B) {
96
    assert(isa<ELFObjectFileBase>(SectionRef::getObject()));
97
  }
98
99
  const ELFObjectFileBase *getObject() const {
100
    return cast<ELFObjectFileBase>(SectionRef::getObject());
101
  }
102
103
  uint32_t getType() const {
104
    return getObject()->getSectionType(getRawDataRefImpl());
105
  }
106
107
  uint64_t getFlags() const {
108
    return getObject()->getSectionFlags(getRawDataRefImpl());
109
  }
110
111
  uint64_t getOffset() const {
112
    return getObject()->getSectionOffset(getRawDataRefImpl());
113
  }
114
};
115
116
class elf_section_iterator : public section_iterator {
117
public:
118
  elf_section_iterator(const section_iterator &B) : section_iterator(B) {
119
    assert(isa<ELFObjectFileBase>(B->getObject()));
120
  }
121
122
  const ELFSectionRef *operator->() const {
123
    return static_cast<const ELFSectionRef *>(section_iterator::operator->());
124
  }
125
126
  const ELFSectionRef &operator*() const {
127
    return static_cast<const ELFSectionRef &>(section_iterator::operator*());
128
  }
129
};
130
131
class ELFSymbolRef : public SymbolRef {
132
public:
133
  ELFSymbolRef(const SymbolRef &B) : SymbolRef(B) {
134
    assert(isa<ELFObjectFileBase>(SymbolRef::getObject()));
135
  }
136
137
  const ELFObjectFileBase *getObject() const {
138
    return cast<ELFObjectFileBase>(BasicSymbolRef::getObject());
139
  }
140
141
  uint64_t getSize() const {
142
    return getObject()->getSymbolSize(getRawDataRefImpl());
143
  }
144
145
  uint8_t getOther() const {
146
    return getObject()->getSymbolOther(getRawDataRefImpl());
147
  }
148
149
  uint8_t getELFType() const {
150
    return getObject()->getSymbolELFType(getRawDataRefImpl());
151
  }
152
};
153
154
class elf_symbol_iterator : public symbol_iterator {
155
public:
156
  elf_symbol_iterator(const basic_symbol_iterator &B)
157
      : symbol_iterator(SymbolRef(B->getRawDataRefImpl(),
158
1.28k
                                  cast<ELFObjectFileBase>(B->getObject()))) {}
159
160
  const ELFSymbolRef *operator->() const {
161
    return static_cast<const ELFSymbolRef *>(symbol_iterator::operator->());
162
  }
163
164
  const ELFSymbolRef &operator*() const {
165
    return static_cast<const ELFSymbolRef &>(symbol_iterator::operator*());
166
  }
167
};
168
169
class ELFRelocationRef : public RelocationRef {
170
public:
171
  ELFRelocationRef(const RelocationRef &B) : RelocationRef(B) {
172
    assert(isa<ELFObjectFileBase>(RelocationRef::getObject()));
173
  }
174
175
  const ELFObjectFileBase *getObject() const {
176
    return cast<ELFObjectFileBase>(RelocationRef::getObject());
177
  }
178
179
  Expected<int64_t> getAddend() const {
180
    return getObject()->getRelocationAddend(getRawDataRefImpl());
181
  }
182
};
183
184
class elf_relocation_iterator : public relocation_iterator {
185
public:
186
  elf_relocation_iterator(const relocation_iterator &B)
187
      : relocation_iterator(RelocationRef(
188
            B->getRawDataRefImpl(), cast<ELFObjectFileBase>(B->getObject()))) {}
189
190
  const ELFRelocationRef *operator->() const {
191
    return static_cast<const ELFRelocationRef *>(
192
        relocation_iterator::operator->());
193
  }
194
195
  const ELFRelocationRef &operator*() const {
196
    return static_cast<const ELFRelocationRef &>(
197
        relocation_iterator::operator*());
198
  }
199
};
200
201
inline ELFObjectFileBase::elf_symbol_iterator_range
202
ELFObjectFileBase::symbols() const {
203
  return elf_symbol_iterator_range(symbol_begin(), symbol_end());
204
}
205
206
template <class ELFT> class ELFObjectFile : public ELFObjectFileBase {
207
  uint16_t getEMachine() const override;
208
  uint16_t getEType() const override;
209
  uint64_t getSymbolSize(DataRefImpl Sym) const override;
210
211
public:
212
  LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
213
214
  using uintX_t = typename ELFT::uint;
215
216
  using Elf_Sym = typename ELFT::Sym;
217
  using Elf_Shdr = typename ELFT::Shdr;
218
  using Elf_Ehdr = typename ELFT::Ehdr;
219
  using Elf_Rel = typename ELFT::Rel;
220
  using Elf_Rela = typename ELFT::Rela;
221
  using Elf_Dyn = typename ELFT::Dyn;
222
223
private:
224
  ELFObjectFile(MemoryBufferRef Object, ELFFile<ELFT> EF,
225
                const Elf_Shdr *DotDynSymSec, const Elf_Shdr *DotSymtabSec,
226
                ArrayRef<Elf_Word> ShndxTable);
227
228
protected:
229
  ELFFile<ELFT> EF;
230
231
  const Elf_Shdr *DotDynSymSec = nullptr; // Dynamic symbol table section.
232
  const Elf_Shdr *DotSymtabSec = nullptr; // Symbol table section.
233
  ArrayRef<Elf_Word> ShndxTable;
234
235
  void moveSymbolNext(DataRefImpl &Symb) const override;
236
  Expected<StringRef> getSymbolName(DataRefImpl Symb) const override;
237
  Expected<uint64_t> getSymbolAddress(DataRefImpl Symb) const override;
238
  uint64_t getSymbolValueImpl(DataRefImpl Symb) const override;
239
  uint32_t getSymbolAlignment(DataRefImpl Symb) const override;
240
  uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override;
241
  uint32_t getSymbolFlags(DataRefImpl Symb) const override;
242
  uint8_t getSymbolOther(DataRefImpl Symb) const override;
243
  uint8_t getSymbolELFType(DataRefImpl Symb) const override;
244
  Expected<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const override;
245
  Expected<section_iterator> getSymbolSection(const Elf_Sym *Symb,
246
                                              const Elf_Shdr *SymTab) const;
247
  Expected<section_iterator> getSymbolSection(DataRefImpl Symb) const override;
248
249
  void moveSectionNext(DataRefImpl &Sec) const override;
250
  std::error_code getSectionName(DataRefImpl Sec,
251
                                 StringRef &Res) const override;
252
  uint64_t getSectionAddress(DataRefImpl Sec) const override;
253
  uint64_t getSectionIndex(DataRefImpl Sec) const override;
254
  uint64_t getSectionSize(DataRefImpl Sec) const override;
255
  std::error_code getSectionContents(DataRefImpl Sec,
256
                                     StringRef &Res) const override;
257
  uint64_t getSectionAlignment(DataRefImpl Sec) const override;
258
  bool isSectionCompressed(DataRefImpl Sec) const override;
259
  bool isSectionText(DataRefImpl Sec) const override;
260
  bool isSectionData(DataRefImpl Sec) const override;
261
  bool isSectionBSS(DataRefImpl Sec) const override;
262
  bool isSectionVirtual(DataRefImpl Sec) const override;
263
  relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
264
  relocation_iterator section_rel_end(DataRefImpl Sec) const override;
265
  std::vector<SectionRef> dynamic_relocation_sections() const override;
266
  section_iterator getRelocatedSection(DataRefImpl Sec) const override;
267
268
  void moveRelocationNext(DataRefImpl &Rel) const override;
269
  uint64_t getRelocationOffset(DataRefImpl Rel) const override;
270
  symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
271
  uint64_t getRelocationType(DataRefImpl Rel) const override;
272
  void getRelocationTypeName(DataRefImpl Rel,
273
                             SmallVectorImpl<char> &Result) const override;
274
275
  uint32_t getSectionType(DataRefImpl Sec) const override;
276
  uint64_t getSectionFlags(DataRefImpl Sec) const override;
277
  uint64_t getSectionOffset(DataRefImpl Sec) const override;
278
  StringRef getRelocationTypeName(uint32_t Type) const;
279
280
  /// Get the relocation section that contains \a Rel.
281
26.6k
  const Elf_Shdr *getRelSection(DataRefImpl Rel) const {
282
26.6k
    auto RelSecOrErr = EF.getSection(Rel.d.a);
283
26.6k
    if (!RelSecOrErr)
284
0
      report_fatal_error(errorToErrorCode(RelSecOrErr.takeError()).message());
285
26.6k
    return *RelSecOrErr;
286
26.6k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelSection(llvm::object::DataRefImpl) const
Line
Count
Source
281
2.69k
  const Elf_Shdr *getRelSection(DataRefImpl Rel) const {
282
2.69k
    auto RelSecOrErr = EF.getSection(Rel.d.a);
283
2.69k
    if (!RelSecOrErr)
284
0
      report_fatal_error(errorToErrorCode(RelSecOrErr.takeError()).message());
285
2.69k
    return *RelSecOrErr;
286
2.69k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelSection(llvm::object::DataRefImpl) const
Line
Count
Source
281
1.08k
  const Elf_Shdr *getRelSection(DataRefImpl Rel) const {
282
1.08k
    auto RelSecOrErr = EF.getSection(Rel.d.a);
283
1.08k
    if (!RelSecOrErr)
284
0
      report_fatal_error(errorToErrorCode(RelSecOrErr.takeError()).message());
285
1.08k
    return *RelSecOrErr;
286
1.08k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelSection(llvm::object::DataRefImpl) const
Line
Count
Source
281
21.8k
  const Elf_Shdr *getRelSection(DataRefImpl Rel) const {
282
21.8k
    auto RelSecOrErr = EF.getSection(Rel.d.a);
283
21.8k
    if (!RelSecOrErr)
284
0
      report_fatal_error(errorToErrorCode(RelSecOrErr.takeError()).message());
285
21.8k
    return *RelSecOrErr;
286
21.8k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelSection(llvm::object::DataRefImpl) const
Line
Count
Source
281
1.04k
  const Elf_Shdr *getRelSection(DataRefImpl Rel) const {
282
1.04k
    auto RelSecOrErr = EF.getSection(Rel.d.a);
283
1.04k
    if (!RelSecOrErr)
284
0
      report_fatal_error(errorToErrorCode(RelSecOrErr.takeError()).message());
285
1.04k
    return *RelSecOrErr;
286
1.04k
  }
287
288
10.1k
  DataRefImpl toDRI(const Elf_Shdr *SymTable, unsigned SymbolNum) const {
289
10.1k
    DataRefImpl DRI;
290
10.1k
    if (!SymTable) {
291
262
      DRI.d.a = 0;
292
262
      DRI.d.b = 0;
293
262
      return DRI;
294
262
    }
295
9.91k
    assert(SymTable->sh_type == ELF::SHT_SYMTAB ||
296
9.91k
           SymTable->sh_type == ELF::SHT_DYNSYM);
297
9.91k
298
9.91k
    auto SectionsOrErr = EF.sections();
299
9.91k
    if (!SectionsOrErr) {
300
0
      DRI.d.a = 0;
301
0
      DRI.d.b = 0;
302
0
      return DRI;
303
0
    }
304
9.91k
    uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
305
9.91k
    unsigned SymTableIndex =
306
9.91k
        (reinterpret_cast<uintptr_t>(SymTable) - SHT) / sizeof(Elf_Shdr);
307
9.91k
308
9.91k
    DRI.d.a = SymTableIndex;
309
9.91k
    DRI.d.b = SymbolNum;
310
9.91k
    return DRI;
311
9.91k
  }
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
288
1.56k
  DataRefImpl toDRI(const Elf_Shdr *SymTable, unsigned SymbolNum) const {
289
1.56k
    DataRefImpl DRI;
290
1.56k
    if (!SymTable) {
291
196
      DRI.d.a = 0;
292
196
      DRI.d.b = 0;
293
196
      return DRI;
294
196
    }
295
1.37k
    assert(SymTable->sh_type == ELF::SHT_SYMTAB ||
296
1.37k
           SymTable->sh_type == ELF::SHT_DYNSYM);
297
1.37k
298
1.37k
    auto SectionsOrErr = EF.sections();
299
1.37k
    if (!SectionsOrErr) {
300
0
      DRI.d.a = 0;
301
0
      DRI.d.b = 0;
302
0
      return DRI;
303
0
    }
304
1.37k
    uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
305
1.37k
    unsigned SymTableIndex =
306
1.37k
        (reinterpret_cast<uintptr_t>(SymTable) - SHT) / sizeof(Elf_Shdr);
307
1.37k
308
1.37k
    DRI.d.a = SymTableIndex;
309
1.37k
    DRI.d.b = SymbolNum;
310
1.37k
    return DRI;
311
1.37k
  }
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
288
432
  DataRefImpl toDRI(const Elf_Shdr *SymTable, unsigned SymbolNum) const {
289
432
    DataRefImpl DRI;
290
432
    if (!SymTable) {
291
8
      DRI.d.a = 0;
292
8
      DRI.d.b = 0;
293
8
      return DRI;
294
8
    }
295
424
    assert(SymTable->sh_type == ELF::SHT_SYMTAB ||
296
424
           SymTable->sh_type == ELF::SHT_DYNSYM);
297
424
298
424
    auto SectionsOrErr = EF.sections();
299
424
    if (!SectionsOrErr) {
300
0
      DRI.d.a = 0;
301
0
      DRI.d.b = 0;
302
0
      return DRI;
303
0
    }
304
424
    uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
305
424
    unsigned SymTableIndex =
306
424
        (reinterpret_cast<uintptr_t>(SymTable) - SHT) / sizeof(Elf_Shdr);
307
424
308
424
    DRI.d.a = SymTableIndex;
309
424
    DRI.d.b = SymbolNum;
310
424
    return DRI;
311
424
  }
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
288
7.80k
  DataRefImpl toDRI(const Elf_Shdr *SymTable, unsigned SymbolNum) const {
289
7.80k
    DataRefImpl DRI;
290
7.80k
    if (!SymTable) {
291
56
      DRI.d.a = 0;
292
56
      DRI.d.b = 0;
293
56
      return DRI;
294
56
    }
295
7.74k
    assert(SymTable->sh_type == ELF::SHT_SYMTAB ||
296
7.74k
           SymTable->sh_type == ELF::SHT_DYNSYM);
297
7.74k
298
7.74k
    auto SectionsOrErr = EF.sections();
299
7.74k
    if (!SectionsOrErr) {
300
0
      DRI.d.a = 0;
301
0
      DRI.d.b = 0;
302
0
      return DRI;
303
0
    }
304
7.74k
    uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
305
7.74k
    unsigned SymTableIndex =
306
7.74k
        (reinterpret_cast<uintptr_t>(SymTable) - SHT) / sizeof(Elf_Shdr);
307
7.74k
308
7.74k
    DRI.d.a = SymTableIndex;
309
7.74k
    DRI.d.b = SymbolNum;
310
7.74k
    return DRI;
311
7.74k
  }
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
288
374
  DataRefImpl toDRI(const Elf_Shdr *SymTable, unsigned SymbolNum) const {
289
374
    DataRefImpl DRI;
290
374
    if (!SymTable) {
291
2
      DRI.d.a = 0;
292
2
      DRI.d.b = 0;
293
2
      return DRI;
294
2
    }
295
372
    assert(SymTable->sh_type == ELF::SHT_SYMTAB ||
296
372
           SymTable->sh_type == ELF::SHT_DYNSYM);
297
372
298
372
    auto SectionsOrErr = EF.sections();
299
372
    if (!SectionsOrErr) {
300
0
      DRI.d.a = 0;
301
0
      DRI.d.b = 0;
302
0
      return DRI;
303
0
    }
304
372
    uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
305
372
    unsigned SymTableIndex =
306
372
        (reinterpret_cast<uintptr_t>(SymTable) - SHT) / sizeof(Elf_Shdr);
307
372
308
372
    DRI.d.a = SymTableIndex;
309
372
    DRI.d.b = SymbolNum;
310
372
    return DRI;
311
372
  }
312
313
  const Elf_Shdr *toELFShdrIter(DataRefImpl Sec) const {
314
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
315
  }
316
317
206k
  DataRefImpl toDRI(const Elf_Shdr *Sec) const {
318
206k
    DataRefImpl DRI;
319
206k
    DRI.p = reinterpret_cast<uintptr_t>(Sec);
320
206k
    return DRI;
321
206k
  }
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
317
35.8k
  DataRefImpl toDRI(const Elf_Shdr *Sec) const {
318
35.8k
    DataRefImpl DRI;
319
35.8k
    DRI.p = reinterpret_cast<uintptr_t>(Sec);
320
35.8k
    return DRI;
321
35.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
317
8.87k
  DataRefImpl toDRI(const Elf_Shdr *Sec) const {
318
8.87k
    DataRefImpl DRI;
319
8.87k
    DRI.p = reinterpret_cast<uintptr_t>(Sec);
320
8.87k
    return DRI;
321
8.87k
  }
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
317
154k
  DataRefImpl toDRI(const Elf_Shdr *Sec) const {
318
154k
    DataRefImpl DRI;
319
154k
    DRI.p = reinterpret_cast<uintptr_t>(Sec);
320
154k
    return DRI;
321
154k
  }
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
317
6.82k
  DataRefImpl toDRI(const Elf_Shdr *Sec) const {
318
6.82k
    DataRefImpl DRI;
319
6.82k
    DRI.p = reinterpret_cast<uintptr_t>(Sec);
320
6.82k
    return DRI;
321
6.82k
  }
322
323
  DataRefImpl toDRI(const Elf_Dyn *Dyn) const {
324
    DataRefImpl DRI;
325
    DRI.p = reinterpret_cast<uintptr_t>(Dyn);
326
    return DRI;
327
  }
328
329
42.0k
  bool isExportedToOtherDSO(const Elf_Sym *ESym) const {
330
42.0k
    unsigned char Binding = ESym->getBinding();
331
42.0k
    unsigned char Visibility = ESym->getVisibility();
332
42.0k
333
42.0k
    // A symbol is exported if its binding is either GLOBAL or WEAK, and its
334
42.0k
    // visibility is either DEFAULT or PROTECTED. All other symbols are not
335
42.0k
    // exported.
336
42.0k
    return ((Binding == ELF::STB_GLOBAL || 
Binding == ELF::STB_WEAK24.8k
) &&
337
42.0k
            
(21.1k
Visibility == ELF::STV_DEFAULT21.1k
||
338
21.1k
             
Visibility == ELF::STV_PROTECTED8.66k
));
339
42.0k
  }
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
329
9.01k
  bool isExportedToOtherDSO(const Elf_Sym *ESym) const {
330
9.01k
    unsigned char Binding = ESym->getBinding();
331
9.01k
    unsigned char Visibility = ESym->getVisibility();
332
9.01k
333
9.01k
    // A symbol is exported if its binding is either GLOBAL or WEAK, and its
334
9.01k
    // visibility is either DEFAULT or PROTECTED. All other symbols are not
335
9.01k
    // exported.
336
9.01k
    return ((Binding == ELF::STB_GLOBAL || 
Binding == ELF::STB_WEAK5.65k
) &&
337
9.01k
            
(3.37k
Visibility == ELF::STV_DEFAULT3.37k
||
338
3.37k
             
Visibility == ELF::STV_PROTECTED11
));
339
9.01k
  }
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
329
1.17k
  bool isExportedToOtherDSO(const Elf_Sym *ESym) const {
330
1.17k
    unsigned char Binding = ESym->getBinding();
331
1.17k
    unsigned char Visibility = ESym->getVisibility();
332
1.17k
333
1.17k
    // A symbol is exported if its binding is either GLOBAL or WEAK, and its
334
1.17k
    // visibility is either DEFAULT or PROTECTED. All other symbols are not
335
1.17k
    // exported.
336
1.17k
    return ((Binding == ELF::STB_GLOBAL || 
Binding == ELF::STB_WEAK802
) &&
337
1.17k
            
(382
Visibility == ELF::STV_DEFAULT382
||
338
382
             
Visibility == ELF::STV_PROTECTED0
));
339
1.17k
  }
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
329
30.9k
  bool isExportedToOtherDSO(const Elf_Sym *ESym) const {
330
30.9k
    unsigned char Binding = ESym->getBinding();
331
30.9k
    unsigned char Visibility = ESym->getVisibility();
332
30.9k
333
30.9k
    // A symbol is exported if its binding is either GLOBAL or WEAK, and its
334
30.9k
    // visibility is either DEFAULT or PROTECTED. All other symbols are not
335
30.9k
    // exported.
336
30.9k
    return ((Binding == ELF::STB_GLOBAL || 
Binding == ELF::STB_WEAK17.8k
) &&
337
30.9k
            
(17.0k
Visibility == ELF::STV_DEFAULT17.0k
||
338
17.0k
             
Visibility == ELF::STV_PROTECTED8.65k
));
339
30.9k
  }
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
329
869
  bool isExportedToOtherDSO(const Elf_Sym *ESym) const {
330
869
    unsigned char Binding = ESym->getBinding();
331
869
    unsigned char Visibility = ESym->getVisibility();
332
869
333
869
    // A symbol is exported if its binding is either GLOBAL or WEAK, and its
334
869
    // visibility is either DEFAULT or PROTECTED. All other symbols are not
335
869
    // exported.
336
869
    return ((Binding == ELF::STB_GLOBAL || 
Binding == ELF::STB_WEAK549
) &&
337
869
            
(323
Visibility == ELF::STV_DEFAULT323
||
338
323
             
Visibility == ELF::STV_PROTECTED0
));
339
869
  }
340
341
  // This flag is used for classof, to distinguish ELFObjectFile from
342
  // its subclass. If more subclasses will be created, this flag will
343
  // have to become an enum.
344
  bool isDyldELFObject;
345
346
public:
347
  ELFObjectFile(ELFObjectFile<ELFT> &&Other);
348
  static Expected<ELFObjectFile<ELFT>> create(MemoryBufferRef Object);
349
350
  const Elf_Rel *getRel(DataRefImpl Rel) const;
351
  const Elf_Rela *getRela(DataRefImpl Rela) const;
352
353
168k
  const Elf_Sym *getSymbol(DataRefImpl Sym) const {
354
168k
    auto Ret = EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
355
168k
    if (!Ret)
356
0
      report_fatal_error(errorToErrorCode(Ret.takeError()).message());
357
168k
    return *Ret;
358
168k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
353
54.5k
  const Elf_Sym *getSymbol(DataRefImpl Sym) const {
354
54.5k
    auto Ret = EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
355
54.5k
    if (!Ret)
356
0
      report_fatal_error(errorToErrorCode(Ret.takeError()).message());
357
54.5k
    return *Ret;
358
54.5k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
353
4.81k
  const Elf_Sym *getSymbol(DataRefImpl Sym) const {
354
4.81k
    auto Ret = EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
355
4.81k
    if (!Ret)
356
0
      report_fatal_error(errorToErrorCode(Ret.takeError()).message());
357
4.81k
    return *Ret;
358
4.81k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
353
106k
  const Elf_Sym *getSymbol(DataRefImpl Sym) const {
354
106k
    auto Ret = EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
355
106k
    if (!Ret)
356
0
      report_fatal_error(errorToErrorCode(Ret.takeError()).message());
357
106k
    return *Ret;
358
106k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
353
3.39k
  const Elf_Sym *getSymbol(DataRefImpl Sym) const {
354
3.39k
    auto Ret = EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
355
3.39k
    if (!Ret)
356
0
      report_fatal_error(errorToErrorCode(Ret.takeError()).message());
357
3.39k
    return *Ret;
358
3.39k
  }
359
360
525k
  const Elf_Shdr *getSection(DataRefImpl Sec) const {
361
525k
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
362
525k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSection(llvm::object::DataRefImpl) const
Line
Count
Source
360
39.8k
  const Elf_Shdr *getSection(DataRefImpl Sec) const {
361
39.8k
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
362
39.8k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSection(llvm::object::DataRefImpl) const
Line
Count
Source
360
12.1k
  const Elf_Shdr *getSection(DataRefImpl Sec) const {
361
12.1k
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
362
12.1k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSection(llvm::object::DataRefImpl) const
Line
Count
Source
360
463k
  const Elf_Shdr *getSection(DataRefImpl Sec) const {
361
463k
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
362
463k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSection(llvm::object::DataRefImpl) const
Line
Count
Source
360
10.0k
  const Elf_Shdr *getSection(DataRefImpl Sec) const {
361
10.0k
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
362
10.0k
  }
363
364
  basic_symbol_iterator symbol_begin() const override;
365
  basic_symbol_iterator symbol_end() const override;
366
367
  elf_symbol_iterator dynamic_symbol_begin() const;
368
  elf_symbol_iterator dynamic_symbol_end() const;
369
370
  section_iterator section_begin() const override;
371
  section_iterator section_end() const override;
372
373
  Expected<int64_t> getRelocationAddend(DataRefImpl Rel) const override;
374
375
  uint8_t getBytesInAddress() const override;
376
  StringRef getFileFormatName() const override;
377
  Triple::ArchType getArch() const override;
378
  Expected<uint64_t> getStartAddress() const override;
379
380
145
  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
380
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
380
73
  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
380
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
380
21
  unsigned getPlatformFlags() const override { return EF.getHeader()->e_flags; }
381
382
234
  std::error_code getBuildAttributes(ARMAttributeParser &Attributes) const override {
383
234
    auto SectionsOrErr = EF.sections();
384
234
    if (!SectionsOrErr)
385
0
      return errorToErrorCode(SectionsOrErr.takeError());
386
234
387
1.56k
    
for (const Elf_Shdr &Sec : *SectionsOrErr)234
{
388
1.56k
      if (Sec.sh_type == ELF::SHT_ARM_ATTRIBUTES) {
389
157
        auto ErrorOrContents = EF.getSectionContents(&Sec);
390
157
        if (!ErrorOrContents)
391
0
          return errorToErrorCode(ErrorOrContents.takeError());
392
157
393
157
        auto Contents = ErrorOrContents.get();
394
157
        if (Contents[0] != ARMBuildAttrs::Format_Version || Contents.size() == 1)
395
0
          return std::error_code();
396
157
397
157
        Attributes.Parse(Contents, ELFT::TargetEndianness == support::little);
398
157
        break;
399
157
      }
400
1.56k
    }
401
234
    return std::error_code();
402
234
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getBuildAttributes(llvm::ARMAttributeParser&) const
Line
Count
Source
382
234
  std::error_code getBuildAttributes(ARMAttributeParser &Attributes) const override {
383
234
    auto SectionsOrErr = EF.sections();
384
234
    if (!SectionsOrErr)
385
0
      return errorToErrorCode(SectionsOrErr.takeError());
386
234
387
1.56k
    
for (const Elf_Shdr &Sec : *SectionsOrErr)234
{
388
1.56k
      if (Sec.sh_type == ELF::SHT_ARM_ATTRIBUTES) {
389
157
        auto ErrorOrContents = EF.getSectionContents(&Sec);
390
157
        if (!ErrorOrContents)
391
0
          return errorToErrorCode(ErrorOrContents.takeError());
392
157
393
157
        auto Contents = ErrorOrContents.get();
394
157
        if (Contents[0] != ARMBuildAttrs::Format_Version || Contents.size() == 1)
395
0
          return std::error_code();
396
157
397
157
        Attributes.Parse(Contents, ELFT::TargetEndianness == support::little);
398
157
        break;
399
157
      }
400
1.56k
    }
401
234
    return std::error_code();
402
234
  }
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
403
404
  const ELFFile<ELFT> *getELFFile() const { return &EF; }
405
406
  bool isDyldType() const { return isDyldELFObject; }
407
  static bool classof(const Binary *v) {
408
    return v->getType() == getELFType(ELFT::TargetEndianness == support::little,
409
                                      ELFT::Is64Bits);
410
  }
411
412
  elf_symbol_iterator_range getDynamicSymbolIterators() const override;
413
414
  bool isRelocatableObject() const override;
415
};
416
417
using ELF32LEObjectFile = ELFObjectFile<ELF32LE>;
418
using ELF64LEObjectFile = ELFObjectFile<ELF64LE>;
419
using ELF32BEObjectFile = ELFObjectFile<ELF32BE>;
420
using ELF64BEObjectFile = ELFObjectFile<ELF64BE>;
421
422
template <class ELFT>
423
30.0k
void ELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Sym) const {
424
30.0k
  ++Sym.d.b;
425
30.0k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::moveSymbolNext(llvm::object::DataRefImpl&) const
Line
Count
Source
423
8.24k
void ELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Sym) const {
424
8.24k
  ++Sym.d.b;
425
8.24k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::moveSymbolNext(llvm::object::DataRefImpl&) const
Line
Count
Source
423
716
void ELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Sym) const {
424
716
  ++Sym.d.b;
425
716
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::moveSymbolNext(llvm::object::DataRefImpl&) const
Line
Count
Source
423
20.5k
void ELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Sym) const {
424
20.5k
  ++Sym.d.b;
425
20.5k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::moveSymbolNext(llvm::object::DataRefImpl&) const
Line
Count
Source
423
558
void ELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Sym) const {
424
558
  ++Sym.d.b;
425
558
}
426
427
template <class ELFT>
428
33.1k
Expected<StringRef> ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Sym) const {
429
33.1k
  const Elf_Sym *ESym = getSymbol(Sym);
430
33.1k
  auto SymTabOrErr = EF.getSection(Sym.d.a);
431
33.1k
  if (!SymTabOrErr)
432
0
    return SymTabOrErr.takeError();
433
33.1k
  const Elf_Shdr *SymTableSec = *SymTabOrErr;
434
33.1k
  auto StrTabOrErr = EF.getSection(SymTableSec->sh_link);
435
33.1k
  if (!StrTabOrErr)
436
0
    return StrTabOrErr.takeError();
437
33.1k
  const Elf_Shdr *StringTableSec = *StrTabOrErr;
438
33.1k
  auto SymStrTabOrErr = EF.getStringTable(StringTableSec);
439
33.1k
  if (!SymStrTabOrErr)
440
0
    return SymStrTabOrErr.takeError();
441
33.1k
  return ESym->getName(*SymStrTabOrErr);
442
33.1k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolName(llvm::object::DataRefImpl) const
Line
Count
Source
428
14.4k
Expected<StringRef> ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Sym) const {
429
14.4k
  const Elf_Sym *ESym = getSymbol(Sym);
430
14.4k
  auto SymTabOrErr = EF.getSection(Sym.d.a);
431
14.4k
  if (!SymTabOrErr)
432
0
    return SymTabOrErr.takeError();
433
14.4k
  const Elf_Shdr *SymTableSec = *SymTabOrErr;
434
14.4k
  auto StrTabOrErr = EF.getSection(SymTableSec->sh_link);
435
14.4k
  if (!StrTabOrErr)
436
0
    return StrTabOrErr.takeError();
437
14.4k
  const Elf_Shdr *StringTableSec = *StrTabOrErr;
438
14.4k
  auto SymStrTabOrErr = EF.getStringTable(StringTableSec);
439
14.4k
  if (!SymStrTabOrErr)
440
0
    return SymStrTabOrErr.takeError();
441
14.4k
  return ESym->getName(*SymStrTabOrErr);
442
14.4k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolName(llvm::object::DataRefImpl) const
Line
Count
Source
428
707
Expected<StringRef> ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Sym) const {
429
707
  const Elf_Sym *ESym = getSymbol(Sym);
430
707
  auto SymTabOrErr = EF.getSection(Sym.d.a);
431
707
  if (!SymTabOrErr)
432
0
    return SymTabOrErr.takeError();
433
707
  const Elf_Shdr *SymTableSec = *SymTabOrErr;
434
707
  auto StrTabOrErr = EF.getSection(SymTableSec->sh_link);
435
707
  if (!StrTabOrErr)
436
0
    return StrTabOrErr.takeError();
437
707
  const Elf_Shdr *StringTableSec = *StrTabOrErr;
438
707
  auto SymStrTabOrErr = EF.getStringTable(StringTableSec);
439
707
  if (!SymStrTabOrErr)
440
0
    return SymStrTabOrErr.takeError();
441
707
  return ESym->getName(*SymStrTabOrErr);
442
707
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolName(llvm::object::DataRefImpl) const
Line
Count
Source
428
17.4k
Expected<StringRef> ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Sym) const {
429
17.4k
  const Elf_Sym *ESym = getSymbol(Sym);
430
17.4k
  auto SymTabOrErr = EF.getSection(Sym.d.a);
431
17.4k
  if (!SymTabOrErr)
432
0
    return SymTabOrErr.takeError();
433
17.4k
  const Elf_Shdr *SymTableSec = *SymTabOrErr;
434
17.4k
  auto StrTabOrErr = EF.getSection(SymTableSec->sh_link);
435
17.4k
  if (!StrTabOrErr)
436
0
    return StrTabOrErr.takeError();
437
17.4k
  const Elf_Shdr *StringTableSec = *StrTabOrErr;
438
17.4k
  auto SymStrTabOrErr = EF.getStringTable(StringTableSec);
439
17.4k
  if (!SymStrTabOrErr)
440
0
    return SymStrTabOrErr.takeError();
441
17.4k
  return ESym->getName(*SymStrTabOrErr);
442
17.4k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolName(llvm::object::DataRefImpl) const
Line
Count
Source
428
503
Expected<StringRef> ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Sym) const {
429
503
  const Elf_Sym *ESym = getSymbol(Sym);
430
503
  auto SymTabOrErr = EF.getSection(Sym.d.a);
431
503
  if (!SymTabOrErr)
432
0
    return SymTabOrErr.takeError();
433
503
  const Elf_Shdr *SymTableSec = *SymTabOrErr;
434
503
  auto StrTabOrErr = EF.getSection(SymTableSec->sh_link);
435
503
  if (!StrTabOrErr)
436
0
    return StrTabOrErr.takeError();
437
503
  const Elf_Shdr *StringTableSec = *StrTabOrErr;
438
503
  auto SymStrTabOrErr = EF.getStringTable(StringTableSec);
439
503
  if (!SymStrTabOrErr)
440
0
    return SymStrTabOrErr.takeError();
441
503
  return ESym->getName(*SymStrTabOrErr);
442
503
}
443
444
template <class ELFT>
445
884
uint64_t ELFObjectFile<ELFT>::getSectionFlags(DataRefImpl Sec) const {
446
884
  return getSection(Sec)->sh_flags;
447
884
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionFlags(llvm::object::DataRefImpl) const
Line
Count
Source
445
72
uint64_t ELFObjectFile<ELFT>::getSectionFlags(DataRefImpl Sec) const {
446
72
  return getSection(Sec)->sh_flags;
447
72
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionFlags(llvm::object::DataRefImpl) const
Line
Count
Source
445
36
uint64_t ELFObjectFile<ELFT>::getSectionFlags(DataRefImpl Sec) const {
446
36
  return getSection(Sec)->sh_flags;
447
36
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionFlags(llvm::object::DataRefImpl) const
Line
Count
Source
445
732
uint64_t ELFObjectFile<ELFT>::getSectionFlags(DataRefImpl Sec) const {
446
732
  return getSection(Sec)->sh_flags;
447
732
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionFlags(llvm::object::DataRefImpl) const
Line
Count
Source
445
44
uint64_t ELFObjectFile<ELFT>::getSectionFlags(DataRefImpl Sec) const {
446
44
  return getSection(Sec)->sh_flags;
447
44
}
448
449
template <class ELFT>
450
578
uint32_t ELFObjectFile<ELFT>::getSectionType(DataRefImpl Sec) const {
451
578
  return getSection(Sec)->sh_type;
452
578
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionType(llvm::object::DataRefImpl) const
Line
Count
Source
450
55
uint32_t ELFObjectFile<ELFT>::getSectionType(DataRefImpl Sec) const {
451
55
  return getSection(Sec)->sh_type;
452
55
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionType(llvm::object::DataRefImpl) const
Line
Count
Source
450
18
uint32_t ELFObjectFile<ELFT>::getSectionType(DataRefImpl Sec) const {
451
18
  return getSection(Sec)->sh_type;
452
18
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionType(llvm::object::DataRefImpl) const
Line
Count
Source
450
483
uint32_t ELFObjectFile<ELFT>::getSectionType(DataRefImpl Sec) const {
451
483
  return getSection(Sec)->sh_type;
452
483
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionType(llvm::object::DataRefImpl) const
Line
Count
Source
450
22
uint32_t ELFObjectFile<ELFT>::getSectionType(DataRefImpl Sec) const {
451
22
  return getSection(Sec)->sh_type;
452
22
}
453
454
template <class ELFT>
455
0
uint64_t ELFObjectFile<ELFT>::getSectionOffset(DataRefImpl Sec) const {
456
0
  return getSection(Sec)->sh_offset;
457
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
458
459
template <class ELFT>
460
25.2k
uint64_t ELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const {
461
25.2k
  const Elf_Sym *ESym = getSymbol(Symb);
462
25.2k
  uint64_t Ret = ESym->st_value;
463
25.2k
  if (ESym->st_shndx == ELF::SHN_ABS)
464
595
    return Ret;
465
24.6k
466
24.6k
  const Elf_Ehdr *Header = EF.getHeader();
467
24.6k
  // Clear the ARM/Thumb or microMIPS indicator flag.
468
24.6k
  if ((Header->e_machine == ELF::EM_ARM || 
Header->e_machine == ELF::EM_MIPS18.6k
) &&
469
24.6k
      
ESym->getType() == ELF::STT_FUNC6.95k
)
470
3.01k
    Ret &= ~1;
471
24.6k
472
24.6k
  return Ret;
473
24.6k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolValueImpl(llvm::object::DataRefImpl) const
Line
Count
Source
460
7.47k
uint64_t ELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const {
461
7.47k
  const Elf_Sym *ESym = getSymbol(Symb);
462
7.47k
  uint64_t Ret = ESym->st_value;
463
7.47k
  if (ESym->st_shndx == ELF::SHN_ABS)
464
150
    return Ret;
465
7.32k
466
7.32k
  const Elf_Ehdr *Header = EF.getHeader();
467
7.32k
  // Clear the ARM/Thumb or microMIPS indicator flag.
468
7.32k
  if ((Header->e_machine == ELF::EM_ARM || 
Header->e_machine == ELF::EM_MIPS1.27k
) &&
469
7.32k
      
ESym->getType() == ELF::STT_FUNC6.21k
)
470
2.83k
    Ret &= ~1;
471
7.32k
472
7.32k
  return Ret;
473
7.32k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolValueImpl(llvm::object::DataRefImpl) const
Line
Count
Source
460
608
uint64_t ELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const {
461
608
  const Elf_Sym *ESym = getSymbol(Symb);
462
608
  uint64_t Ret = ESym->st_value;
463
608
  if (ESym->st_shndx == ELF::SHN_ABS)
464
30
    return Ret;
465
578
466
578
  const Elf_Ehdr *Header = EF.getHeader();
467
578
  // Clear the ARM/Thumb or microMIPS indicator flag.
468
578
  if ((Header->e_machine == ELF::EM_ARM || 
Header->e_machine == ELF::EM_MIPS560
) &&
469
578
      
ESym->getType() == ELF::STT_FUNC554
)
470
138
    Ret &= ~1;
471
578
472
578
  return Ret;
473
578
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolValueImpl(llvm::object::DataRefImpl) const
Line
Count
Source
460
16.7k
uint64_t ELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const {
461
16.7k
  const Elf_Sym *ESym = getSymbol(Symb);
462
16.7k
  uint64_t Ret = ESym->st_value;
463
16.7k
  if (ESym->st_shndx == ELF::SHN_ABS)
464
400
    return Ret;
465
16.3k
466
16.3k
  const Elf_Ehdr *Header = EF.getHeader();
467
16.3k
  // Clear the ARM/Thumb or microMIPS indicator flag.
468
16.3k
  if ((Header->e_machine == ELF::EM_ARM || Header->e_machine == ELF::EM_MIPS) &&
469
16.3k
      
ESym->getType() == ELF::STT_FUNC60
)
470
30
    Ret &= ~1;
471
16.3k
472
16.3k
  return Ret;
473
16.3k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolValueImpl(llvm::object::DataRefImpl) const
Line
Count
Source
460
415
uint64_t ELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const {
461
415
  const Elf_Sym *ESym = getSymbol(Symb);
462
415
  uint64_t Ret = ESym->st_value;
463
415
  if (ESym->st_shndx == ELF::SHN_ABS)
464
15
    return Ret;
465
400
466
400
  const Elf_Ehdr *Header = EF.getHeader();
467
400
  // Clear the ARM/Thumb or microMIPS indicator flag.
468
400
  if ((Header->e_machine == ELF::EM_ARM || Header->e_machine == ELF::EM_MIPS) &&
469
400
      
ESym->getType() == ELF::STT_FUNC131
)
470
11
    Ret &= ~1;
471
400
472
400
  return Ret;
473
400
}
474
475
template <class ELFT>
476
Expected<uint64_t>
477
27.7k
ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb) const {
478
27.7k
  uint64_t Result = getSymbolValue(Symb);
479
27.7k
  const Elf_Sym *ESym = getSymbol(Symb);
480
27.7k
  switch (ESym->st_shndx) {
481
27.7k
  case ELF::SHN_COMMON:
482
3.03k
  case ELF::SHN_UNDEF:
483
3.03k
  case ELF::SHN_ABS:
484
3.03k
    return Result;
485
24.6k
  }
486
24.6k
487
24.6k
  const Elf_Ehdr *Header = EF.getHeader();
488
24.6k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
489
24.6k
  if (!SymTabOrErr)
490
0
    return SymTabOrErr.takeError();
491
24.6k
  const Elf_Shdr *SymTab = *SymTabOrErr;
492
24.6k
493
24.6k
  if (Header->e_type == ELF::ET_REL) {
494
5.26k
    auto SectionOrErr = EF.getSection(ESym, SymTab, ShndxTable);
495
5.26k
    if (!SectionOrErr)
496
0
      return SectionOrErr.takeError();
497
5.26k
    const Elf_Shdr *Section = *SectionOrErr;
498
5.26k
    if (Section)
499
5.26k
      Result += Section->sh_addr;
500
5.26k
  }
501
24.6k
502
24.6k
  return Result;
503
24.6k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolAddress(llvm::object::DataRefImpl) const
Line
Count
Source
477
8.12k
ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb) const {
478
8.12k
  uint64_t Result = getSymbolValue(Symb);
479
8.12k
  const Elf_Sym *ESym = getSymbol(Symb);
480
8.12k
  switch (ESym->st_shndx) {
481
8.12k
  case ELF::SHN_COMMON:
482
800
  case ELF::SHN_UNDEF:
483
800
  case ELF::SHN_ABS:
484
800
    return Result;
485
7.32k
  }
486
7.32k
487
7.32k
  const Elf_Ehdr *Header = EF.getHeader();
488
7.32k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
489
7.32k
  if (!SymTabOrErr)
490
0
    return SymTabOrErr.takeError();
491
7.32k
  const Elf_Shdr *SymTab = *SymTabOrErr;
492
7.32k
493
7.32k
  if (Header->e_type == ELF::ET_REL) {
494
1.70k
    auto SectionOrErr = EF.getSection(ESym, SymTab, ShndxTable);
495
1.70k
    if (!SectionOrErr)
496
0
      return SectionOrErr.takeError();
497
1.70k
    const Elf_Shdr *Section = *SectionOrErr;
498
1.70k
    if (Section)
499
1.70k
      Result += Section->sh_addr;
500
1.70k
  }
501
7.32k
502
7.32k
  return Result;
503
7.32k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolAddress(llvm::object::DataRefImpl) const
Line
Count
Source
477
743
ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb) const {
478
743
  uint64_t Result = getSymbolValue(Symb);
479
743
  const Elf_Sym *ESym = getSymbol(Symb);
480
743
  switch (ESym->st_shndx) {
481
743
  case ELF::SHN_COMMON:
482
165
  case ELF::SHN_UNDEF:
483
165
  case ELF::SHN_ABS:
484
165
    return Result;
485
578
  }
486
578
487
578
  const Elf_Ehdr *Header = EF.getHeader();
488
578
  auto SymTabOrErr = EF.getSection(Symb.d.a);
489
578
  if (!SymTabOrErr)
490
0
    return SymTabOrErr.takeError();
491
578
  const Elf_Shdr *SymTab = *SymTabOrErr;
492
578
493
578
  if (Header->e_type == ELF::ET_REL) {
494
237
    auto SectionOrErr = EF.getSection(ESym, SymTab, ShndxTable);
495
237
    if (!SectionOrErr)
496
0
      return SectionOrErr.takeError();
497
237
    const Elf_Shdr *Section = *SectionOrErr;
498
237
    if (Section)
499
237
      Result += Section->sh_addr;
500
237
  }
501
578
502
578
  return Result;
503
578
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolAddress(llvm::object::DataRefImpl) const
Line
Count
Source
477
18.3k
ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb) const {
478
18.3k
  uint64_t Result = getSymbolValue(Symb);
479
18.3k
  const Elf_Sym *ESym = getSymbol(Symb);
480
18.3k
  switch (ESym->st_shndx) {
481
18.3k
  case ELF::SHN_COMMON:
482
1.95k
  case ELF::SHN_UNDEF:
483
1.95k
  case ELF::SHN_ABS:
484
1.95k
    return Result;
485
16.3k
  }
486
16.3k
487
16.3k
  const Elf_Ehdr *Header = EF.getHeader();
488
16.3k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
489
16.3k
  if (!SymTabOrErr)
490
0
    return SymTabOrErr.takeError();
491
16.3k
  const Elf_Shdr *SymTab = *SymTabOrErr;
492
16.3k
493
16.3k
  if (Header->e_type == ELF::ET_REL) {
494
3.17k
    auto SectionOrErr = EF.getSection(ESym, SymTab, ShndxTable);
495
3.17k
    if (!SectionOrErr)
496
0
      return SectionOrErr.takeError();
497
3.17k
    const Elf_Shdr *Section = *SectionOrErr;
498
3.17k
    if (Section)
499
3.17k
      Result += Section->sh_addr;
500
3.17k
  }
501
16.3k
502
16.3k
  return Result;
503
16.3k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolAddress(llvm::object::DataRefImpl) const
Line
Count
Source
477
517
ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb) const {
478
517
  uint64_t Result = getSymbolValue(Symb);
479
517
  const Elf_Sym *ESym = getSymbol(Symb);
480
517
  switch (ESym->st_shndx) {
481
517
  case ELF::SHN_COMMON:
482
117
  case ELF::SHN_UNDEF:
483
117
  case ELF::SHN_ABS:
484
117
    return Result;
485
400
  }
486
400
487
400
  const Elf_Ehdr *Header = EF.getHeader();
488
400
  auto SymTabOrErr = EF.getSection(Symb.d.a);
489
400
  if (!SymTabOrErr)
490
0
    return SymTabOrErr.takeError();
491
400
  const Elf_Shdr *SymTab = *SymTabOrErr;
492
400
493
400
  if (Header->e_type == ELF::ET_REL) {
494
145
    auto SectionOrErr = EF.getSection(ESym, SymTab, ShndxTable);
495
145
    if (!SectionOrErr)
496
0
      return SectionOrErr.takeError();
497
145
    const Elf_Shdr *Section = *SectionOrErr;
498
145
    if (Section)
499
145
      Result += Section->sh_addr;
500
145
  }
501
400
502
400
  return Result;
503
400
}
504
505
template <class ELFT>
506
99
uint32_t ELFObjectFile<ELFT>::getSymbolAlignment(DataRefImpl Symb) const {
507
99
  const Elf_Sym *Sym = getSymbol(Symb);
508
99
  if (Sym->st_shndx == ELF::SHN_COMMON)
509
99
    return Sym->st_value;
510
0
  return 0;
511
0
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
506
6
uint32_t ELFObjectFile<ELFT>::getSymbolAlignment(DataRefImpl Symb) const {
507
6
  const Elf_Sym *Sym = getSymbol(Symb);
508
6
  if (Sym->st_shndx == ELF::SHN_COMMON)
509
6
    return Sym->st_value;
510
0
  return 0;
511
0
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
506
4
uint32_t ELFObjectFile<ELFT>::getSymbolAlignment(DataRefImpl Symb) const {
507
4
  const Elf_Sym *Sym = getSymbol(Symb);
508
4
  if (Sym->st_shndx == ELF::SHN_COMMON)
509
4
    return Sym->st_value;
510
0
  return 0;
511
0
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
506
87
uint32_t ELFObjectFile<ELFT>::getSymbolAlignment(DataRefImpl Symb) const {
507
87
  const Elf_Sym *Sym = getSymbol(Symb);
508
87
  if (Sym->st_shndx == ELF::SHN_COMMON)
509
87
    return Sym->st_value;
510
0
  return 0;
511
0
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
506
2
uint32_t ELFObjectFile<ELFT>::getSymbolAlignment(DataRefImpl Symb) const {
507
2
  const Elf_Sym *Sym = getSymbol(Symb);
508
2
  if (Sym->st_shndx == ELF::SHN_COMMON)
509
2
    return Sym->st_value;
510
0
  return 0;
511
0
}
512
513
template <class ELFT>
514
1.43k
uint16_t ELFObjectFile<ELFT>::getEMachine() const {
515
1.43k
  return EF.getHeader()->e_machine;
516
1.43k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getEMachine() const
Line
Count
Source
514
382
uint16_t ELFObjectFile<ELFT>::getEMachine() const {
515
382
  return EF.getHeader()->e_machine;
516
382
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getEMachine() const
Line
Count
Source
514
67
uint16_t ELFObjectFile<ELFT>::getEMachine() const {
515
67
  return EF.getHeader()->e_machine;
516
67
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getEMachine() const
Line
Count
Source
514
930
uint16_t ELFObjectFile<ELFT>::getEMachine() const {
515
930
  return EF.getHeader()->e_machine;
516
930
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getEMachine() const
Line
Count
Source
514
53
uint16_t ELFObjectFile<ELFT>::getEMachine() const {
515
53
  return EF.getHeader()->e_machine;
516
53
}
517
518
0
template <class ELFT> uint16_t ELFObjectFile<ELFT>::getEType() const {
519
0
  return EF.getHeader()->e_type;
520
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
521
522
template <class ELFT>
523
7.07k
uint64_t ELFObjectFile<ELFT>::getSymbolSize(DataRefImpl Sym) const {
524
7.07k
  return getSymbol(Sym)->st_size;
525
7.07k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolSize(llvm::object::DataRefImpl) const
Line
Count
Source
523
197
uint64_t ELFObjectFile<ELFT>::getSymbolSize(DataRefImpl Sym) const {
524
197
  return getSymbol(Sym)->st_size;
525
197
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolSize(llvm::object::DataRefImpl) const
Line
Count
Source
523
175
uint64_t ELFObjectFile<ELFT>::getSymbolSize(DataRefImpl Sym) const {
524
175
  return getSymbol(Sym)->st_size;
525
175
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolSize(llvm::object::DataRefImpl) const
Line
Count
Source
523
6.63k
uint64_t ELFObjectFile<ELFT>::getSymbolSize(DataRefImpl Sym) const {
524
6.63k
  return getSymbol(Sym)->st_size;
525
6.63k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolSize(llvm::object::DataRefImpl) const
Line
Count
Source
523
64
uint64_t ELFObjectFile<ELFT>::getSymbolSize(DataRefImpl Sym) const {
524
64
  return getSymbol(Sym)->st_size;
525
64
}
526
527
template <class ELFT>
528
142
uint64_t ELFObjectFile<ELFT>::getCommonSymbolSizeImpl(DataRefImpl Symb) const {
529
142
  return getSymbol(Symb)->st_size;
530
142
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getCommonSymbolSizeImpl(llvm::object::DataRefImpl) const
Line
Count
Source
528
13
uint64_t ELFObjectFile<ELFT>::getCommonSymbolSizeImpl(DataRefImpl Symb) const {
529
13
  return getSymbol(Symb)->st_size;
530
13
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getCommonSymbolSizeImpl(llvm::object::DataRefImpl) const
Line
Count
Source
528
5
uint64_t ELFObjectFile<ELFT>::getCommonSymbolSizeImpl(DataRefImpl Symb) const {
529
5
  return getSymbol(Symb)->st_size;
530
5
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getCommonSymbolSizeImpl(llvm::object::DataRefImpl) const
Line
Count
Source
528
121
uint64_t ELFObjectFile<ELFT>::getCommonSymbolSizeImpl(DataRefImpl Symb) const {
529
121
  return getSymbol(Symb)->st_size;
530
121
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getCommonSymbolSizeImpl(llvm::object::DataRefImpl) const
Line
Count
Source
528
3
uint64_t ELFObjectFile<ELFT>::getCommonSymbolSizeImpl(DataRefImpl Symb) const {
529
3
  return getSymbol(Symb)->st_size;
530
3
}
531
532
template <class ELFT>
533
0
uint8_t ELFObjectFile<ELFT>::getSymbolOther(DataRefImpl Symb) const {
534
0
  return getSymbol(Symb)->st_other;
535
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
536
537
template <class ELFT>
538
78
uint8_t ELFObjectFile<ELFT>::getSymbolELFType(DataRefImpl Symb) const {
539
78
  return getSymbol(Symb)->getType();
540
78
}
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
538
78
uint8_t ELFObjectFile<ELFT>::getSymbolELFType(DataRefImpl Symb) const {
539
78
  return getSymbol(Symb)->getType();
540
78
}
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolELFType(llvm::object::DataRefImpl) const
541
542
template <class ELFT>
543
Expected<SymbolRef::Type>
544
8.32k
ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const {
545
8.32k
  const Elf_Sym *ESym = getSymbol(Symb);
546
8.32k
547
8.32k
  switch (ESym->getType()) {
548
8.32k
  case ELF::STT_NOTYPE:
549
1.58k
    return SymbolRef::ST_Unknown;
550
8.32k
  case ELF::STT_SECTION:
551
1.91k
    return SymbolRef::ST_Debug;
552
8.32k
  case ELF::STT_FILE:
553
415
    return SymbolRef::ST_File;
554
8.32k
  case ELF::STT_FUNC:
555
2.21k
    return SymbolRef::ST_Function;
556
8.32k
  case ELF::STT_OBJECT:
557
2.20k
  case ELF::STT_COMMON:
558
2.20k
  case ELF::STT_TLS:
559
2.20k
    return SymbolRef::ST_Data;
560
2.20k
  default:
561
2
    return SymbolRef::ST_Other;
562
8.32k
  }
563
8.32k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolType(llvm::object::DataRefImpl) const
Line
Count
Source
544
306
ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const {
545
306
  const Elf_Sym *ESym = getSymbol(Symb);
546
306
547
306
  switch (ESym->getType()) {
548
306
  case ELF::STT_NOTYPE:
549
159
    return SymbolRef::ST_Unknown;
550
306
  case ELF::STT_SECTION:
551
59
    return SymbolRef::ST_Debug;
552
306
  case ELF::STT_FILE:
553
18
    return SymbolRef::ST_File;
554
306
  case ELF::STT_FUNC:
555
38
    return SymbolRef::ST_Function;
556
306
  case ELF::STT_OBJECT:
557
32
  case ELF::STT_COMMON:
558
32
  case ELF::STT_TLS:
559
32
    return SymbolRef::ST_Data;
560
32
  default:
561
0
    return SymbolRef::ST_Other;
562
306
  }
563
306
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolType(llvm::object::DataRefImpl) const
Line
Count
Source
544
304
ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const {
545
304
  const Elf_Sym *ESym = getSymbol(Symb);
546
304
547
304
  switch (ESym->getType()) {
548
304
  case ELF::STT_NOTYPE:
549
201
    return SymbolRef::ST_Unknown;
550
304
  case ELF::STT_SECTION:
551
17
    return SymbolRef::ST_Debug;
552
304
  case ELF::STT_FILE:
553
10
    return SymbolRef::ST_File;
554
304
  case ELF::STT_FUNC:
555
36
    return SymbolRef::ST_Function;
556
304
  case ELF::STT_OBJECT:
557
40
  case ELF::STT_COMMON:
558
40
  case ELF::STT_TLS:
559
40
    return SymbolRef::ST_Data;
560
40
  default:
561
0
    return SymbolRef::ST_Other;
562
304
  }
563
304
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolType(llvm::object::DataRefImpl) const
Line
Count
Source
544
7.50k
ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const {
545
7.50k
  const Elf_Sym *ESym = getSymbol(Symb);
546
7.50k
547
7.50k
  switch (ESym->getType()) {
548
7.50k
  case ELF::STT_NOTYPE:
549
1.10k
    return SymbolRef::ST_Unknown;
550
7.50k
  case ELF::STT_SECTION:
551
1.81k
    return SymbolRef::ST_Debug;
552
7.50k
  case ELF::STT_FILE:
553
373
    return SymbolRef::ST_File;
554
7.50k
  case ELF::STT_FUNC:
555
2.10k
    return SymbolRef::ST_Function;
556
7.50k
  case ELF::STT_OBJECT:
557
2.11k
  case ELF::STT_COMMON:
558
2.11k
  case ELF::STT_TLS:
559
2.11k
    return SymbolRef::ST_Data;
560
2.11k
  default:
561
2
    return SymbolRef::ST_Other;
562
7.50k
  }
563
7.50k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolType(llvm::object::DataRefImpl) const
Line
Count
Source
544
211
ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const {
545
211
  const Elf_Sym *ESym = getSymbol(Symb);
546
211
547
211
  switch (ESym->getType()) {
548
211
  case ELF::STT_NOTYPE:
549
121
    return SymbolRef::ST_Unknown;
550
211
  case ELF::STT_SECTION:
551
28
    return SymbolRef::ST_Debug;
552
211
  case ELF::STT_FILE:
553
14
    return SymbolRef::ST_File;
554
211
  case ELF::STT_FUNC:
555
29
    return SymbolRef::ST_Function;
556
211
  case ELF::STT_OBJECT:
557
19
  case ELF::STT_COMMON:
558
19
  case ELF::STT_TLS:
559
19
    return SymbolRef::ST_Data;
560
19
  default:
561
0
    return SymbolRef::ST_Other;
562
211
  }
563
211
}
564
565
template <class ELFT>
566
42.0k
uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
567
42.0k
  const Elf_Sym *ESym = getSymbol(Sym);
568
42.0k
569
42.0k
  uint32_t Result = SymbolRef::SF_None;
570
42.0k
571
42.0k
  if (ESym->getBinding() != ELF::STB_LOCAL)
572
21.1k
    Result |= SymbolRef::SF_Global;
573
42.0k
574
42.0k
  if (ESym->getBinding() == ELF::STB_WEAK)
575
4.03k
    Result |= SymbolRef::SF_Weak;
576
42.0k
577
42.0k
  if (ESym->st_shndx == ELF::SHN_ABS)
578
1.34k
    Result |= SymbolRef::SF_Absolute;
579
42.0k
580
42.0k
  if (ESym->getType() == ELF::STT_FILE || 
ESym->getType() == ELF::STT_SECTION41.1k
)
581
4.41k
    Result |= SymbolRef::SF_FormatSpecific;
582
42.0k
583
42.0k
  auto DotSymtabSecSyms = EF.symbols(DotSymtabSec);
584
42.0k
  if (DotSymtabSecSyms && ESym == (*DotSymtabSecSyms).begin())
585
2.11k
    Result |= SymbolRef::SF_FormatSpecific;
586
42.0k
  auto DotDynSymSecSyms = EF.symbols(DotDynSymSec);
587
42.0k
  if (DotDynSymSecSyms && ESym == (*DotDynSymSecSyms).begin())
588
5
    Result |= SymbolRef::SF_FormatSpecific;
589
42.0k
590
42.0k
  if (EF.getHeader()->e_machine == ELF::EM_ARM) {
591
6.61k
    if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
592
6.61k
      StringRef Name = *NameOrErr;
593
6.61k
      if (Name.startswith("$d") || 
Name.startswith("$t")6.43k
||
594
6.61k
          
Name.startswith("$a")4.40k
)
595
2.90k
        Result |= SymbolRef::SF_FormatSpecific;
596
6.61k
    } else {
597
0
      // TODO: Actually report errors helpfully.
598
0
      consumeError(NameOrErr.takeError());
599
0
    }
600
6.61k
    if (ESym->getType() == ELF::STT_FUNC && 
(ESym->st_value & 1) == 12.85k
)
601
2.16k
      Result |= SymbolRef::SF_Thumb;
602
6.61k
  }
603
42.0k
604
42.0k
  if (ESym->st_shndx == ELF::SHN_UNDEF)
605
3.54k
    Result |= SymbolRef::SF_Undefined;
606
42.0k
607
42.0k
  if (ESym->getType() == ELF::STT_COMMON || ESym->st_shndx == ELF::SHN_COMMON)
608
455
    Result |= SymbolRef::SF_Common;
609
42.0k
610
42.0k
  if (isExportedToOtherDSO(ESym))
611
12.5k
    Result |= SymbolRef::SF_Exported;
612
42.0k
613
42.0k
  if (ESym->getVisibility() == ELF::STV_HIDDEN)
614
9.38k
    Result |= SymbolRef::SF_Hidden;
615
42.0k
616
42.0k
  return Result;
617
42.0k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolFlags(llvm::object::DataRefImpl) const
Line
Count
Source
566
9.01k
uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
567
9.01k
  const Elf_Sym *ESym = getSymbol(Sym);
568
9.01k
569
9.01k
  uint32_t Result = SymbolRef::SF_None;
570
9.01k
571
9.01k
  if (ESym->getBinding() != ELF::STB_LOCAL)
572
3.37k
    Result |= SymbolRef::SF_Global;
573
9.01k
574
9.01k
  if (ESym->getBinding() == ELF::STB_WEAK)
575
14
    Result |= SymbolRef::SF_Weak;
576
9.01k
577
9.01k
  if (ESym->st_shndx == ELF::SHN_ABS)
578
223
    Result |= SymbolRef::SF_Absolute;
579
9.01k
580
9.01k
  if (ESym->getType() == ELF::STT_FILE || 
ESym->getType() == ELF::STT_SECTION8.88k
)
581
766
    Result |= SymbolRef::SF_FormatSpecific;
582
9.01k
583
9.01k
  auto DotSymtabSecSyms = EF.symbols(DotSymtabSec);
584
9.01k
  if (DotSymtabSecSyms && ESym == (*DotSymtabSecSyms).begin())
585
478
    Result |= SymbolRef::SF_FormatSpecific;
586
9.01k
  auto DotDynSymSecSyms = EF.symbols(DotDynSymSec);
587
9.01k
  if (DotDynSymSecSyms && ESym == (*DotDynSymSecSyms).begin())
588
1
    Result |= SymbolRef::SF_FormatSpecific;
589
9.01k
590
9.01k
  if (EF.getHeader()->e_machine == ELF::EM_ARM) {
591
6.58k
    if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
592
6.58k
      StringRef Name = *NameOrErr;
593
6.58k
      if (Name.startswith("$d") || 
Name.startswith("$t")6.40k
||
594
6.58k
          
Name.startswith("$a")4.38k
)
595
2.89k
        Result |= SymbolRef::SF_FormatSpecific;
596
6.58k
    } else {
597
0
      // TODO: Actually report errors helpfully.
598
0
      consumeError(NameOrErr.takeError());
599
0
    }
600
6.58k
    if (ESym->getType() == ELF::STT_FUNC && 
(ESym->st_value & 1) == 12.85k
)
601
2.16k
      Result |= SymbolRef::SF_Thumb;
602
6.58k
  }
603
9.01k
604
9.01k
  if (ESym->st_shndx == ELF::SHN_UNDEF)
605
800
    Result |= SymbolRef::SF_Undefined;
606
9.01k
607
9.01k
  if (ESym->getType() == ELF::STT_COMMON || ESym->st_shndx == ELF::SHN_COMMON)
608
27
    Result |= SymbolRef::SF_Common;
609
9.01k
610
9.01k
  if (isExportedToOtherDSO(ESym))
611
3.36k
    Result |= SymbolRef::SF_Exported;
612
9.01k
613
9.01k
  if (ESym->getVisibility() == ELF::STV_HIDDEN)
614
126
    Result |= SymbolRef::SF_Hidden;
615
9.01k
616
9.01k
  return Result;
617
9.01k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolFlags(llvm::object::DataRefImpl) const
Line
Count
Source
566
1.17k
uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
567
1.17k
  const Elf_Sym *ESym = getSymbol(Sym);
568
1.17k
569
1.17k
  uint32_t Result = SymbolRef::SF_None;
570
1.17k
571
1.17k
  if (ESym->getBinding() != ELF::STB_LOCAL)
572
382
    Result |= SymbolRef::SF_Global;
573
1.17k
574
1.17k
  if (ESym->getBinding() == ELF::STB_WEAK)
575
5
    Result |= SymbolRef::SF_Weak;
576
1.17k
577
1.17k
  if (ESym->st_shndx == ELF::SHN_ABS)
578
68
    Result |= SymbolRef::SF_Absolute;
579
1.17k
580
1.17k
  if (ESym->getType() == ELF::STT_FILE || 
ESym->getType() == ELF::STT_SECTION1.14k
)
581
125
    Result |= SymbolRef::SF_FormatSpecific;
582
1.17k
583
1.17k
  auto DotSymtabSecSyms = EF.symbols(DotSymtabSec);
584
1.17k
  if (DotSymtabSecSyms && ESym == (*DotSymtabSecSyms).begin())
585
139
    Result |= SymbolRef::SF_FormatSpecific;
586
1.17k
  auto DotDynSymSecSyms = EF.symbols(DotDynSymSec);
587
1.17k
  if (DotDynSymSecSyms && ESym == (*DotDynSymSecSyms).begin())
588
0
    Result |= SymbolRef::SF_FormatSpecific;
589
1.17k
590
1.17k
  if (EF.getHeader()->e_machine == ELF::EM_ARM) {
591
25
    if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
592
25
      StringRef Name = *NameOrErr;
593
25
      if (Name.startswith("$d") || Name.startswith("$t") ||
594
25
          
Name.startswith("$a")23
)
595
4
        Result |= SymbolRef::SF_FormatSpecific;
596
25
    } else {
597
0
      // TODO: Actually report errors helpfully.
598
0
      consumeError(NameOrErr.takeError());
599
0
    }
600
25
    if (ESym->getType() == ELF::STT_FUNC && 
(ESym->st_value & 1) == 10
)
601
0
      Result |= SymbolRef::SF_Thumb;
602
25
  }
603
1.17k
604
1.17k
  if (ESym->st_shndx == ELF::SHN_UNDEF)
605
190
    Result |= SymbolRef::SF_Undefined;
606
1.17k
607
1.17k
  if (ESym->getType() == ELF::STT_COMMON || ESym->st_shndx == ELF::SHN_COMMON)
608
17
    Result |= SymbolRef::SF_Common;
609
1.17k
610
1.17k
  if (isExportedToOtherDSO(ESym))
611
382
    Result |= SymbolRef::SF_Exported;
612
1.17k
613
1.17k
  if (ESym->getVisibility() == ELF::STV_HIDDEN)
614
162
    Result |= SymbolRef::SF_Hidden;
615
1.17k
616
1.17k
  return Result;
617
1.17k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolFlags(llvm::object::DataRefImpl) const
Line
Count
Source
566
30.9k
uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
567
30.9k
  const Elf_Sym *ESym = getSymbol(Sym);
568
30.9k
569
30.9k
  uint32_t Result = SymbolRef::SF_None;
570
30.9k
571
30.9k
  if (ESym->getBinding() != ELF::STB_LOCAL)
572
17.0k
    Result |= SymbolRef::SF_Global;
573
30.9k
574
30.9k
  if (ESym->getBinding() == ELF::STB_WEAK)
575
4.01k
    Result |= SymbolRef::SF_Weak;
576
30.9k
577
30.9k
  if (ESym->st_shndx == ELF::SHN_ABS)
578
1.00k
    Result |= SymbolRef::SF_Absolute;
579
30.9k
580
30.9k
  if (ESym->getType() == ELF::STT_FILE || 
ESym->getType() == ELF::STT_SECTION30.2k
)
581
3.39k
    Result |= SymbolRef::SF_FormatSpecific;
582
30.9k
583
30.9k
  auto DotSymtabSecSyms = EF.symbols(DotSymtabSec);
584
30.9k
  if (DotSymtabSecSyms && ESym == (*DotSymtabSecSyms).begin())
585
1.41k
    Result |= SymbolRef::SF_FormatSpecific;
586
30.9k
  auto DotDynSymSecSyms = EF.symbols(DotDynSymSec);
587
30.9k
  if (DotDynSymSecSyms && ESym == (*DotDynSymSecSyms).begin())
588
4
    Result |= SymbolRef::SF_FormatSpecific;
589
30.9k
590
30.9k
  if (EF.getHeader()->e_machine == ELF::EM_ARM) {
591
0
    if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
592
0
      StringRef Name = *NameOrErr;
593
0
      if (Name.startswith("$d") || Name.startswith("$t") ||
594
0
          Name.startswith("$a"))
595
0
        Result |= SymbolRef::SF_FormatSpecific;
596
0
    } else {
597
0
      // TODO: Actually report errors helpfully.
598
0
      consumeError(NameOrErr.takeError());
599
0
    }
600
0
    if (ESym->getType() == ELF::STT_FUNC && (ESym->st_value & 1) == 1)
601
0
      Result |= SymbolRef::SF_Thumb;
602
0
  }
603
30.9k
604
30.9k
  if (ESym->st_shndx == ELF::SHN_UNDEF)
605
2.41k
    Result |= SymbolRef::SF_Undefined;
606
30.9k
607
30.9k
  if (ESym->getType() == ELF::STT_COMMON || ESym->st_shndx == ELF::SHN_COMMON)
608
402
    Result |= SymbolRef::SF_Common;
609
30.9k
610
30.9k
  if (isExportedToOtherDSO(ESym))
611
8.45k
    Result |= SymbolRef::SF_Exported;
612
30.9k
613
30.9k
  if (ESym->getVisibility() == ELF::STV_HIDDEN)
614
9.01k
    Result |= SymbolRef::SF_Hidden;
615
30.9k
616
30.9k
  return Result;
617
30.9k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolFlags(llvm::object::DataRefImpl) const
Line
Count
Source
566
869
uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
567
869
  const Elf_Sym *ESym = getSymbol(Sym);
568
869
569
869
  uint32_t Result = SymbolRef::SF_None;
570
869
571
869
  if (ESym->getBinding() != ELF::STB_LOCAL)
572
323
    Result |= SymbolRef::SF_Global;
573
869
574
869
  if (ESym->getBinding() == ELF::STB_WEAK)
575
3
    Result |= SymbolRef::SF_Weak;
576
869
577
869
  if (ESym->st_shndx == ELF::SHN_ABS)
578
45
    Result |= SymbolRef::SF_Absolute;
579
869
580
869
  if (ESym->getType() == ELF::STT_FILE || 
ESym->getType() == ELF::STT_SECTION837
)
581
133
    Result |= SymbolRef::SF_FormatSpecific;
582
869
583
869
  auto DotSymtabSecSyms = EF.symbols(DotSymtabSec);
584
869
  if (DotSymtabSecSyms && ESym == (*DotSymtabSecSyms).begin())
585
90
    Result |= SymbolRef::SF_FormatSpecific;
586
869
  auto DotDynSymSecSyms = EF.symbols(DotDynSymSec);
587
869
  if (DotDynSymSecSyms && ESym == (*DotDynSymSecSyms).begin())
588
0
    Result |= SymbolRef::SF_FormatSpecific;
589
869
590
869
  if (EF.getHeader()->e_machine == ELF::EM_ARM) {
591
0
    if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
592
0
      StringRef Name = *NameOrErr;
593
0
      if (Name.startswith("$d") || Name.startswith("$t") ||
594
0
          Name.startswith("$a"))
595
0
        Result |= SymbolRef::SF_FormatSpecific;
596
0
    } else {
597
0
      // TODO: Actually report errors helpfully.
598
0
      consumeError(NameOrErr.takeError());
599
0
    }
600
0
    if (ESym->getType() == ELF::STT_FUNC && (ESym->st_value & 1) == 1)
601
0
      Result |= SymbolRef::SF_Thumb;
602
0
  }
603
869
604
869
  if (ESym->st_shndx == ELF::SHN_UNDEF)
605
147
    Result |= SymbolRef::SF_Undefined;
606
869
607
869
  if (ESym->getType() == ELF::STT_COMMON || ESym->st_shndx == ELF::SHN_COMMON)
608
9
    Result |= SymbolRef::SF_Common;
609
869
610
869
  if (isExportedToOtherDSO(ESym))
611
323
    Result |= SymbolRef::SF_Exported;
612
869
613
869
  if (ESym->getVisibility() == ELF::STV_HIDDEN)
614
82
    Result |= SymbolRef::SF_Hidden;
615
869
616
869
  return Result;
617
869
}
618
619
template <class ELFT>
620
Expected<section_iterator>
621
ELFObjectFile<ELFT>::getSymbolSection(const Elf_Sym *ESym,
622
14.1k
                                      const Elf_Shdr *SymTab) const {
623
14.1k
  auto ESecOrErr = EF.getSection(ESym, SymTab, ShndxTable);
624
14.1k
  if (!ESecOrErr)
625
0
    return ESecOrErr.takeError();
626
14.1k
627
14.1k
  const Elf_Shdr *ESec = *ESecOrErr;
628
14.1k
  if (!ESec)
629
1.06k
    return section_end();
630
13.0k
631
13.0k
  DataRefImpl Sec;
632
13.0k
  Sec.p = reinterpret_cast<intptr_t>(ESec);
633
13.0k
  return section_iterator(SectionRef(Sec, this));
634
13.0k
}
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
622
7.63k
                                      const Elf_Shdr *SymTab) const {
623
7.63k
  auto ESecOrErr = EF.getSection(ESym, SymTab, ShndxTable);
624
7.63k
  if (!ESecOrErr)
625
0
    return ESecOrErr.takeError();
626
7.63k
627
7.63k
  const Elf_Shdr *ESec = *ESecOrErr;
628
7.63k
  if (!ESec)
629
401
    return section_end();
630
7.23k
631
7.23k
  DataRefImpl Sec;
632
7.23k
  Sec.p = reinterpret_cast<intptr_t>(ESec);
633
7.23k
  return section_iterator(SectionRef(Sec, this));
634
7.23k
}
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
622
686
                                      const Elf_Shdr *SymTab) const {
623
686
  auto ESecOrErr = EF.getSection(ESym, SymTab, ShndxTable);
624
686
  if (!ESecOrErr)
625
0
    return ESecOrErr.takeError();
626
686
627
686
  const Elf_Shdr *ESec = *ESecOrErr;
628
686
  if (!ESec)
629
100
    return section_end();
630
586
631
586
  DataRefImpl Sec;
632
586
  Sec.p = reinterpret_cast<intptr_t>(ESec);
633
586
  return section_iterator(SectionRef(Sec, this));
634
586
}
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
622
5.34k
                                      const Elf_Shdr *SymTab) const {
623
5.34k
  auto ESecOrErr = EF.getSection(ESym, SymTab, ShndxTable);
624
5.34k
  if (!ESecOrErr)
625
0
    return ESecOrErr.takeError();
626
5.34k
627
5.34k
  const Elf_Shdr *ESec = *ESecOrErr;
628
5.34k
  if (!ESec)
629
498
    return section_end();
630
4.84k
631
4.84k
  DataRefImpl Sec;
632
4.84k
  Sec.p = reinterpret_cast<intptr_t>(ESec);
633
4.84k
  return section_iterator(SectionRef(Sec, this));
634
4.84k
}
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
622
472
                                      const Elf_Shdr *SymTab) const {
623
472
  auto ESecOrErr = EF.getSection(ESym, SymTab, ShndxTable);
624
472
  if (!ESecOrErr)
625
0
    return ESecOrErr.takeError();
626
472
627
472
  const Elf_Shdr *ESec = *ESecOrErr;
628
472
  if (!ESec)
629
65
    return section_end();
630
407
631
407
  DataRefImpl Sec;
632
407
  Sec.p = reinterpret_cast<intptr_t>(ESec);
633
407
  return section_iterator(SectionRef(Sec, this));
634
407
}
635
636
template <class ELFT>
637
Expected<section_iterator>
638
14.1k
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb) const {
639
14.1k
  const Elf_Sym *Sym = getSymbol(Symb);
640
14.1k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
641
14.1k
  if (!SymTabOrErr)
642
0
    return SymTabOrErr.takeError();
643
14.1k
  const Elf_Shdr *SymTab = *SymTabOrErr;
644
14.1k
  return getSymbolSection(Sym, SymTab);
645
14.1k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolSection(llvm::object::DataRefImpl) const
Line
Count
Source
638
7.63k
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb) const {
639
7.63k
  const Elf_Sym *Sym = getSymbol(Symb);
640
7.63k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
641
7.63k
  if (!SymTabOrErr)
642
0
    return SymTabOrErr.takeError();
643
7.63k
  const Elf_Shdr *SymTab = *SymTabOrErr;
644
7.63k
  return getSymbolSection(Sym, SymTab);
645
7.63k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolSection(llvm::object::DataRefImpl) const
Line
Count
Source
638
686
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb) const {
639
686
  const Elf_Sym *Sym = getSymbol(Symb);
640
686
  auto SymTabOrErr = EF.getSection(Symb.d.a);
641
686
  if (!SymTabOrErr)
642
0
    return SymTabOrErr.takeError();
643
686
  const Elf_Shdr *SymTab = *SymTabOrErr;
644
686
  return getSymbolSection(Sym, SymTab);
645
686
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolSection(llvm::object::DataRefImpl) const
Line
Count
Source
638
5.34k
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb) const {
639
5.34k
  const Elf_Sym *Sym = getSymbol(Symb);
640
5.34k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
641
5.34k
  if (!SymTabOrErr)
642
0
    return SymTabOrErr.takeError();
643
5.34k
  const Elf_Shdr *SymTab = *SymTabOrErr;
644
5.34k
  return getSymbolSection(Sym, SymTab);
645
5.34k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolSection(llvm::object::DataRefImpl) const
Line
Count
Source
638
472
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb) const {
639
472
  const Elf_Sym *Sym = getSymbol(Symb);
640
472
  auto SymTabOrErr = EF.getSection(Symb.d.a);
641
472
  if (!SymTabOrErr)
642
0
    return SymTabOrErr.takeError();
643
472
  const Elf_Shdr *SymTab = *SymTabOrErr;
644
472
  return getSymbolSection(Sym, SymTab);
645
472
}
646
647
template <class ELFT>
648
125k
void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {
649
125k
  const Elf_Shdr *ESec = getSection(Sec);
650
125k
  Sec = toDRI(++ESec);
651
125k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::moveSectionNext(llvm::object::DataRefImpl&) const
Line
Count
Source
648
14.4k
void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {
649
14.4k
  const Elf_Shdr *ESec = getSection(Sec);
650
14.4k
  Sec = toDRI(++ESec);
651
14.4k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::moveSectionNext(llvm::object::DataRefImpl&) const
Line
Count
Source
648
4.43k
void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {
649
4.43k
  const Elf_Shdr *ESec = getSection(Sec);
650
4.43k
  Sec = toDRI(++ESec);
651
4.43k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::moveSectionNext(llvm::object::DataRefImpl&) const
Line
Count
Source
648
103k
void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {
649
103k
  const Elf_Shdr *ESec = getSection(Sec);
650
103k
  Sec = toDRI(++ESec);
651
103k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::moveSectionNext(llvm::object::DataRefImpl&) const
Line
Count
Source
648
3.24k
void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {
649
3.24k
  const Elf_Shdr *ESec = getSection(Sec);
650
3.24k
  Sec = toDRI(++ESec);
651
3.24k
}
652
653
template <class ELFT>
654
std::error_code ELFObjectFile<ELFT>::getSectionName(DataRefImpl Sec,
655
106k
                                                    StringRef &Result) const {
656
106k
  auto Name = EF.getSectionName(&*getSection(Sec));
657
106k
  if (!Name)
658
32
    return errorToErrorCode(Name.takeError());
659
106k
  Result = *Name;
660
106k
  return std::error_code();
661
106k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionName(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
655
6.66k
                                                    StringRef &Result) const {
656
6.66k
  auto Name = EF.getSectionName(&*getSection(Sec));
657
6.66k
  if (!Name)
658
28
    return errorToErrorCode(Name.takeError());
659
6.63k
  Result = *Name;
660
6.63k
  return std::error_code();
661
6.63k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionName(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
655
2.06k
                                                    StringRef &Result) const {
656
2.06k
  auto Name = EF.getSectionName(&*getSection(Sec));
657
2.06k
  if (!Name)
658
0
    return errorToErrorCode(Name.takeError());
659
2.06k
  Result = *Name;
660
2.06k
  return std::error_code();
661
2.06k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionName(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
655
95.9k
                                                    StringRef &Result) const {
656
95.9k
  auto Name = EF.getSectionName(&*getSection(Sec));
657
95.9k
  if (!Name)
658
4
    return errorToErrorCode(Name.takeError());
659
95.9k
  Result = *Name;
660
95.9k
  return std::error_code();
661
95.9k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionName(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
655
1.72k
                                                    StringRef &Result) const {
656
1.72k
  auto Name = EF.getSectionName(&*getSection(Sec));
657
1.72k
  if (!Name)
658
0
    return errorToErrorCode(Name.takeError());
659
1.72k
  Result = *Name;
660
1.72k
  return std::error_code();
661
1.72k
}
662
663
template <class ELFT>
664
15.3k
uint64_t ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec) const {
665
15.3k
  return getSection(Sec)->sh_addr;
666
15.3k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionAddress(llvm::object::DataRefImpl) const
Line
Count
Source
664
4.21k
uint64_t ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec) const {
665
4.21k
  return getSection(Sec)->sh_addr;
666
4.21k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionAddress(llvm::object::DataRefImpl) const
Line
Count
Source
664
1.29k
uint64_t ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec) const {
665
1.29k
  return getSection(Sec)->sh_addr;
666
1.29k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionAddress(llvm::object::DataRefImpl) const
Line
Count
Source
664
8.84k
uint64_t ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec) const {
665
8.84k
  return getSection(Sec)->sh_addr;
666
8.84k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionAddress(llvm::object::DataRefImpl) const
Line
Count
Source
664
1.00k
uint64_t ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec) const {
665
1.00k
  return getSection(Sec)->sh_addr;
666
1.00k
}
667
668
template <class ELFT>
669
3.57k
uint64_t ELFObjectFile<ELFT>::getSectionIndex(DataRefImpl Sec) const {
670
3.57k
  auto SectionsOrErr = EF.sections();
671
3.57k
  handleAllErrors(std::move(SectionsOrErr.takeError()),
672
3.57k
                  [](const ErrorInfoBase &) {
673
0
                    llvm_unreachable("unable to get section index");
674
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
675
3.57k
  const Elf_Shdr *First = SectionsOrErr->begin();
676
3.57k
  return getSection(Sec) - First;
677
3.57k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionIndex(llvm::object::DataRefImpl) const
Line
Count
Source
669
341
uint64_t ELFObjectFile<ELFT>::getSectionIndex(DataRefImpl Sec) const {
670
341
  auto SectionsOrErr = EF.sections();
671
341
  handleAllErrors(std::move(SectionsOrErr.takeError()),
672
341
                  [](const ErrorInfoBase &) {
673
341
                    llvm_unreachable("unable to get section index");
674
341
                  });
675
341
  const Elf_Shdr *First = SectionsOrErr->begin();
676
341
  return getSection(Sec) - First;
677
341
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionIndex(llvm::object::DataRefImpl) const
Line
Count
Source
669
130
uint64_t ELFObjectFile<ELFT>::getSectionIndex(DataRefImpl Sec) const {
670
130
  auto SectionsOrErr = EF.sections();
671
130
  handleAllErrors(std::move(SectionsOrErr.takeError()),
672
130
                  [](const ErrorInfoBase &) {
673
130
                    llvm_unreachable("unable to get section index");
674
130
                  });
675
130
  const Elf_Shdr *First = SectionsOrErr->begin();
676
130
  return getSection(Sec) - First;
677
130
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionIndex(llvm::object::DataRefImpl) const
Line
Count
Source
669
2.95k
uint64_t ELFObjectFile<ELFT>::getSectionIndex(DataRefImpl Sec) const {
670
2.95k
  auto SectionsOrErr = EF.sections();
671
2.95k
  handleAllErrors(std::move(SectionsOrErr.takeError()),
672
2.95k
                  [](const ErrorInfoBase &) {
673
2.95k
                    llvm_unreachable("unable to get section index");
674
2.95k
                  });
675
2.95k
  const Elf_Shdr *First = SectionsOrErr->begin();
676
2.95k
  return getSection(Sec) - First;
677
2.95k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionIndex(llvm::object::DataRefImpl) const
Line
Count
Source
669
146
uint64_t ELFObjectFile<ELFT>::getSectionIndex(DataRefImpl Sec) const {
670
146
  auto SectionsOrErr = EF.sections();
671
146
  handleAllErrors(std::move(SectionsOrErr.takeError()),
672
146
                  [](const ErrorInfoBase &) {
673
146
                    llvm_unreachable("unable to get section index");
674
146
                  });
675
146
  const Elf_Shdr *First = SectionsOrErr->begin();
676
146
  return getSection(Sec) - First;
677
146
}
678
679
template <class ELFT>
680
195k
uint64_t ELFObjectFile<ELFT>::getSectionSize(DataRefImpl Sec) const {
681
195k
  return getSection(Sec)->sh_size;
682
195k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionSize(llvm::object::DataRefImpl) const
Line
Count
Source
680
1.17k
uint64_t ELFObjectFile<ELFT>::getSectionSize(DataRefImpl Sec) const {
681
1.17k
  return getSection(Sec)->sh_size;
682
1.17k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionSize(llvm::object::DataRefImpl) const
Line
Count
Source
680
431
uint64_t ELFObjectFile<ELFT>::getSectionSize(DataRefImpl Sec) const {
681
431
  return getSection(Sec)->sh_size;
682
431
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionSize(llvm::object::DataRefImpl) const
Line
Count
Source
680
193k
uint64_t ELFObjectFile<ELFT>::getSectionSize(DataRefImpl Sec) const {
681
193k
  return getSection(Sec)->sh_size;
682
193k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionSize(llvm::object::DataRefImpl) const
Line
Count
Source
680
417
uint64_t ELFObjectFile<ELFT>::getSectionSize(DataRefImpl Sec) const {
681
417
  return getSection(Sec)->sh_size;
682
417
}
683
684
template <class ELFT>
685
std::error_code
686
ELFObjectFile<ELFT>::getSectionContents(DataRefImpl Sec,
687
12.9k
                                        StringRef &Result) const {
688
12.9k
  const Elf_Shdr *EShdr = getSection(Sec);
689
12.9k
  if (std::error_code EC =
690
16
          checkOffset(getMemoryBufferRef(),
691
16
                      (uintptr_t)base() + EShdr->sh_offset, EShdr->sh_size))
692
16
    return EC;
693
12.9k
  Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
694
12.9k
  return std::error_code();
695
12.9k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionContents(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
687
1.75k
                                        StringRef &Result) const {
688
1.75k
  const Elf_Shdr *EShdr = getSection(Sec);
689
1.75k
  if (std::error_code EC =
690
16
          checkOffset(getMemoryBufferRef(),
691
16
                      (uintptr_t)base() + EShdr->sh_offset, EShdr->sh_size))
692
16
    return EC;
693
1.74k
  Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
694
1.74k
  return std::error_code();
695
1.74k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionContents(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
687
574
                                        StringRef &Result) const {
688
574
  const Elf_Shdr *EShdr = getSection(Sec);
689
574
  if (std::error_code EC =
690
0
          checkOffset(getMemoryBufferRef(),
691
0
                      (uintptr_t)base() + EShdr->sh_offset, EShdr->sh_size))
692
0
    return EC;
693
574
  Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
694
574
  return std::error_code();
695
574
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionContents(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
687
10.0k
                                        StringRef &Result) const {
688
10.0k
  const Elf_Shdr *EShdr = getSection(Sec);
689
10.0k
  if (std::error_code EC =
690
0
          checkOffset(getMemoryBufferRef(),
691
0
                      (uintptr_t)base() + EShdr->sh_offset, EShdr->sh_size))
692
0
    return EC;
693
10.0k
  Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
694
10.0k
  return std::error_code();
695
10.0k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionContents(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
687
561
                                        StringRef &Result) const {
688
561
  const Elf_Shdr *EShdr = getSection(Sec);
689
561
  if (std::error_code EC =
690
0
          checkOffset(getMemoryBufferRef(),
691
0
                      (uintptr_t)base() + EShdr->sh_offset, EShdr->sh_size))
692
0
    return EC;
693
561
  Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
694
561
  return std::error_code();
695
561
}
696
697
template <class ELFT>
698
310
uint64_t ELFObjectFile<ELFT>::getSectionAlignment(DataRefImpl Sec) const {
699
310
  return getSection(Sec)->sh_addralign;
700
310
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
698
36
uint64_t ELFObjectFile<ELFT>::getSectionAlignment(DataRefImpl Sec) const {
699
36
  return getSection(Sec)->sh_addralign;
700
36
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
698
34
uint64_t ELFObjectFile<ELFT>::getSectionAlignment(DataRefImpl Sec) const {
699
34
  return getSection(Sec)->sh_addralign;
700
34
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
698
196
uint64_t ELFObjectFile<ELFT>::getSectionAlignment(DataRefImpl Sec) const {
699
196
  return getSection(Sec)->sh_addralign;
700
196
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
698
44
uint64_t ELFObjectFile<ELFT>::getSectionAlignment(DataRefImpl Sec) const {
699
44
  return getSection(Sec)->sh_addralign;
700
44
}
701
702
template <class ELFT>
703
8.71k
bool ELFObjectFile<ELFT>::isSectionCompressed(DataRefImpl Sec) const {
704
8.71k
  return getSection(Sec)->sh_flags & ELF::SHF_COMPRESSED;
705
8.71k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isSectionCompressed(llvm::object::DataRefImpl) const
Line
Count
Source
703
731
bool ELFObjectFile<ELFT>::isSectionCompressed(DataRefImpl Sec) const {
704
731
  return getSection(Sec)->sh_flags & ELF::SHF_COMPRESSED;
705
731
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isSectionCompressed(llvm::object::DataRefImpl) const
Line
Count
Source
703
239
bool ELFObjectFile<ELFT>::isSectionCompressed(DataRefImpl Sec) const {
704
239
  return getSection(Sec)->sh_flags & ELF::SHF_COMPRESSED;
705
239
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isSectionCompressed(llvm::object::DataRefImpl) const
Line
Count
Source
703
7.46k
bool ELFObjectFile<ELFT>::isSectionCompressed(DataRefImpl Sec) const {
704
7.46k
  return getSection(Sec)->sh_flags & ELF::SHF_COMPRESSED;
705
7.46k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isSectionCompressed(llvm::object::DataRefImpl) const
Line
Count
Source
703
278
bool ELFObjectFile<ELFT>::isSectionCompressed(DataRefImpl Sec) const {
704
278
  return getSection(Sec)->sh_flags & ELF::SHF_COMPRESSED;
705
278
}
706
707
template <class ELFT>
708
12.3k
bool ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec) const {
709
12.3k
  return getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR;
710
12.3k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isSectionText(llvm::object::DataRefImpl) const
Line
Count
Source
708
3.47k
bool ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec) const {
709
3.47k
  return getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR;
710
3.47k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isSectionText(llvm::object::DataRefImpl) const
Line
Count
Source
708
1.00k
bool ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec) const {
709
1.00k
  return getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR;
710
1.00k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isSectionText(llvm::object::DataRefImpl) const
Line
Count
Source
708
7.10k
bool ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec) const {
709
7.10k
  return getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR;
710
7.10k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isSectionText(llvm::object::DataRefImpl) const
Line
Count
Source
708
753
bool ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec) const {
709
753
  return getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR;
710
753
}
711
712
template <class ELFT>
713
1.38k
bool ELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec) const {
714
1.38k
  const Elf_Shdr *EShdr = getSection(Sec);
715
1.38k
  return EShdr->sh_type == ELF::SHT_PROGBITS &&
716
1.38k
         
EShdr->sh_flags & ELF::SHF_ALLOC560
&&
717
1.38k
         
!(EShdr->sh_flags & ELF::SHF_EXECINSTR)357
;
718
1.38k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isSectionData(llvm::object::DataRefImpl) const
Line
Count
Source
713
56
bool ELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec) const {
714
56
  const Elf_Shdr *EShdr = getSection(Sec);
715
56
  return EShdr->sh_type == ELF::SHT_PROGBITS &&
716
56
         
EShdr->sh_flags & ELF::SHF_ALLOC19
&&
717
56
         
!(EShdr->sh_flags & ELF::SHF_EXECINSTR)14
;
718
56
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isSectionData(llvm::object::DataRefImpl) const
Line
Count
Source
713
26
bool ELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec) const {
714
26
  const Elf_Shdr *EShdr = getSection(Sec);
715
26
  return EShdr->sh_type == ELF::SHT_PROGBITS &&
716
26
         
EShdr->sh_flags & ELF::SHF_ALLOC8
&&
717
26
         
!(EShdr->sh_flags & ELF::SHF_EXECINSTR)6
;
718
26
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isSectionData(llvm::object::DataRefImpl) const
Line
Count
Source
713
1.22k
bool ELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec) const {
714
1.22k
  const Elf_Shdr *EShdr = getSection(Sec);
715
1.22k
  return EShdr->sh_type == ELF::SHT_PROGBITS &&
716
1.22k
         
EShdr->sh_flags & ELF::SHF_ALLOC513
&&
717
1.22k
         
!(EShdr->sh_flags & ELF::SHF_EXECINSTR)322
;
718
1.22k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isSectionData(llvm::object::DataRefImpl) const
Line
Count
Source
713
76
bool ELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec) const {
714
76
  const Elf_Shdr *EShdr = getSection(Sec);
715
76
  return EShdr->sh_type == ELF::SHT_PROGBITS &&
716
76
         
EShdr->sh_flags & ELF::SHF_ALLOC20
&&
717
76
         
!(EShdr->sh_flags & ELF::SHF_EXECINSTR)15
;
718
76
}
719
720
template <class ELFT>
721
12.2k
bool ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec) const {
722
12.2k
  const Elf_Shdr *EShdr = getSection(Sec);
723
12.2k
  return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
724
12.2k
         
EShdr->sh_type == ELF::SHT_NOBITS3.74k
;
725
12.2k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isSectionBSS(llvm::object::DataRefImpl) const
Line
Count
Source
721
1.26k
bool ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec) const {
722
1.26k
  const Elf_Shdr *EShdr = getSection(Sec);
723
1.26k
  return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
724
1.26k
         
EShdr->sh_type == ELF::SHT_NOBITS438
;
725
1.26k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isSectionBSS(llvm::object::DataRefImpl) const
Line
Count
Source
721
508
bool ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec) const {
722
508
  const Elf_Shdr *EShdr = getSection(Sec);
723
508
  return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
724
508
         
EShdr->sh_type == ELF::SHT_NOBITS225
;
725
508
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isSectionBSS(llvm::object::DataRefImpl) const
Line
Count
Source
721
10.0k
bool ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec) const {
722
10.0k
  const Elf_Shdr *EShdr = getSection(Sec);
723
10.0k
  return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
724
10.0k
         
EShdr->sh_type == ELF::SHT_NOBITS2.91k
;
725
10.0k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isSectionBSS(llvm::object::DataRefImpl) const
Line
Count
Source
721
441
bool ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec) const {
722
441
  const Elf_Shdr *EShdr = getSection(Sec);
723
441
  return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
724
441
         
EShdr->sh_type == ELF::SHT_NOBITS172
;
725
441
}
726
727
template <class ELFT>
728
std::vector<SectionRef>
729
0
ELFObjectFile<ELFT>::dynamic_relocation_sections() const {
730
0
  std::vector<SectionRef> Res;
731
0
  std::vector<uintptr_t> Offsets;
732
0
733
0
  auto SectionsOrErr = EF.sections();
734
0
  if (!SectionsOrErr)
735
0
    return Res;
736
0
737
0
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
738
0
    if (Sec.sh_type != ELF::SHT_DYNAMIC)
739
0
      continue;
740
0
    Elf_Dyn *Dynamic =
741
0
        reinterpret_cast<Elf_Dyn *>((uintptr_t)base() + Sec.sh_offset);
742
0
    for (; Dynamic->d_tag != ELF::DT_NULL; Dynamic++) {
743
0
      if (Dynamic->d_tag == ELF::DT_REL || Dynamic->d_tag == ELF::DT_RELA ||
744
0
          Dynamic->d_tag == ELF::DT_JMPREL) {
745
0
        Offsets.push_back(Dynamic->d_un.d_val);
746
0
      }
747
0
    }
748
0
  }
749
0
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
750
0
    if (is_contained(Offsets, Sec.sh_offset))
751
0
      Res.emplace_back(toDRI(&Sec), this);
752
0
  }
753
0
  return Res;
754
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
755
756
template <class ELFT>
757
15.1k
bool ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec) const {
758
15.1k
  return getSection(Sec)->sh_type == ELF::SHT_NOBITS;
759
15.1k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isSectionVirtual(llvm::object::DataRefImpl) const
Line
Count
Source
757
3.19k
bool ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec) const {
758
3.19k
  return getSection(Sec)->sh_type == ELF::SHT_NOBITS;
759
3.19k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isSectionVirtual(llvm::object::DataRefImpl) const
Line
Count
Source
757
559
bool ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec) const {
758
559
  return getSection(Sec)->sh_type == ELF::SHT_NOBITS;
759
559
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isSectionVirtual(llvm::object::DataRefImpl) const
Line
Count
Source
757
10.7k
bool ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec) const {
758
10.7k
  return getSection(Sec)->sh_type == ELF::SHT_NOBITS;
759
10.7k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isSectionVirtual(llvm::object::DataRefImpl) const
Line
Count
Source
757
611
bool ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec) const {
758
611
  return getSection(Sec)->sh_type == ELF::SHT_NOBITS;
759
611
}
760
761
template <class ELFT>
762
relocation_iterator
763
5.77k
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
764
5.77k
  DataRefImpl RelData;
765
5.77k
  auto SectionsOrErr = EF.sections();
766
5.77k
  if (!SectionsOrErr)
767
0
    return relocation_iterator(RelocationRef());
768
5.77k
  uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
769
5.77k
  RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
770
5.77k
  RelData.d.b = 0;
771
5.77k
  return relocation_iterator(RelocationRef(RelData, this));
772
5.77k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::section_rel_begin(llvm::object::DataRefImpl) const
Line
Count
Source
763
908
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
764
908
  DataRefImpl RelData;
765
908
  auto SectionsOrErr = EF.sections();
766
908
  if (!SectionsOrErr)
767
0
    return relocation_iterator(RelocationRef());
768
908
  uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
769
908
  RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
770
908
  RelData.d.b = 0;
771
908
  return relocation_iterator(RelocationRef(RelData, this));
772
908
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::section_rel_begin(llvm::object::DataRefImpl) const
Line
Count
Source
763
212
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
764
212
  DataRefImpl RelData;
765
212
  auto SectionsOrErr = EF.sections();
766
212
  if (!SectionsOrErr)
767
0
    return relocation_iterator(RelocationRef());
768
212
  uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
769
212
  RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
770
212
  RelData.d.b = 0;
771
212
  return relocation_iterator(RelocationRef(RelData, this));
772
212
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::section_rel_begin(llvm::object::DataRefImpl) const
Line
Count
Source
763
4.42k
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
764
4.42k
  DataRefImpl RelData;
765
4.42k
  auto SectionsOrErr = EF.sections();
766
4.42k
  if (!SectionsOrErr)
767
0
    return relocation_iterator(RelocationRef());
768
4.42k
  uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
769
4.42k
  RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
770
4.42k
  RelData.d.b = 0;
771
4.42k
  return relocation_iterator(RelocationRef(RelData, this));
772
4.42k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::section_rel_begin(llvm::object::DataRefImpl) const
Line
Count
Source
763
230
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
764
230
  DataRefImpl RelData;
765
230
  auto SectionsOrErr = EF.sections();
766
230
  if (!SectionsOrErr)
767
0
    return relocation_iterator(RelocationRef());
768
230
  uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
769
230
  RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
770
230
  RelData.d.b = 0;
771
230
  return relocation_iterator(RelocationRef(RelData, this));
772
230
}
773
774
template <class ELFT>
775
relocation_iterator
776
2.88k
ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
777
2.88k
  const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
778
2.88k
  relocation_iterator Begin = section_rel_begin(Sec);
779
2.88k
  if (S->sh_type != ELF::SHT_RELA && 
S->sh_type != ELF::SHT_REL734
)
780
371
    return Begin;
781
2.51k
  DataRefImpl RelData = Begin->getRawDataRefImpl();
782
2.51k
  const Elf_Shdr *RelSec = getRelSection(RelData);
783
2.51k
784
2.51k
  // Error check sh_link here so that getRelocationSymbol can just use it.
785
2.51k
  auto SymSecOrErr = EF.getSection(RelSec->sh_link);
786
2.51k
  if (!SymSecOrErr)
787
0
    report_fatal_error(errorToErrorCode(SymSecOrErr.takeError()).message());
788
2.51k
789
2.51k
  RelData.d.b += S->sh_size / S->sh_entsize;
790
2.51k
  return relocation_iterator(RelocationRef(RelData, this));
791
2.51k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::section_rel_end(llvm::object::DataRefImpl) const
Line
Count
Source
776
454
ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
777
454
  const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
778
454
  relocation_iterator Begin = section_rel_begin(Sec);
779
454
  if (S->sh_type != ELF::SHT_RELA && 
S->sh_type != ELF::SHT_REL405
)
780
131
    return Begin;
781
323
  DataRefImpl RelData = Begin->getRawDataRefImpl();
782
323
  const Elf_Shdr *RelSec = getRelSection(RelData);
783
323
784
323
  // Error check sh_link here so that getRelocationSymbol can just use it.
785
323
  auto SymSecOrErr = EF.getSection(RelSec->sh_link);
786
323
  if (!SymSecOrErr)
787
0
    report_fatal_error(errorToErrorCode(SymSecOrErr.takeError()).message());
788
323
789
323
  RelData.d.b += S->sh_size / S->sh_entsize;
790
323
  return relocation_iterator(RelocationRef(RelData, this));
791
323
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::section_rel_end(llvm::object::DataRefImpl) const
Line
Count
Source
776
106
ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
777
106
  const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
778
106
  relocation_iterator Begin = section_rel_begin(Sec);
779
106
  if (S->sh_type != ELF::SHT_RELA && 
S->sh_type != ELF::SHT_REL75
)
780
12
    return Begin;
781
94
  DataRefImpl RelData = Begin->getRawDataRefImpl();
782
94
  const Elf_Shdr *RelSec = getRelSection(RelData);
783
94
784
94
  // Error check sh_link here so that getRelocationSymbol can just use it.
785
94
  auto SymSecOrErr = EF.getSection(RelSec->sh_link);
786
94
  if (!SymSecOrErr)
787
0
    report_fatal_error(errorToErrorCode(SymSecOrErr.takeError()).message());
788
94
789
94
  RelData.d.b += S->sh_size / S->sh_entsize;
790
94
  return relocation_iterator(RelocationRef(RelData, this));
791
94
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::section_rel_end(llvm::object::DataRefImpl) const
Line
Count
Source
776
2.21k
ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
777
2.21k
  const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
778
2.21k
  relocation_iterator Begin = section_rel_begin(Sec);
779
2.21k
  if (S->sh_type != ELF::SHT_RELA && 
S->sh_type != ELF::SHT_REL234
)
780
216
    return Begin;
781
1.99k
  DataRefImpl RelData = Begin->getRawDataRefImpl();
782
1.99k
  const Elf_Shdr *RelSec = getRelSection(RelData);
783
1.99k
784
1.99k
  // Error check sh_link here so that getRelocationSymbol can just use it.
785
1.99k
  auto SymSecOrErr = EF.getSection(RelSec->sh_link);
786
1.99k
  if (!SymSecOrErr)
787
0
    report_fatal_error(errorToErrorCode(SymSecOrErr.takeError()).message());
788
1.99k
789
1.99k
  RelData.d.b += S->sh_size / S->sh_entsize;
790
1.99k
  return relocation_iterator(RelocationRef(RelData, this));
791
1.99k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::section_rel_end(llvm::object::DataRefImpl) const
Line
Count
Source
776
115
ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
777
115
  const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
778
115
  relocation_iterator Begin = section_rel_begin(Sec);
779
115
  if (S->sh_type != ELF::SHT_RELA && 
S->sh_type != ELF::SHT_REL20
)
780
12
    return Begin;
781
103
  DataRefImpl RelData = Begin->getRawDataRefImpl();
782
103
  const Elf_Shdr *RelSec = getRelSection(RelData);
783
103
784
103
  // Error check sh_link here so that getRelocationSymbol can just use it.
785
103
  auto SymSecOrErr = EF.getSection(RelSec->sh_link);
786
103
  if (!SymSecOrErr)
787
0
    report_fatal_error(errorToErrorCode(SymSecOrErr.takeError()).message());
788
103
789
103
  RelData.d.b += S->sh_size / S->sh_entsize;
790
103
  return relocation_iterator(RelocationRef(RelData, this));
791
103
}
792
793
template <class ELFT>
794
section_iterator
795
21.0k
ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const {
796
21.0k
  if (EF.getHeader()->e_type != ELF::ET_REL)
797
7.30k
    return section_end();
798
13.7k
799
13.7k
  const Elf_Shdr *EShdr = getSection(Sec);
800
13.7k
  uintX_t Type = EShdr->sh_type;
801
13.7k
  if (Type != ELF::SHT_REL && 
Type != ELF::SHT_RELA13.4k
)
802
11.6k
    return section_end();
803
2.11k
804
2.11k
  auto R = EF.getSection(EShdr->sh_info);
805
2.11k
  if (!R)
806
0
    report_fatal_error(errorToErrorCode(R.takeError()).message());
807
2.11k
  return section_iterator(SectionRef(toDRI(*R), this));
808
2.11k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocatedSection(llvm::object::DataRefImpl) const
Line
Count
Source
795
4.04k
ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const {
796
4.04k
  if (EF.getHeader()->e_type != ELF::ET_REL)
797
1.78k
    return section_end();
798
2.25k
799
2.25k
  const Elf_Shdr *EShdr = getSection(Sec);
800
2.25k
  uintX_t Type = EShdr->sh_type;
801
2.25k
  if (Type != ELF::SHT_REL && 
Type != ELF::SHT_RELA2.02k
)
802
1.93k
    return section_end();
803
321
804
321
  auto R = EF.getSection(EShdr->sh_info);
805
321
  if (!R)
806
0
    report_fatal_error(errorToErrorCode(R.takeError()).message());
807
321
  return section_iterator(SectionRef(toDRI(*R), this));
808
321
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocatedSection(llvm::object::DataRefImpl) const
Line
Count
Source
795
1.40k
ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const {
796
1.40k
  if (EF.getHeader()->e_type != ELF::ET_REL)
797
591
    return section_end();
798
812
799
812
  const Elf_Shdr *EShdr = getSection(Sec);
800
812
  uintX_t Type = EShdr->sh_type;
801
812
  if (Type != ELF::SHT_REL && 
Type != ELF::SHT_RELA724
)
802
680
    return section_end();
803
132
804
132
  auto R = EF.getSection(EShdr->sh_info);
805
132
  if (!R)
806
0
    report_fatal_error(errorToErrorCode(R.takeError()).message());
807
132
  return section_iterator(SectionRef(toDRI(*R), this));
808
132
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocatedSection(llvm::object::DataRefImpl) const
Line
Count
Source
795
14.4k
ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const {
796
14.4k
  if (EF.getHeader()->e_type != ELF::ET_REL)
797
4.37k
    return section_end();
798
10.0k
799
10.0k
  const Elf_Shdr *EShdr = getSection(Sec);
800
10.0k
  uintX_t Type = EShdr->sh_type;
801
10.0k
  if (Type != ELF::SHT_REL && 
Type != ELF::SHT_RELA10.0k
)
802
8.53k
    return section_end();
803
1.54k
804
1.54k
  auto R = EF.getSection(EShdr->sh_info);
805
1.54k
  if (!R)
806
0
    report_fatal_error(errorToErrorCode(R.takeError()).message());
807
1.54k
  return section_iterator(SectionRef(toDRI(*R), this));
808
1.54k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocatedSection(llvm::object::DataRefImpl) const
Line
Count
Source
795
1.20k
ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const {
796
1.20k
  if (EF.getHeader()->e_type != ELF::ET_REL)
797
559
    return section_end();
798
643
799
643
  const Elf_Shdr *EShdr = getSection(Sec);
800
643
  uintX_t Type = EShdr->sh_type;
801
643
  if (Type != ELF::SHT_REL && 
Type != ELF::SHT_RELA636
)
802
524
    return section_end();
803
119
804
119
  auto R = EF.getSection(EShdr->sh_info);
805
119
  if (!R)
806
0
    report_fatal_error(errorToErrorCode(R.takeError()).message());
807
119
  return section_iterator(SectionRef(toDRI(*R), this));
808
119
}
809
810
// Relocations
811
template <class ELFT>
812
6.59k
void ELFObjectFile<ELFT>::moveRelocationNext(DataRefImpl &Rel) const {
813
6.59k
  ++Rel.d.b;
814
6.59k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::moveRelocationNext(llvm::object::DataRefImpl&) const
Line
Count
Source
812
742
void ELFObjectFile<ELFT>::moveRelocationNext(DataRefImpl &Rel) const {
813
742
  ++Rel.d.b;
814
742
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::moveRelocationNext(llvm::object::DataRefImpl&) const
Line
Count
Source
812
269
void ELFObjectFile<ELFT>::moveRelocationNext(DataRefImpl &Rel) const {
813
269
  ++Rel.d.b;
814
269
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::moveRelocationNext(llvm::object::DataRefImpl&) const
Line
Count
Source
812
5.32k
void ELFObjectFile<ELFT>::moveRelocationNext(DataRefImpl &Rel) const {
813
5.32k
  ++Rel.d.b;
814
5.32k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::moveRelocationNext(llvm::object::DataRefImpl&) const
Line
Count
Source
812
252
void ELFObjectFile<ELFT>::moveRelocationNext(DataRefImpl &Rel) const {
813
252
  ++Rel.d.b;
814
252
}
815
816
template <class ELFT>
817
symbol_iterator
818
6.14k
ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
819
6.14k
  uint32_t symbolIdx;
820
6.14k
  const Elf_Shdr *sec = getRelSection(Rel);
821
6.14k
  if (sec->sh_type == ELF::SHT_REL)
822
736
    symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL());
823
5.40k
  else
824
5.40k
    symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL());
825
6.14k
  if (!symbolIdx)
826
29
    return symbol_end();
827
6.11k
828
6.11k
  // FIXME: error check symbolIdx
829
6.11k
  DataRefImpl SymbolData;
830
6.11k
  SymbolData.d.a = sec->sh_link;
831
6.11k
  SymbolData.d.b = symbolIdx;
832
6.11k
  return symbol_iterator(SymbolRef(SymbolData, this));
833
6.11k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
818
692
ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
819
692
  uint32_t symbolIdx;
820
692
  const Elf_Shdr *sec = getRelSection(Rel);
821
692
  if (sec->sh_type == ELF::SHT_REL)
822
522
    symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL());
823
170
  else
824
170
    symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL());
825
692
  if (!symbolIdx)
826
0
    return symbol_end();
827
692
828
692
  // FIXME: error check symbolIdx
829
692
  DataRefImpl SymbolData;
830
692
  SymbolData.d.a = sec->sh_link;
831
692
  SymbolData.d.b = symbolIdx;
832
692
  return symbol_iterator(SymbolRef(SymbolData, this));
833
692
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
818
238
ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
819
238
  uint32_t symbolIdx;
820
238
  const Elf_Shdr *sec = getRelSection(Rel);
821
238
  if (sec->sh_type == ELF::SHT_REL)
822
168
    symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL());
823
70
  else
824
70
    symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL());
825
238
  if (!symbolIdx)
826
0
    return symbol_end();
827
238
828
238
  // FIXME: error check symbolIdx
829
238
  DataRefImpl SymbolData;
830
238
  SymbolData.d.a = sec->sh_link;
831
238
  SymbolData.d.b = symbolIdx;
832
238
  return symbol_iterator(SymbolRef(SymbolData, this));
833
238
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
818
5.00k
ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
819
5.00k
  uint32_t symbolIdx;
820
5.00k
  const Elf_Shdr *sec = getRelSection(Rel);
821
5.00k
  if (sec->sh_type == ELF::SHT_REL)
822
28
    symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL());
823
4.97k
  else
824
4.97k
    symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL());
825
5.00k
  if (!symbolIdx)
826
29
    return symbol_end();
827
4.97k
828
4.97k
  // FIXME: error check symbolIdx
829
4.97k
  DataRefImpl SymbolData;
830
4.97k
  SymbolData.d.a = sec->sh_link;
831
4.97k
  SymbolData.d.b = symbolIdx;
832
4.97k
  return symbol_iterator(SymbolRef(SymbolData, this));
833
4.97k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
818
212
ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
819
212
  uint32_t symbolIdx;
820
212
  const Elf_Shdr *sec = getRelSection(Rel);
821
212
  if (sec->sh_type == ELF::SHT_REL)
822
18
    symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL());
823
194
  else
824
194
    symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL());
825
212
  if (!symbolIdx)
826
0
    return symbol_end();
827
212
828
212
  // FIXME: error check symbolIdx
829
212
  DataRefImpl SymbolData;
830
212
  SymbolData.d.a = sec->sh_link;
831
212
  SymbolData.d.b = symbolIdx;
832
212
  return symbol_iterator(SymbolRef(SymbolData, this));
833
212
}
834
835
template <class ELFT>
836
6.82k
uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const {
837
6.82k
  const Elf_Shdr *sec = getRelSection(Rel);
838
6.82k
  if (sec->sh_type == ELF::SHT_REL)
839
1.00k
    return getRel(Rel)->r_offset;
840
5.82k
841
5.82k
  return getRela(Rel)->r_offset;
842
5.82k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationOffset(llvm::object::DataRefImpl) const
Line
Count
Source
836
898
uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const {
837
898
  const Elf_Shdr *sec = getRelSection(Rel);
838
898
  if (sec->sh_type == ELF::SHT_REL)
839
679
    return getRel(Rel)->r_offset;
840
219
841
219
  return getRela(Rel)->r_offset;
842
219
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationOffset(llvm::object::DataRefImpl) const
Line
Count
Source
836
468
uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const {
837
468
  const Elf_Shdr *sec = getRelSection(Rel);
838
468
  if (sec->sh_type == ELF::SHT_REL)
839
262
    return getRel(Rel)->r_offset;
840
206
841
206
  return getRela(Rel)->r_offset;
842
206
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationOffset(llvm::object::DataRefImpl) const
Line
Count
Source
836
5.09k
uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const {
837
5.09k
  const Elf_Shdr *sec = getRelSection(Rel);
838
5.09k
  if (sec->sh_type == ELF::SHT_REL)
839
45
    return getRel(Rel)->r_offset;
840
5.05k
841
5.05k
  return getRela(Rel)->r_offset;
842
5.05k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationOffset(llvm::object::DataRefImpl) const
Line
Count
Source
836
366
uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const {
837
366
  const Elf_Shdr *sec = getRelSection(Rel);
838
366
  if (sec->sh_type == ELF::SHT_REL)
839
18
    return getRel(Rel)->r_offset;
840
348
841
348
  return getRela(Rel)->r_offset;
842
348
}
843
844
template <class ELFT>
845
6.43k
uint64_t ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel) const {
846
6.43k
  const Elf_Shdr *sec = getRelSection(Rel);
847
6.43k
  if (sec->sh_type == ELF::SHT_REL)
848
750
    return getRel(Rel)->getType(EF.isMips64EL());
849
5.68k
  else
850
5.68k
    return getRela(Rel)->getType(EF.isMips64EL());
851
6.43k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationType(llvm::object::DataRefImpl) const
Line
Count
Source
845
715
uint64_t ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel) const {
846
715
  const Elf_Shdr *sec = getRelSection(Rel);
847
715
  if (sec->sh_type == ELF::SHT_REL)
848
536
    return getRel(Rel)->getType(EF.isMips64EL());
849
179
  else
850
179
    return getRela(Rel)->getType(EF.isMips64EL());
851
715
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationType(llvm::object::DataRefImpl) const
Line
Count
Source
845
238
uint64_t ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel) const {
846
238
  const Elf_Shdr *sec = getRelSection(Rel);
847
238
  if (sec->sh_type == ELF::SHT_REL)
848
168
    return getRel(Rel)->getType(EF.isMips64EL());
849
70
  else
850
70
    return getRela(Rel)->getType(EF.isMips64EL());
851
238
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationType(llvm::object::DataRefImpl) const
Line
Count
Source
845
5.27k
uint64_t ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel) const {
846
5.27k
  const Elf_Shdr *sec = getRelSection(Rel);
847
5.27k
  if (sec->sh_type == ELF::SHT_REL)
848
28
    return getRel(Rel)->getType(EF.isMips64EL());
849
5.24k
  else
850
5.24k
    return getRela(Rel)->getType(EF.isMips64EL());
851
5.27k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationType(llvm::object::DataRefImpl) const
Line
Count
Source
845
212
uint64_t ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel) const {
846
212
  const Elf_Shdr *sec = getRelSection(Rel);
847
212
  if (sec->sh_type == ELF::SHT_REL)
848
18
    return getRel(Rel)->getType(EF.isMips64EL());
849
194
  else
850
194
    return getRela(Rel)->getType(EF.isMips64EL());
851
212
}
852
853
template <class ELFT>
854
StringRef ELFObjectFile<ELFT>::getRelocationTypeName(uint32_t Type) const {
855
  return getELFRelocationTypeName(EF.getHeader()->e_machine, Type);
856
}
857
858
template <class ELFT>
859
void ELFObjectFile<ELFT>::getRelocationTypeName(
860
846
    DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
861
846
  uint32_t type = getRelocationType(Rel);
862
846
  EF.getRelocationTypeName(type, Result);
863
846
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationTypeName(llvm::object::DataRefImpl, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
860
274
    DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
861
274
  uint32_t type = getRelocationType(Rel);
862
274
  EF.getRelocationTypeName(type, Result);
863
274
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationTypeName(llvm::object::DataRefImpl, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
860
67
    DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
861
67
  uint32_t type = getRelocationType(Rel);
862
67
  EF.getRelocationTypeName(type, Result);
863
67
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationTypeName(llvm::object::DataRefImpl, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
860
461
    DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
861
461
  uint32_t type = getRelocationType(Rel);
862
461
  EF.getRelocationTypeName(type, Result);
863
461
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationTypeName(llvm::object::DataRefImpl, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
860
44
    DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
861
44
  uint32_t type = getRelocationType(Rel);
862
44
  EF.getRelocationTypeName(type, Result);
863
44
}
864
865
template <class ELFT>
866
Expected<int64_t>
867
4.74k
ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel) const {
868
4.74k
  if (getRelSection(Rel)->sh_type != ELF::SHT_RELA)
869
41
    return createError("Section is not SHT_RELA");
870
4.70k
  return (int64_t)getRela(Rel)->r_addend;
871
4.70k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationAddend(llvm::object::DataRefImpl) const
Line
Count
Source
867
67
ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel) const {
868
67
  if (getRelSection(Rel)->sh_type != ELF::SHT_RELA)
869
21
    return createError("Section is not SHT_RELA");
870
46
  return (int64_t)getRela(Rel)->r_addend;
871
46
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationAddend(llvm::object::DataRefImpl) const
Line
Count
Source
867
45
ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel) const {
868
45
  if (getRelSection(Rel)->sh_type != ELF::SHT_RELA)
869
19
    return createError("Section is not SHT_RELA");
870
26
  return (int64_t)getRela(Rel)->r_addend;
871
26
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationAddend(llvm::object::DataRefImpl) const
Line
Count
Source
867
4.48k
ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel) const {
868
4.48k
  if (getRelSection(Rel)->sh_type != ELF::SHT_RELA)
869
1
    return createError("Section is not SHT_RELA");
870
4.48k
  return (int64_t)getRela(Rel)->r_addend;
871
4.48k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationAddend(llvm::object::DataRefImpl) const
Line
Count
Source
867
150
ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel) const {
868
150
  if (getRelSection(Rel)->sh_type != ELF::SHT_RELA)
869
0
    return createError("Section is not SHT_RELA");
870
150
  return (int64_t)getRela(Rel)->r_addend;
871
150
}
872
873
template <class ELFT>
874
const typename ELFObjectFile<ELFT>::Elf_Rel *
875
2.49k
ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const {
876
2.49k
  assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
877
2.49k
  auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
878
2.49k
  if (!Ret)
879
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
880
2.49k
  return *Ret;
881
2.49k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRel(llvm::object::DataRefImpl) const
Line
Count
Source
875
1.73k
ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const {
876
1.73k
  assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
877
1.73k
  auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
878
1.73k
  if (!Ret)
879
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
880
1.73k
  return *Ret;
881
1.73k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRel(llvm::object::DataRefImpl) const
Line
Count
Source
875
598
ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const {
876
598
  assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
877
598
  auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
878
598
  if (!Ret)
879
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
880
598
  return *Ret;
881
598
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRel(llvm::object::DataRefImpl) const
Line
Count
Source
875
101
ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const {
876
101
  assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
877
101
  auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
878
101
  if (!Ret)
879
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
880
101
  return *Ret;
881
101
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRel(llvm::object::DataRefImpl) const
Line
Count
Source
875
54
ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const {
876
54
  assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
877
54
  auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
878
54
  if (!Ret)
879
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
880
54
  return *Ret;
881
54
}
882
883
template <class ELFT>
884
const typename ELFObjectFile<ELFT>::Elf_Rela *
885
22.2k
ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
886
22.2k
  assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
887
22.2k
  auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
888
22.2k
  if (!Ret)
889
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
890
22.2k
  return *Ret;
891
22.2k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRela(llvm::object::DataRefImpl) const
Line
Count
Source
885
729
ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
886
729
  assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
887
729
  auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
888
729
  if (!Ret)
889
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
890
729
  return *Ret;
891
729
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRela(llvm::object::DataRefImpl) const
Line
Count
Source
885
410
ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
886
410
  assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
887
410
  auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
888
410
  if (!Ret)
889
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
890
410
  return *Ret;
891
410
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRela(llvm::object::DataRefImpl) const
Line
Count
Source
885
20.1k
ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
886
20.1k
  assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
887
20.1k
  auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
888
20.1k
  if (!Ret)
889
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
890
20.1k
  return *Ret;
891
20.1k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRela(llvm::object::DataRefImpl) const
Line
Count
Source
885
930
ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
886
930
  assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
887
930
  auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
888
930
  if (!Ret)
889
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
890
930
  return *Ret;
891
930
}
892
893
template <class ELFT>
894
Expected<ELFObjectFile<ELFT>>
895
5.54k
ELFObjectFile<ELFT>::create(MemoryBufferRef Object) {
896
5.54k
  auto EFOrErr = ELFFile<ELFT>::create(Object.getBuffer());
897
5.54k
  if (Error E = EFOrErr.takeError())
898
1
    return std::move(E);
899
5.54k
  auto EF = std::move(*EFOrErr);
900
5.54k
901
5.54k
  auto SectionsOrErr = EF.sections();
902
5.54k
  if (!SectionsOrErr)
903
3
    return SectionsOrErr.takeError();
904
5.54k
905
5.54k
  const Elf_Shdr *DotDynSymSec = nullptr;
906
5.54k
  const Elf_Shdr *DotSymtabSec = nullptr;
907
5.54k
  ArrayRef<Elf_Word> ShndxTable;
908
1.55M
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
909
1.55M
    switch (Sec.sh_type) {
910
1.55M
    case ELF::SHT_DYNSYM: {
911
1.03k
      if (DotDynSymSec)
912
0
        return createError("More than one dynamic symbol table!");
913
1.03k
      DotDynSymSec = &Sec;
914
1.03k
      break;
915
1.03k
    }
916
5.46k
    case ELF::SHT_SYMTAB: {
917
5.46k
      if (DotSymtabSec)
918
0
        return createError("More than one static symbol table!");
919
5.46k
      DotSymtabSec = &Sec;
920
5.46k
      break;
921
5.46k
    }
922
5.46k
    case ELF::SHT_SYMTAB_SHNDX: {
923
20
      auto TableOrErr = EF.getSHNDXTable(Sec);
924
20
      if (!TableOrErr)
925
1
        return TableOrErr.takeError();
926
19
      ShndxTable = *TableOrErr;
927
19
      break;
928
19
    }
929
1.55M
    }
930
1.55M
  }
931
5.54k
  return ELFObjectFile<ELFT>(Object, EF, DotDynSymSec, DotSymtabSec,
932
5.54k
                             ShndxTable);
933
5.54k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::create(llvm::MemoryBufferRef)
Line
Count
Source
895
1.13k
ELFObjectFile<ELFT>::create(MemoryBufferRef Object) {
896
1.13k
  auto EFOrErr = ELFFile<ELFT>::create(Object.getBuffer());
897
1.13k
  if (Error E = EFOrErr.takeError())
898
1
    return std::move(E);
899
1.13k
  auto EF = std::move(*EFOrErr);
900
1.13k
901
1.13k
  auto SectionsOrErr = EF.sections();
902
1.13k
  if (!SectionsOrErr)
903
0
    return SectionsOrErr.takeError();
904
1.13k
905
1.13k
  const Elf_Shdr *DotDynSymSec = nullptr;
906
1.13k
  const Elf_Shdr *DotSymtabSec = nullptr;
907
1.13k
  ArrayRef<Elf_Word> ShndxTable;
908
10.2k
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
909
10.2k
    switch (Sec.sh_type) {
910
10.2k
    case ELF::SHT_DYNSYM: {
911
185
      if (DotDynSymSec)
912
0
        return createError("More than one dynamic symbol table!");
913
185
      DotDynSymSec = &Sec;
914
185
      break;
915
185
    }
916
1.13k
    case ELF::SHT_SYMTAB: {
917
1.13k
      if (DotSymtabSec)
918
0
        return createError("More than one static symbol table!");
919
1.13k
      DotSymtabSec = &Sec;
920
1.13k
      break;
921
1.13k
    }
922
1.13k
    case ELF::SHT_SYMTAB_SHNDX: {
923
0
      auto TableOrErr = EF.getSHNDXTable(Sec);
924
0
      if (!TableOrErr)
925
0
        return TableOrErr.takeError();
926
0
      ShndxTable = *TableOrErr;
927
0
      break;
928
0
    }
929
10.2k
    }
930
10.2k
  }
931
1.13k
  return ELFObjectFile<ELFT>(Object, EF, DotDynSymSec, DotSymtabSec,
932
1.13k
                             ShndxTable);
933
1.13k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::create(llvm::MemoryBufferRef)
Line
Count
Source
895
284
ELFObjectFile<ELFT>::create(MemoryBufferRef Object) {
896
284
  auto EFOrErr = ELFFile<ELFT>::create(Object.getBuffer());
897
284
  if (Error E = EFOrErr.takeError())
898
0
    return std::move(E);
899
284
  auto EF = std::move(*EFOrErr);
900
284
901
284
  auto SectionsOrErr = EF.sections();
902
284
  if (!SectionsOrErr)
903
0
    return SectionsOrErr.takeError();
904
284
905
284
  const Elf_Shdr *DotDynSymSec = nullptr;
906
284
  const Elf_Shdr *DotSymtabSec = nullptr;
907
284
  ArrayRef<Elf_Word> ShndxTable;
908
3.35k
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
909
3.35k
    switch (Sec.sh_type) {
910
3.35k
    case ELF::SHT_DYNSYM: {
911
74
      if (DotDynSymSec)
912
0
        return createError("More than one dynamic symbol table!");
913
74
      DotDynSymSec = &Sec;
914
74
      break;
915
74
    }
916
284
    case ELF::SHT_SYMTAB: {
917
284
      if (DotSymtabSec)
918
0
        return createError("More than one static symbol table!");
919
284
      DotSymtabSec = &Sec;
920
284
      break;
921
284
    }
922
284
    case ELF::SHT_SYMTAB_SHNDX: {
923
0
      auto TableOrErr = EF.getSHNDXTable(Sec);
924
0
      if (!TableOrErr)
925
0
        return TableOrErr.takeError();
926
0
      ShndxTable = *TableOrErr;
927
0
      break;
928
0
    }
929
3.35k
    }
930
3.35k
  }
931
284
  return ELFObjectFile<ELFT>(Object, EF, DotDynSymSec, DotSymtabSec,
932
284
                             ShndxTable);
933
284
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::create(llvm::MemoryBufferRef)
Line
Count
Source
895
3.89k
ELFObjectFile<ELFT>::create(MemoryBufferRef Object) {
896
3.89k
  auto EFOrErr = ELFFile<ELFT>::create(Object.getBuffer());
897
3.89k
  if (Error E = EFOrErr.takeError())
898
0
    return std::move(E);
899
3.89k
  auto EF = std::move(*EFOrErr);
900
3.89k
901
3.89k
  auto SectionsOrErr = EF.sections();
902
3.89k
  if (!SectionsOrErr)
903
3
    return SectionsOrErr.takeError();
904
3.88k
905
3.88k
  const Elf_Shdr *DotDynSymSec = nullptr;
906
3.88k
  const Elf_Shdr *DotSymtabSec = nullptr;
907
3.88k
  ArrayRef<Elf_Word> ShndxTable;
908
1.53M
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
909
1.53M
    switch (Sec.sh_type) {
910
1.53M
    case ELF::SHT_DYNSYM: {
911
723
      if (DotDynSymSec)
912
0
        return createError("More than one dynamic symbol table!");
913
723
      DotDynSymSec = &Sec;
914
723
      break;
915
723
    }
916
3.81k
    case ELF::SHT_SYMTAB: {
917
3.81k
      if (DotSymtabSec)
918
0
        return createError("More than one static symbol table!");
919
3.81k
      DotSymtabSec = &Sec;
920
3.81k
      break;
921
3.81k
    }
922
3.81k
    case ELF::SHT_SYMTAB_SHNDX: {
923
20
      auto TableOrErr = EF.getSHNDXTable(Sec);
924
20
      if (!TableOrErr)
925
1
        return TableOrErr.takeError();
926
19
      ShndxTable = *TableOrErr;
927
19
      break;
928
19
    }
929
1.53M
    }
930
1.53M
  }
931
3.88k
  return ELFObjectFile<ELFT>(Object, EF, DotDynSymSec, DotSymtabSec,
932
3.88k
                             ShndxTable);
933
3.88k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::create(llvm::MemoryBufferRef)
Line
Count
Source
895
238
ELFObjectFile<ELFT>::create(MemoryBufferRef Object) {
896
238
  auto EFOrErr = ELFFile<ELFT>::create(Object.getBuffer());
897
238
  if (Error E = EFOrErr.takeError())
898
0
    return std::move(E);
899
238
  auto EF = std::move(*EFOrErr);
900
238
901
238
  auto SectionsOrErr = EF.sections();
902
238
  if (!SectionsOrErr)
903
0
    return SectionsOrErr.takeError();
904
238
905
238
  const Elf_Shdr *DotDynSymSec = nullptr;
906
238
  const Elf_Shdr *DotSymtabSec = nullptr;
907
238
  ArrayRef<Elf_Word> ShndxTable;
908
2.54k
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
909
2.54k
    switch (Sec.sh_type) {
910
2.54k
    case ELF::SHT_DYNSYM: {
911
56
      if (DotDynSymSec)
912
0
        return createError("More than one dynamic symbol table!");
913
56
      DotDynSymSec = &Sec;
914
56
      break;
915
56
    }
916
237
    case ELF::SHT_SYMTAB: {
917
237
      if (DotSymtabSec)
918
0
        return createError("More than one static symbol table!");
919
237
      DotSymtabSec = &Sec;
920
237
      break;
921
237
    }
922
237
    case ELF::SHT_SYMTAB_SHNDX: {
923
0
      auto TableOrErr = EF.getSHNDXTable(Sec);
924
0
      if (!TableOrErr)
925
0
        return TableOrErr.takeError();
926
0
      ShndxTable = *TableOrErr;
927
0
      break;
928
0
    }
929
2.54k
    }
930
2.54k
  }
931
238
  return ELFObjectFile<ELFT>(Object, EF, DotDynSymSec, DotSymtabSec,
932
238
                             ShndxTable);
933
238
}
934
935
template <class ELFT>
936
ELFObjectFile<ELFT>::ELFObjectFile(MemoryBufferRef Object, ELFFile<ELFT> EF,
937
                                   const Elf_Shdr *DotDynSymSec,
938
                                   const Elf_Shdr *DotSymtabSec,
939
                                   ArrayRef<Elf_Word> ShndxTable)
940
    : ELFObjectFileBase(
941
          getELFType(ELFT::TargetEndianness == support::little, ELFT::Is64Bits),
942
          Object),
943
      EF(EF), DotDynSymSec(DotDynSymSec), DotSymtabSec(DotSymtabSec),
944
16.6k
      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
944
3.40k
      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
944
852
      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
944
11.6k
      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
944
714
      ShndxTable(ShndxTable) {}
945
946
template <class ELFT>
947
ELFObjectFile<ELFT>::ELFObjectFile(ELFObjectFile<ELFT> &&Other)
948
    : ELFObjectFile(Other.Data, Other.EF, Other.DotDynSymSec,
949
11.0k
                    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
949
2.27k
                    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
949
568
                    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
949
7.77k
                    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
949
476
                    Other.DotSymtabSec, Other.ShndxTable) {}
950
951
template <class ELFT>
952
2.11k
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin() const {
953
2.11k
  DataRefImpl Sym = toDRI(DotSymtabSec, 0);
954
2.11k
  return basic_symbol_iterator(SymbolRef(Sym, this));
955
2.11k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::symbol_begin() const
Line
Count
Source
952
459
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin() const {
953
459
  DataRefImpl Sym = toDRI(DotSymtabSec, 0);
954
459
  return basic_symbol_iterator(SymbolRef(Sym, this));
955
459
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::symbol_begin() const
Line
Count
Source
952
110
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin() const {
953
110
  DataRefImpl Sym = toDRI(DotSymtabSec, 0);
954
110
  return basic_symbol_iterator(SymbolRef(Sym, this));
955
110
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::symbol_begin() const
Line
Count
Source
952
1.46k
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin() const {
953
1.46k
  DataRefImpl Sym = toDRI(DotSymtabSec, 0);
954
1.46k
  return basic_symbol_iterator(SymbolRef(Sym, this));
955
1.46k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::symbol_begin() const
Line
Count
Source
952
82
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin() const {
953
82
  DataRefImpl Sym = toDRI(DotSymtabSec, 0);
954
82
  return basic_symbol_iterator(SymbolRef(Sym, this));
955
82
}
956
957
template <class ELFT>
958
7.81k
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
959
7.81k
  const Elf_Shdr *SymTab = DotSymtabSec;
960
7.81k
  if (!SymTab)
961
13
    return symbol_begin();
962
7.80k
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
963
7.80k
  return basic_symbol_iterator(SymbolRef(Sym, this));
964
7.80k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::symbol_end() const
Line
Count
Source
958
910
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
959
910
  const Elf_Shdr *SymTab = DotSymtabSec;
960
910
  if (!SymTab)
961
1
    return symbol_begin();
962
909
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
963
909
  return basic_symbol_iterator(SymbolRef(Sym, this));
964
909
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::symbol_end() const
Line
Count
Source
958
314
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
959
314
  const Elf_Shdr *SymTab = DotSymtabSec;
960
314
  if (!SymTab)
961
0
    return symbol_begin();
962
314
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
963
314
  return basic_symbol_iterator(SymbolRef(Sym, this));
964
314
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::symbol_end() const
Line
Count
Source
958
6.30k
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
959
6.30k
  const Elf_Shdr *SymTab = DotSymtabSec;
960
6.30k
  if (!SymTab)
961
12
    return symbol_begin();
962
6.28k
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
963
6.28k
  return basic_symbol_iterator(SymbolRef(Sym, this));
964
6.28k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::symbol_end() const
Line
Count
Source
958
290
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
959
290
  const Elf_Shdr *SymTab = DotSymtabSec;
960
290
  if (!SymTab)
961
0
    return symbol_begin();
962
290
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
963
290
  return basic_symbol_iterator(SymbolRef(Sym, this));
964
290
}
965
966
template <class ELFT>
967
244
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_begin() const {
968
244
  DataRefImpl Sym = toDRI(DotDynSymSec, 0);
969
244
  return symbol_iterator(SymbolRef(Sym, this));
970
244
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::dynamic_symbol_begin() const
Line
Count
Source
967
196
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_begin() const {
968
196
  DataRefImpl Sym = toDRI(DotDynSymSec, 0);
969
196
  return symbol_iterator(SymbolRef(Sym, this));
970
196
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::dynamic_symbol_begin() const
Line
Count
Source
967
8
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_begin() const {
968
8
  DataRefImpl Sym = toDRI(DotDynSymSec, 0);
969
8
  return symbol_iterator(SymbolRef(Sym, this));
970
8
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::dynamic_symbol_begin() const
Line
Count
Source
967
38
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_begin() const {
968
38
  DataRefImpl Sym = toDRI(DotDynSymSec, 0);
969
38
  return symbol_iterator(SymbolRef(Sym, this));
970
38
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::dynamic_symbol_begin() const
Line
Count
Source
967
2
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_begin() const {
968
2
  DataRefImpl Sym = toDRI(DotDynSymSec, 0);
969
2
  return symbol_iterator(SymbolRef(Sym, this));
970
2
}
971
972
template <class ELFT>
973
126
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_end() const {
974
126
  const Elf_Shdr *SymTab = DotDynSymSec;
975
126
  if (!SymTab)
976
118
    return dynamic_symbol_begin();
977
8
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
978
8
  return basic_symbol_iterator(SymbolRef(Sym, this));
979
8
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::dynamic_symbol_end() const
Line
Count
Source
973
99
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_end() const {
974
99
  const Elf_Shdr *SymTab = DotDynSymSec;
975
99
  if (!SymTab)
976
97
    return dynamic_symbol_begin();
977
2
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
978
2
  return basic_symbol_iterator(SymbolRef(Sym, this));
979
2
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::dynamic_symbol_end() const
Line
Count
Source
973
4
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_end() const {
974
4
  const Elf_Shdr *SymTab = DotDynSymSec;
975
4
  if (!SymTab)
976
4
    return dynamic_symbol_begin();
977
0
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
978
0
  return basic_symbol_iterator(SymbolRef(Sym, this));
979
0
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::dynamic_symbol_end() const
Line
Count
Source
973
22
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_end() const {
974
22
  const Elf_Shdr *SymTab = DotDynSymSec;
975
22
  if (!SymTab)
976
16
    return dynamic_symbol_begin();
977
6
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
978
6
  return basic_symbol_iterator(SymbolRef(Sym, this));
979
6
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::dynamic_symbol_end() const
Line
Count
Source
973
1
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_end() const {
974
1
  const Elf_Shdr *SymTab = DotDynSymSec;
975
1
  if (!SymTab)
976
1
    return dynamic_symbol_begin();
977
0
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
978
0
  return basic_symbol_iterator(SymbolRef(Sym, this));
979
0
}
980
981
template <class ELFT>
982
7.21k
section_iterator ELFObjectFile<ELFT>::section_begin() const {
983
7.21k
  auto SectionsOrErr = EF.sections();
984
7.21k
  if (!SectionsOrErr)
985
0
    return section_iterator(SectionRef());
986
7.21k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).begin()), this));
987
7.21k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::section_begin() const
Line
Count
Source
982
1.73k
section_iterator ELFObjectFile<ELFT>::section_begin() const {
983
1.73k
  auto SectionsOrErr = EF.sections();
984
1.73k
  if (!SectionsOrErr)
985
0
    return section_iterator(SectionRef());
986
1.73k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).begin()), this));
987
1.73k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::section_begin() const
Line
Count
Source
982
338
section_iterator ELFObjectFile<ELFT>::section_begin() const {
983
338
  auto SectionsOrErr = EF.sections();
984
338
  if (!SectionsOrErr)
985
0
    return section_iterator(SectionRef());
986
338
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).begin()), this));
987
338
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::section_begin() const
Line
Count
Source
982
4.85k
section_iterator ELFObjectFile<ELFT>::section_begin() const {
983
4.85k
  auto SectionsOrErr = EF.sections();
984
4.85k
  if (!SectionsOrErr)
985
0
    return section_iterator(SectionRef());
986
4.85k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).begin()), this));
987
4.85k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::section_begin() const
Line
Count
Source
982
285
section_iterator ELFObjectFile<ELFT>::section_begin() const {
983
285
  auto SectionsOrErr = EF.sections();
984
285
  if (!SectionsOrErr)
985
0
    return section_iterator(SectionRef());
986
285
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).begin()), this));
987
285
}
988
989
template <class ELFT>
990
71.1k
section_iterator ELFObjectFile<ELFT>::section_end() const {
991
71.1k
  auto SectionsOrErr = EF.sections();
992
71.1k
  if (!SectionsOrErr)
993
0
    return section_iterator(SectionRef());
994
71.1k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).end()), this));
995
71.1k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::section_end() const
Line
Count
Source
990
19.2k
section_iterator ELFObjectFile<ELFT>::section_end() const {
991
19.2k
  auto SectionsOrErr = EF.sections();
992
19.2k
  if (!SectionsOrErr)
993
0
    return section_iterator(SectionRef());
994
19.2k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).end()), this));
995
19.2k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::section_end() const
Line
Count
Source
990
3.96k
section_iterator ELFObjectFile<ELFT>::section_end() const {
991
3.96k
  auto SectionsOrErr = EF.sections();
992
3.96k
  if (!SectionsOrErr)
993
0
    return section_iterator(SectionRef());
994
3.96k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).end()), this));
995
3.96k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::section_end() const
Line
Count
Source
990
44.6k
section_iterator ELFObjectFile<ELFT>::section_end() const {
991
44.6k
  auto SectionsOrErr = EF.sections();
992
44.6k
  if (!SectionsOrErr)
993
0
    return section_iterator(SectionRef());
994
44.6k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).end()), this));
995
44.6k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::section_end() const
Line
Count
Source
990
3.17k
section_iterator ELFObjectFile<ELFT>::section_end() const {
991
3.17k
  auto SectionsOrErr = EF.sections();
992
3.17k
  if (!SectionsOrErr)
993
0
    return section_iterator(SectionRef());
994
3.17k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).end()), this));
995
3.17k
}
996
997
template <class ELFT>
998
9.77k
uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
999
9.77k
  return ELFT::Is64Bits ? 
87.71k
:
42.06k
;
1000
9.77k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getBytesInAddress() const
Line
Count
Source
998
1.50k
uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
999
1.50k
  return ELFT::Is64Bits ? 
80
: 4;
1000
1.50k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getBytesInAddress() const
Line
Count
Source
998
558
uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
999
558
  return ELFT::Is64Bits ? 
80
: 4;
1000
558
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getBytesInAddress() const
Line
Count
Source
998
7.34k
uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
999
7.34k
  return ELFT::Is64Bits ? 8 : 
40
;
1000
7.34k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getBytesInAddress() const
Line
Count
Source
998
367
uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
999
367
  return ELFT::Is64Bits ? 8 : 
40
;
1000
367
}
1001
1002
template <class ELFT>
1003
4.38k
StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
1004
4.38k
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1005
4.38k
  switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1006
4.38k
  case ELF::ELFCLASS32:
1007
1.30k
    switch (EF.getHeader()->e_machine) {
1008
1.30k
    case ELF::EM_386:
1009
256
      return "ELF32-i386";
1010
1.30k
    case ELF::EM_IAMCU:
1011
4
      return "ELF32-iamcu";
1012
1.30k
    case ELF::EM_X86_64:
1013
7
      return "ELF32-x86-64";
1014
1.30k
    case ELF::EM_ARM:
1015
453
      return (IsLittleEndian ? 
"ELF32-arm-little"442
:
"ELF32-arm-big"11
);
1016
1.30k
    case ELF::EM_AVR:
1017
0
      return "ELF32-avr";
1018
1.30k
    case ELF::EM_HEXAGON:
1019
117
      return "ELF32-hexagon";
1020
1.30k
    case ELF::EM_LANAI:
1021
4
      return "ELF32-lanai";
1022
1.30k
    case ELF::EM_MIPS:
1023
406
      return "ELF32-mips";
1024
1.30k
    case ELF::EM_PPC:
1025
11
      return "ELF32-ppc";
1026
1.30k
    case ELF::EM_RISCV:
1027
0
      return "ELF32-riscv";
1028
1.30k
    case ELF::EM_SPARC:
1029
9
    case ELF::EM_SPARC32PLUS:
1030
9
      return "ELF32-sparc";
1031
36
    case ELF::EM_AMDGPU:
1032
36
      return "ELF32-amdgpu";
1033
9
    default:
1034
2
      return "ELF32-unknown";
1035
0
    }
1036
3.07k
  case ELF::ELFCLASS64:
1037
3.07k
    switch (EF.getHeader()->e_machine) {
1038
3.07k
    case ELF::EM_386:
1039
0
      return "ELF64-i386";
1040
3.07k
    case ELF::EM_X86_64:
1041
1.79k
      return "ELF64-x86-64";
1042
3.07k
    case ELF::EM_AARCH64:
1043
808
      return (IsLittleEndian ? 
"ELF64-aarch64-little"800
:
"ELF64-aarch64-big"8
);
1044
3.07k
    case ELF::EM_PPC64:
1045
157
      return "ELF64-ppc64";
1046
3.07k
    case ELF::EM_RISCV:
1047
0
      return "ELF64-riscv";
1048
3.07k
    case ELF::EM_S390:
1049
10
      return "ELF64-s390";
1050
3.07k
    case ELF::EM_SPARCV9:
1051
14
      return "ELF64-sparc";
1052
3.07k
    case ELF::EM_MIPS:
1053
154
      return "ELF64-mips";
1054
3.07k
    case ELF::EM_AMDGPU:
1055
121
      return "ELF64-amdgpu";
1056
3.07k
    case ELF::EM_BPF:
1057
17
      return "ELF64-BPF";
1058
3.07k
    default:
1059
3
      return "ELF64-unknown";
1060
0
    }
1061
0
  default:
1062
0
    // FIXME: Proper error handling.
1063
0
    report_fatal_error("Invalid ELFCLASS!");
1064
4.38k
  }
1065
4.38k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getFileFormatName() const
Line
Count
Source
1003
1.02k
StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
1004
1.02k
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1005
1.02k
  switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1006
1.02k
  case ELF::ELFCLASS32:
1007
1.02k
    switch (EF.getHeader()->e_machine) {
1008
1.02k
    case ELF::EM_386:
1009
256
      return "ELF32-i386";
1010
1.02k
    case ELF::EM_IAMCU:
1011
4
      return "ELF32-iamcu";
1012
1.02k
    case ELF::EM_X86_64:
1013
6
      return "ELF32-x86-64";
1014
1.02k
    case ELF::EM_ARM:
1015
442
      return (IsLittleEndian ? "ELF32-arm-little" : 
"ELF32-arm-big"0
);
1016
1.02k
    case ELF::EM_AVR:
1017
0
      return "ELF32-avr";
1018
1.02k
    case ELF::EM_HEXAGON:
1019
117
      return "ELF32-hexagon";
1020
1.02k
    case ELF::EM_LANAI:
1021
1
      return "ELF32-lanai";
1022
1.02k
    case ELF::EM_MIPS:
1023
162
      return "ELF32-mips";
1024
1.02k
    case ELF::EM_PPC:
1025
0
      return "ELF32-ppc";
1026
1.02k
    case ELF::EM_RISCV:
1027
0
      return "ELF32-riscv";
1028
1.02k
    case ELF::EM_SPARC:
1029
2
    case ELF::EM_SPARC32PLUS:
1030
2
      return "ELF32-sparc";
1031
36
    case ELF::EM_AMDGPU:
1032
36
      return "ELF32-amdgpu";
1033
2
    default:
1034
2
      return "ELF32-unknown";
1035
0
    }
1036
0
  case ELF::ELFCLASS64:
1037
0
    switch (EF.getHeader()->e_machine) {
1038
0
    case ELF::EM_386:
1039
0
      return "ELF64-i386";
1040
0
    case ELF::EM_X86_64:
1041
0
      return "ELF64-x86-64";
1042
0
    case ELF::EM_AARCH64:
1043
0
      return (IsLittleEndian ? "ELF64-aarch64-little" : "ELF64-aarch64-big");
1044
0
    case ELF::EM_PPC64:
1045
0
      return "ELF64-ppc64";
1046
0
    case ELF::EM_RISCV:
1047
0
      return "ELF64-riscv";
1048
0
    case ELF::EM_S390:
1049
0
      return "ELF64-s390";
1050
0
    case ELF::EM_SPARCV9:
1051
0
      return "ELF64-sparc";
1052
0
    case ELF::EM_MIPS:
1053
0
      return "ELF64-mips";
1054
0
    case ELF::EM_AMDGPU:
1055
0
      return "ELF64-amdgpu";
1056
0
    case ELF::EM_BPF:
1057
0
      return "ELF64-BPF";
1058
0
    default:
1059
0
      return "ELF64-unknown";
1060
0
    }
1061
0
  default:
1062
0
    // FIXME: Proper error handling.
1063
0
    report_fatal_error("Invalid ELFCLASS!");
1064
1.02k
  }
1065
1.02k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getFileFormatName() const
Line
Count
Source
1003
277
StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
1004
277
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1005
277
  switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1006
277
  case ELF::ELFCLASS32:
1007
277
    switch (EF.getHeader()->e_machine) {
1008
277
    case ELF::EM_386:
1009
0
      return "ELF32-i386";
1010
277
    case ELF::EM_IAMCU:
1011
0
      return "ELF32-iamcu";
1012
277
    case ELF::EM_X86_64:
1013
1
      return "ELF32-x86-64";
1014
277
    case ELF::EM_ARM:
1015
11
      return (IsLittleEndian ? 
"ELF32-arm-little"0
: "ELF32-arm-big");
1016
277
    case ELF::EM_AVR:
1017
0
      return "ELF32-avr";
1018
277
    case ELF::EM_HEXAGON:
1019
0
      return "ELF32-hexagon";
1020
277
    case ELF::EM_LANAI:
1021
3
      return "ELF32-lanai";
1022
277
    case ELF::EM_MIPS:
1023
244
      return "ELF32-mips";
1024
277
    case ELF::EM_PPC:
1025
11
      return "ELF32-ppc";
1026
277
    case ELF::EM_RISCV:
1027
0
      return "ELF32-riscv";
1028
277
    case ELF::EM_SPARC:
1029
7
    case ELF::EM_SPARC32PLUS:
1030
7
      return "ELF32-sparc";
1031
7
    case ELF::EM_AMDGPU:
1032
0
      return "ELF32-amdgpu";
1033
7
    default:
1034
0
      return "ELF32-unknown";
1035
0
    }
1036
0
  case ELF::ELFCLASS64:
1037
0
    switch (EF.getHeader()->e_machine) {
1038
0
    case ELF::EM_386:
1039
0
      return "ELF64-i386";
1040
0
    case ELF::EM_X86_64:
1041
0
      return "ELF64-x86-64";
1042
0
    case ELF::EM_AARCH64:
1043
0
      return (IsLittleEndian ? "ELF64-aarch64-little" : "ELF64-aarch64-big");
1044
0
    case ELF::EM_PPC64:
1045
0
      return "ELF64-ppc64";
1046
0
    case ELF::EM_RISCV:
1047
0
      return "ELF64-riscv";
1048
0
    case ELF::EM_S390:
1049
0
      return "ELF64-s390";
1050
0
    case ELF::EM_SPARCV9:
1051
0
      return "ELF64-sparc";
1052
0
    case ELF::EM_MIPS:
1053
0
      return "ELF64-mips";
1054
0
    case ELF::EM_AMDGPU:
1055
0
      return "ELF64-amdgpu";
1056
0
    case ELF::EM_BPF:
1057
0
      return "ELF64-BPF";
1058
0
    default:
1059
0
      return "ELF64-unknown";
1060
0
    }
1061
0
  default:
1062
0
    // FIXME: Proper error handling.
1063
0
    report_fatal_error("Invalid ELFCLASS!");
1064
277
  }
1065
277
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getFileFormatName() const
Line
Count
Source
1003
2.87k
StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
1004
2.87k
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1005
2.87k
  switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1006
2.87k
  case ELF::ELFCLASS32:
1007
0
    switch (EF.getHeader()->e_machine) {
1008
0
    case ELF::EM_386:
1009
0
      return "ELF32-i386";
1010
0
    case ELF::EM_IAMCU:
1011
0
      return "ELF32-iamcu";
1012
0
    case ELF::EM_X86_64:
1013
0
      return "ELF32-x86-64";
1014
0
    case ELF::EM_ARM:
1015
0
      return (IsLittleEndian ? "ELF32-arm-little" : "ELF32-arm-big");
1016
0
    case ELF::EM_AVR:
1017
0
      return "ELF32-avr";
1018
0
    case ELF::EM_HEXAGON:
1019
0
      return "ELF32-hexagon";
1020
0
    case ELF::EM_LANAI:
1021
0
      return "ELF32-lanai";
1022
0
    case ELF::EM_MIPS:
1023
0
      return "ELF32-mips";
1024
0
    case ELF::EM_PPC:
1025
0
      return "ELF32-ppc";
1026
0
    case ELF::EM_RISCV:
1027
0
      return "ELF32-riscv";
1028
0
    case ELF::EM_SPARC:
1029
0
    case ELF::EM_SPARC32PLUS:
1030
0
      return "ELF32-sparc";
1031
0
    case ELF::EM_AMDGPU:
1032
0
      return "ELF32-amdgpu";
1033
0
    default:
1034
0
      return "ELF32-unknown";
1035
0
    }
1036
2.87k
  case ELF::ELFCLASS64:
1037
2.87k
    switch (EF.getHeader()->e_machine) {
1038
2.87k
    case ELF::EM_386:
1039
0
      return "ELF64-i386";
1040
2.87k
    case ELF::EM_X86_64:
1041
1.78k
      return "ELF64-x86-64";
1042
2.87k
    case ELF::EM_AARCH64:
1043
800
      return (IsLittleEndian ? "ELF64-aarch64-little" : 
"ELF64-aarch64-big"0
);
1044
2.87k
    case ELF::EM_PPC64:
1045
76
      return "ELF64-ppc64";
1046
2.87k
    case ELF::EM_RISCV:
1047
0
      return "ELF64-riscv";
1048
2.87k
    case ELF::EM_S390:
1049
0
      return "ELF64-s390";
1050
2.87k
    case ELF::EM_SPARCV9:
1051
0
      return "ELF64-sparc";
1052
2.87k
    case ELF::EM_MIPS:
1053
66
      return "ELF64-mips";
1054
2.87k
    case ELF::EM_AMDGPU:
1055
121
      return "ELF64-amdgpu";
1056
2.87k
    case ELF::EM_BPF:
1057
15
      return "ELF64-BPF";
1058
2.87k
    default:
1059
3
      return "ELF64-unknown";
1060
0
    }
1061
0
  default:
1062
0
    // FIXME: Proper error handling.
1063
0
    report_fatal_error("Invalid ELFCLASS!");
1064
2.87k
  }
1065
2.87k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getFileFormatName() const
Line
Count
Source
1003
205
StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
1004
205
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1005
205
  switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1006
205
  case ELF::ELFCLASS32:
1007
0
    switch (EF.getHeader()->e_machine) {
1008
0
    case ELF::EM_386:
1009
0
      return "ELF32-i386";
1010
0
    case ELF::EM_IAMCU:
1011
0
      return "ELF32-iamcu";
1012
0
    case ELF::EM_X86_64:
1013
0
      return "ELF32-x86-64";
1014
0
    case ELF::EM_ARM:
1015
0
      return (IsLittleEndian ? "ELF32-arm-little" : "ELF32-arm-big");
1016
0
    case ELF::EM_AVR:
1017
0
      return "ELF32-avr";
1018
0
    case ELF::EM_HEXAGON:
1019
0
      return "ELF32-hexagon";
1020
0
    case ELF::EM_LANAI:
1021
0
      return "ELF32-lanai";
1022
0
    case ELF::EM_MIPS:
1023
0
      return "ELF32-mips";
1024
0
    case ELF::EM_PPC:
1025
0
      return "ELF32-ppc";
1026
0
    case ELF::EM_RISCV:
1027
0
      return "ELF32-riscv";
1028
0
    case ELF::EM_SPARC:
1029
0
    case ELF::EM_SPARC32PLUS:
1030
0
      return "ELF32-sparc";
1031
0
    case ELF::EM_AMDGPU:
1032
0
      return "ELF32-amdgpu";
1033
0
    default:
1034
0
      return "ELF32-unknown";
1035
0
    }
1036
205
  case ELF::ELFCLASS64:
1037
205
    switch (EF.getHeader()->e_machine) {
1038
205
    case ELF::EM_386:
1039
0
      return "ELF64-i386";
1040
205
    case ELF::EM_X86_64:
1041
2
      return "ELF64-x86-64";
1042
205
    case ELF::EM_AARCH64:
1043
8
      return (IsLittleEndian ? 
"ELF64-aarch64-little"0
: "ELF64-aarch64-big");
1044
205
    case ELF::EM_PPC64:
1045
81
      return "ELF64-ppc64";
1046
205
    case ELF::EM_RISCV:
1047
0
      return "ELF64-riscv";
1048
205
    case ELF::EM_S390:
1049
10
      return "ELF64-s390";
1050
205
    case ELF::EM_SPARCV9:
1051
14
      return "ELF64-sparc";
1052
205
    case ELF::EM_MIPS:
1053
88
      return "ELF64-mips";
1054
205
    case ELF::EM_AMDGPU:
1055
0
      return "ELF64-amdgpu";
1056
205
    case ELF::EM_BPF:
1057
2
      return "ELF64-BPF";
1058
205
    default:
1059
0
      return "ELF64-unknown";
1060
0
    }
1061
0
  default:
1062
0
    // FIXME: Proper error handling.
1063
0
    report_fatal_error("Invalid ELFCLASS!");
1064
205
  }
1065
205
}
1066
1067
31.3M
template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::getArch() const {
1068
31.3M
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1069
31.3M
  switch (EF.getHeader()->e_machine) {
1070
31.3M
  case ELF::EM_386:
1071
126k
  case ELF::EM_IAMCU:
1072
126k
    return Triple::x86;
1073
126k
  case ELF::EM_X86_64:
1074
29.4k
    return Triple::x86_64;
1075
134k
  case ELF::EM_AARCH64:
1076
134k
    return IsLittleEndian ? 
Triple::aarch64134k
:
Triple::aarch64_be48
;
1077
126k
  case ELF::EM_ARM:
1078
52.0k
    return Triple::arm;
1079
126k
  case ELF::EM_AVR:
1080
0
    return Triple::avr;
1081
126k
  case ELF::EM_HEXAGON:
1082
22.6k
    return Triple::hexagon;
1083
126k
  case ELF::EM_LANAI:
1084
10
    return Triple::lanai;
1085
591k
  case ELF::EM_MIPS:
1086
591k
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1087
591k
    case ELF::ELFCLASS32:
1088
589k
      return IsLittleEndian ? 
Triple::mipsel347k
:
Triple::mips241k
;
1089
591k
    case ELF::ELFCLASS64:
1090
2.46k
      return IsLittleEndian ? 
Triple::mips64el1.10k
:
Triple::mips641.35k
;
1091
591k
    default:
1092
0
      report_fatal_error("Invalid ELFCLASS!");
1093
0
    }
1094
167
  case ELF::EM_PPC:
1095
167
    return Triple::ppc;
1096
30.3M
  case ELF::EM_PPC64:
1097
30.3M
    return IsLittleEndian ? 
Triple::ppc64le15.1M
:
Triple::ppc6415.1M
;
1098
0
  case ELF::EM_RISCV:
1099
0
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1100
0
    case ELF::ELFCLASS32:
1101
0
      return Triple::riscv32;
1102
0
    case ELF::ELFCLASS64:
1103
0
      return Triple::riscv64;
1104
0
    default:
1105
0
      report_fatal_error("Invalid ELFCLASS!");
1106
0
    }
1107
266
  case ELF::EM_S390:
1108
266
    return Triple::systemz;
1109
0
1110
194
  case ELF::EM_SPARC:
1111
194
  case ELF::EM_SPARC32PLUS:
1112
194
    return IsLittleEndian ? 
Triple::sparcel26
:
Triple::sparc168
;
1113
201
  case ELF::EM_SPARCV9:
1114
201
    return Triple::sparcv9;
1115
194
1116
2.87k
  case ELF::EM_AMDGPU: {
1117
2.87k
    if (!IsLittleEndian)
1118
0
      return Triple::UnknownArch;
1119
2.87k
1120
2.87k
    unsigned MACH = EF.getHeader()->e_flags & ELF::EF_AMDGPU_MACH;
1121
2.87k
    if (MACH >= ELF::EF_AMDGPU_MACH_R600_FIRST &&
1122
2.87k
        
MACH <= ELF::EF_AMDGPU_MACH_R600_LAST2.82k
)
1123
105
      return Triple::r600;
1124
2.76k
    if (MACH >= ELF::EF_AMDGPU_MACH_AMDGCN_FIRST &&
1125
2.76k
        
MACH <= ELF::EF_AMDGPU_MACH_AMDGCN_LAST2.72k
)
1126
2.72k
      return Triple::amdgcn;
1127
47
1128
47
    return Triple::UnknownArch;
1129
47
  }
1130
47
1131
2.91k
  case ELF::EM_BPF:
1132
2.91k
    return IsLittleEndian ? 
Triple::bpfel2.51k
:
Triple::bpfeb396
;
1133
47
1134
47
  default:
1135
2
    return Triple::UnknownArch;
1136
31.3M
  }
1137
31.3M
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getArch() const
Line
Count
Source
1067
548k
template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::getArch() const {
1068
548k
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1069
548k
  switch (EF.getHeader()->e_machine) {
1070
548k
  case ELF::EM_386:
1071
126k
  case ELF::EM_IAMCU:
1072
126k
    return Triple::x86;
1073
126k
  case ELF::EM_X86_64:
1074
25
    return Triple::x86_64;
1075
126k
  case ELF::EM_AARCH64:
1076
0
    return IsLittleEndian ? Triple::aarch64 : Triple::aarch64_be;
1077
126k
  case ELF::EM_ARM:
1078
52.0k
    return Triple::arm;
1079
126k
  case ELF::EM_AVR:
1080
0
    return Triple::avr;
1081
126k
  case ELF::EM_HEXAGON:
1082
22.6k
    return Triple::hexagon;
1083
126k
  case ELF::EM_LANAI:
1084
3
    return Triple::lanai;
1085
347k
  case ELF::EM_MIPS:
1086
347k
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1087
347k
    case ELF::ELFCLASS32:
1088
347k
      return IsLittleEndian ? Triple::mipsel : 
Triple::mips0
;
1089
347k
    case ELF::ELFCLASS64:
1090
0
      return IsLittleEndian ? Triple::mips64el : Triple::mips64;
1091
347k
    default:
1092
0
      report_fatal_error("Invalid ELFCLASS!");
1093
0
    }
1094
0
  case ELF::EM_PPC:
1095
0
    return Triple::ppc;
1096
0
  case ELF::EM_PPC64:
1097
0
    return IsLittleEndian ? Triple::ppc64le : Triple::ppc64;
1098
0
  case ELF::EM_RISCV:
1099
0
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1100
0
    case ELF::ELFCLASS32:
1101
0
      return Triple::riscv32;
1102
0
    case ELF::ELFCLASS64:
1103
0
      return Triple::riscv64;
1104
0
    default:
1105
0
      report_fatal_error("Invalid ELFCLASS!");
1106
0
    }
1107
0
  case ELF::EM_S390:
1108
0
    return Triple::systemz;
1109
0
1110
26
  case ELF::EM_SPARC:
1111
26
  case ELF::EM_SPARC32PLUS:
1112
26
    return IsLittleEndian ? Triple::sparcel : 
Triple::sparc0
;
1113
26
  case ELF::EM_SPARCV9:
1114
0
    return Triple::sparcv9;
1115
26
1116
108
  case ELF::EM_AMDGPU: {
1117
108
    if (!IsLittleEndian)
1118
0
      return Triple::UnknownArch;
1119
108
1120
108
    unsigned MACH = EF.getHeader()->e_flags & ELF::EF_AMDGPU_MACH;
1121
108
    if (MACH >= ELF::EF_AMDGPU_MACH_R600_FIRST &&
1122
108
        
MACH <= ELF::EF_AMDGPU_MACH_R600_LAST105
)
1123
105
      return Triple::r600;
1124
3
    if (MACH >= ELF::EF_AMDGPU_MACH_AMDGCN_FIRST &&
1125
3
        
MACH <= ELF::EF_AMDGPU_MACH_AMDGCN_LAST0
)
1126
0
      return Triple::amdgcn;
1127
3
1128
3
    return Triple::UnknownArch;
1129
3
  }
1130
3
1131
3
  case ELF::EM_BPF:
1132
0
    return IsLittleEndian ? Triple::bpfel : Triple::bpfeb;
1133
3
1134
3
  default:
1135
2
    return Triple::UnknownArch;
1136
548k
  }
1137
548k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getArch() const
Line
Count
Source
1067
242k
template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::getArch() const {
1068
242k
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1069
242k
  switch (EF.getHeader()->e_machine) {
1070
242k
  case ELF::EM_386:
1071
0
  case ELF::EM_IAMCU:
1072
0
    return Triple::x86;
1073
3
  case ELF::EM_X86_64:
1074
3
    return Triple::x86_64;
1075
0
  case ELF::EM_AARCH64:
1076
0
    return IsLittleEndian ? Triple::aarch64 : Triple::aarch64_be;
1077
25
  case ELF::EM_ARM:
1078
25
    return Triple::arm;
1079
0
  case ELF::EM_AVR:
1080
0
    return Triple::avr;
1081
0
  case ELF::EM_HEXAGON:
1082
0
    return Triple::hexagon;
1083
7
  case ELF::EM_LANAI:
1084
7
    return Triple::lanai;
1085
241k
  case ELF::EM_MIPS:
1086
241k
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1087
241k
    case ELF::ELFCLASS32:
1088
241k
      return IsLittleEndian ? 
Triple::mipsel0
: Triple::mips;
1089
241k
    case ELF::ELFCLASS64:
1090
0
      return IsLittleEndian ? Triple::mips64el : Triple::mips64;
1091
241k
    default:
1092
0
      report_fatal_error("Invalid ELFCLASS!");
1093
0
    }
1094
167
  case ELF::EM_PPC:
1095
167
    return Triple::ppc;
1096
0
  case ELF::EM_PPC64:
1097
0
    return IsLittleEndian ? Triple::ppc64le : Triple::ppc64;
1098
0
  case ELF::EM_RISCV:
1099
0
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1100
0
    case ELF::ELFCLASS32:
1101
0
      return Triple::riscv32;
1102
0
    case ELF::ELFCLASS64:
1103
0
      return Triple::riscv64;
1104
0
    default:
1105
0
      report_fatal_error("Invalid ELFCLASS!");
1106
0
    }
1107
0
  case ELF::EM_S390:
1108
0
    return Triple::systemz;
1109
0
1110
168
  case ELF::EM_SPARC:
1111
168
  case ELF::EM_SPARC32PLUS:
1112
168
    return IsLittleEndian ? 
Triple::sparcel0
: Triple::sparc;
1113
168
  case ELF::EM_SPARCV9:
1114
0
    return Triple::sparcv9;
1115
168
1116
168
  case ELF::EM_AMDGPU: {
1117
0
    if (!IsLittleEndian)
1118
0
      return Triple::UnknownArch;
1119
0
1120
0
    unsigned MACH = EF.getHeader()->e_flags & ELF::EF_AMDGPU_MACH;
1121
0
    if (MACH >= ELF::EF_AMDGPU_MACH_R600_FIRST &&
1122
0
        MACH <= ELF::EF_AMDGPU_MACH_R600_LAST)
1123
0
      return Triple::r600;
1124
0
    if (MACH >= ELF::EF_AMDGPU_MACH_AMDGCN_FIRST &&
1125
0
        MACH <= ELF::EF_AMDGPU_MACH_AMDGCN_LAST)
1126
0
      return Triple::amdgcn;
1127
0
1128
0
    return Triple::UnknownArch;
1129
0
  }
1130
0
1131
0
  case ELF::EM_BPF:
1132
0
    return IsLittleEndian ? Triple::bpfel : Triple::bpfeb;
1133
0
1134
0
  default:
1135
0
    return Triple::UnknownArch;
1136
242k
  }
1137
242k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getArch() const
Line
Count
Source
1067
15.3M
template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::getArch() const {
1068
15.3M
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1069
15.3M
  switch (EF.getHeader()->e_machine) {
1070
15.3M
  case ELF::EM_386:
1071
0
  case ELF::EM_IAMCU:
1072
0
    return Triple::x86;
1073
29.4k
  case ELF::EM_X86_64:
1074
29.4k
    return Triple::x86_64;
1075
134k
  case ELF::EM_AARCH64:
1076
134k
    return IsLittleEndian ? Triple::aarch64 : 
Triple::aarch64_be0
;
1077
3
  case ELF::EM_ARM:
1078
3
    return Triple::arm;
1079
0
  case ELF::EM_AVR:
1080
0
    return Triple::avr;
1081
6
  case ELF::EM_HEXAGON:
1082
6
    return Triple::hexagon;
1083
0
  case ELF::EM_LANAI:
1084
0
    return Triple::lanai;
1085
1.10k
  case ELF::EM_MIPS:
1086
1.10k
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1087
1.10k
    case ELF::ELFCLASS32:
1088
0
      return IsLittleEndian ? Triple::mipsel : Triple::mips;
1089
1.10k
    case ELF::ELFCLASS64:
1090
1.10k
      return IsLittleEndian ? Triple::mips64el : 
Triple::mips640
;
1091
1.10k
    default:
1092
0
      report_fatal_error("Invalid ELFCLASS!");
1093
0
    }
1094
0
  case ELF::EM_PPC:
1095
0
    return Triple::ppc;
1096
15.1M
  case ELF::EM_PPC64:
1097
15.1M
    return IsLittleEndian ? Triple::ppc64le : 
Triple::ppc640
;
1098
0
  case ELF::EM_RISCV:
1099
0
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1100
0
    case ELF::ELFCLASS32:
1101
0
      return Triple::riscv32;
1102
0
    case ELF::ELFCLASS64:
1103
0
      return Triple::riscv64;
1104
0
    default:
1105
0
      report_fatal_error("Invalid ELFCLASS!");
1106
0
    }
1107
0
  case ELF::EM_S390:
1108
0
    return Triple::systemz;
1109
0
1110
0
  case ELF::EM_SPARC:
1111
0
  case ELF::EM_SPARC32PLUS:
1112
0
    return IsLittleEndian ? Triple::sparcel : Triple::sparc;
1113
0
  case ELF::EM_SPARCV9:
1114
0
    return Triple::sparcv9;
1115
0
1116
2.76k
  case ELF::EM_AMDGPU: {
1117
2.76k
    if (!IsLittleEndian)
1118
0
      return Triple::UnknownArch;
1119
2.76k
1120
2.76k
    unsigned MACH = EF.getHeader()->e_flags & ELF::EF_AMDGPU_MACH;
1121
2.76k
    if (MACH >= ELF::EF_AMDGPU_MACH_R600_FIRST &&
1122
2.76k
        
MACH <= ELF::EF_AMDGPU_MACH_R600_LAST2.72k
)
1123
0
      return Triple::r600;
1124
2.76k
    if (MACH >= ELF::EF_AMDGPU_MACH_AMDGCN_FIRST &&
1125
2.76k
        
MACH <= ELF::EF_AMDGPU_MACH_AMDGCN_LAST2.72k
)
1126
2.72k
      return Triple::amdgcn;
1127
44
1128
44
    return Triple::UnknownArch;
1129
44
  }
1130
44
1131
2.51k
  case ELF::EM_BPF:
1132
2.51k
    return IsLittleEndian ? Triple::bpfel : 
Triple::bpfeb0
;
1133
44
1134
44
  default:
1135
0
    return Triple::UnknownArch;
1136
15.3M
  }
1137
15.3M
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getArch() const
Line
Count
Source
1067
15.1M
template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::getArch() const {
1068
15.1M
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1069
15.1M
  switch (EF.getHeader()->e_machine) {
1070
15.1M
  case ELF::EM_386:
1071
0
  case ELF::EM_IAMCU:
1072
0
    return Triple::x86;
1073
6
  case ELF::EM_X86_64:
1074
6
    return Triple::x86_64;
1075
48
  case ELF::EM_AARCH64:
1076
48
    return IsLittleEndian ? 
Triple::aarch640
: Triple::aarch64_be;
1077
0
  case ELF::EM_ARM:
1078
0
    return Triple::arm;
1079
0
  case ELF::EM_AVR:
1080
0
    return Triple::avr;
1081
0
  case ELF::EM_HEXAGON:
1082
0
    return Triple::hexagon;
1083
0
  case ELF::EM_LANAI:
1084
0
    return Triple::lanai;
1085
1.35k
  case ELF::EM_MIPS:
1086
1.35k
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1087
1.35k
    case ELF::ELFCLASS32:
1088
0
      return IsLittleEndian ? Triple::mipsel : Triple::mips;
1089
1.35k
    case ELF::ELFCLASS64:
1090
1.35k
      return IsLittleEndian ? 
Triple::mips64el0
: Triple::mips64;
1091
1.35k
    default:
1092
0
      report_fatal_error("Invalid ELFCLASS!");
1093
0
    }
1094
0
  case ELF::EM_PPC:
1095
0
    return Triple::ppc;
1096
15.1M
  case ELF::EM_PPC64:
1097
15.1M
    return IsLittleEndian ? 
Triple::ppc64le0
: Triple::ppc64;
1098
0
  case ELF::EM_RISCV:
1099
0
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1100
0
    case ELF::ELFCLASS32:
1101
0
      return Triple::riscv32;
1102
0
    case ELF::ELFCLASS64:
1103
0
      return Triple::riscv64;
1104
0
    default:
1105
0
      report_fatal_error("Invalid ELFCLASS!");
1106
0
    }
1107
266
  case ELF::EM_S390:
1108
266
    return Triple::systemz;
1109
0
1110
0
  case ELF::EM_SPARC:
1111
0
  case ELF::EM_SPARC32PLUS:
1112
0
    return IsLittleEndian ? Triple::sparcel : Triple::sparc;
1113
201
  case ELF::EM_SPARCV9:
1114
201
    return Triple::sparcv9;
1115
0
1116
0
  case ELF::EM_AMDGPU: {
1117
0
    if (!IsLittleEndian)
1118
0
      return Triple::UnknownArch;
1119
0
1120
0
    unsigned MACH = EF.getHeader()->e_flags & ELF::EF_AMDGPU_MACH;
1121
0
    if (MACH >= ELF::EF_AMDGPU_MACH_R600_FIRST &&
1122
0
        MACH <= ELF::EF_AMDGPU_MACH_R600_LAST)
1123
0
      return Triple::r600;
1124
0
    if (MACH >= ELF::EF_AMDGPU_MACH_AMDGCN_FIRST &&
1125
0
        MACH <= ELF::EF_AMDGPU_MACH_AMDGCN_LAST)
1126
0
      return Triple::amdgcn;
1127
0
1128
0
    return Triple::UnknownArch;
1129
0
  }
1130
0
1131
396
  case ELF::EM_BPF:
1132
396
    return IsLittleEndian ? 
Triple::bpfel0
: Triple::bpfeb;
1133
0
1134
0
  default:
1135
0
    return Triple::UnknownArch;
1136
15.1M
  }
1137
15.1M
}
1138
1139
template <class ELFT>
1140
2
Expected<uint64_t> ELFObjectFile<ELFT>::getStartAddress() const {
1141
2
  return EF.getHeader()->e_entry;
1142
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
1140
2
Expected<uint64_t> ELFObjectFile<ELFT>::getStartAddress() const {
1141
2
  return EF.getHeader()->e_entry;
1142
2
}
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getStartAddress() const
1143
1144
template <class ELFT>
1145
ELFObjectFileBase::elf_symbol_iterator_range
1146
126
ELFObjectFile<ELFT>::getDynamicSymbolIterators() const {
1147
126
  return make_range(dynamic_symbol_begin(), dynamic_symbol_end());
1148
126
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getDynamicSymbolIterators() const
Line
Count
Source
1146
99
ELFObjectFile<ELFT>::getDynamicSymbolIterators() const {
1147
99
  return make_range(dynamic_symbol_begin(), dynamic_symbol_end());
1148
99
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getDynamicSymbolIterators() const
Line
Count
Source
1146
4
ELFObjectFile<ELFT>::getDynamicSymbolIterators() const {
1147
4
  return make_range(dynamic_symbol_begin(), dynamic_symbol_end());
1148
4
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getDynamicSymbolIterators() const
Line
Count
Source
1146
22
ELFObjectFile<ELFT>::getDynamicSymbolIterators() const {
1147
22
  return make_range(dynamic_symbol_begin(), dynamic_symbol_end());
1148
22
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getDynamicSymbolIterators() const
Line
Count
Source
1146
1
ELFObjectFile<ELFT>::getDynamicSymbolIterators() const {
1147
1
  return make_range(dynamic_symbol_begin(), dynamic_symbol_end());
1148
1
}
1149
1150
1.54k
template <class ELFT> bool ELFObjectFile<ELFT>::isRelocatableObject() const {
1151
1.54k
  return EF.getHeader()->e_type == ELF::ET_REL;
1152
1.54k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isRelocatableObject() const
Line
Count
Source
1150
747
template <class ELFT> bool ELFObjectFile<ELFT>::isRelocatableObject() const {
1151
747
  return EF.getHeader()->e_type == ELF::ET_REL;
1152
747
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isRelocatableObject() const
Line
Count
Source
1150
151
template <class ELFT> bool ELFObjectFile<ELFT>::isRelocatableObject() const {
1151
151
  return EF.getHeader()->e_type == ELF::ET_REL;
1152
151
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isRelocatableObject() const
Line
Count
Source
1150
638
template <class ELFT> bool ELFObjectFile<ELFT>::isRelocatableObject() const {
1151
638
  return EF.getHeader()->e_type == ELF::ET_REL;
1152
638
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isRelocatableObject() const
Line
Count
Source
1150
12
template <class ELFT> bool ELFObjectFile<ELFT>::isRelocatableObject() const {
1151
12
  return EF.getHeader()->e_type == ELF::ET_REL;
1152
12
}
1153
1154
} // end namespace object
1155
} // end namespace llvm
1156
1157
#endif // LLVM_OBJECT_ELFOBJECTFILE_H