Coverage Report

Created: 2018-09-17 19:50

/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.26k
                                  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
23.2k
  const Elf_Shdr *getRelSection(DataRefImpl Rel) const {
282
23.2k
    auto RelSecOrErr = EF.getSection(Rel.d.a);
283
23.2k
    if (!RelSecOrErr)
284
0
      report_fatal_error(errorToErrorCode(RelSecOrErr.takeError()).message());
285
23.2k
    return *RelSecOrErr;
286
23.2k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelSection(llvm::object::DataRefImpl) const
Line
Count
Source
281
2.54k
  const Elf_Shdr *getRelSection(DataRefImpl Rel) const {
282
2.54k
    auto RelSecOrErr = EF.getSection(Rel.d.a);
283
2.54k
    if (!RelSecOrErr)
284
0
      report_fatal_error(errorToErrorCode(RelSecOrErr.takeError()).message());
285
2.54k
    return *RelSecOrErr;
286
2.54k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelSection(llvm::object::DataRefImpl) const
Line
Count
Source
281
1.00k
  const Elf_Shdr *getRelSection(DataRefImpl Rel) const {
282
1.00k
    auto RelSecOrErr = EF.getSection(Rel.d.a);
283
1.00k
    if (!RelSecOrErr)
284
0
      report_fatal_error(errorToErrorCode(RelSecOrErr.takeError()).message());
285
1.00k
    return *RelSecOrErr;
286
1.00k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelSection(llvm::object::DataRefImpl) const
Line
Count
Source
281
18.7k
  const Elf_Shdr *getRelSection(DataRefImpl Rel) const {
282
18.7k
    auto RelSecOrErr = EF.getSection(Rel.d.a);
283
18.7k
    if (!RelSecOrErr)
284
0
      report_fatal_error(errorToErrorCode(RelSecOrErr.takeError()).message());
285
18.7k
    return *RelSecOrErr;
286
18.7k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelSection(llvm::object::DataRefImpl) const
Line
Count
Source
281
945
  const Elf_Shdr *getRelSection(DataRefImpl Rel) const {
282
945
    auto RelSecOrErr = EF.getSection(Rel.d.a);
283
945
    if (!RelSecOrErr)
284
0
      report_fatal_error(errorToErrorCode(RelSecOrErr.takeError()).message());
285
945
    return *RelSecOrErr;
286
945
  }
287
288
9.36k
  DataRefImpl toDRI(const Elf_Shdr *SymTable, unsigned SymbolNum) const {
289
9.36k
    DataRefImpl DRI;
290
9.36k
    if (!SymTable) {
291
246
      DRI.d.a = 0;
292
246
      DRI.d.b = 0;
293
246
      return DRI;
294
246
    }
295
9.12k
    assert(SymTable->sh_type == ELF::SHT_SYMTAB ||
296
9.12k
           SymTable->sh_type == ELF::SHT_DYNSYM);
297
9.12k
298
9.12k
    auto SectionsOrErr = EF.sections();
299
9.12k
    if (!SectionsOrErr) {
300
0
      DRI.d.a = 0;
301
0
      DRI.d.b = 0;
302
0
      return DRI;
303
0
    }
304
9.12k
    uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
305
9.12k
    unsigned SymTableIndex =
306
9.12k
        (reinterpret_cast<uintptr_t>(SymTable) - SHT) / sizeof(Elf_Shdr);
307
9.12k
308
9.12k
    DRI.d.a = SymTableIndex;
309
9.12k
    DRI.d.b = SymbolNum;
310
9.12k
    return DRI;
311
9.12k
  }
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.52k
  DataRefImpl toDRI(const Elf_Shdr *SymTable, unsigned SymbolNum) const {
289
1.52k
    DataRefImpl DRI;
290
1.52k
    if (!SymTable) {
291
196
      DRI.d.a = 0;
292
196
      DRI.d.b = 0;
293
196
      return DRI;
294
196
    }
295
1.33k
    assert(SymTable->sh_type == ELF::SHT_SYMTAB ||
296
1.33k
           SymTable->sh_type == ELF::SHT_DYNSYM);
297
1.33k
298
1.33k
    auto SectionsOrErr = EF.sections();
299
1.33k
    if (!SectionsOrErr) {
300
0
      DRI.d.a = 0;
301
0
      DRI.d.b = 0;
302
0
      return DRI;
303
0
    }
304
1.33k
    uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
305
1.33k
    unsigned SymTableIndex =
306
1.33k
        (reinterpret_cast<uintptr_t>(SymTable) - SHT) / sizeof(Elf_Shdr);
307
1.33k
308
1.33k
    DRI.d.a = SymTableIndex;
309
1.33k
    DRI.d.b = SymbolNum;
310
1.33k
    return DRI;
311
1.33k
  }
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
414
  DataRefImpl toDRI(const Elf_Shdr *SymTable, unsigned SymbolNum) const {
289
414
    DataRefImpl DRI;
290
414
    if (!SymTable) {
291
8
      DRI.d.a = 0;
292
8
      DRI.d.b = 0;
293
8
      return DRI;
294
8
    }
295
406
    assert(SymTable->sh_type == ELF::SHT_SYMTAB ||
296
406
           SymTable->sh_type == ELF::SHT_DYNSYM);
297
406
298
406
    auto SectionsOrErr = EF.sections();
299
406
    if (!SectionsOrErr) {
300
0
      DRI.d.a = 0;
301
0
      DRI.d.b = 0;
302
0
      return DRI;
303
0
    }
304
406
    uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
305
406
    unsigned SymTableIndex =
306
406
        (reinterpret_cast<uintptr_t>(SymTable) - SHT) / sizeof(Elf_Shdr);
307
406
308
406
    DRI.d.a = SymTableIndex;
309
406
    DRI.d.b = SymbolNum;
310
406
    return DRI;
311
406
  }
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.08k
  DataRefImpl toDRI(const Elf_Shdr *SymTable, unsigned SymbolNum) const {
289
7.08k
    DataRefImpl DRI;
290
7.08k
    if (!SymTable) {
291
40
      DRI.d.a = 0;
292
40
      DRI.d.b = 0;
293
40
      return DRI;
294
40
    }
295
7.04k
    assert(SymTable->sh_type == ELF::SHT_SYMTAB ||
296
7.04k
           SymTable->sh_type == ELF::SHT_DYNSYM);
297
7.04k
298
7.04k
    auto SectionsOrErr = EF.sections();
299
7.04k
    if (!SectionsOrErr) {
300
0
      DRI.d.a = 0;
301
0
      DRI.d.b = 0;
302
0
      return DRI;
303
0
    }
304
7.04k
    uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
305
7.04k
    unsigned SymTableIndex =
306
7.04k
        (reinterpret_cast<uintptr_t>(SymTable) - SHT) / sizeof(Elf_Shdr);
307
7.04k
308
7.04k
    DRI.d.a = SymTableIndex;
309
7.04k
    DRI.d.b = SymbolNum;
310
7.04k
    return DRI;
311
7.04k
  }
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
338
  DataRefImpl toDRI(const Elf_Shdr *SymTable, unsigned SymbolNum) const {
289
338
    DataRefImpl DRI;
290
338
    if (!SymTable) {
291
2
      DRI.d.a = 0;
292
2
      DRI.d.b = 0;
293
2
      return DRI;
294
2
    }
295
336
    assert(SymTable->sh_type == ELF::SHT_SYMTAB ||
296
336
           SymTable->sh_type == ELF::SHT_DYNSYM);
297
336
298
336
    auto SectionsOrErr = EF.sections();
299
336
    if (!SectionsOrErr) {
300
0
      DRI.d.a = 0;
301
0
      DRI.d.b = 0;
302
0
      return DRI;
303
0
    }
304
336
    uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
305
336
    unsigned SymTableIndex =
306
336
        (reinterpret_cast<uintptr_t>(SymTable) - SHT) / sizeof(Elf_Shdr);
307
336
308
336
    DRI.d.a = SymTableIndex;
309
336
    DRI.d.b = SymbolNum;
310
336
    return DRI;
311
336
  }
312
313
  const Elf_Shdr *toELFShdrIter(DataRefImpl Sec) const {
314
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
315
  }
316
317
201k
  DataRefImpl toDRI(const Elf_Shdr *Sec) const {
318
201k
    DataRefImpl DRI;
319
201k
    DRI.p = reinterpret_cast<uintptr_t>(Sec);
320
201k
    return DRI;
321
201k
  }
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.4k
  DataRefImpl toDRI(const Elf_Shdr *Sec) const {
318
35.4k
    DataRefImpl DRI;
319
35.4k
    DRI.p = reinterpret_cast<uintptr_t>(Sec);
320
35.4k
    return DRI;
321
35.4k
  }
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.68k
  DataRefImpl toDRI(const Elf_Shdr *Sec) const {
318
8.68k
    DataRefImpl DRI;
319
8.68k
    DRI.p = reinterpret_cast<uintptr_t>(Sec);
320
8.68k
    return DRI;
321
8.68k
  }
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
150k
  DataRefImpl toDRI(const Elf_Shdr *Sec) const {
318
150k
    DataRefImpl DRI;
319
150k
    DRI.p = reinterpret_cast<uintptr_t>(Sec);
320
150k
    return DRI;
321
150k
  }
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.13k
  DataRefImpl toDRI(const Elf_Shdr *Sec) const {
318
6.13k
    DataRefImpl DRI;
319
6.13k
    DRI.p = reinterpret_cast<uintptr_t>(Sec);
320
6.13k
    return DRI;
321
6.13k
  }
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
40.9k
  bool isExportedToOtherDSO(const Elf_Sym *ESym) const {
330
40.9k
    unsigned char Binding = ESym->getBinding();
331
40.9k
    unsigned char Visibility = ESym->getVisibility();
332
40.9k
333
40.9k
    // A symbol is exported if its binding is either GLOBAL or WEAK, and its
334
40.9k
    // visibility is either DEFAULT or PROTECTED. All other symbols are not
335
40.9k
    // exported.
336
40.9k
    return ((Binding == ELF::STB_GLOBAL || 
Binding == ELF::STB_WEAK24.0k
) &&
337
40.9k
            
(20.9k
Visibility == ELF::STV_DEFAULT20.9k
||
338
20.9k
             
Visibility == ELF::STV_PROTECTED8.66k
));
339
40.9k
  }
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
8.93k
  bool isExportedToOtherDSO(const Elf_Sym *ESym) const {
330
8.93k
    unsigned char Binding = ESym->getBinding();
331
8.93k
    unsigned char Visibility = ESym->getVisibility();
332
8.93k
333
8.93k
    // A symbol is exported if its binding is either GLOBAL or WEAK, and its
334
8.93k
    // visibility is either DEFAULT or PROTECTED. All other symbols are not
335
8.93k
    // exported.
336
8.93k
    return ((Binding == ELF::STB_GLOBAL || 
Binding == ELF::STB_WEAK5.59k
) &&
337
8.93k
            
(3.36k
Visibility == ELF::STV_DEFAULT3.36k
||
338
3.36k
             
Visibility == ELF::STV_PROTECTED11
));
339
8.93k
  }
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.16k
  bool isExportedToOtherDSO(const Elf_Sym *ESym) const {
330
1.16k
    unsigned char Binding = ESym->getBinding();
331
1.16k
    unsigned char Visibility = ESym->getVisibility();
332
1.16k
333
1.16k
    // A symbol is exported if its binding is either GLOBAL or WEAK, and its
334
1.16k
    // visibility is either DEFAULT or PROTECTED. All other symbols are not
335
1.16k
    // exported.
336
1.16k
    return ((Binding == ELF::STB_GLOBAL || 
Binding == ELF::STB_WEAK790
) &&
337
1.16k
            
(382
Visibility == ELF::STV_DEFAULT382
||
338
382
             
Visibility == ELF::STV_PROTECTED0
));
339
1.16k
  }
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.0k
  bool isExportedToOtherDSO(const Elf_Sym *ESym) const {
330
30.0k
    unsigned char Binding = ESym->getBinding();
331
30.0k
    unsigned char Visibility = ESym->getVisibility();
332
30.0k
333
30.0k
    // A symbol is exported if its binding is either GLOBAL or WEAK, and its
334
30.0k
    // visibility is either DEFAULT or PROTECTED. All other symbols are not
335
30.0k
    // exported.
336
30.0k
    return ((Binding == ELF::STB_GLOBAL || 
Binding == ELF::STB_WEAK17.1k
) &&
337
30.0k
            
(16.9k
Visibility == ELF::STV_DEFAULT16.9k
||
338
16.9k
             
Visibility == ELF::STV_PROTECTED8.65k
));
339
30.0k
  }
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
798
  bool isExportedToOtherDSO(const Elf_Sym *ESym) const {
330
798
    unsigned char Binding = ESym->getBinding();
331
798
    unsigned char Visibility = ESym->getVisibility();
332
798
333
798
    // A symbol is exported if its binding is either GLOBAL or WEAK, and its
334
798
    // visibility is either DEFAULT or PROTECTED. All other symbols are not
335
798
    // exported.
336
798
    return ((Binding == ELF::STB_GLOBAL || 
Binding == ELF::STB_WEAK512
) &&
337
798
            
(289
Visibility == ELF::STV_DEFAULT289
||
338
289
             
Visibility == ELF::STV_PROTECTED0
));
339
798
  }
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
164k
  const Elf_Sym *getSymbol(DataRefImpl Sym) const {
354
164k
    auto Ret = EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
355
164k
    if (!Ret)
356
0
      report_fatal_error(errorToErrorCode(Ret.takeError()).message());
357
164k
    return *Ret;
358
164k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
353
54.1k
  const Elf_Sym *getSymbol(DataRefImpl Sym) const {
354
54.1k
    auto Ret = EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
355
54.1k
    if (!Ret)
356
0
      report_fatal_error(errorToErrorCode(Ret.takeError()).message());
357
54.1k
    return *Ret;
358
54.1k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
353
4.77k
  const Elf_Sym *getSymbol(DataRefImpl Sym) const {
354
4.77k
    auto Ret = EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
355
4.77k
    if (!Ret)
356
0
      report_fatal_error(errorToErrorCode(Ret.takeError()).message());
357
4.77k
    return *Ret;
358
4.77k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
353
102k
  const Elf_Sym *getSymbol(DataRefImpl Sym) const {
354
102k
    auto Ret = EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
355
102k
    if (!Ret)
356
0
      report_fatal_error(errorToErrorCode(Ret.takeError()).message());
357
102k
    return *Ret;
358
102k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
353
3.03k
  const Elf_Sym *getSymbol(DataRefImpl Sym) const {
354
3.03k
    auto Ret = EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
355
3.03k
    if (!Ret)
356
0
      report_fatal_error(errorToErrorCode(Ret.takeError()).message());
357
3.03k
    return *Ret;
358
3.03k
  }
359
360
518k
  const Elf_Shdr *getSection(DataRefImpl Sec) const {
361
518k
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
362
518k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSection(llvm::object::DataRefImpl) const
Line
Count
Source
360
39.3k
  const Elf_Shdr *getSection(DataRefImpl Sec) const {
361
39.3k
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
362
39.3k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSection(llvm::object::DataRefImpl) const
Line
Count
Source
360
11.8k
  const Elf_Shdr *getSection(DataRefImpl Sec) const {
361
11.8k
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
362
11.8k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSection(llvm::object::DataRefImpl) const
Line
Count
Source
360
457k
  const Elf_Shdr *getSection(DataRefImpl Sec) const {
361
457k
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
362
457k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSection(llvm::object::DataRefImpl) const
Line
Count
Source
360
9.25k
  const Elf_Shdr *getSection(DataRefImpl Sec) const {
361
9.25k
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
362
9.25k
  }
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
29.5k
void ELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Sym) const {
424
29.5k
  ++Sym.d.b;
425
29.5k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::moveSymbolNext(llvm::object::DataRefImpl&) const
Line
Count
Source
423
8.19k
void ELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Sym) const {
424
8.19k
  ++Sym.d.b;
425
8.19k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::moveSymbolNext(llvm::object::DataRefImpl&) const
Line
Count
Source
423
718
void ELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Sym) const {
424
718
  ++Sym.d.b;
425
718
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::moveSymbolNext(llvm::object::DataRefImpl&) const
Line
Count
Source
423
20.1k
void ELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Sym) const {
424
20.1k
  ++Sym.d.b;
425
20.1k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::moveSymbolNext(llvm::object::DataRefImpl&) const
Line
Count
Source
423
503
void ELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Sym) const {
424
503
  ++Sym.d.b;
425
503
}
426
427
template <class ELFT>
428
32.7k
Expected<StringRef> ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Sym) const {
429
32.7k
  const Elf_Sym *ESym = getSymbol(Sym);
430
32.7k
  auto SymTabOrErr = EF.getSection(Sym.d.a);
431
32.7k
  if (!SymTabOrErr)
432
0
    return SymTabOrErr.takeError();
433
32.7k
  const Elf_Shdr *SymTableSec = *SymTabOrErr;
434
32.7k
  auto StrTabOrErr = EF.getSection(SymTableSec->sh_link);
435
32.7k
  if (!StrTabOrErr)
436
0
    return StrTabOrErr.takeError();
437
32.7k
  const Elf_Shdr *StringTableSec = *StrTabOrErr;
438
32.7k
  auto SymStrTabOrErr = EF.getStringTable(StringTableSec);
439
32.7k
  if (!SymStrTabOrErr)
440
0
    return SymStrTabOrErr.takeError();
441
32.7k
  return ESym->getName(*SymStrTabOrErr);
442
32.7k
}
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
709
Expected<StringRef> ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Sym) const {
429
709
  const Elf_Sym *ESym = getSymbol(Sym);
430
709
  auto SymTabOrErr = EF.getSection(Sym.d.a);
431
709
  if (!SymTabOrErr)
432
0
    return SymTabOrErr.takeError();
433
709
  const Elf_Shdr *SymTableSec = *SymTabOrErr;
434
709
  auto StrTabOrErr = EF.getSection(SymTableSec->sh_link);
435
709
  if (!StrTabOrErr)
436
0
    return StrTabOrErr.takeError();
437
709
  const Elf_Shdr *StringTableSec = *StrTabOrErr;
438
709
  auto SymStrTabOrErr = EF.getStringTable(StringTableSec);
439
709
  if (!SymStrTabOrErr)
440
0
    return SymStrTabOrErr.takeError();
441
709
  return ESym->getName(*SymStrTabOrErr);
442
709
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolName(llvm::object::DataRefImpl) const
Line
Count
Source
428
17.1k
Expected<StringRef> ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Sym) const {
429
17.1k
  const Elf_Sym *ESym = getSymbol(Sym);
430
17.1k
  auto SymTabOrErr = EF.getSection(Sym.d.a);
431
17.1k
  if (!SymTabOrErr)
432
0
    return SymTabOrErr.takeError();
433
17.1k
  const Elf_Shdr *SymTableSec = *SymTabOrErr;
434
17.1k
  auto StrTabOrErr = EF.getSection(SymTableSec->sh_link);
435
17.1k
  if (!StrTabOrErr)
436
0
    return StrTabOrErr.takeError();
437
17.1k
  const Elf_Shdr *StringTableSec = *StrTabOrErr;
438
17.1k
  auto SymStrTabOrErr = EF.getStringTable(StringTableSec);
439
17.1k
  if (!SymStrTabOrErr)
440
0
    return SymStrTabOrErr.takeError();
441
17.1k
  return ESym->getName(*SymStrTabOrErr);
442
17.1k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolName(llvm::object::DataRefImpl) const
Line
Count
Source
428
448
Expected<StringRef> ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Sym) const {
429
448
  const Elf_Sym *ESym = getSymbol(Sym);
430
448
  auto SymTabOrErr = EF.getSection(Sym.d.a);
431
448
  if (!SymTabOrErr)
432
0
    return SymTabOrErr.takeError();
433
448
  const Elf_Shdr *SymTableSec = *SymTabOrErr;
434
448
  auto StrTabOrErr = EF.getSection(SymTableSec->sh_link);
435
448
  if (!StrTabOrErr)
436
0
    return StrTabOrErr.takeError();
437
448
  const Elf_Shdr *StringTableSec = *StrTabOrErr;
438
448
  auto SymStrTabOrErr = EF.getStringTable(StringTableSec);
439
448
  if (!SymStrTabOrErr)
440
0
    return SymStrTabOrErr.takeError();
441
448
  return ESym->getName(*SymStrTabOrErr);
442
448
}
443
444
template <class ELFT>
445
867
uint64_t ELFObjectFile<ELFT>::getSectionFlags(DataRefImpl Sec) const {
446
867
  return getSection(Sec)->sh_flags;
447
867
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionFlags(llvm::object::DataRefImpl) const
Line
Count
Source
445
71
uint64_t ELFObjectFile<ELFT>::getSectionFlags(DataRefImpl Sec) const {
446
71
  return getSection(Sec)->sh_flags;
447
71
}
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
716
uint64_t ELFObjectFile<ELFT>::getSectionFlags(DataRefImpl Sec) const {
446
716
  return getSection(Sec)->sh_flags;
447
716
}
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
561
uint32_t ELFObjectFile<ELFT>::getSectionType(DataRefImpl Sec) const {
451
561
  return getSection(Sec)->sh_type;
452
561
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionType(llvm::object::DataRefImpl) const
Line
Count
Source
450
54
uint32_t ELFObjectFile<ELFT>::getSectionType(DataRefImpl Sec) const {
451
54
  return getSection(Sec)->sh_type;
452
54
}
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
467
uint32_t ELFObjectFile<ELFT>::getSectionType(DataRefImpl Sec) const {
451
467
  return getSection(Sec)->sh_type;
452
467
}
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
24.5k
uint64_t ELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const {
461
24.5k
  const Elf_Sym *ESym = getSymbol(Symb);
462
24.5k
  uint64_t Ret = ESym->st_value;
463
24.5k
  if (ESym->st_shndx == ELF::SHN_ABS)
464
554
    return Ret;
465
23.9k
466
23.9k
  const Elf_Ehdr *Header = EF.getHeader();
467
23.9k
  // Clear the ARM/Thumb or microMIPS indicator flag.
468
23.9k
  if ((Header->e_machine == ELF::EM_ARM || 
Header->e_machine == ELF::EM_MIPS17.9k
) &&
469
23.9k
      
ESym->getType() == ELF::STT_FUNC6.91k
)
470
3.01k
    Ret &= ~1;
471
23.9k
472
23.9k
  return Ret;
473
23.9k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolValueImpl(llvm::object::DataRefImpl) const
Line
Count
Source
460
7.41k
uint64_t ELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const {
461
7.41k
  const Elf_Sym *ESym = getSymbol(Symb);
462
7.41k
  uint64_t Ret = ESym->st_value;
463
7.41k
  if (ESym->st_shndx == ELF::SHN_ABS)
464
150
    return Ret;
465
7.26k
466
7.26k
  const Elf_Ehdr *Header = EF.getHeader();
467
7.26k
  // Clear the ARM/Thumb or microMIPS indicator flag.
468
7.26k
  if ((Header->e_machine == ELF::EM_ARM || 
Header->e_machine == ELF::EM_MIPS1.24k
) &&
469
7.26k
      
ESym->getType() == ELF::STT_FUNC6.18k
)
470
2.83k
    Ret &= ~1;
471
7.26k
472
7.26k
  return Ret;
473
7.26k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolValueImpl(llvm::object::DataRefImpl) const
Line
Count
Source
460
596
uint64_t ELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const {
461
596
  const Elf_Sym *ESym = getSymbol(Symb);
462
596
  uint64_t Ret = ESym->st_value;
463
596
  if (ESym->st_shndx == ELF::SHN_ABS)
464
30
    return Ret;
465
566
466
566
  const Elf_Ehdr *Header = EF.getHeader();
467
566
  // Clear the ARM/Thumb or microMIPS indicator flag.
468
566
  if ((Header->e_machine == ELF::EM_ARM || 
Header->e_machine == ELF::EM_MIPS548
) &&
469
566
      
ESym->getType() == ELF::STT_FUNC544
)
470
138
    Ret &= ~1;
471
566
472
566
  return Ret;
473
566
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolValueImpl(llvm::object::DataRefImpl) const
Line
Count
Source
460
16.1k
uint64_t ELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const {
461
16.1k
  const Elf_Sym *ESym = getSymbol(Symb);
462
16.1k
  uint64_t Ret = ESym->st_value;
463
16.1k
  if (ESym->st_shndx == ELF::SHN_ABS)
464
371
    return Ret;
465
15.7k
466
15.7k
  const Elf_Ehdr *Header = EF.getHeader();
467
15.7k
  // Clear the ARM/Thumb or microMIPS indicator flag.
468
15.7k
  if ((Header->e_machine == ELF::EM_ARM || Header->e_machine == ELF::EM_MIPS) &&
469
15.7k
      
ESym->getType() == ELF::STT_FUNC60
)
470
30
    Ret &= ~1;
471
15.7k
472
15.7k
  return Ret;
473
15.7k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolValueImpl(llvm::object::DataRefImpl) const
Line
Count
Source
460
354
uint64_t ELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const {
461
354
  const Elf_Sym *ESym = getSymbol(Symb);
462
354
  uint64_t Ret = ESym->st_value;
463
354
  if (ESym->st_shndx == ELF::SHN_ABS)
464
3
    return Ret;
465
351
466
351
  const Elf_Ehdr *Header = EF.getHeader();
467
351
  // Clear the ARM/Thumb or microMIPS indicator flag.
468
351
  if ((Header->e_machine == ELF::EM_ARM || Header->e_machine == ELF::EM_MIPS) &&
469
351
      
ESym->getType() == ELF::STT_FUNC125
)
470
11
    Ret &= ~1;
471
351
472
351
  return Ret;
473
351
}
474
475
template <class ELFT>
476
Expected<uint64_t>
477
26.9k
ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb) const {
478
26.9k
  uint64_t Result = getSymbolValue(Symb);
479
26.9k
  const Elf_Sym *ESym = getSymbol(Symb);
480
26.9k
  switch (ESym->st_shndx) {
481
26.9k
  case ELF::SHN_COMMON:
482
2.95k
  case ELF::SHN_UNDEF:
483
2.95k
  case ELF::SHN_ABS:
484
2.95k
    return Result;
485
23.9k
  }
486
23.9k
487
23.9k
  const Elf_Ehdr *Header = EF.getHeader();
488
23.9k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
489
23.9k
  if (!SymTabOrErr)
490
0
    return SymTabOrErr.takeError();
491
23.9k
  const Elf_Shdr *SymTab = *SymTabOrErr;
492
23.9k
493
23.9k
  if (Header->e_type == ELF::ET_REL) {
494
4.80k
    auto SectionOrErr = EF.getSection(ESym, SymTab, ShndxTable);
495
4.80k
    if (!SectionOrErr)
496
0
      return SectionOrErr.takeError();
497
4.80k
    const Elf_Shdr *Section = *SectionOrErr;
498
4.80k
    if (Section)
499
4.80k
      Result += Section->sh_addr;
500
4.80k
  }
501
23.9k
502
23.9k
  return Result;
503
23.9k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolAddress(llvm::object::DataRefImpl) const
Line
Count
Source
477
8.06k
ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb) const {
478
8.06k
  uint64_t Result = getSymbolValue(Symb);
479
8.06k
  const Elf_Sym *ESym = getSymbol(Symb);
480
8.06k
  switch (ESym->st_shndx) {
481
8.06k
  case ELF::SHN_COMMON:
482
792
  case ELF::SHN_UNDEF:
483
792
  case ELF::SHN_ABS:
484
792
    return Result;
485
7.26k
  }
486
7.26k
487
7.26k
  const Elf_Ehdr *Header = EF.getHeader();
488
7.26k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
489
7.26k
  if (!SymTabOrErr)
490
0
    return SymTabOrErr.takeError();
491
7.26k
  const Elf_Shdr *SymTab = *SymTabOrErr;
492
7.26k
493
7.26k
  if (Header->e_type == ELF::ET_REL) {
494
1.67k
    auto SectionOrErr = EF.getSection(ESym, SymTab, ShndxTable);
495
1.67k
    if (!SectionOrErr)
496
0
      return SectionOrErr.takeError();
497
1.67k
    const Elf_Shdr *Section = *SectionOrErr;
498
1.67k
    if (Section)
499
1.67k
      Result += Section->sh_addr;
500
1.67k
  }
501
7.26k
502
7.26k
  return Result;
503
7.26k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolAddress(llvm::object::DataRefImpl) const
Line
Count
Source
477
731
ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb) const {
478
731
  uint64_t Result = getSymbolValue(Symb);
479
731
  const Elf_Sym *ESym = getSymbol(Symb);
480
731
  switch (ESym->st_shndx) {
481
731
  case ELF::SHN_COMMON:
482
165
  case ELF::SHN_UNDEF:
483
165
  case ELF::SHN_ABS:
484
165
    return Result;
485
566
  }
486
566
487
566
  const Elf_Ehdr *Header = EF.getHeader();
488
566
  auto SymTabOrErr = EF.getSection(Symb.d.a);
489
566
  if (!SymTabOrErr)
490
0
    return SymTabOrErr.takeError();
491
566
  const Elf_Shdr *SymTab = *SymTabOrErr;
492
566
493
566
  if (Header->e_type == ELF::ET_REL) {
494
225
    auto SectionOrErr = EF.getSection(ESym, SymTab, ShndxTable);
495
225
    if (!SectionOrErr)
496
0
      return SectionOrErr.takeError();
497
225
    const Elf_Shdr *Section = *SectionOrErr;
498
225
    if (Section)
499
225
      Result += Section->sh_addr;
500
225
  }
501
566
502
566
  return Result;
503
566
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolAddress(llvm::object::DataRefImpl) const
Line
Count
Source
477
17.6k
ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb) const {
478
17.6k
  uint64_t Result = getSymbolValue(Symb);
479
17.6k
  const Elf_Sym *ESym = getSymbol(Symb);
480
17.6k
  switch (ESym->st_shndx) {
481
17.6k
  case ELF::SHN_COMMON:
482
1.90k
  case ELF::SHN_UNDEF:
483
1.90k
  case ELF::SHN_ABS:
484
1.90k
    return Result;
485
15.7k
  }
486
15.7k
487
15.7k
  const Elf_Ehdr *Header = EF.getHeader();
488
15.7k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
489
15.7k
  if (!SymTabOrErr)
490
0
    return SymTabOrErr.takeError();
491
15.7k
  const Elf_Shdr *SymTab = *SymTabOrErr;
492
15.7k
493
15.7k
  if (Header->e_type == ELF::ET_REL) {
494
2.77k
    auto SectionOrErr = EF.getSection(ESym, SymTab, ShndxTable);
495
2.77k
    if (!SectionOrErr)
496
0
      return SectionOrErr.takeError();
497
2.77k
    const Elf_Shdr *Section = *SectionOrErr;
498
2.77k
    if (Section)
499
2.77k
      Result += Section->sh_addr;
500
2.77k
  }
501
15.7k
502
15.7k
  return Result;
503
15.7k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolAddress(llvm::object::DataRefImpl) const
Line
Count
Source
477
446
ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb) const {
478
446
  uint64_t Result = getSymbolValue(Symb);
479
446
  const Elf_Sym *ESym = getSymbol(Symb);
480
446
  switch (ESym->st_shndx) {
481
446
  case ELF::SHN_COMMON:
482
95
  case ELF::SHN_UNDEF:
483
95
  case ELF::SHN_ABS:
484
95
    return Result;
485
351
  }
486
351
487
351
  const Elf_Ehdr *Header = EF.getHeader();
488
351
  auto SymTabOrErr = EF.getSection(Symb.d.a);
489
351
  if (!SymTabOrErr)
490
0
    return SymTabOrErr.takeError();
491
351
  const Elf_Shdr *SymTab = *SymTabOrErr;
492
351
493
351
  if (Header->e_type == ELF::ET_REL) {
494
129
    auto SectionOrErr = EF.getSection(ESym, SymTab, ShndxTable);
495
129
    if (!SectionOrErr)
496
0
      return SectionOrErr.takeError();
497
129
    const Elf_Shdr *Section = *SectionOrErr;
498
129
    if (Section)
499
129
      Result += Section->sh_addr;
500
129
  }
501
351
502
351
  return Result;
503
351
}
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.40k
uint16_t ELFObjectFile<ELFT>::getEMachine() const {
515
1.40k
  return EF.getHeader()->e_machine;
516
1.40k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getEMachine() const
Line
Count
Source
514
379
uint16_t ELFObjectFile<ELFT>::getEMachine() const {
515
379
  return EF.getHeader()->e_machine;
516
379
}
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
912
uint16_t ELFObjectFile<ELFT>::getEMachine() const {
515
912
  return EF.getHeader()->e_machine;
516
912
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getEMachine() const
Line
Count
Source
514
44
uint16_t ELFObjectFile<ELFT>::getEMachine() const {
515
44
  return EF.getHeader()->e_machine;
516
44
}
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.06k
uint64_t ELFObjectFile<ELFT>::getSymbolSize(DataRefImpl Sym) const {
524
7.06k
  return getSymbol(Sym)->st_size;
525
7.06k
}
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.62k
uint64_t ELFObjectFile<ELFT>::getSymbolSize(DataRefImpl Sym) const {
524
6.62k
  return getSymbol(Sym)->st_size;
525
6.62k
}
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
77
uint8_t ELFObjectFile<ELFT>::getSymbolELFType(DataRefImpl Symb) const {
539
77
  return getSymbol(Symb)->getType();
540
77
}
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
77
uint8_t ELFObjectFile<ELFT>::getSymbolELFType(DataRefImpl Symb) const {
539
77
  return getSymbol(Symb)->getType();
540
77
}
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.31k
ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const {
545
8.31k
  const Elf_Sym *ESym = getSymbol(Symb);
546
8.31k
547
8.31k
  switch (ESym->getType()) {
548
8.31k
  case ELF::STT_NOTYPE:
549
1.58k
    return SymbolRef::ST_Unknown;
550
8.31k
  case ELF::STT_SECTION:
551
1.91k
    return SymbolRef::ST_Debug;
552
8.31k
  case ELF::STT_FILE:
553
415
    return SymbolRef::ST_File;
554
8.31k
  case ELF::STT_FUNC:
555
2.20k
    return SymbolRef::ST_Function;
556
8.31k
  case ELF::STT_OBJECT:
557
2.19k
  case ELF::STT_COMMON:
558
2.19k
  case ELF::STT_TLS:
559
2.19k
    return SymbolRef::ST_Data;
560
2.19k
  default:
561
2
    return SymbolRef::ST_Other;
562
8.31k
  }
563
8.31k
}
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.49k
ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const {
545
7.49k
  const Elf_Sym *ESym = getSymbol(Symb);
546
7.49k
547
7.49k
  switch (ESym->getType()) {
548
7.49k
  case ELF::STT_NOTYPE:
549
1.10k
    return SymbolRef::ST_Unknown;
550
7.49k
  case ELF::STT_SECTION:
551
1.81k
    return SymbolRef::ST_Debug;
552
7.49k
  case ELF::STT_FILE:
553
373
    return SymbolRef::ST_File;
554
7.49k
  case ELF::STT_FUNC:
555
2.10k
    return SymbolRef::ST_Function;
556
7.49k
  case ELF::STT_OBJECT:
557
2.10k
  case ELF::STT_COMMON:
558
2.10k
  case ELF::STT_TLS:
559
2.10k
    return SymbolRef::ST_Data;
560
2.10k
  default:
561
2
    return SymbolRef::ST_Other;
562
7.49k
  }
563
7.49k
}
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
40.9k
uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
567
40.9k
  const Elf_Sym *ESym = getSymbol(Sym);
568
40.9k
569
40.9k
  uint32_t Result = SymbolRef::SF_None;
570
40.9k
571
40.9k
  if (ESym->getBinding() != ELF::STB_LOCAL)
572
20.9k
    Result |= SymbolRef::SF_Global;
573
40.9k
574
40.9k
  if (ESym->getBinding() == ELF::STB_WEAK)
575
4.03k
    Result |= SymbolRef::SF_Weak;
576
40.9k
577
40.9k
  if (ESym->st_shndx == ELF::SHN_ABS)
578
1.25k
    Result |= SymbolRef::SF_Absolute;
579
40.9k
580
40.9k
  if (ESym->getType() == ELF::STT_FILE || 
ESym->getType() == ELF::STT_SECTION40.1k
)
581
3.90k
    Result |= SymbolRef::SF_FormatSpecific;
582
40.9k
583
40.9k
  auto DotSymtabSecSyms = EF.symbols(DotSymtabSec);
584
40.9k
  if (DotSymtabSecSyms && ESym == (*DotSymtabSecSyms).begin())
585
2.04k
    Result |= SymbolRef::SF_FormatSpecific;
586
40.9k
  auto DotDynSymSecSyms = EF.symbols(DotDynSymSec);
587
40.9k
  if (DotDynSymSecSyms && ESym == (*DotDynSymSecSyms).begin())
588
5
    Result |= SymbolRef::SF_FormatSpecific;
589
40.9k
590
40.9k
  if (EF.getHeader()->e_machine == ELF::EM_ARM) {
591
6.56k
    if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
592
6.56k
      StringRef Name = *NameOrErr;
593
6.56k
      if (Name.startswith("$d") || 
Name.startswith("$t")6.40k
||
594
6.56k
          
Name.startswith("$a")4.38k
)
595
2.87k
        Result |= SymbolRef::SF_FormatSpecific;
596
6.56k
    } else {
597
0
      // TODO: Actually report errors helpfully.
598
0
      consumeError(NameOrErr.takeError());
599
0
    }
600
6.56k
    if (ESym->getType() == ELF::STT_FUNC && 
(ESym->st_value & 1) == 12.85k
)
601
2.16k
      Result |= SymbolRef::SF_Thumb;
602
6.56k
  }
603
40.9k
604
40.9k
  if (ESym->st_shndx == ELF::SHN_UNDEF)
605
3.42k
    Result |= SymbolRef::SF_Undefined;
606
40.9k
607
40.9k
  if (ESym->getType() == ELF::STT_COMMON || ESym->st_shndx == ELF::SHN_COMMON)
608
455
    Result |= SymbolRef::SF_Common;
609
40.9k
610
40.9k
  if (isExportedToOtherDSO(ESym))
611
12.3k
    Result |= SymbolRef::SF_Exported;
612
40.9k
613
40.9k
  if (ESym->getVisibility() == ELF::STV_HIDDEN)
614
9.34k
    Result |= SymbolRef::SF_Hidden;
615
40.9k
616
40.9k
  return Result;
617
40.9k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolFlags(llvm::object::DataRefImpl) const
Line
Count
Source
566
8.93k
uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
567
8.93k
  const Elf_Sym *ESym = getSymbol(Sym);
568
8.93k
569
8.93k
  uint32_t Result = SymbolRef::SF_None;
570
8.93k
571
8.93k
  if (ESym->getBinding() != ELF::STB_LOCAL)
572
3.36k
    Result |= SymbolRef::SF_Global;
573
8.93k
574
8.93k
  if (ESym->getBinding() == ELF::STB_WEAK)
575
14
    Result |= SymbolRef::SF_Weak;
576
8.93k
577
8.93k
  if (ESym->st_shndx == ELF::SHN_ABS)
578
222
    Result |= SymbolRef::SF_Absolute;
579
8.93k
580
8.93k
  if (ESym->getType() == ELF::STT_FILE || 
ESym->getType() == ELF::STT_SECTION8.80k
)
581
735
    Result |= SymbolRef::SF_FormatSpecific;
582
8.93k
583
8.93k
  auto DotSymtabSecSyms = EF.symbols(DotSymtabSec);
584
8.93k
  if (DotSymtabSecSyms && ESym == (*DotSymtabSecSyms).begin())
585
474
    Result |= SymbolRef::SF_FormatSpecific;
586
8.93k
  auto DotDynSymSecSyms = EF.symbols(DotDynSymSec);
587
8.93k
  if (DotDynSymSecSyms && ESym == (*DotDynSymSecSyms).begin())
588
1
    Result |= SymbolRef::SF_FormatSpecific;
589
8.93k
590
8.93k
  if (EF.getHeader()->e_machine == ELF::EM_ARM) {
591
6.54k
    if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
592
6.54k
      StringRef Name = *NameOrErr;
593
6.54k
      if (Name.startswith("$d") || 
Name.startswith("$t")6.38k
||
594
6.54k
          
Name.startswith("$a")4.35k
)
595
2.87k
        Result |= SymbolRef::SF_FormatSpecific;
596
6.54k
    } else {
597
0
      // TODO: Actually report errors helpfully.
598
0
      consumeError(NameOrErr.takeError());
599
0
    }
600
6.54k
    if (ESym->getType() == ELF::STT_FUNC && 
(ESym->st_value & 1) == 12.85k
)
601
2.16k
      Result |= SymbolRef::SF_Thumb;
602
6.54k
  }
603
8.93k
604
8.93k
  if (ESym->st_shndx == ELF::SHN_UNDEF)
605
785
    Result |= SymbolRef::SF_Undefined;
606
8.93k
607
8.93k
  if (ESym->getType() == ELF::STT_COMMON || ESym->st_shndx == ELF::SHN_COMMON)
608
27
    Result |= SymbolRef::SF_Common;
609
8.93k
610
8.93k
  if (isExportedToOtherDSO(ESym))
611
3.34k
    Result |= SymbolRef::SF_Exported;
612
8.93k
613
8.93k
  if (ESym->getVisibility() == ELF::STV_HIDDEN)
614
120
    Result |= SymbolRef::SF_Hidden;
615
8.93k
616
8.93k
  return Result;
617
8.93k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolFlags(llvm::object::DataRefImpl) const
Line
Count
Source
566
1.16k
uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
567
1.16k
  const Elf_Sym *ESym = getSymbol(Sym);
568
1.16k
569
1.16k
  uint32_t Result = SymbolRef::SF_None;
570
1.16k
571
1.16k
  if (ESym->getBinding() != ELF::STB_LOCAL)
572
382
    Result |= SymbolRef::SF_Global;
573
1.16k
574
1.16k
  if (ESym->getBinding() == ELF::STB_WEAK)
575
5
    Result |= SymbolRef::SF_Weak;
576
1.16k
577
1.16k
  if (ESym->st_shndx == ELF::SHN_ABS)
578
68
    Result |= SymbolRef::SF_Absolute;
579
1.16k
580
1.16k
  if (ESym->getType() == ELF::STT_FILE || 
ESym->getType() == ELF::STT_SECTION1.13k
)
581
107
    Result |= SymbolRef::SF_FormatSpecific;
582
1.16k
583
1.16k
  auto DotSymtabSecSyms = EF.symbols(DotSymtabSec);
584
1.16k
  if (DotSymtabSecSyms && ESym == (*DotSymtabSecSyms).begin())
585
139
    Result |= SymbolRef::SF_FormatSpecific;
586
1.16k
  auto DotDynSymSecSyms = EF.symbols(DotDynSymSec);
587
1.16k
  if (DotDynSymSecSyms && ESym == (*DotDynSymSecSyms).begin())
588
0
    Result |= SymbolRef::SF_FormatSpecific;
589
1.16k
590
1.16k
  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.16k
604
1.16k
  if (ESym->st_shndx == ELF::SHN_UNDEF)
605
190
    Result |= SymbolRef::SF_Undefined;
606
1.16k
607
1.16k
  if (ESym->getType() == ELF::STT_COMMON || ESym->st_shndx == ELF::SHN_COMMON)
608
17
    Result |= SymbolRef::SF_Common;
609
1.16k
610
1.16k
  if (isExportedToOtherDSO(ESym))
611
382
    Result |= SymbolRef::SF_Exported;
612
1.16k
613
1.16k
  if (ESym->getVisibility() == ELF::STV_HIDDEN)
614
162
    Result |= SymbolRef::SF_Hidden;
615
1.16k
616
1.16k
  return Result;
617
1.16k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolFlags(llvm::object::DataRefImpl) const
Line
Count
Source
566
30.0k
uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
567
30.0k
  const Elf_Sym *ESym = getSymbol(Sym);
568
30.0k
569
30.0k
  uint32_t Result = SymbolRef::SF_None;
570
30.0k
571
30.0k
  if (ESym->getBinding() != ELF::STB_LOCAL)
572
16.9k
    Result |= SymbolRef::SF_Global;
573
30.0k
574
30.0k
  if (ESym->getBinding() == ELF::STB_WEAK)
575
4.01k
    Result |= SymbolRef::SF_Weak;
576
30.0k
577
30.0k
  if (ESym->st_shndx == ELF::SHN_ABS)
578
933
    Result |= SymbolRef::SF_Absolute;
579
30.0k
580
30.0k
  if (ESym->getType() == ELF::STT_FILE || 
ESym->getType() == ELF::STT_SECTION29.4k
)
581
2.94k
    Result |= SymbolRef::SF_FormatSpecific;
582
30.0k
583
30.0k
  auto DotSymtabSecSyms = EF.symbols(DotSymtabSec);
584
30.0k
  if (DotSymtabSecSyms && ESym == (*DotSymtabSecSyms).begin())
585
1.34k
    Result |= SymbolRef::SF_FormatSpecific;
586
30.0k
  auto DotDynSymSecSyms = EF.symbols(DotDynSymSec);
587
30.0k
  if (DotDynSymSecSyms && ESym == (*DotDynSymSecSyms).begin())
588
4
    Result |= SymbolRef::SF_FormatSpecific;
589
30.0k
590
30.0k
  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.0k
604
30.0k
  if (ESym->st_shndx == ELF::SHN_UNDEF)
605
2.31k
    Result |= SymbolRef::SF_Undefined;
606
30.0k
607
30.0k
  if (ESym->getType() == ELF::STT_COMMON || ESym->st_shndx == ELF::SHN_COMMON)
608
402
    Result |= SymbolRef::SF_Common;
609
30.0k
610
30.0k
  if (isExportedToOtherDSO(ESym))
611
8.28k
    Result |= SymbolRef::SF_Exported;
612
30.0k
613
30.0k
  if (ESym->getVisibility() == ELF::STV_HIDDEN)
614
8.99k
    Result |= SymbolRef::SF_Hidden;
615
30.0k
616
30.0k
  return Result;
617
30.0k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolFlags(llvm::object::DataRefImpl) const
Line
Count
Source
566
798
uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
567
798
  const Elf_Sym *ESym = getSymbol(Sym);
568
798
569
798
  uint32_t Result = SymbolRef::SF_None;
570
798
571
798
  if (ESym->getBinding() != ELF::STB_LOCAL)
572
289
    Result |= SymbolRef::SF_Global;
573
798
574
798
  if (ESym->getBinding() == ELF::STB_WEAK)
575
3
    Result |= SymbolRef::SF_Weak;
576
798
577
798
  if (ESym->st_shndx == ELF::SHN_ABS)
578
33
    Result |= SymbolRef::SF_Absolute;
579
798
580
798
  if (ESym->getType() == ELF::STT_FILE || 
ESym->getType() == ELF::STT_SECTION767
)
581
116
    Result |= SymbolRef::SF_FormatSpecific;
582
798
583
798
  auto DotSymtabSecSyms = EF.symbols(DotSymtabSec);
584
798
  if (DotSymtabSecSyms && ESym == (*DotSymtabSecSyms).begin())
585
81
    Result |= SymbolRef::SF_FormatSpecific;
586
798
  auto DotDynSymSecSyms = EF.symbols(DotDynSymSec);
587
798
  if (DotDynSymSecSyms && ESym == (*DotDynSymSecSyms).begin())
588
0
    Result |= SymbolRef::SF_FormatSpecific;
589
798
590
798
  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
798
604
798
  if (ESym->st_shndx == ELF::SHN_UNDEF)
605
137
    Result |= SymbolRef::SF_Undefined;
606
798
607
798
  if (ESym->getType() == ELF::STT_COMMON || ESym->st_shndx == ELF::SHN_COMMON)
608
9
    Result |= SymbolRef::SF_Common;
609
798
610
798
  if (isExportedToOtherDSO(ESym))
611
289
    Result |= SymbolRef::SF_Exported;
612
798
613
798
  if (ESym->getVisibility() == ELF::STV_HIDDEN)
614
72
    Result |= SymbolRef::SF_Hidden;
615
798
616
798
  return Result;
617
798
}
618
619
template <class ELFT>
620
Expected<section_iterator>
621
ELFObjectFile<ELFT>::getSymbolSection(const Elf_Sym *ESym,
622
13.3k
                                      const Elf_Shdr *SymTab) const {
623
13.3k
  auto ESecOrErr = EF.getSection(ESym, SymTab, ShndxTable);
624
13.3k
  if (!ESecOrErr)
625
0
    return ESecOrErr.takeError();
626
13.3k
627
13.3k
  const Elf_Shdr *ESec = *ESecOrErr;
628
13.3k
  if (!ESec)
629
1.02k
    return section_end();
630
12.3k
631
12.3k
  DataRefImpl Sec;
632
12.3k
  Sec.p = reinterpret_cast<intptr_t>(ESec);
633
12.3k
  return section_iterator(SectionRef(Sec, this));
634
12.3k
}
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.57k
                                      const Elf_Shdr *SymTab) const {
623
7.57k
  auto ESecOrErr = EF.getSection(ESym, SymTab, ShndxTable);
624
7.57k
  if (!ESecOrErr)
625
0
    return ESecOrErr.takeError();
626
7.57k
627
7.57k
  const Elf_Shdr *ESec = *ESecOrErr;
628
7.57k
  if (!ESec)
629
398
    return section_end();
630
7.17k
631
7.17k
  DataRefImpl Sec;
632
7.17k
  Sec.p = reinterpret_cast<intptr_t>(ESec);
633
7.17k
  return section_iterator(SectionRef(Sec, this));
634
7.17k
}
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
672
                                      const Elf_Shdr *SymTab) const {
623
672
  auto ESecOrErr = EF.getSection(ESym, SymTab, ShndxTable);
624
672
  if (!ESecOrErr)
625
0
    return ESecOrErr.takeError();
626
672
627
672
  const Elf_Shdr *ESec = *ESecOrErr;
628
672
  if (!ESec)
629
100
    return section_end();
630
572
631
572
  DataRefImpl Sec;
632
572
  Sec.p = reinterpret_cast<intptr_t>(ESec);
633
572
  return section_iterator(SectionRef(Sec, this));
634
572
}
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
4.71k
                                      const Elf_Shdr *SymTab) const {
623
4.71k
  auto ESecOrErr = EF.getSection(ESym, SymTab, ShndxTable);
624
4.71k
  if (!ESecOrErr)
625
0
    return ESecOrErr.takeError();
626
4.71k
627
4.71k
  const Elf_Shdr *ESec = *ESecOrErr;
628
4.71k
  if (!ESec)
629
473
    return section_end();
630
4.23k
631
4.23k
  DataRefImpl Sec;
632
4.23k
  Sec.p = reinterpret_cast<intptr_t>(ESec);
633
4.23k
  return section_iterator(SectionRef(Sec, this));
634
4.23k
}
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
410
                                      const Elf_Shdr *SymTab) const {
623
410
  auto ESecOrErr = EF.getSection(ESym, SymTab, ShndxTable);
624
410
  if (!ESecOrErr)
625
0
    return ESecOrErr.takeError();
626
410
627
410
  const Elf_Shdr *ESec = *ESecOrErr;
628
410
  if (!ESec)
629
52
    return section_end();
630
358
631
358
  DataRefImpl Sec;
632
358
  Sec.p = reinterpret_cast<intptr_t>(ESec);
633
358
  return section_iterator(SectionRef(Sec, this));
634
358
}
635
636
template <class ELFT>
637
Expected<section_iterator>
638
13.3k
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb) const {
639
13.3k
  const Elf_Sym *Sym = getSymbol(Symb);
640
13.3k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
641
13.3k
  if (!SymTabOrErr)
642
0
    return SymTabOrErr.takeError();
643
13.3k
  const Elf_Shdr *SymTab = *SymTabOrErr;
644
13.3k
  return getSymbolSection(Sym, SymTab);
645
13.3k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolSection(llvm::object::DataRefImpl) const
Line
Count
Source
638
7.57k
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb) const {
639
7.57k
  const Elf_Sym *Sym = getSymbol(Symb);
640
7.57k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
641
7.57k
  if (!SymTabOrErr)
642
0
    return SymTabOrErr.takeError();
643
7.57k
  const Elf_Shdr *SymTab = *SymTabOrErr;
644
7.57k
  return getSymbolSection(Sym, SymTab);
645
7.57k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolSection(llvm::object::DataRefImpl) const
Line
Count
Source
638
672
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb) const {
639
672
  const Elf_Sym *Sym = getSymbol(Symb);
640
672
  auto SymTabOrErr = EF.getSection(Symb.d.a);
641
672
  if (!SymTabOrErr)
642
0
    return SymTabOrErr.takeError();
643
672
  const Elf_Shdr *SymTab = *SymTabOrErr;
644
672
  return getSymbolSection(Sym, SymTab);
645
672
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolSection(llvm::object::DataRefImpl) const
Line
Count
Source
638
4.71k
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb) const {
639
4.71k
  const Elf_Sym *Sym = getSymbol(Symb);
640
4.71k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
641
4.71k
  if (!SymTabOrErr)
642
0
    return SymTabOrErr.takeError();
643
4.71k
  const Elf_Shdr *SymTab = *SymTabOrErr;
644
4.71k
  return getSymbolSection(Sym, SymTab);
645
4.71k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolSection(llvm::object::DataRefImpl) const
Line
Count
Source
638
410
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb) const {
639
410
  const Elf_Sym *Sym = getSymbol(Symb);
640
410
  auto SymTabOrErr = EF.getSection(Symb.d.a);
641
410
  if (!SymTabOrErr)
642
0
    return SymTabOrErr.takeError();
643
410
  const Elf_Shdr *SymTab = *SymTabOrErr;
644
410
  return getSymbolSection(Sym, SymTab);
645
410
}
646
647
template <class ELFT>
648
123k
void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {
649
123k
  const Elf_Shdr *ESec = getSection(Sec);
650
123k
  Sec = toDRI(++ESec);
651
123k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::moveSectionNext(llvm::object::DataRefImpl&) const
Line
Count
Source
648
14.2k
void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {
649
14.2k
  const Elf_Shdr *ESec = getSection(Sec);
650
14.2k
  Sec = toDRI(++ESec);
651
14.2k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::moveSectionNext(llvm::object::DataRefImpl&) const
Line
Count
Source
648
4.35k
void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {
649
4.35k
  const Elf_Shdr *ESec = getSection(Sec);
650
4.35k
  Sec = toDRI(++ESec);
651
4.35k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::moveSectionNext(llvm::object::DataRefImpl&) const
Line
Count
Source
648
102k
void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {
649
102k
  const Elf_Shdr *ESec = getSection(Sec);
650
102k
  Sec = toDRI(++ESec);
651
102k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::moveSectionNext(llvm::object::DataRefImpl&) const
Line
Count
Source
648
2.92k
void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {
649
2.92k
  const Elf_Shdr *ESec = getSection(Sec);
650
2.92k
  Sec = toDRI(++ESec);
651
2.92k
}
652
653
template <class ELFT>
654
std::error_code ELFObjectFile<ELFT>::getSectionName(DataRefImpl Sec,
655
104k
                                                    StringRef &Result) const {
656
104k
  auto Name = EF.getSectionName(&*getSection(Sec));
657
104k
  if (!Name)
658
32
    return errorToErrorCode(Name.takeError());
659
104k
  Result = *Name;
660
104k
  return std::error_code();
661
104k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionName(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
655
6.51k
                                                    StringRef &Result) const {
656
6.51k
  auto Name = EF.getSectionName(&*getSection(Sec));
657
6.51k
  if (!Name)
658
28
    return errorToErrorCode(Name.takeError());
659
6.48k
  Result = *Name;
660
6.48k
  return std::error_code();
661
6.48k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionName(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
655
1.94k
                                                    StringRef &Result) const {
656
1.94k
  auto Name = EF.getSectionName(&*getSection(Sec));
657
1.94k
  if (!Name)
658
0
    return errorToErrorCode(Name.takeError());
659
1.94k
  Result = *Name;
660
1.94k
  return std::error_code();
661
1.94k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionName(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
655
94.7k
                                                    StringRef &Result) const {
656
94.7k
  auto Name = EF.getSectionName(&*getSection(Sec));
657
94.7k
  if (!Name)
658
4
    return errorToErrorCode(Name.takeError());
659
94.7k
  Result = *Name;
660
94.7k
  return std::error_code();
661
94.7k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionName(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
655
1.58k
                                                    StringRef &Result) const {
656
1.58k
  auto Name = EF.getSectionName(&*getSection(Sec));
657
1.58k
  if (!Name)
658
0
    return errorToErrorCode(Name.takeError());
659
1.58k
  Result = *Name;
660
1.58k
  return std::error_code();
661
1.58k
}
662
663
template <class ELFT>
664
14.9k
uint64_t ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec) const {
665
14.9k
  return getSection(Sec)->sh_addr;
666
14.9k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionAddress(llvm::object::DataRefImpl) const
Line
Count
Source
664
4.16k
uint64_t ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec) const {
665
4.16k
  return getSection(Sec)->sh_addr;
666
4.16k
}
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.54k
uint64_t ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec) const {
665
8.54k
  return getSection(Sec)->sh_addr;
666
8.54k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionAddress(llvm::object::DataRefImpl) const
Line
Count
Source
664
920
uint64_t ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec) const {
665
920
  return getSection(Sec)->sh_addr;
666
920
}
667
668
template <class ELFT>
669
3.08k
uint64_t ELFObjectFile<ELFT>::getSectionIndex(DataRefImpl Sec) const {
670
3.08k
  auto SectionsOrErr = EF.sections();
671
3.08k
  handleAllErrors(std::move(SectionsOrErr.takeError()),
672
3.08k
                  [](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.08k
  const Elf_Shdr *First = SectionsOrErr->begin();
676
3.08k
  return getSection(Sec) - First;
677
3.08k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionIndex(llvm::object::DataRefImpl) const
Line
Count
Source
669
314
uint64_t ELFObjectFile<ELFT>::getSectionIndex(DataRefImpl Sec) const {
670
314
  auto SectionsOrErr = EF.sections();
671
314
  handleAllErrors(std::move(SectionsOrErr.takeError()),
672
314
                  [](const ErrorInfoBase &) {
673
314
                    llvm_unreachable("unable to get section index");
674
314
                  });
675
314
  const Elf_Shdr *First = SectionsOrErr->begin();
676
314
  return getSection(Sec) - First;
677
314
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionIndex(llvm::object::DataRefImpl) const
Line
Count
Source
669
116
uint64_t ELFObjectFile<ELFT>::getSectionIndex(DataRefImpl Sec) const {
670
116
  auto SectionsOrErr = EF.sections();
671
116
  handleAllErrors(std::move(SectionsOrErr.takeError()),
672
116
                  [](const ErrorInfoBase &) {
673
116
                    llvm_unreachable("unable to get section index");
674
116
                  });
675
116
  const Elf_Shdr *First = SectionsOrErr->begin();
676
116
  return getSection(Sec) - First;
677
116
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionIndex(llvm::object::DataRefImpl) const
Line
Count
Source
669
2.52k
uint64_t ELFObjectFile<ELFT>::getSectionIndex(DataRefImpl Sec) const {
670
2.52k
  auto SectionsOrErr = EF.sections();
671
2.52k
  handleAllErrors(std::move(SectionsOrErr.takeError()),
672
2.52k
                  [](const ErrorInfoBase &) {
673
2.52k
                    llvm_unreachable("unable to get section index");
674
2.52k
                  });
675
2.52k
  const Elf_Shdr *First = SectionsOrErr->begin();
676
2.52k
  return getSection(Sec) - First;
677
2.52k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::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
}
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
428
uint64_t ELFObjectFile<ELFT>::getSectionSize(DataRefImpl Sec) const {
681
428
  return getSection(Sec)->sh_size;
682
428
}
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
406
uint64_t ELFObjectFile<ELFT>::getSectionSize(DataRefImpl Sec) const {
681
406
  return getSection(Sec)->sh_size;
682
406
}
683
684
template <class ELFT>
685
std::error_code
686
ELFObjectFile<ELFT>::getSectionContents(DataRefImpl Sec,
687
12.4k
                                        StringRef &Result) const {
688
12.4k
  const Elf_Shdr *EShdr = getSection(Sec);
689
12.4k
  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.4k
  Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
694
12.4k
  return std::error_code();
695
12.4k
}
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.73k
  Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
694
1.73k
  return std::error_code();
695
1.73k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionContents(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
687
543
                                        StringRef &Result) const {
688
543
  const Elf_Shdr *EShdr = getSection(Sec);
689
543
  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
543
  Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
694
543
  return std::error_code();
695
543
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionContents(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
687
9.63k
                                        StringRef &Result) const {
688
9.63k
  const Elf_Shdr *EShdr = getSection(Sec);
689
9.63k
  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
9.63k
  Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
694
9.63k
  return std::error_code();
695
9.63k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionContents(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
687
536
                                        StringRef &Result) const {
688
536
  const Elf_Shdr *EShdr = getSection(Sec);
689
536
  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
536
  Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
694
536
  return std::error_code();
695
536
}
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.34k
bool ELFObjectFile<ELFT>::isSectionCompressed(DataRefImpl Sec) const {
704
8.34k
  return getSection(Sec)->sh_flags & ELF::SHF_COMPRESSED;
705
8.34k
}
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
211
bool ELFObjectFile<ELFT>::isSectionCompressed(DataRefImpl Sec) const {
704
211
  return getSection(Sec)->sh_flags & ELF::SHF_COMPRESSED;
705
211
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isSectionCompressed(llvm::object::DataRefImpl) const
Line
Count
Source
703
7.13k
bool ELFObjectFile<ELFT>::isSectionCompressed(DataRefImpl Sec) const {
704
7.13k
  return getSection(Sec)->sh_flags & ELF::SHF_COMPRESSED;
705
7.13k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isSectionCompressed(llvm::object::DataRefImpl) const
Line
Count
Source
703
264
bool ELFObjectFile<ELFT>::isSectionCompressed(DataRefImpl Sec) const {
704
264
  return getSection(Sec)->sh_flags & ELF::SHF_COMPRESSED;
705
264
}
706
707
template <class ELFT>
708
12.0k
bool ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec) const {
709
12.0k
  return getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR;
710
12.0k
}
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
6.88k
bool ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec) const {
709
6.88k
  return getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR;
710
6.88k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isSectionText(llvm::object::DataRefImpl) const
Line
Count
Source
708
672
bool ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec) const {
709
672
  return getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR;
710
672
}
711
712
template <class ELFT>
713
1.33k
bool ELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec) const {
714
1.33k
  const Elf_Shdr *EShdr = getSection(Sec);
715
1.33k
  return EShdr->sh_type == ELF::SHT_PROGBITS &&
716
1.33k
         
EShdr->sh_flags & ELF::SHF_ALLOC536
&&
717
1.33k
         
!(EShdr->sh_flags & ELF::SHF_EXECINSTR)340
;
718
1.33k
}
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.17k
bool ELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec) const {
714
1.17k
  const Elf_Shdr *EShdr = getSection(Sec);
715
1.17k
  return EShdr->sh_type == ELF::SHT_PROGBITS &&
716
1.17k
         
EShdr->sh_flags & ELF::SHF_ALLOC489
&&
717
1.17k
         
!(EShdr->sh_flags & ELF::SHF_EXECINSTR)305
;
718
1.17k
}
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
11.7k
bool ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec) const {
722
11.7k
  const Elf_Shdr *EShdr = getSection(Sec);
723
11.7k
  return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
724
11.7k
         
EShdr->sh_type == ELF::SHT_NOBITS3.66k
;
725
11.7k
}
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
475
bool ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec) const {
722
475
  const Elf_Shdr *EShdr = getSection(Sec);
723
475
  return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
724
475
         
EShdr->sh_type == ELF::SHT_NOBITS212
;
725
475
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isSectionBSS(llvm::object::DataRefImpl) const
Line
Count
Source
721
9.61k
bool ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec) const {
722
9.61k
  const Elf_Shdr *EShdr = getSection(Sec);
723
9.61k
  return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
724
9.61k
         
EShdr->sh_type == ELF::SHT_NOBITS2.84k
;
725
9.61k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isSectionBSS(llvm::object::DataRefImpl) const
Line
Count
Source
721
425
bool ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec) const {
722
425
  const Elf_Shdr *EShdr = getSection(Sec);
723
425
  return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
724
425
         
EShdr->sh_type == ELF::SHT_NOBITS166
;
725
425
}
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
14.5k
bool ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec) const {
758
14.5k
  return getSection(Sec)->sh_type == ELF::SHT_NOBITS;
759
14.5k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isSectionVirtual(llvm::object::DataRefImpl) const
Line
Count
Source
757
3.18k
bool ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec) const {
758
3.18k
  return getSection(Sec)->sh_type == ELF::SHT_NOBITS;
759
3.18k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isSectionVirtual(llvm::object::DataRefImpl) const
Line
Count
Source
757
531
bool ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec) const {
758
531
  return getSection(Sec)->sh_type == ELF::SHT_NOBITS;
759
531
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isSectionVirtual(llvm::object::DataRefImpl) const
Line
Count
Source
757
10.2k
bool ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec) const {
758
10.2k
  return getSection(Sec)->sh_type == ELF::SHT_NOBITS;
759
10.2k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isSectionVirtual(llvm::object::DataRefImpl) const
Line
Count
Source
757
563
bool ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec) const {
758
563
  return getSection(Sec)->sh_type == ELF::SHT_NOBITS;
759
563
}
760
761
template <class ELFT>
762
relocation_iterator
763
4.18k
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
764
4.18k
  DataRefImpl RelData;
765
4.18k
  auto SectionsOrErr = EF.sections();
766
4.18k
  if (!SectionsOrErr)
767
0
    return relocation_iterator(RelocationRef());
768
4.18k
  uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
769
4.18k
  RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
770
4.18k
  RelData.d.b = 0;
771
4.18k
  return relocation_iterator(RelocationRef(RelData, this));
772
4.18k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::section_rel_begin(llvm::object::DataRefImpl) const
Line
Count
Source
763
796
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
764
796
  DataRefImpl RelData;
765
796
  auto SectionsOrErr = EF.sections();
766
796
  if (!SectionsOrErr)
767
0
    return relocation_iterator(RelocationRef());
768
796
  uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
769
796
  RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
770
796
  RelData.d.b = 0;
771
796
  return relocation_iterator(RelocationRef(RelData, this));
772
796
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::section_rel_begin(llvm::object::DataRefImpl) const
Line
Count
Source
763
172
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
764
172
  DataRefImpl RelData;
765
172
  auto SectionsOrErr = EF.sections();
766
172
  if (!SectionsOrErr)
767
0
    return relocation_iterator(RelocationRef());
768
172
  uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
769
172
  RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
770
172
  RelData.d.b = 0;
771
172
  return relocation_iterator(RelocationRef(RelData, this));
772
172
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::section_rel_begin(llvm::object::DataRefImpl) const
Line
Count
Source
763
3.04k
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
764
3.04k
  DataRefImpl RelData;
765
3.04k
  auto SectionsOrErr = EF.sections();
766
3.04k
  if (!SectionsOrErr)
767
0
    return relocation_iterator(RelocationRef());
768
3.04k
  uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
769
3.04k
  RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
770
3.04k
  RelData.d.b = 0;
771
3.04k
  return relocation_iterator(RelocationRef(RelData, this));
772
3.04k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::section_rel_begin(llvm::object::DataRefImpl) const
Line
Count
Source
763
174
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
764
174
  DataRefImpl RelData;
765
174
  auto SectionsOrErr = EF.sections();
766
174
  if (!SectionsOrErr)
767
0
    return relocation_iterator(RelocationRef());
768
174
  uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
769
174
  RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
770
174
  RelData.d.b = 0;
771
174
  return relocation_iterator(RelocationRef(RelData, this));
772
174
}
773
774
template <class ELFT>
775
relocation_iterator
776
2.09k
ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
777
2.09k
  const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
778
2.09k
  relocation_iterator Begin = section_rel_begin(Sec);
779
2.09k
  if (S->sh_type != ELF::SHT_RELA && 
S->sh_type != ELF::SHT_REL652
)
780
361
    return Begin;
781
1.73k
  DataRefImpl RelData = Begin->getRawDataRefImpl();
782
1.73k
  const Elf_Shdr *RelSec = getRelSection(RelData);
783
1.73k
784
1.73k
  // Error check sh_link here so that getRelocationSymbol can just use it.
785
1.73k
  auto SymSecOrErr = EF.getSection(RelSec->sh_link);
786
1.73k
  if (!SymSecOrErr)
787
0
    report_fatal_error(errorToErrorCode(SymSecOrErr.takeError()).message());
788
1.73k
789
1.73k
  RelData.d.b += S->sh_size / S->sh_entsize;
790
1.73k
  return relocation_iterator(RelocationRef(RelData, this));
791
1.73k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::section_rel_end(llvm::object::DataRefImpl) const
Line
Count
Source
776
398
ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
777
398
  const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
778
398
  relocation_iterator Begin = section_rel_begin(Sec);
779
398
  if (S->sh_type != ELF::SHT_RELA && 
S->sh_type != ELF::SHT_REL357
)
780
131
    return Begin;
781
267
  DataRefImpl RelData = Begin->getRawDataRefImpl();
782
267
  const Elf_Shdr *RelSec = getRelSection(RelData);
783
267
784
267
  // Error check sh_link here so that getRelocationSymbol can just use it.
785
267
  auto SymSecOrErr = EF.getSection(RelSec->sh_link);
786
267
  if (!SymSecOrErr)
787
0
    report_fatal_error(errorToErrorCode(SymSecOrErr.takeError()).message());
788
267
789
267
  RelData.d.b += S->sh_size / S->sh_entsize;
790
267
  return relocation_iterator(RelocationRef(RelData, this));
791
267
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::section_rel_end(llvm::object::DataRefImpl) const
Line
Count
Source
776
86
ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
777
86
  const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
778
86
  relocation_iterator Begin = section_rel_begin(Sec);
779
86
  if (S->sh_type != ELF::SHT_RELA && 
S->sh_type != ELF::SHT_REL63
)
780
12
    return Begin;
781
74
  DataRefImpl RelData = Begin->getRawDataRefImpl();
782
74
  const Elf_Shdr *RelSec = getRelSection(RelData);
783
74
784
74
  // Error check sh_link here so that getRelocationSymbol can just use it.
785
74
  auto SymSecOrErr = EF.getSection(RelSec->sh_link);
786
74
  if (!SymSecOrErr)
787
0
    report_fatal_error(errorToErrorCode(SymSecOrErr.takeError()).message());
788
74
789
74
  RelData.d.b += S->sh_size / S->sh_entsize;
790
74
  return relocation_iterator(RelocationRef(RelData, this));
791
74
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::section_rel_end(llvm::object::DataRefImpl) const
Line
Count
Source
776
1.52k
ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
777
1.52k
  const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
778
1.52k
  relocation_iterator Begin = section_rel_begin(Sec);
779
1.52k
  if (S->sh_type != ELF::SHT_RELA && 
S->sh_type != ELF::SHT_REL216
)
780
206
    return Begin;
781
1.31k
  DataRefImpl RelData = Begin->getRawDataRefImpl();
782
1.31k
  const Elf_Shdr *RelSec = getRelSection(RelData);
783
1.31k
784
1.31k
  // Error check sh_link here so that getRelocationSymbol can just use it.
785
1.31k
  auto SymSecOrErr = EF.getSection(RelSec->sh_link);
786
1.31k
  if (!SymSecOrErr)
787
0
    report_fatal_error(errorToErrorCode(SymSecOrErr.takeError()).message());
788
1.31k
789
1.31k
  RelData.d.b += S->sh_size / S->sh_entsize;
790
1.31k
  return relocation_iterator(RelocationRef(RelData, this));
791
1.31k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::section_rel_end(llvm::object::DataRefImpl) const
Line
Count
Source
776
87
ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
777
87
  const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
778
87
  relocation_iterator Begin = section_rel_begin(Sec);
779
87
  if (S->sh_type != ELF::SHT_RELA && 
S->sh_type != ELF::SHT_REL16
)
780
12
    return Begin;
781
75
  DataRefImpl RelData = Begin->getRawDataRefImpl();
782
75
  const Elf_Shdr *RelSec = getRelSection(RelData);
783
75
784
75
  // Error check sh_link here so that getRelocationSymbol can just use it.
785
75
  auto SymSecOrErr = EF.getSection(RelSec->sh_link);
786
75
  if (!SymSecOrErr)
787
0
    report_fatal_error(errorToErrorCode(SymSecOrErr.takeError()).message());
788
75
789
75
  RelData.d.b += S->sh_size / S->sh_entsize;
790
75
  return relocation_iterator(RelocationRef(RelData, this));
791
75
}
792
793
template <class ELFT>
794
section_iterator
795
20.4k
ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const {
796
20.4k
  if (EF.getHeader()->e_type != ELF::ET_REL)
797
7.08k
    return section_end();
798
13.4k
799
13.4k
  const Elf_Shdr *EShdr = getSection(Sec);
800
13.4k
  uintX_t Type = EShdr->sh_type;
801
13.4k
  if (Type != ELF::SHT_REL && 
Type != ELF::SHT_RELA13.0k
)
802
11.3k
    return section_end();
803
2.02k
804
2.02k
  auto R = EF.getSection(EShdr->sh_info);
805
2.02k
  if (!R)
806
0
    report_fatal_error(errorToErrorCode(R.takeError()).message());
807
2.02k
  return section_iterator(SectionRef(toDRI(*R), this));
808
2.02k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocatedSection(llvm::object::DataRefImpl) const
Line
Count
Source
795
4.03k
ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const {
796
4.03k
  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.37k
ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const {
796
1.37k
  if (EF.getHeader()->e_type != ELF::ET_REL)
797
591
    return section_end();
798
784
799
784
  const Elf_Shdr *EShdr = getSection(Sec);
800
784
  uintX_t Type = EShdr->sh_type;
801
784
  if (Type != ELF::SHT_REL && 
Type != ELF::SHT_RELA699
)
802
658
    return section_end();
803
126
804
126
  auto R = EF.getSection(EShdr->sh_info);
805
126
  if (!R)
806
0
    report_fatal_error(errorToErrorCode(R.takeError()).message());
807
126
  return section_iterator(SectionRef(toDRI(*R), this));
808
126
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocatedSection(llvm::object::DataRefImpl) const
Line
Count
Source
795
13.9k
ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const {
796
13.9k
  if (EF.getHeader()->e_type != ELF::ET_REL)
797
4.22k
    return section_end();
798
9.74k
799
9.74k
  const Elf_Shdr *EShdr = getSection(Sec);
800
9.74k
  uintX_t Type = EShdr->sh_type;
801
9.74k
  if (Type != ELF::SHT_REL && 
Type != ELF::SHT_RELA9.73k
)
802
8.28k
    return section_end();
803
1.46k
804
1.46k
  auto R = EF.getSection(EShdr->sh_info);
805
1.46k
  if (!R)
806
0
    report_fatal_error(errorToErrorCode(R.takeError()).message());
807
1.46k
  return section_iterator(SectionRef(toDRI(*R), this));
808
1.46k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocatedSection(llvm::object::DataRefImpl) const
Line
Count
Source
795
1.11k
ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const {
796
1.11k
  if (EF.getHeader()->e_type != ELF::ET_REL)
797
488
    return section_end();
798
629
799
629
  const Elf_Shdr *EShdr = getSection(Sec);
800
629
  uintX_t Type = EShdr->sh_type;
801
629
  if (Type != ELF::SHT_REL && 
Type != ELF::SHT_RELA622
)
802
513
    return section_end();
803
116
804
116
  auto R = EF.getSection(EShdr->sh_info);
805
116
  if (!R)
806
0
    report_fatal_error(errorToErrorCode(R.takeError()).message());
807
116
  return section_iterator(SectionRef(toDRI(*R), this));
808
116
}
809
810
// Relocations
811
template <class ELFT>
812
5.92k
void ELFObjectFile<ELFT>::moveRelocationNext(DataRefImpl &Rel) const {
813
5.92k
  ++Rel.d.b;
814
5.92k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::moveRelocationNext(llvm::object::DataRefImpl&) const
Line
Count
Source
812
713
void ELFObjectFile<ELFT>::moveRelocationNext(DataRefImpl &Rel) const {
813
713
  ++Rel.d.b;
814
713
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::moveRelocationNext(llvm::object::DataRefImpl&) const
Line
Count
Source
812
251
void ELFObjectFile<ELFT>::moveRelocationNext(DataRefImpl &Rel) const {
813
251
  ++Rel.d.b;
814
251
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::moveRelocationNext(llvm::object::DataRefImpl&) const
Line
Count
Source
812
4.72k
void ELFObjectFile<ELFT>::moveRelocationNext(DataRefImpl &Rel) const {
813
4.72k
  ++Rel.d.b;
814
4.72k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::moveRelocationNext(llvm::object::DataRefImpl&) const
Line
Count
Source
812
234
void ELFObjectFile<ELFT>::moveRelocationNext(DataRefImpl &Rel) const {
813
234
  ++Rel.d.b;
814
234
}
815
816
template <class ELFT>
817
symbol_iterator
818
5.47k
ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
819
5.47k
  uint32_t symbolIdx;
820
5.47k
  const Elf_Shdr *sec = getRelSection(Rel);
821
5.47k
  if (sec->sh_type == ELF::SHT_REL)
822
691
    symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL());
823
4.78k
  else
824
4.78k
    symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL());
825
5.47k
  if (!symbolIdx)
826
27
    return symbol_end();
827
5.44k
828
5.44k
  // FIXME: error check symbolIdx
829
5.44k
  DataRefImpl SymbolData;
830
5.44k
  SymbolData.d.a = sec->sh_link;
831
5.44k
  SymbolData.d.b = symbolIdx;
832
5.44k
  return symbol_iterator(SymbolRef(SymbolData, this));
833
5.44k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
818
663
ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
819
663
  uint32_t symbolIdx;
820
663
  const Elf_Shdr *sec = getRelSection(Rel);
821
663
  if (sec->sh_type == ELF::SHT_REL)
822
497
    symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL());
823
166
  else
824
166
    symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL());
825
663
  if (!symbolIdx)
826
0
    return symbol_end();
827
663
828
663
  // FIXME: error check symbolIdx
829
663
  DataRefImpl SymbolData;
830
663
  SymbolData.d.a = sec->sh_link;
831
663
  SymbolData.d.b = symbolIdx;
832
663
  return symbol_iterator(SymbolRef(SymbolData, this));
833
663
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
818
220
ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
819
220
  uint32_t symbolIdx;
820
220
  const Elf_Shdr *sec = getRelSection(Rel);
821
220
  if (sec->sh_type == ELF::SHT_REL)
822
158
    symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL());
823
62
  else
824
62
    symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL());
825
220
  if (!symbolIdx)
826
0
    return symbol_end();
827
220
828
220
  // FIXME: error check symbolIdx
829
220
  DataRefImpl SymbolData;
830
220
  SymbolData.d.a = sec->sh_link;
831
220
  SymbolData.d.b = symbolIdx;
832
220
  return symbol_iterator(SymbolRef(SymbolData, this));
833
220
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
818
4.39k
ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
819
4.39k
  uint32_t symbolIdx;
820
4.39k
  const Elf_Shdr *sec = getRelSection(Rel);
821
4.39k
  if (sec->sh_type == ELF::SHT_REL)
822
20
    symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL());
823
4.37k
  else
824
4.37k
    symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL());
825
4.39k
  if (!symbolIdx)
826
27
    return symbol_end();
827
4.36k
828
4.36k
  // FIXME: error check symbolIdx
829
4.36k
  DataRefImpl SymbolData;
830
4.36k
  SymbolData.d.a = sec->sh_link;
831
4.36k
  SymbolData.d.b = symbolIdx;
832
4.36k
  return symbol_iterator(SymbolRef(SymbolData, this));
833
4.36k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
818
194
ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
819
194
  uint32_t symbolIdx;
820
194
  const Elf_Shdr *sec = getRelSection(Rel);
821
194
  if (sec->sh_type == ELF::SHT_REL)
822
16
    symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL());
823
178
  else
824
178
    symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL());
825
194
  if (!symbolIdx)
826
0
    return symbol_end();
827
194
828
194
  // FIXME: error check symbolIdx
829
194
  DataRefImpl SymbolData;
830
194
  SymbolData.d.a = sec->sh_link;
831
194
  SymbolData.d.b = symbolIdx;
832
194
  return symbol_iterator(SymbolRef(SymbolData, this));
833
194
}
834
835
template <class ELFT>
836
6.12k
uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const {
837
6.12k
  const Elf_Shdr *sec = getRelSection(Rel);
838
6.12k
  if (sec->sh_type == ELF::SHT_REL)
839
959
    return getRel(Rel)->r_offset;
840
5.16k
841
5.16k
  return getRela(Rel)->r_offset;
842
5.16k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationOffset(llvm::object::DataRefImpl) const
Line
Count
Source
836
869
uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const {
837
869
  const Elf_Shdr *sec = getRelSection(Rel);
838
869
  if (sec->sh_type == ELF::SHT_REL)
839
654
    return getRel(Rel)->r_offset;
840
215
841
215
  return getRela(Rel)->r_offset;
842
215
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationOffset(llvm::object::DataRefImpl) const
Line
Count
Source
836
450
uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const {
837
450
  const Elf_Shdr *sec = getRelSection(Rel);
838
450
  if (sec->sh_type == ELF::SHT_REL)
839
252
    return getRel(Rel)->r_offset;
840
198
841
198
  return getRela(Rel)->r_offset;
842
198
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationOffset(llvm::object::DataRefImpl) const
Line
Count
Source
836
4.46k
uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const {
837
4.46k
  const Elf_Shdr *sec = getRelSection(Rel);
838
4.46k
  if (sec->sh_type == ELF::SHT_REL)
839
37
    return getRel(Rel)->r_offset;
840
4.42k
841
4.42k
  return getRela(Rel)->r_offset;
842
4.42k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationOffset(llvm::object::DataRefImpl) const
Line
Count
Source
836
348
uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const {
837
348
  const Elf_Shdr *sec = getRelSection(Rel);
838
348
  if (sec->sh_type == ELF::SHT_REL)
839
16
    return getRel(Rel)->r_offset;
840
332
841
332
  return getRela(Rel)->r_offset;
842
332
}
843
844
template <class ELFT>
845
5.76k
uint64_t ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel) const {
846
5.76k
  const Elf_Shdr *sec = getRelSection(Rel);
847
5.76k
  if (sec->sh_type == ELF::SHT_REL)
848
705
    return getRel(Rel)->getType(EF.isMips64EL());
849
5.06k
  else
850
5.06k
    return getRela(Rel)->getType(EF.isMips64EL());
851
5.76k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationType(llvm::object::DataRefImpl) const
Line
Count
Source
845
686
uint64_t ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel) const {
846
686
  const Elf_Shdr *sec = getRelSection(Rel);
847
686
  if (sec->sh_type == ELF::SHT_REL)
848
511
    return getRel(Rel)->getType(EF.isMips64EL());
849
175
  else
850
175
    return getRela(Rel)->getType(EF.isMips64EL());
851
686
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationType(llvm::object::DataRefImpl) const
Line
Count
Source
845
220
uint64_t ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel) const {
846
220
  const Elf_Shdr *sec = getRelSection(Rel);
847
220
  if (sec->sh_type == ELF::SHT_REL)
848
158
    return getRel(Rel)->getType(EF.isMips64EL());
849
62
  else
850
62
    return getRela(Rel)->getType(EF.isMips64EL());
851
220
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationType(llvm::object::DataRefImpl) const
Line
Count
Source
845
4.66k
uint64_t ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel) const {
846
4.66k
  const Elf_Shdr *sec = getRelSection(Rel);
847
4.66k
  if (sec->sh_type == ELF::SHT_REL)
848
20
    return getRel(Rel)->getType(EF.isMips64EL());
849
4.64k
  else
850
4.64k
    return getRela(Rel)->getType(EF.isMips64EL());
851
4.66k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationType(llvm::object::DataRefImpl) const
Line
Count
Source
845
194
uint64_t ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel) const {
846
194
  const Elf_Shdr *sec = getRelSection(Rel);
847
194
  if (sec->sh_type == ELF::SHT_REL)
848
16
    return getRel(Rel)->getType(EF.isMips64EL());
849
178
  else
850
178
    return getRela(Rel)->getType(EF.isMips64EL());
851
194
}
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
814
    DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
861
814
  uint32_t type = getRelocationType(Rel);
862
814
  EF.getRelocationTypeName(type, Result);
863
814
}
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
429
    DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
861
429
  uint32_t type = getRelocationType(Rel);
862
429
  EF.getRelocationTypeName(type, Result);
863
429
}
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.14k
ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel) const {
868
4.14k
  if (getRelSection(Rel)->sh_type != ELF::SHT_RELA)
869
41
    return createError("Section is not SHT_RELA");
870
4.10k
  return (int64_t)getRela(Rel)->r_addend;
871
4.10k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationAddend(llvm::object::DataRefImpl) const
Line
Count
Source
867
63
ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel) const {
868
63
  if (getRelSection(Rel)->sh_type != ELF::SHT_RELA)
869
21
    return createError("Section is not SHT_RELA");
870
42
  return (int64_t)getRela(Rel)->r_addend;
871
42
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationAddend(llvm::object::DataRefImpl) const
Line
Count
Source
867
43
ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel) const {
868
43
  if (getRelSection(Rel)->sh_type != ELF::SHT_RELA)
869
19
    return createError("Section is not SHT_RELA");
870
24
  return (int64_t)getRela(Rel)->r_addend;
871
24
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationAddend(llvm::object::DataRefImpl) const
Line
Count
Source
867
3.90k
ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel) const {
868
3.90k
  if (getRelSection(Rel)->sh_type != ELF::SHT_RELA)
869
1
    return createError("Section is not SHT_RELA");
870
3.90k
  return (int64_t)getRela(Rel)->r_addend;
871
3.90k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationAddend(llvm::object::DataRefImpl) const
Line
Count
Source
867
134
ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel) const {
868
134
  if (getRelSection(Rel)->sh_type != ELF::SHT_RELA)
869
0
    return createError("Section is not SHT_RELA");
870
134
  return (int64_t)getRela(Rel)->r_addend;
871
134
}
872
873
template <class ELFT>
874
const typename ELFObjectFile<ELFT>::Elf_Rel *
875
2.35k
ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const {
876
2.35k
  assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
877
2.35k
  auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
878
2.35k
  if (!Ret)
879
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
880
2.35k
  return *Ret;
881
2.35k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRel(llvm::object::DataRefImpl) const
Line
Count
Source
875
1.66k
ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const {
876
1.66k
  assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
877
1.66k
  auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
878
1.66k
  if (!Ret)
879
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
880
1.66k
  return *Ret;
881
1.66k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRel(llvm::object::DataRefImpl) const
Line
Count
Source
875
568
ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const {
876
568
  assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
877
568
  auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
878
568
  if (!Ret)
879
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
880
568
  return *Ret;
881
568
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRel(llvm::object::DataRefImpl) const
Line
Count
Source
875
77
ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const {
876
77
  assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
877
77
  auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
878
77
  if (!Ret)
879
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
880
77
  return *Ret;
881
77
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRel(llvm::object::DataRefImpl) const
Line
Count
Source
875
48
ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const {
876
48
  assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
877
48
  auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
878
48
  if (!Ret)
879
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
880
48
  return *Ret;
881
48
}
882
883
template <class ELFT>
884
const typename ELFObjectFile<ELFT>::Elf_Rela *
885
19.7k
ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
886
19.7k
  assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
887
19.7k
  auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
888
19.7k
  if (!Ret)
889
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
890
19.7k
  return *Ret;
891
19.7k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRela(llvm::object::DataRefImpl) const
Line
Count
Source
885
713
ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
886
713
  assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
887
713
  auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
888
713
  if (!Ret)
889
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
890
713
  return *Ret;
891
713
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRela(llvm::object::DataRefImpl) const
Line
Count
Source
885
384
ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
886
384
  assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
887
384
  auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
888
384
  if (!Ret)
889
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
890
384
  return *Ret;
891
384
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRela(llvm::object::DataRefImpl) const
Line
Count
Source
885
17.7k
ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
886
17.7k
  assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
887
17.7k
  auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
888
17.7k
  if (!Ret)
889
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
890
17.7k
  return *Ret;
891
17.7k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRela(llvm::object::DataRefImpl) const
Line
Count
Source
885
866
ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
886
866
  assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
887
866
  auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
888
866
  if (!Ret)
889
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
890
866
  return *Ret;
891
866
}
892
893
template <class ELFT>
894
Expected<ELFObjectFile<ELFT>>
895
5.32k
ELFObjectFile<ELFT>::create(MemoryBufferRef Object) {
896
5.32k
  auto EFOrErr = ELFFile<ELFT>::create(Object.getBuffer());
897
5.32k
  if (Error E = EFOrErr.takeError())
898
1
    return std::move(E);
899
5.32k
  auto EF = std::move(*EFOrErr);
900
5.32k
901
5.32k
  auto SectionsOrErr = EF.sections();
902
5.32k
  if (!SectionsOrErr)
903
3
    return SectionsOrErr.takeError();
904
5.32k
905
5.32k
  const Elf_Shdr *DotDynSymSec = nullptr;
906
5.32k
  const Elf_Shdr *DotSymtabSec = nullptr;
907
5.32k
  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.02k
      if (DotDynSymSec)
912
0
        return createError("More than one dynamic symbol table!");
913
1.02k
      DotDynSymSec = &Sec;
914
1.02k
      break;
915
1.02k
    }
916
5.24k
    case ELF::SHT_SYMTAB: {
917
5.24k
      if (DotSymtabSec)
918
0
        return createError("More than one static symbol table!");
919
5.24k
      DotSymtabSec = &Sec;
920
5.24k
      break;
921
5.24k
    }
922
5.24k
    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.32k
  return ELFObjectFile<ELFT>(Object, EF, DotDynSymSec, DotSymtabSec,
932
5.31k
                             ShndxTable);
933
5.32k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::create(llvm::MemoryBufferRef)
Line
Count
Source
895
1.11k
ELFObjectFile<ELFT>::create(MemoryBufferRef Object) {
896
1.11k
  auto EFOrErr = ELFFile<ELFT>::create(Object.getBuffer());
897
1.11k
  if (Error E = EFOrErr.takeError())
898
1
    return std::move(E);
899
1.10k
  auto EF = std::move(*EFOrErr);
900
1.10k
901
1.10k
  auto SectionsOrErr = EF.sections();
902
1.10k
  if (!SectionsOrErr)
903
0
    return SectionsOrErr.takeError();
904
1.10k
905
1.10k
  const Elf_Shdr *DotDynSymSec = nullptr;
906
1.10k
  const Elf_Shdr *DotSymtabSec = nullptr;
907
1.10k
  ArrayRef<Elf_Word> ShndxTable;
908
9.95k
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
909
9.95k
    switch (Sec.sh_type) {
910
9.95k
    case ELF::SHT_DYNSYM: {
911
182
      if (DotDynSymSec)
912
0
        return createError("More than one dynamic symbol table!");
913
182
      DotDynSymSec = &Sec;
914
182
      break;
915
182
    }
916
1.10k
    case ELF::SHT_SYMTAB: {
917
1.10k
      if (DotSymtabSec)
918
0
        return createError("More than one static symbol table!");
919
1.10k
      DotSymtabSec = &Sec;
920
1.10k
      break;
921
1.10k
    }
922
1.10k
    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
9.95k
    }
930
9.95k
  }
931
1.10k
  return ELFObjectFile<ELFT>(Object, EF, DotDynSymSec, DotSymtabSec,
932
1.10k
                             ShndxTable);
933
1.10k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::create(llvm::MemoryBufferRef)
Line
Count
Source
895
276
ELFObjectFile<ELFT>::create(MemoryBufferRef Object) {
896
276
  auto EFOrErr = ELFFile<ELFT>::create(Object.getBuffer());
897
276
  if (Error E = EFOrErr.takeError())
898
0
    return std::move(E);
899
276
  auto EF = std::move(*EFOrErr);
900
276
901
276
  auto SectionsOrErr = EF.sections();
902
276
  if (!SectionsOrErr)
903
0
    return SectionsOrErr.takeError();
904
276
905
276
  const Elf_Shdr *DotDynSymSec = nullptr;
906
276
  const Elf_Shdr *DotSymtabSec = nullptr;
907
276
  ArrayRef<Elf_Word> ShndxTable;
908
3.22k
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
909
3.22k
    switch (Sec.sh_type) {
910
3.22k
    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
276
    case ELF::SHT_SYMTAB: {
917
276
      if (DotSymtabSec)
918
0
        return createError("More than one static symbol table!");
919
276
      DotSymtabSec = &Sec;
920
276
      break;
921
276
    }
922
276
    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.22k
    }
930
3.22k
  }
931
276
  return ELFObjectFile<ELFT>(Object, EF, DotDynSymSec, DotSymtabSec,
932
276
                             ShndxTable);
933
276
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::create(llvm::MemoryBufferRef)
Line
Count
Source
895
3.71k
ELFObjectFile<ELFT>::create(MemoryBufferRef Object) {
896
3.71k
  auto EFOrErr = ELFFile<ELFT>::create(Object.getBuffer());
897
3.71k
  if (Error E = EFOrErr.takeError())
898
0
    return std::move(E);
899
3.71k
  auto EF = std::move(*EFOrErr);
900
3.71k
901
3.71k
  auto SectionsOrErr = EF.sections();
902
3.71k
  if (!SectionsOrErr)
903
3
    return SectionsOrErr.takeError();
904
3.70k
905
3.70k
  const Elf_Shdr *DotDynSymSec = nullptr;
906
3.70k
  const Elf_Shdr *DotSymtabSec = nullptr;
907
3.70k
  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
714
      if (DotDynSymSec)
912
0
        return createError("More than one dynamic symbol table!");
913
714
      DotDynSymSec = &Sec;
914
714
      break;
915
714
    }
916
3.64k
    case ELF::SHT_SYMTAB: {
917
3.64k
      if (DotSymtabSec)
918
0
        return createError("More than one static symbol table!");
919
3.64k
      DotSymtabSec = &Sec;
920
3.64k
      break;
921
3.64k
    }
922
3.64k
    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.70k
  return ELFObjectFile<ELFT>(Object, EF, DotDynSymSec, DotSymtabSec,
932
3.70k
                             ShndxTable);
933
3.70k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::create(llvm::MemoryBufferRef)
Line
Count
Source
895
226
ELFObjectFile<ELFT>::create(MemoryBufferRef Object) {
896
226
  auto EFOrErr = ELFFile<ELFT>::create(Object.getBuffer());
897
226
  if (Error E = EFOrErr.takeError())
898
0
    return std::move(E);
899
226
  auto EF = std::move(*EFOrErr);
900
226
901
226
  auto SectionsOrErr = EF.sections();
902
226
  if (!SectionsOrErr)
903
0
    return SectionsOrErr.takeError();
904
226
905
226
  const Elf_Shdr *DotDynSymSec = nullptr;
906
226
  const Elf_Shdr *DotSymtabSec = nullptr;
907
226
  ArrayRef<Elf_Word> ShndxTable;
908
2.43k
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
909
2.43k
    switch (Sec.sh_type) {
910
2.43k
    case ELF::SHT_DYNSYM: {
911
55
      if (DotDynSymSec)
912
0
        return createError("More than one dynamic symbol table!");
913
55
      DotDynSymSec = &Sec;
914
55
      break;
915
55
    }
916
225
    case ELF::SHT_SYMTAB: {
917
225
      if (DotSymtabSec)
918
0
        return createError("More than one static symbol table!");
919
225
      DotSymtabSec = &Sec;
920
225
      break;
921
225
    }
922
225
    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.43k
    }
930
2.43k
  }
931
226
  return ELFObjectFile<ELFT>(Object, EF, DotDynSymSec, DotSymtabSec,
932
226
                             ShndxTable);
933
226
}
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
15.9k
      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.32k
      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
828
      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.1k
      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
678
      ShndxTable(ShndxTable) {}
945
946
template <class ELFT>
947
ELFObjectFile<ELFT>::ELFObjectFile(ELFObjectFile<ELFT> &&Other)
948
    : ELFObjectFile(Other.Data, Other.EF, Other.DotDynSymSec,
949
10.6k
                    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.21k
                    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
552
                    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.41k
                    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
452
                    Other.DotSymtabSec, Other.ShndxTable) {}
950
951
template <class ELFT>
952
2.03k
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin() const {
953
2.03k
  DataRefImpl Sym = toDRI(DotSymtabSec, 0);
954
2.03k
  return basic_symbol_iterator(SymbolRef(Sym, this));
955
2.03k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::symbol_begin() const
Line
Count
Source
952
455
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin() const {
953
455
  DataRefImpl Sym = toDRI(DotSymtabSec, 0);
954
455
  return basic_symbol_iterator(SymbolRef(Sym, this));
955
455
}
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.39k
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin() const {
953
1.39k
  DataRefImpl Sym = toDRI(DotSymtabSec, 0);
954
1.39k
  return basic_symbol_iterator(SymbolRef(Sym, this));
955
1.39k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::symbol_begin() const
Line
Count
Source
952
73
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin() const {
953
73
  DataRefImpl Sym = toDRI(DotSymtabSec, 0);
954
73
  return basic_symbol_iterator(SymbolRef(Sym, this));
955
73
}
956
957
template <class ELFT>
958
7.09k
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
959
7.09k
  const Elf_Shdr *SymTab = DotSymtabSec;
960
7.09k
  if (!SymTab)
961
5
    return symbol_begin();
962
7.08k
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
963
7.08k
  return basic_symbol_iterator(SymbolRef(Sym, this));
964
7.08k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::symbol_end() const
Line
Count
Source
958
877
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
959
877
  const Elf_Shdr *SymTab = DotSymtabSec;
960
877
  if (!SymTab)
961
1
    return symbol_begin();
962
876
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
963
876
  return basic_symbol_iterator(SymbolRef(Sym, this));
964
876
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::symbol_end() const
Line
Count
Source
958
296
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
959
296
  const Elf_Shdr *SymTab = DotSymtabSec;
960
296
  if (!SymTab)
961
0
    return symbol_begin();
962
296
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
963
296
  return basic_symbol_iterator(SymbolRef(Sym, this));
964
296
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::symbol_end() const
Line
Count
Source
958
5.65k
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
959
5.65k
  const Elf_Shdr *SymTab = DotSymtabSec;
960
5.65k
  if (!SymTab)
961
4
    return symbol_begin();
962
5.65k
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
963
5.65k
  return basic_symbol_iterator(SymbolRef(Sym, this));
964
5.65k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::symbol_end() const
Line
Count
Source
958
263
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
959
263
  const Elf_Shdr *SymTab = DotSymtabSec;
960
263
  if (!SymTab)
961
0
    return symbol_begin();
962
263
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
963
263
  return basic_symbol_iterator(SymbolRef(Sym, this));
964
263
}
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.03k
section_iterator ELFObjectFile<ELFT>::section_begin() const {
983
7.03k
  auto SectionsOrErr = EF.sections();
984
7.03k
  if (!SectionsOrErr)
985
0
    return section_iterator(SectionRef());
986
7.03k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).begin()), this));
987
7.03k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::section_begin() const
Line
Count
Source
982
1.71k
section_iterator ELFObjectFile<ELFT>::section_begin() const {
983
1.71k
  auto SectionsOrErr = EF.sections();
984
1.71k
  if (!SectionsOrErr)
985
0
    return section_iterator(SectionRef());
986
1.71k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).begin()), this));
987
1.71k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::section_begin() const
Line
Count
Source
982
333
section_iterator ELFObjectFile<ELFT>::section_begin() const {
983
333
  auto SectionsOrErr = EF.sections();
984
333
  if (!SectionsOrErr)
985
0
    return section_iterator(SectionRef());
986
333
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).begin()), this));
987
333
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::section_begin() const
Line
Count
Source
982
4.73k
section_iterator ELFObjectFile<ELFT>::section_begin() const {
983
4.73k
  auto SectionsOrErr = EF.sections();
984
4.73k
  if (!SectionsOrErr)
985
0
    return section_iterator(SectionRef());
986
4.73k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).begin()), this));
987
4.73k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::section_begin() const
Line
Count
Source
982
247
section_iterator ELFObjectFile<ELFT>::section_begin() const {
983
247
  auto SectionsOrErr = EF.sections();
984
247
  if (!SectionsOrErr)
985
0
    return section_iterator(SectionRef());
986
247
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).begin()), this));
987
247
}
988
989
template <class ELFT>
990
68.2k
section_iterator ELFObjectFile<ELFT>::section_end() const {
991
68.2k
  auto SectionsOrErr = EF.sections();
992
68.2k
  if (!SectionsOrErr)
993
0
    return section_iterator(SectionRef());
994
68.2k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).end()), this));
995
68.2k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::section_end() const
Line
Count
Source
990
19.1k
section_iterator ELFObjectFile<ELFT>::section_end() const {
991
19.1k
  auto SectionsOrErr = EF.sections();
992
19.1k
  if (!SectionsOrErr)
993
0
    return section_iterator(SectionRef());
994
19.1k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).end()), this));
995
19.1k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::section_end() const
Line
Count
Source
990
3.87k
section_iterator ELFObjectFile<ELFT>::section_end() const {
991
3.87k
  auto SectionsOrErr = EF.sections();
992
3.87k
  if (!SectionsOrErr)
993
0
    return section_iterator(SectionRef());
994
3.87k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).end()), this));
995
3.87k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::section_end() const
Line
Count
Source
990
42.3k
section_iterator ELFObjectFile<ELFT>::section_end() const {
991
42.3k
  auto SectionsOrErr = EF.sections();
992
42.3k
  if (!SectionsOrErr)
993
0
    return section_iterator(SectionRef());
994
42.3k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).end()), this));
995
42.3k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::section_end() const
Line
Count
Source
990
2.84k
section_iterator ELFObjectFile<ELFT>::section_end() const {
991
2.84k
  auto SectionsOrErr = EF.sections();
992
2.84k
  if (!SectionsOrErr)
993
0
    return section_iterator(SectionRef());
994
2.84k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).end()), this));
995
2.84k
}
996
997
template <class ELFT>
998
8.99k
uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
999
8.99k
  return ELFT::Is64Bits ? 
87.00k
:
41.98k
;
1000
8.99k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getBytesInAddress() const
Line
Count
Source
998
1.45k
uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
999
1.45k
  return ELFT::Is64Bits ? 
80
: 4;
1000
1.45k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getBytesInAddress() const
Line
Count
Source
998
536
uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
999
536
  return ELFT::Is64Bits ? 
80
: 4;
1000
536
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getBytesInAddress() const
Line
Count
Source
998
6.67k
uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
999
6.67k
  return ELFT::Is64Bits ? 8 : 
40
;
1000
6.67k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getBytesInAddress() const
Line
Count
Source
998
338
uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
999
338
  return ELFT::Is64Bits ? 8 : 
40
;
1000
338
}
1001
1002
template <class ELFT>
1003
4.25k
StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
1004
4.25k
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1005
4.25k
  switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1006
4.25k
  case ELF::ELFCLASS32:
1007
1.27k
    switch (EF.getHeader()->e_machine) {
1008
1.27k
    case ELF::EM_386:
1009
243
      return "ELF32-i386";
1010
1.27k
    case ELF::EM_IAMCU:
1011
3
      return "ELF32-iamcu";
1012
1.27k
    case ELF::EM_X86_64:
1013
6
      return "ELF32-x86-64";
1014
1.27k
    case ELF::EM_ARM:
1015
448
      return (IsLittleEndian ? 
"ELF32-arm-little"437
:
"ELF32-arm-big"11
);
1016
1.27k
    case ELF::EM_AVR:
1017
0
      return "ELF32-avr";
1018
1.27k
    case ELF::EM_HEXAGON:
1019
114
      return "ELF32-hexagon";
1020
1.27k
    case ELF::EM_LANAI:
1021
4
      return "ELF32-lanai";
1022
1.27k
    case ELF::EM_MIPS:
1023
399
      return "ELF32-mips";
1024
1.27k
    case ELF::EM_PPC:
1025
11
      return "ELF32-ppc";
1026
1.27k
    case ELF::EM_RISCV:
1027
0
      return "ELF32-riscv";
1028
1.27k
    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
2.97k
  case ELF::ELFCLASS64:
1037
2.97k
    switch (EF.getHeader()->e_machine) {
1038
2.97k
    case ELF::EM_386:
1039
0
      return "ELF64-i386";
1040
2.97k
    case ELF::EM_X86_64:
1041
1.73k
      return "ELF64-x86-64";
1042
2.97k
    case ELF::EM_AARCH64:
1043
802
      return (IsLittleEndian ? 
"ELF64-aarch64-little"794
:
"ELF64-aarch64-big"8
);
1044
2.97k
    case ELF::EM_PPC64:
1045
132
      return "ELF64-ppc64";
1046
2.97k
    case ELF::EM_RISCV:
1047
0
      return "ELF64-riscv";
1048
2.97k
    case ELF::EM_S390:
1049
10
      return "ELF64-s390";
1050
2.97k
    case ELF::EM_SPARCV9:
1051
14
      return "ELF64-sparc";
1052
2.97k
    case ELF::EM_MIPS:
1053
152
      return "ELF64-mips";
1054
2.97k
    case ELF::EM_AMDGPU:
1055
109
      return "ELF64-amdgpu";
1056
2.97k
    case ELF::EM_BPF:
1057
17
      return "ELF64-BPF";
1058
2.97k
    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.25k
  }
1065
4.25k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getFileFormatName() const
Line
Count
Source
1003
1.00k
StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
1004
1.00k
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1005
1.00k
  switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1006
1.00k
  case ELF::ELFCLASS32:
1007
1.00k
    switch (EF.getHeader()->e_machine) {
1008
1.00k
    case ELF::EM_386:
1009
243
      return "ELF32-i386";
1010
1.00k
    case ELF::EM_IAMCU:
1011
3
      return "ELF32-iamcu";
1012
1.00k
    case ELF::EM_X86_64:
1013
5
      return "ELF32-x86-64";
1014
1.00k
    case ELF::EM_ARM:
1015
437
      return (IsLittleEndian ? "ELF32-arm-little" : 
"ELF32-arm-big"0
);
1016
1.00k
    case ELF::EM_AVR:
1017
0
      return "ELF32-avr";
1018
1.00k
    case ELF::EM_HEXAGON:
1019
114
      return "ELF32-hexagon";
1020
1.00k
    case ELF::EM_LANAI:
1021
1
      return "ELF32-lanai";
1022
1.00k
    case ELF::EM_MIPS:
1023
162
      return "ELF32-mips";
1024
1.00k
    case ELF::EM_PPC:
1025
0
      return "ELF32-ppc";
1026
1.00k
    case ELF::EM_RISCV:
1027
0
      return "ELF32-riscv";
1028
1.00k
    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.00k
  }
1065
1.00k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getFileFormatName() const
Line
Count
Source
1003
270
StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
1004
270
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1005
270
  switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1006
270
  case ELF::ELFCLASS32:
1007
270
    switch (EF.getHeader()->e_machine) {
1008
270
    case ELF::EM_386:
1009
0
      return "ELF32-i386";
1010
270
    case ELF::EM_IAMCU:
1011
0
      return "ELF32-iamcu";
1012
270
    case ELF::EM_X86_64:
1013
1
      return "ELF32-x86-64";
1014
270
    case ELF::EM_ARM:
1015
11
      return (IsLittleEndian ? 
"ELF32-arm-little"0
: "ELF32-arm-big");
1016
270
    case ELF::EM_AVR:
1017
0
      return "ELF32-avr";
1018
270
    case ELF::EM_HEXAGON:
1019
0
      return "ELF32-hexagon";
1020
270
    case ELF::EM_LANAI:
1021
3
      return "ELF32-lanai";
1022
270
    case ELF::EM_MIPS:
1023
237
      return "ELF32-mips";
1024
270
    case ELF::EM_PPC:
1025
11
      return "ELF32-ppc";
1026
270
    case ELF::EM_RISCV:
1027
0
      return "ELF32-riscv";
1028
270
    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
270
  }
1065
270
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getFileFormatName() const
Line
Count
Source
1003
2.78k
StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
1004
2.78k
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1005
2.78k
  switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1006
2.78k
  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.78k
  case ELF::ELFCLASS64:
1037
2.78k
    switch (EF.getHeader()->e_machine) {
1038
2.78k
    case ELF::EM_386:
1039
0
      return "ELF64-i386";
1040
2.78k
    case ELF::EM_X86_64:
1041
1.73k
      return "ELF64-x86-64";
1042
2.78k
    case ELF::EM_AARCH64:
1043
794
      return (IsLittleEndian ? "ELF64-aarch64-little" : 
"ELF64-aarch64-big"0
);
1044
2.78k
    case ELF::EM_PPC64:
1045
61
      return "ELF64-ppc64";
1046
2.78k
    case ELF::EM_RISCV:
1047
0
      return "ELF64-riscv";
1048
2.78k
    case ELF::EM_S390:
1049
0
      return "ELF64-s390";
1050
2.78k
    case ELF::EM_SPARCV9:
1051
0
      return "ELF64-sparc";
1052
2.78k
    case ELF::EM_MIPS:
1053
66
      return "ELF64-mips";
1054
2.78k
    case ELF::EM_AMDGPU:
1055
109
      return "ELF64-amdgpu";
1056
2.78k
    case ELF::EM_BPF:
1057
15
      return "ELF64-BPF";
1058
2.78k
    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.78k
  }
1065
2.78k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getFileFormatName() const
Line
Count
Source
1003
193
StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
1004
193
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1005
193
  switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1006
193
  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
193
  case ELF::ELFCLASS64:
1037
193
    switch (EF.getHeader()->e_machine) {
1038
193
    case ELF::EM_386:
1039
0
      return "ELF64-i386";
1040
193
    case ELF::EM_X86_64:
1041
2
      return "ELF64-x86-64";
1042
193
    case ELF::EM_AARCH64:
1043
8
      return (IsLittleEndian ? 
"ELF64-aarch64-little"0
: "ELF64-aarch64-big");
1044
193
    case ELF::EM_PPC64:
1045
71
      return "ELF64-ppc64";
1046
193
    case ELF::EM_RISCV:
1047
0
      return "ELF64-riscv";
1048
193
    case ELF::EM_S390:
1049
10
      return "ELF64-s390";
1050
193
    case ELF::EM_SPARCV9:
1051
14
      return "ELF64-sparc";
1052
193
    case ELF::EM_MIPS:
1053
86
      return "ELF64-mips";
1054
193
    case ELF::EM_AMDGPU:
1055
0
      return "ELF64-amdgpu";
1056
193
    case ELF::EM_BPF:
1057
2
      return "ELF64-BPF";
1058
193
    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
193
  }
1065
193
}
1066
1067
31.4M
template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::getArch() const {
1068
31.4M
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1069
31.4M
  switch (EF.getHeader()->e_machine) {
1070
31.4M
  case ELF::EM_386:
1071
126k
  case ELF::EM_IAMCU:
1072
126k
    return Triple::x86;
1073
126k
  case ELF::EM_X86_64:
1074
28.8k
    return Triple::x86_64;
1075
249k
  case ELF::EM_AARCH64:
1076
249k
    return IsLittleEndian ? 
Triple::aarch64249k
:
Triple::aarch64_be46
;
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.5k
    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.45k
      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
264
  case ELF::EM_S390:
1108
264
    return Triple::systemz;
1109
0
1110
192
  case ELF::EM_SPARC:
1111
192
  case ELF::EM_SPARC32PLUS:
1112
192
    return IsLittleEndian ? 
Triple::sparcel26
:
Triple::sparc166
;
1113
197
  case ELF::EM_SPARCV9:
1114
197
    return Triple::sparcv9;
1115
192
1116
2.82k
  case ELF::EM_AMDGPU: {
1117
2.82k
    if (!IsLittleEndian)
1118
0
      return Triple::UnknownArch;
1119
2.82k
1120
2.82k
    unsigned MACH = EF.getHeader()->e_flags & ELF::EF_AMDGPU_MACH;
1121
2.82k
    if (MACH >= ELF::EF_AMDGPU_MACH_R600_FIRST &&
1122
2.82k
        
MACH <= ELF::EF_AMDGPU_MACH_R600_LAST2.78k
)
1123
105
      return Triple::r600;
1124
2.71k
    if (MACH >= ELF::EF_AMDGPU_MACH_AMDGCN_FIRST &&
1125
2.71k
        
MACH <= ELF::EF_AMDGPU_MACH_AMDGCN_LAST2.67k
)
1126
2.67k
      return Triple::amdgcn;
1127
44
1128
44
    return Triple::UnknownArch;
1129
44
  }
1130
44
1131
2.90k
  case ELF::EM_BPF:
1132
2.90k
    return IsLittleEndian ? 
Triple::bpfel2.51k
:
Triple::bpfeb394
;
1133
44
1134
44
  default:
1135
2
    return Triple::UnknownArch;
1136
31.4M
  }
1137
31.4M
}
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
22
    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.5k
    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
166
  case ELF::EM_SPARC:
1111
166
  case ELF::EM_SPARC32PLUS:
1112
166
    return IsLittleEndian ? 
Triple::sparcel0
: Triple::sparc;
1113
166
  case ELF::EM_SPARCV9:
1114
0
    return Triple::sparcv9;
1115
166
1116
166
  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.4M
template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::getArch() const {
1068
15.4M
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1069
15.4M
  switch (EF.getHeader()->e_machine) {
1070
15.4M
  case ELF::EM_386:
1071
0
  case ELF::EM_IAMCU:
1072
0
    return Triple::x86;
1073
28.7k
  case ELF::EM_X86_64:
1074
28.7k
    return Triple::x86_64;
1075
249k
  case ELF::EM_AARCH64:
1076
249k
    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.71k
  case ELF::EM_AMDGPU: {
1117
2.71k
    if (!IsLittleEndian)
1118
0
      return Triple::UnknownArch;
1119
2.71k
1120
2.71k
    unsigned MACH = EF.getHeader()->e_flags & ELF::EF_AMDGPU_MACH;
1121
2.71k
    if (MACH >= ELF::EF_AMDGPU_MACH_R600_FIRST &&
1122
2.71k
        
MACH <= ELF::EF_AMDGPU_MACH_R600_LAST2.67k
)
1123
0
      return Triple::r600;
1124
2.71k
    if (MACH >= ELF::EF_AMDGPU_MACH_AMDGCN_FIRST &&
1125
2.71k
        
MACH <= ELF::EF_AMDGPU_MACH_AMDGCN_LAST2.67k
)
1126
2.67k
      return Triple::amdgcn;
1127
41
1128
41
    return Triple::UnknownArch;
1129
41
  }
1130
41
1131
2.51k
  case ELF::EM_BPF:
1132
2.51k
    return IsLittleEndian ? Triple::bpfel : 
Triple::bpfeb0
;
1133
41
1134
41
  default:
1135
0
    return Triple::UnknownArch;
1136
15.4M
  }
1137
15.4M
}
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
46
  case ELF::EM_AARCH64:
1076
46
    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
264
  case ELF::EM_S390:
1108
264
    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
197
  case ELF::EM_SPARCV9:
1114
197
    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
394
  case ELF::EM_BPF:
1132
394
    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.52k
template <class ELFT> bool ELFObjectFile<ELFT>::isRelocatableObject() const {
1151
1.52k
  return EF.getHeader()->e_type == ELF::ET_REL;
1152
1.52k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isRelocatableObject() const
Line
Count
Source
1150
745
template <class ELFT> bool ELFObjectFile<ELFT>::isRelocatableObject() const {
1151
745
  return EF.getHeader()->e_type == ELF::ET_REL;
1152
745
}
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
614
template <class ELFT> bool ELFObjectFile<ELFT>::isRelocatableObject() const {
1151
614
  return EF.getHeader()->e_type == ELF::ET_REL;
1152
614
}
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