Coverage Report

Created: 2019-02-20 07:29

/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
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file declares the ELFObjectFile template class.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_OBJECT_ELFOBJECTFILE_H
14
#define LLVM_OBJECT_ELFOBJECTFILE_H
15
16
#include "llvm/ADT/ArrayRef.h"
17
#include "llvm/ADT/STLExtras.h"
18
#include "llvm/ADT/SmallVector.h"
19
#include "llvm/ADT/StringRef.h"
20
#include "llvm/ADT/Triple.h"
21
#include "llvm/ADT/iterator_range.h"
22
#include "llvm/BinaryFormat/ELF.h"
23
#include "llvm/MC/SubtargetFeature.h"
24
#include "llvm/Object/Binary.h"
25
#include "llvm/Object/ELF.h"
26
#include "llvm/Object/ELFTypes.h"
27
#include "llvm/Object/Error.h"
28
#include "llvm/Object/ObjectFile.h"
29
#include "llvm/Object/SymbolicFile.h"
30
#include "llvm/Support/ARMAttributeParser.h"
31
#include "llvm/Support/ARMBuildAttributes.h"
32
#include "llvm/Support/Casting.h"
33
#include "llvm/Support/Endian.h"
34
#include "llvm/Support/Error.h"
35
#include "llvm/Support/ErrorHandling.h"
36
#include "llvm/Support/MemoryBuffer.h"
37
#include <cassert>
38
#include <cstdint>
39
#include <system_error>
40
41
namespace llvm {
42
namespace object {
43
44
class elf_symbol_iterator;
45
46
class ELFObjectFileBase : public ObjectFile {
47
  friend class ELFRelocationRef;
48
  friend class ELFSectionRef;
49
  friend class ELFSymbolRef;
50
51
protected:
52
  ELFObjectFileBase(unsigned int Type, MemoryBufferRef Source);
53
54
  virtual uint16_t getEMachine() const = 0;
55
  virtual uint64_t getSymbolSize(DataRefImpl Symb) const = 0;
56
  virtual uint8_t getSymbolOther(DataRefImpl Symb) const = 0;
57
  virtual uint8_t getSymbolELFType(DataRefImpl Symb) const = 0;
58
59
  virtual uint32_t getSectionType(DataRefImpl Sec) const = 0;
60
  virtual uint64_t getSectionFlags(DataRefImpl Sec) const = 0;
61
  virtual uint64_t getSectionOffset(DataRefImpl Sec) const = 0;
62
63
  virtual Expected<int64_t> getRelocationAddend(DataRefImpl Rel) const = 0;
64
65
public:
66
  using elf_symbol_iterator_range = iterator_range<elf_symbol_iterator>;
67
68
  virtual elf_symbol_iterator_range getDynamicSymbolIterators() const = 0;
69
70
  /// Returns platform-specific object flags, if any.
71
  virtual unsigned getPlatformFlags() const = 0;
72
73
  elf_symbol_iterator_range symbols() const;
74
75
  static bool classof(const Binary *v) { return v->isELF(); }
76
77
  SubtargetFeatures getFeatures() const override;
78
79
  SubtargetFeatures getMIPSFeatures() const;
80
81
  SubtargetFeatures getARMFeatures() const;
82
83
  SubtargetFeatures getRISCVFeatures() const;
84
85
  void setARMSubArch(Triple &TheTriple) const override;
86
87
  virtual uint16_t getEType() const = 0;
88
89
  std::vector<std::pair<DataRefImpl, uint64_t>> getPltAddresses() const;
90
};
91
92
class ELFSectionRef : public SectionRef {
93
public:
94
  ELFSectionRef(const SectionRef &B) : SectionRef(B) {
95
    assert(isa<ELFObjectFileBase>(SectionRef::getObject()));
96
  }
97
98
  const ELFObjectFileBase *getObject() const {
99
    return cast<ELFObjectFileBase>(SectionRef::getObject());
100
  }
101
102
  uint32_t getType() const {
103
    return getObject()->getSectionType(getRawDataRefImpl());
104
  }
105
106
  uint64_t getFlags() const {
107
    return getObject()->getSectionFlags(getRawDataRefImpl());
108
  }
109
110
  uint64_t getOffset() const {
111
    return getObject()->getSectionOffset(getRawDataRefImpl());
112
  }
113
};
114
115
class elf_section_iterator : public section_iterator {
116
public:
117
  elf_section_iterator(const section_iterator &B) : section_iterator(B) {
118
    assert(isa<ELFObjectFileBase>(B->getObject()));
119
  }
120
121
  const ELFSectionRef *operator->() const {
122
    return static_cast<const ELFSectionRef *>(section_iterator::operator->());
123
  }
124
125
  const ELFSectionRef &operator*() const {
126
    return static_cast<const ELFSectionRef &>(section_iterator::operator*());
127
  }
128
};
129
130
class ELFSymbolRef : public SymbolRef {
131
public:
132
  ELFSymbolRef(const SymbolRef &B) : SymbolRef(B) {
133
    assert(isa<ELFObjectFileBase>(SymbolRef::getObject()));
134
  }
135
136
  const ELFObjectFileBase *getObject() const {
137
    return cast<ELFObjectFileBase>(BasicSymbolRef::getObject());
138
  }
139
140
  uint64_t getSize() const {
141
    return getObject()->getSymbolSize(getRawDataRefImpl());
142
  }
143
144
  uint8_t getOther() const {
145
    return getObject()->getSymbolOther(getRawDataRefImpl());
146
  }
147
148
  uint8_t getELFType() const {
149
    return getObject()->getSymbolELFType(getRawDataRefImpl());
150
  }
151
};
152
153
class elf_symbol_iterator : public symbol_iterator {
154
public:
155
  elf_symbol_iterator(const basic_symbol_iterator &B)
156
      : symbol_iterator(SymbolRef(B->getRawDataRefImpl(),
157
1.20k
                                  cast<ELFObjectFileBase>(B->getObject()))) {}
158
159
  const ELFSymbolRef *operator->() const {
160
    return static_cast<const ELFSymbolRef *>(symbol_iterator::operator->());
161
  }
162
163
  const ELFSymbolRef &operator*() const {
164
    return static_cast<const ELFSymbolRef &>(symbol_iterator::operator*());
165
  }
166
};
167
168
class ELFRelocationRef : public RelocationRef {
169
public:
170
  ELFRelocationRef(const RelocationRef &B) : RelocationRef(B) {
171
    assert(isa<ELFObjectFileBase>(RelocationRef::getObject()));
172
  }
173
174
  const ELFObjectFileBase *getObject() const {
175
    return cast<ELFObjectFileBase>(RelocationRef::getObject());
176
  }
177
178
  Expected<int64_t> getAddend() const {
179
    return getObject()->getRelocationAddend(getRawDataRefImpl());
180
  }
181
};
182
183
class elf_relocation_iterator : public relocation_iterator {
184
public:
185
  elf_relocation_iterator(const relocation_iterator &B)
186
      : relocation_iterator(RelocationRef(
187
            B->getRawDataRefImpl(), cast<ELFObjectFileBase>(B->getObject()))) {}
188
189
  const ELFRelocationRef *operator->() const {
190
    return static_cast<const ELFRelocationRef *>(
191
        relocation_iterator::operator->());
192
  }
193
194
  const ELFRelocationRef &operator*() const {
195
    return static_cast<const ELFRelocationRef &>(
196
        relocation_iterator::operator*());
197
  }
198
};
199
200
inline ELFObjectFileBase::elf_symbol_iterator_range
201
ELFObjectFileBase::symbols() const {
202
  return elf_symbol_iterator_range(symbol_begin(), symbol_end());
203
}
204
205
template <class ELFT> class ELFObjectFile : public ELFObjectFileBase {
206
  uint16_t getEMachine() const override;
207
  uint16_t getEType() const override;
208
  uint64_t getSymbolSize(DataRefImpl Sym) const override;
209
210
public:
211
  LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
212
213
  using uintX_t = typename ELFT::uint;
214
215
  using Elf_Sym = typename ELFT::Sym;
216
  using Elf_Shdr = typename ELFT::Shdr;
217
  using Elf_Ehdr = typename ELFT::Ehdr;
218
  using Elf_Rel = typename ELFT::Rel;
219
  using Elf_Rela = typename ELFT::Rela;
220
  using Elf_Dyn = typename ELFT::Dyn;
221
222
private:
223
  ELFObjectFile(MemoryBufferRef Object, ELFFile<ELFT> EF,
224
                const Elf_Shdr *DotDynSymSec, const Elf_Shdr *DotSymtabSec,
225
                ArrayRef<Elf_Word> ShndxTable);
226
227
protected:
228
  ELFFile<ELFT> EF;
229
230
  const Elf_Shdr *DotDynSymSec = nullptr; // Dynamic symbol table section.
231
  const Elf_Shdr *DotSymtabSec = nullptr; // Symbol table section.
232
  ArrayRef<Elf_Word> ShndxTable;
233
234
  void moveSymbolNext(DataRefImpl &Symb) const override;
235
  Expected<StringRef> getSymbolName(DataRefImpl Symb) const override;
236
  Expected<uint64_t> getSymbolAddress(DataRefImpl Symb) const override;
237
  uint64_t getSymbolValueImpl(DataRefImpl Symb) const override;
238
  uint32_t getSymbolAlignment(DataRefImpl Symb) const override;
239
  uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override;
240
  uint32_t getSymbolFlags(DataRefImpl Symb) const override;
241
  uint8_t getSymbolOther(DataRefImpl Symb) const override;
242
  uint8_t getSymbolELFType(DataRefImpl Symb) const override;
243
  Expected<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const override;
244
  Expected<section_iterator> getSymbolSection(const Elf_Sym *Symb,
245
                                              const Elf_Shdr *SymTab) const;
246
  Expected<section_iterator> getSymbolSection(DataRefImpl Symb) const override;
247
248
  void moveSectionNext(DataRefImpl &Sec) const override;
249
  std::error_code getSectionName(DataRefImpl Sec,
250
                                 StringRef &Res) const override;
251
  uint64_t getSectionAddress(DataRefImpl Sec) const override;
252
  uint64_t getSectionIndex(DataRefImpl Sec) const override;
253
  uint64_t getSectionSize(DataRefImpl Sec) const override;
254
  std::error_code getSectionContents(DataRefImpl Sec,
255
                                     StringRef &Res) const override;
256
  uint64_t getSectionAlignment(DataRefImpl Sec) const override;
257
  bool isSectionCompressed(DataRefImpl Sec) const override;
258
  bool isSectionText(DataRefImpl Sec) const override;
259
  bool isSectionData(DataRefImpl Sec) const override;
260
  bool isSectionBSS(DataRefImpl Sec) const override;
261
  bool isSectionVirtual(DataRefImpl Sec) const override;
262
  bool isBerkeleyText(DataRefImpl Sec) const override;
263
  bool isBerkeleyData(DataRefImpl Sec) const override;
264
  relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
265
  relocation_iterator section_rel_end(DataRefImpl Sec) const override;
266
  std::vector<SectionRef> dynamic_relocation_sections() const override;
267
  section_iterator getRelocatedSection(DataRefImpl Sec) const override;
268
269
  void moveRelocationNext(DataRefImpl &Rel) const override;
270
  uint64_t getRelocationOffset(DataRefImpl Rel) const override;
271
  symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
272
  uint64_t getRelocationType(DataRefImpl Rel) const override;
273
  void getRelocationTypeName(DataRefImpl Rel,
274
                             SmallVectorImpl<char> &Result) const override;
275
276
  uint32_t getSectionType(DataRefImpl Sec) const override;
277
  uint64_t getSectionFlags(DataRefImpl Sec) const override;
278
  uint64_t getSectionOffset(DataRefImpl Sec) const override;
279
  StringRef getRelocationTypeName(uint32_t Type) const;
280
281
  /// Get the relocation section that contains \a Rel.
282
27.9k
  const Elf_Shdr *getRelSection(DataRefImpl Rel) const {
283
27.9k
    auto RelSecOrErr = EF.getSection(Rel.d.a);
284
27.9k
    if (!RelSecOrErr)
285
0
      report_fatal_error(errorToErrorCode(RelSecOrErr.takeError()).message());
286
27.9k
    return *RelSecOrErr;
287
27.9k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelSection(llvm::object::DataRefImpl) const
Line
Count
Source
282
2.93k
  const Elf_Shdr *getRelSection(DataRefImpl Rel) const {
283
2.93k
    auto RelSecOrErr = EF.getSection(Rel.d.a);
284
2.93k
    if (!RelSecOrErr)
285
0
      report_fatal_error(errorToErrorCode(RelSecOrErr.takeError()).message());
286
2.93k
    return *RelSecOrErr;
287
2.93k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelSection(llvm::object::DataRefImpl) const
Line
Count
Source
282
1.49k
  const Elf_Shdr *getRelSection(DataRefImpl Rel) const {
283
1.49k
    auto RelSecOrErr = EF.getSection(Rel.d.a);
284
1.49k
    if (!RelSecOrErr)
285
0
      report_fatal_error(errorToErrorCode(RelSecOrErr.takeError()).message());
286
1.49k
    return *RelSecOrErr;
287
1.49k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelSection(llvm::object::DataRefImpl) const
Line
Count
Source
282
22.2k
  const Elf_Shdr *getRelSection(DataRefImpl Rel) const {
283
22.2k
    auto RelSecOrErr = EF.getSection(Rel.d.a);
284
22.2k
    if (!RelSecOrErr)
285
0
      report_fatal_error(errorToErrorCode(RelSecOrErr.takeError()).message());
286
22.2k
    return *RelSecOrErr;
287
22.2k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelSection(llvm::object::DataRefImpl) const
Line
Count
Source
282
1.25k
  const Elf_Shdr *getRelSection(DataRefImpl Rel) const {
283
1.25k
    auto RelSecOrErr = EF.getSection(Rel.d.a);
284
1.25k
    if (!RelSecOrErr)
285
0
      report_fatal_error(errorToErrorCode(RelSecOrErr.takeError()).message());
286
1.25k
    return *RelSecOrErr;
287
1.25k
  }
288
289
11.2k
  DataRefImpl toDRI(const Elf_Shdr *SymTable, unsigned SymbolNum) const {
290
11.2k
    DataRefImpl DRI;
291
11.2k
    if (!SymTable) {
292
276
      DRI.d.a = 0;
293
276
      DRI.d.b = 0;
294
276
      return DRI;
295
276
    }
296
10.9k
    assert(SymTable->sh_type == ELF::SHT_SYMTAB ||
297
10.9k
           SymTable->sh_type == ELF::SHT_DYNSYM);
298
10.9k
299
10.9k
    auto SectionsOrErr = EF.sections();
300
10.9k
    if (!SectionsOrErr) {
301
0
      DRI.d.a = 0;
302
0
      DRI.d.b = 0;
303
0
      return DRI;
304
0
    }
305
10.9k
    uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
306
10.9k
    unsigned SymTableIndex =
307
10.9k
        (reinterpret_cast<uintptr_t>(SymTable) - SHT) / sizeof(Elf_Shdr);
308
10.9k
309
10.9k
    DRI.d.a = SymTableIndex;
310
10.9k
    DRI.d.b = SymbolNum;
311
10.9k
    return DRI;
312
10.9k
  }
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
289
1.79k
  DataRefImpl toDRI(const Elf_Shdr *SymTable, unsigned SymbolNum) const {
290
1.79k
    DataRefImpl DRI;
291
1.79k
    if (!SymTable) {
292
204
      DRI.d.a = 0;
293
204
      DRI.d.b = 0;
294
204
      return DRI;
295
204
    }
296
1.58k
    assert(SymTable->sh_type == ELF::SHT_SYMTAB ||
297
1.58k
           SymTable->sh_type == ELF::SHT_DYNSYM);
298
1.58k
299
1.58k
    auto SectionsOrErr = EF.sections();
300
1.58k
    if (!SectionsOrErr) {
301
0
      DRI.d.a = 0;
302
0
      DRI.d.b = 0;
303
0
      return DRI;
304
0
    }
305
1.58k
    uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
306
1.58k
    unsigned SymTableIndex =
307
1.58k
        (reinterpret_cast<uintptr_t>(SymTable) - SHT) / sizeof(Elf_Shdr);
308
1.58k
309
1.58k
    DRI.d.a = SymTableIndex;
310
1.58k
    DRI.d.b = SymbolNum;
311
1.58k
    return DRI;
312
1.58k
  }
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
289
701
  DataRefImpl toDRI(const Elf_Shdr *SymTable, unsigned SymbolNum) const {
290
701
    DataRefImpl DRI;
291
701
    if (!SymTable) {
292
8
      DRI.d.a = 0;
293
8
      DRI.d.b = 0;
294
8
      return DRI;
295
8
    }
296
693
    assert(SymTable->sh_type == ELF::SHT_SYMTAB ||
297
693
           SymTable->sh_type == ELF::SHT_DYNSYM);
298
693
299
693
    auto SectionsOrErr = EF.sections();
300
693
    if (!SectionsOrErr) {
301
0
      DRI.d.a = 0;
302
0
      DRI.d.b = 0;
303
0
      return DRI;
304
0
    }
305
693
    uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
306
693
    unsigned SymTableIndex =
307
693
        (reinterpret_cast<uintptr_t>(SymTable) - SHT) / sizeof(Elf_Shdr);
308
693
309
693
    DRI.d.a = SymTableIndex;
310
693
    DRI.d.b = SymbolNum;
311
693
    return DRI;
312
693
  }
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
289
8.27k
  DataRefImpl toDRI(const Elf_Shdr *SymTable, unsigned SymbolNum) const {
290
8.27k
    DataRefImpl DRI;
291
8.27k
    if (!SymTable) {
292
62
      DRI.d.a = 0;
293
62
      DRI.d.b = 0;
294
62
      return DRI;
295
62
    }
296
8.21k
    assert(SymTable->sh_type == ELF::SHT_SYMTAB ||
297
8.21k
           SymTable->sh_type == ELF::SHT_DYNSYM);
298
8.21k
299
8.21k
    auto SectionsOrErr = EF.sections();
300
8.21k
    if (!SectionsOrErr) {
301
0
      DRI.d.a = 0;
302
0
      DRI.d.b = 0;
303
0
      return DRI;
304
0
    }
305
8.21k
    uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
306
8.21k
    unsigned SymTableIndex =
307
8.21k
        (reinterpret_cast<uintptr_t>(SymTable) - SHT) / sizeof(Elf_Shdr);
308
8.21k
309
8.21k
    DRI.d.a = SymTableIndex;
310
8.21k
    DRI.d.b = SymbolNum;
311
8.21k
    return DRI;
312
8.21k
  }
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
289
485
  DataRefImpl toDRI(const Elf_Shdr *SymTable, unsigned SymbolNum) const {
290
485
    DataRefImpl DRI;
291
485
    if (!SymTable) {
292
2
      DRI.d.a = 0;
293
2
      DRI.d.b = 0;
294
2
      return DRI;
295
2
    }
296
483
    assert(SymTable->sh_type == ELF::SHT_SYMTAB ||
297
483
           SymTable->sh_type == ELF::SHT_DYNSYM);
298
483
299
483
    auto SectionsOrErr = EF.sections();
300
483
    if (!SectionsOrErr) {
301
0
      DRI.d.a = 0;
302
0
      DRI.d.b = 0;
303
0
      return DRI;
304
0
    }
305
483
    uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
306
483
    unsigned SymTableIndex =
307
483
        (reinterpret_cast<uintptr_t>(SymTable) - SHT) / sizeof(Elf_Shdr);
308
483
309
483
    DRI.d.a = SymTableIndex;
310
483
    DRI.d.b = SymbolNum;
311
483
    return DRI;
312
483
  }
313
314
  const Elf_Shdr *toELFShdrIter(DataRefImpl Sec) const {
315
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
316
  }
317
318
195k
  DataRefImpl toDRI(const Elf_Shdr *Sec) const {
319
195k
    DataRefImpl DRI;
320
195k
    DRI.p = reinterpret_cast<uintptr_t>(Sec);
321
195k
    return DRI;
322
195k
  }
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
318
28.5k
  DataRefImpl toDRI(const Elf_Shdr *Sec) const {
319
28.5k
    DataRefImpl DRI;
320
28.5k
    DRI.p = reinterpret_cast<uintptr_t>(Sec);
321
28.5k
    return DRI;
322
28.5k
  }
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
318
8.72k
  DataRefImpl toDRI(const Elf_Shdr *Sec) const {
319
8.72k
    DataRefImpl DRI;
320
8.72k
    DRI.p = reinterpret_cast<uintptr_t>(Sec);
321
8.72k
    return DRI;
322
8.72k
  }
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
318
150k
  DataRefImpl toDRI(const Elf_Shdr *Sec) const {
319
150k
    DataRefImpl DRI;
320
150k
    DRI.p = reinterpret_cast<uintptr_t>(Sec);
321
150k
    return DRI;
322
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
318
7.59k
  DataRefImpl toDRI(const Elf_Shdr *Sec) const {
319
7.59k
    DataRefImpl DRI;
320
7.59k
    DRI.p = reinterpret_cast<uintptr_t>(Sec);
321
7.59k
    return DRI;
322
7.59k
  }
323
324
  DataRefImpl toDRI(const Elf_Dyn *Dyn) const {
325
    DataRefImpl DRI;
326
    DRI.p = reinterpret_cast<uintptr_t>(Dyn);
327
    return DRI;
328
  }
329
330
43.3k
  bool isExportedToOtherDSO(const Elf_Sym *ESym) const {
331
43.3k
    unsigned char Binding = ESym->getBinding();
332
43.3k
    unsigned char Visibility = ESym->getVisibility();
333
43.3k
334
43.3k
    // A symbol is exported if its binding is either GLOBAL or WEAK, and its
335
43.3k
    // visibility is either DEFAULT or PROTECTED. All other symbols are not
336
43.3k
    // exported.
337
43.3k
    return (
338
43.3k
        (Binding == ELF::STB_GLOBAL || 
Binding == ELF::STB_WEAK26.1k
||
339
43.3k
         
Binding == ELF::STB_GNU_UNIQUE22.0k
) &&
340
43.3k
        
(21.2k
Visibility == ELF::STV_DEFAULT21.2k
||
Visibility == ELF::STV_PROTECTED8.70k
));
341
43.3k
  }
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
330
9.19k
  bool isExportedToOtherDSO(const Elf_Sym *ESym) const {
331
9.19k
    unsigned char Binding = ESym->getBinding();
332
9.19k
    unsigned char Visibility = ESym->getVisibility();
333
9.19k
334
9.19k
    // A symbol is exported if its binding is either GLOBAL or WEAK, and its
335
9.19k
    // visibility is either DEFAULT or PROTECTED. All other symbols are not
336
9.19k
    // exported.
337
9.19k
    return (
338
9.19k
        (Binding == ELF::STB_GLOBAL || 
Binding == ELF::STB_WEAK5.78k
||
339
9.19k
         
Binding == ELF::STB_GNU_UNIQUE5.76k
) &&
340
9.19k
        
(3.42k
Visibility == ELF::STV_DEFAULT3.42k
||
Visibility == ELF::STV_PROTECTED11
));
341
9.19k
  }
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
330
1.17k
  bool isExportedToOtherDSO(const Elf_Sym *ESym) const {
331
1.17k
    unsigned char Binding = ESym->getBinding();
332
1.17k
    unsigned char Visibility = ESym->getVisibility();
333
1.17k
334
1.17k
    // A symbol is exported if its binding is either GLOBAL or WEAK, and its
335
1.17k
    // visibility is either DEFAULT or PROTECTED. All other symbols are not
336
1.17k
    // exported.
337
1.17k
    return (
338
1.17k
        (Binding == ELF::STB_GLOBAL || 
Binding == ELF::STB_WEAK772
||
339
1.17k
         
Binding == ELF::STB_GNU_UNIQUE767
) &&
340
1.17k
        
(405
Visibility == ELF::STV_DEFAULT405
||
Visibility == ELF::STV_PROTECTED0
));
341
1.17k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isExportedToOtherDSO(llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*) const
Line
Count
Source
330
32.0k
  bool isExportedToOtherDSO(const Elf_Sym *ESym) const {
331
32.0k
    unsigned char Binding = ESym->getBinding();
332
32.0k
    unsigned char Visibility = ESym->getVisibility();
333
32.0k
334
32.0k
    // A symbol is exported if its binding is either GLOBAL or WEAK, and its
335
32.0k
    // visibility is either DEFAULT or PROTECTED. All other symbols are not
336
32.0k
    // exported.
337
32.0k
    return (
338
32.0k
        (Binding == ELF::STB_GLOBAL || 
Binding == ELF::STB_WEAK18.9k
||
339
32.0k
         
Binding == ELF::STB_GNU_UNIQUE15.0k
) &&
340
32.0k
        
(17.0k
Visibility == ELF::STV_DEFAULT17.0k
||
Visibility == ELF::STV_PROTECTED8.69k
));
341
32.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
330
906
  bool isExportedToOtherDSO(const Elf_Sym *ESym) const {
331
906
    unsigned char Binding = ESym->getBinding();
332
906
    unsigned char Visibility = ESym->getVisibility();
333
906
334
906
    // A symbol is exported if its binding is either GLOBAL or WEAK, and its
335
906
    // visibility is either DEFAULT or PROTECTED. All other symbols are not
336
906
    // exported.
337
906
    return (
338
906
        (Binding == ELF::STB_GLOBAL || 
Binding == ELF::STB_WEAK560
||
339
906
         
Binding == ELF::STB_GNU_UNIQUE557
) &&
340
906
        
(349
Visibility == ELF::STV_DEFAULT349
||
Visibility == ELF::STV_PROTECTED6
));
341
906
  }
342
343
  // This flag is used for classof, to distinguish ELFObjectFile from
344
  // its subclass. If more subclasses will be created, this flag will
345
  // have to become an enum.
346
  bool isDyldELFObject;
347
348
public:
349
  ELFObjectFile(ELFObjectFile<ELFT> &&Other);
350
  static Expected<ELFObjectFile<ELFT>> create(MemoryBufferRef Object);
351
352
  const Elf_Rel *getRel(DataRefImpl Rel) const;
353
  const Elf_Rela *getRela(DataRefImpl Rela) const;
354
355
186k
  const Elf_Sym *getSymbol(DataRefImpl Sym) const {
356
186k
    auto Ret = EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
357
186k
    if (!Ret)
358
0
      report_fatal_error(errorToErrorCode(Ret.takeError()).message());
359
186k
    return *Ret;
360
186k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
355
56.5k
  const Elf_Sym *getSymbol(DataRefImpl Sym) const {
356
56.5k
    auto Ret = EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
357
56.5k
    if (!Ret)
358
0
      report_fatal_error(errorToErrorCode(Ret.takeError()).message());
359
56.5k
    return *Ret;
360
56.5k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
355
5.14k
  const Elf_Sym *getSymbol(DataRefImpl Sym) const {
356
5.14k
    auto Ret = EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
357
5.14k
    if (!Ret)
358
0
      report_fatal_error(errorToErrorCode(Ret.takeError()).message());
359
5.14k
    return *Ret;
360
5.14k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
355
120k
  const Elf_Sym *getSymbol(DataRefImpl Sym) const {
356
120k
    auto Ret = EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
357
120k
    if (!Ret)
358
0
      report_fatal_error(errorToErrorCode(Ret.takeError()).message());
359
120k
    return *Ret;
360
120k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
355
3.77k
  const Elf_Sym *getSymbol(DataRefImpl Sym) const {
356
3.77k
    auto Ret = EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
357
3.77k
    if (!Ret)
358
0
      report_fatal_error(errorToErrorCode(Ret.takeError()).message());
359
3.77k
    return *Ret;
360
3.77k
  }
361
362
542k
  const Elf_Shdr *getSection(DataRefImpl Sec) const {
363
542k
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
364
542k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSection(llvm::object::DataRefImpl) const
Line
Count
Source
362
40.8k
  const Elf_Shdr *getSection(DataRefImpl Sec) const {
363
40.8k
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
364
40.8k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSection(llvm::object::DataRefImpl) const
Line
Count
Source
362
14.6k
  const Elf_Shdr *getSection(DataRefImpl Sec) const {
363
14.6k
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
364
14.6k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSection(llvm::object::DataRefImpl) const
Line
Count
Source
362
473k
  const Elf_Shdr *getSection(DataRefImpl Sec) const {
363
473k
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
364
473k
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSection(llvm::object::DataRefImpl) const
Line
Count
Source
362
13.8k
  const Elf_Shdr *getSection(DataRefImpl Sec) const {
363
13.8k
    return reinterpret_cast<const Elf_Shdr *>(Sec.p);
364
13.8k
  }
365
366
  basic_symbol_iterator symbol_begin() const override;
367
  basic_symbol_iterator symbol_end() const override;
368
369
  elf_symbol_iterator dynamic_symbol_begin() const;
370
  elf_symbol_iterator dynamic_symbol_end() const;
371
372
  section_iterator section_begin() const override;
373
  section_iterator section_end() const override;
374
375
  Expected<int64_t> getRelocationAddend(DataRefImpl Rel) const override;
376
377
  uint8_t getBytesInAddress() const override;
378
  StringRef getFileFormatName() const override;
379
  Triple::ArchType getArch() const override;
380
  Expected<uint64_t> getStartAddress() const override;
381
382
151
  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
382
33
  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
382
78
  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
382
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
382
21
  unsigned getPlatformFlags() const override { return EF.getHeader()->e_flags; }
383
384
246
  std::error_code getBuildAttributes(ARMAttributeParser &Attributes) const override {
385
246
    auto SectionsOrErr = EF.sections();
386
246
    if (!SectionsOrErr)
387
0
      return errorToErrorCode(SectionsOrErr.takeError());
388
246
389
1.67k
    
for (const Elf_Shdr &Sec : *SectionsOrErr)246
{
390
1.67k
      if (Sec.sh_type == ELF::SHT_ARM_ATTRIBUTES) {
391
169
        auto ErrorOrContents = EF.getSectionContents(&Sec);
392
169
        if (!ErrorOrContents)
393
0
          return errorToErrorCode(ErrorOrContents.takeError());
394
169
395
169
        auto Contents = ErrorOrContents.get();
396
169
        if (Contents[0] != ARMBuildAttrs::Format_Version || Contents.size() == 1)
397
0
          return std::error_code();
398
169
399
169
        Attributes.Parse(Contents, ELFT::TargetEndianness == support::little);
400
169
        break;
401
169
      }
402
1.67k
    }
403
246
    return std::error_code();
404
246
  }
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getBuildAttributes(llvm::ARMAttributeParser&) const
Line
Count
Source
384
246
  std::error_code getBuildAttributes(ARMAttributeParser &Attributes) const override {
385
246
    auto SectionsOrErr = EF.sections();
386
246
    if (!SectionsOrErr)
387
0
      return errorToErrorCode(SectionsOrErr.takeError());
388
246
389
1.67k
    
for (const Elf_Shdr &Sec : *SectionsOrErr)246
{
390
1.67k
      if (Sec.sh_type == ELF::SHT_ARM_ATTRIBUTES) {
391
169
        auto ErrorOrContents = EF.getSectionContents(&Sec);
392
169
        if (!ErrorOrContents)
393
0
          return errorToErrorCode(ErrorOrContents.takeError());
394
169
395
169
        auto Contents = ErrorOrContents.get();
396
169
        if (Contents[0] != ARMBuildAttrs::Format_Version || Contents.size() == 1)
397
0
          return std::error_code();
398
169
399
169
        Attributes.Parse(Contents, ELFT::TargetEndianness == support::little);
400
169
        break;
401
169
      }
402
1.67k
    }
403
246
    return std::error_code();
404
246
  }
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
405
406
  const ELFFile<ELFT> *getELFFile() const { return &EF; }
407
408
  bool isDyldType() const { return isDyldELFObject; }
409
  static bool classof(const Binary *v) {
410
    return v->getType() == getELFType(ELFT::TargetEndianness == support::little,
411
                                      ELFT::Is64Bits);
412
  }
413
414
  elf_symbol_iterator_range getDynamicSymbolIterators() const override;
415
416
  bool isRelocatableObject() const override;
417
};
418
419
using ELF32LEObjectFile = ELFObjectFile<ELF32LE>;
420
using ELF64LEObjectFile = ELFObjectFile<ELF64LE>;
421
using ELF32BEObjectFile = ELFObjectFile<ELF32BE>;
422
using ELF64BEObjectFile = ELFObjectFile<ELF64BE>;
423
424
template <class ELFT>
425
31.6k
void ELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Sym) const {
426
31.6k
  ++Sym.d.b;
427
31.6k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::moveSymbolNext(llvm::object::DataRefImpl&) const
Line
Count
Source
425
8.41k
void ELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Sym) const {
426
8.41k
  ++Sym.d.b;
427
8.41k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::moveSymbolNext(llvm::object::DataRefImpl&) const
Line
Count
Source
425
769
void ELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Sym) const {
426
769
  ++Sym.d.b;
427
769
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::moveSymbolNext(llvm::object::DataRefImpl&) const
Line
Count
Source
425
21.8k
void ELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Sym) const {
426
21.8k
  ++Sym.d.b;
427
21.8k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::moveSymbolNext(llvm::object::DataRefImpl&) const
Line
Count
Source
425
612
void ELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Sym) const {
426
612
  ++Sym.d.b;
427
612
}
428
429
template <class ELFT>
430
34.9k
Expected<StringRef> ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Sym) const {
431
34.9k
  const Elf_Sym *ESym = getSymbol(Sym);
432
34.9k
  auto SymTabOrErr = EF.getSection(Sym.d.a);
433
34.9k
  if (!SymTabOrErr)
434
0
    return SymTabOrErr.takeError();
435
34.9k
  const Elf_Shdr *SymTableSec = *SymTabOrErr;
436
34.9k
  auto StrTabOrErr = EF.getSection(SymTableSec->sh_link);
437
34.9k
  if (!StrTabOrErr)
438
0
    return StrTabOrErr.takeError();
439
34.9k
  const Elf_Shdr *StringTableSec = *StrTabOrErr;
440
34.9k
  auto SymStrTabOrErr = EF.getStringTable(StringTableSec);
441
34.9k
  if (!SymStrTabOrErr)
442
0
    return SymStrTabOrErr.takeError();
443
34.9k
  Expected<StringRef> Name = ESym->getName(*SymStrTabOrErr);
444
34.9k
445
34.9k
  // If the symbol name is empty use the section name.
446
34.9k
  if ((!Name || Name->empty()) && 
ESym->getType() == ELF::STT_SECTION2.58k
) {
447
827
    StringRef SecName;
448
827
    Expected<section_iterator> Sec = getSymbolSection(Sym);
449
827
    if (Sec && !(*Sec)->getName(SecName))
450
827
      return SecName;
451
34.1k
  }
452
34.1k
  return Name;
453
34.1k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolName(llvm::object::DataRefImpl) const
Line
Count
Source
430
14.9k
Expected<StringRef> ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Sym) const {
431
14.9k
  const Elf_Sym *ESym = getSymbol(Sym);
432
14.9k
  auto SymTabOrErr = EF.getSection(Sym.d.a);
433
14.9k
  if (!SymTabOrErr)
434
0
    return SymTabOrErr.takeError();
435
14.9k
  const Elf_Shdr *SymTableSec = *SymTabOrErr;
436
14.9k
  auto StrTabOrErr = EF.getSection(SymTableSec->sh_link);
437
14.9k
  if (!StrTabOrErr)
438
0
    return StrTabOrErr.takeError();
439
14.9k
  const Elf_Shdr *StringTableSec = *StrTabOrErr;
440
14.9k
  auto SymStrTabOrErr = EF.getStringTable(StringTableSec);
441
14.9k
  if (!SymStrTabOrErr)
442
0
    return SymStrTabOrErr.takeError();
443
14.9k
  Expected<StringRef> Name = ESym->getName(*SymStrTabOrErr);
444
14.9k
445
14.9k
  // If the symbol name is empty use the section name.
446
14.9k
  if ((!Name || Name->empty()) && 
ESym->getType() == ELF::STT_SECTION960
) {
447
336
    StringRef SecName;
448
336
    Expected<section_iterator> Sec = getSymbolSection(Sym);
449
336
    if (Sec && !(*Sec)->getName(SecName))
450
336
      return SecName;
451
14.6k
  }
452
14.6k
  return Name;
453
14.6k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolName(llvm::object::DataRefImpl) const
Line
Count
Source
430
784
Expected<StringRef> ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Sym) const {
431
784
  const Elf_Sym *ESym = getSymbol(Sym);
432
784
  auto SymTabOrErr = EF.getSection(Sym.d.a);
433
784
  if (!SymTabOrErr)
434
0
    return SymTabOrErr.takeError();
435
784
  const Elf_Shdr *SymTableSec = *SymTabOrErr;
436
784
  auto StrTabOrErr = EF.getSection(SymTableSec->sh_link);
437
784
  if (!StrTabOrErr)
438
0
    return StrTabOrErr.takeError();
439
784
  const Elf_Shdr *StringTableSec = *StrTabOrErr;
440
784
  auto SymStrTabOrErr = EF.getStringTable(StringTableSec);
441
784
  if (!SymStrTabOrErr)
442
0
    return SymStrTabOrErr.takeError();
443
784
  Expected<StringRef> Name = ESym->getName(*SymStrTabOrErr);
444
784
445
784
  // If the symbol name is empty use the section name.
446
784
  if ((!Name || Name->empty()) && 
ESym->getType() == ELF::STT_SECTION120
) {
447
34
    StringRef SecName;
448
34
    Expected<section_iterator> Sec = getSymbolSection(Sym);
449
34
    if (Sec && !(*Sec)->getName(SecName))
450
34
      return SecName;
451
750
  }
452
750
  return Name;
453
750
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolName(llvm::object::DataRefImpl) const
Line
Count
Source
430
18.6k
Expected<StringRef> ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Sym) const {
431
18.6k
  const Elf_Sym *ESym = getSymbol(Sym);
432
18.6k
  auto SymTabOrErr = EF.getSection(Sym.d.a);
433
18.6k
  if (!SymTabOrErr)
434
0
    return SymTabOrErr.takeError();
435
18.6k
  const Elf_Shdr *SymTableSec = *SymTabOrErr;
436
18.6k
  auto StrTabOrErr = EF.getSection(SymTableSec->sh_link);
437
18.6k
  if (!StrTabOrErr)
438
0
    return StrTabOrErr.takeError();
439
18.6k
  const Elf_Shdr *StringTableSec = *StrTabOrErr;
440
18.6k
  auto SymStrTabOrErr = EF.getStringTable(StringTableSec);
441
18.6k
  if (!SymStrTabOrErr)
442
0
    return SymStrTabOrErr.takeError();
443
18.6k
  Expected<StringRef> Name = ESym->getName(*SymStrTabOrErr);
444
18.6k
445
18.6k
  // If the symbol name is empty use the section name.
446
18.6k
  if ((!Name || Name->empty()) && 
ESym->getType() == ELF::STT_SECTION1.42k
) {
447
436
    StringRef SecName;
448
436
    Expected<section_iterator> Sec = getSymbolSection(Sym);
449
436
    if (Sec && !(*Sec)->getName(SecName))
450
436
      return SecName;
451
18.1k
  }
452
18.1k
  return Name;
453
18.1k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolName(llvm::object::DataRefImpl) const
Line
Count
Source
430
591
Expected<StringRef> ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Sym) const {
431
591
  const Elf_Sym *ESym = getSymbol(Sym);
432
591
  auto SymTabOrErr = EF.getSection(Sym.d.a);
433
591
  if (!SymTabOrErr)
434
0
    return SymTabOrErr.takeError();
435
591
  const Elf_Shdr *SymTableSec = *SymTabOrErr;
436
591
  auto StrTabOrErr = EF.getSection(SymTableSec->sh_link);
437
591
  if (!StrTabOrErr)
438
0
    return StrTabOrErr.takeError();
439
591
  const Elf_Shdr *StringTableSec = *StrTabOrErr;
440
591
  auto SymStrTabOrErr = EF.getStringTable(StringTableSec);
441
591
  if (!SymStrTabOrErr)
442
0
    return SymStrTabOrErr.takeError();
443
591
  Expected<StringRef> Name = ESym->getName(*SymStrTabOrErr);
444
591
445
591
  // If the symbol name is empty use the section name.
446
591
  if ((!Name || Name->empty()) && 
ESym->getType() == ELF::STT_SECTION81
) {
447
21
    StringRef SecName;
448
21
    Expected<section_iterator> Sec = getSymbolSection(Sym);
449
21
    if (Sec && !(*Sec)->getName(SecName))
450
21
      return SecName;
451
570
  }
452
570
  return Name;
453
570
}
454
455
template <class ELFT>
456
5.44k
uint64_t ELFObjectFile<ELFT>::getSectionFlags(DataRefImpl Sec) const {
457
5.44k
  return getSection(Sec)->sh_flags;
458
5.44k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionFlags(llvm::object::DataRefImpl) const
Line
Count
Source
456
836
uint64_t ELFObjectFile<ELFT>::getSectionFlags(DataRefImpl Sec) const {
457
836
  return getSection(Sec)->sh_flags;
458
836
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionFlags(llvm::object::DataRefImpl) const
Line
Count
Source
456
332
uint64_t ELFObjectFile<ELFT>::getSectionFlags(DataRefImpl Sec) const {
457
332
  return getSection(Sec)->sh_flags;
458
332
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionFlags(llvm::object::DataRefImpl) const
Line
Count
Source
456
3.79k
uint64_t ELFObjectFile<ELFT>::getSectionFlags(DataRefImpl Sec) const {
457
3.79k
  return getSection(Sec)->sh_flags;
458
3.79k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionFlags(llvm::object::DataRefImpl) const
Line
Count
Source
456
489
uint64_t ELFObjectFile<ELFT>::getSectionFlags(DataRefImpl Sec) const {
457
489
  return getSection(Sec)->sh_flags;
458
489
}
459
460
template <class ELFT>
461
956
uint32_t ELFObjectFile<ELFT>::getSectionType(DataRefImpl Sec) const {
462
956
  return getSection(Sec)->sh_type;
463
956
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionType(llvm::object::DataRefImpl) const
Line
Count
Source
461
133
uint32_t ELFObjectFile<ELFT>::getSectionType(DataRefImpl Sec) const {
462
133
  return getSection(Sec)->sh_type;
463
133
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionType(llvm::object::DataRefImpl) const
Line
Count
Source
461
84
uint32_t ELFObjectFile<ELFT>::getSectionType(DataRefImpl Sec) const {
462
84
  return getSection(Sec)->sh_type;
463
84
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionType(llvm::object::DataRefImpl) const
Line
Count
Source
461
651
uint32_t ELFObjectFile<ELFT>::getSectionType(DataRefImpl Sec) const {
462
651
  return getSection(Sec)->sh_type;
463
651
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionType(llvm::object::DataRefImpl) const
Line
Count
Source
461
88
uint32_t ELFObjectFile<ELFT>::getSectionType(DataRefImpl Sec) const {
462
88
  return getSection(Sec)->sh_type;
463
88
}
464
465
template <class ELFT>
466
0
uint64_t ELFObjectFile<ELFT>::getSectionOffset(DataRefImpl Sec) const {
467
0
  return getSection(Sec)->sh_offset;
468
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
469
470
template <class ELFT>
471
26.8k
uint64_t ELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const {
472
26.8k
  const Elf_Sym *ESym = getSymbol(Symb);
473
26.8k
  uint64_t Ret = ESym->st_value;
474
26.8k
  if (ESym->st_shndx == ELF::SHN_ABS)
475
613
    return Ret;
476
26.2k
477
26.2k
  const Elf_Ehdr *Header = EF.getHeader();
478
26.2k
  // Clear the ARM/Thumb or microMIPS indicator flag.
479
26.2k
  if ((Header->e_machine == ELF::EM_ARM || 
Header->e_machine == ELF::EM_MIPS20.0k
) &&
480
26.2k
      
ESym->getType() == ELF::STT_FUNC7.12k
)
481
3.08k
    Ret &= ~1;
482
26.2k
483
26.2k
  return Ret;
484
26.2k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolValueImpl(llvm::object::DataRefImpl) const
Line
Count
Source
471
7.63k
uint64_t ELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const {
472
7.63k
  const Elf_Sym *ESym = getSymbol(Symb);
473
7.63k
  uint64_t Ret = ESym->st_value;
474
7.63k
  if (ESym->st_shndx == ELF::SHN_ABS)
475
152
    return Ret;
476
7.48k
477
7.48k
  const Elf_Ehdr *Header = EF.getHeader();
478
7.48k
  // Clear the ARM/Thumb or microMIPS indicator flag.
479
7.48k
  if ((Header->e_machine == ELF::EM_ARM || 
Header->e_machine == ELF::EM_MIPS1.30k
) &&
480
7.48k
      
ESym->getType() == ELF::STT_FUNC6.34k
)
481
2.88k
    Ret &= ~1;
482
7.48k
483
7.48k
  return Ret;
484
7.48k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolValueImpl(llvm::object::DataRefImpl) const
Line
Count
Source
471
652
uint64_t ELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const {
472
652
  const Elf_Sym *ESym = getSymbol(Symb);
473
652
  uint64_t Ret = ESym->st_value;
474
652
  if (ESym->st_shndx == ELF::SHN_ABS)
475
30
    return Ret;
476
622
477
622
  const Elf_Ehdr *Header = EF.getHeader();
478
622
  // Clear the ARM/Thumb or microMIPS indicator flag.
479
622
  if ((Header->e_machine == ELF::EM_ARM || 
Header->e_machine == ELF::EM_MIPS604
) &&
480
622
      
ESym->getType() == ELF::STT_FUNC594
)
481
164
    Ret &= ~1;
482
622
483
622
  return Ret;
484
622
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolValueImpl(llvm::object::DataRefImpl) const
Line
Count
Source
471
18.1k
uint64_t ELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const {
472
18.1k
  const Elf_Sym *ESym = getSymbol(Symb);
473
18.1k
  uint64_t Ret = ESym->st_value;
474
18.1k
  if (ESym->st_shndx == ELF::SHN_ABS)
475
414
    return Ret;
476
17.7k
477
17.7k
  const Elf_Ehdr *Header = EF.getHeader();
478
17.7k
  // Clear the ARM/Thumb or microMIPS indicator flag.
479
17.7k
  if ((Header->e_machine == ELF::EM_ARM || Header->e_machine == ELF::EM_MIPS) &&
480
17.7k
      
ESym->getType() == ELF::STT_FUNC60
)
481
30
    Ret &= ~1;
482
17.7k
483
17.7k
  return Ret;
484
17.7k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolValueImpl(llvm::object::DataRefImpl) const
Line
Count
Source
471
456
uint64_t ELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const {
472
456
  const Elf_Sym *ESym = getSymbol(Symb);
473
456
  uint64_t Ret = ESym->st_value;
474
456
  if (ESym->st_shndx == ELF::SHN_ABS)
475
17
    return Ret;
476
439
477
439
  const Elf_Ehdr *Header = EF.getHeader();
478
439
  // Clear the ARM/Thumb or microMIPS indicator flag.
479
439
  if ((Header->e_machine == ELF::EM_ARM || Header->e_machine == ELF::EM_MIPS) &&
480
439
      
ESym->getType() == ELF::STT_FUNC132
)
481
11
    Ret &= ~1;
482
439
483
439
  return Ret;
484
439
}
485
486
template <class ELFT>
487
Expected<uint64_t>
488
29.1k
ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb) const {
489
29.1k
  uint64_t Result = getSymbolValue(Symb);
490
29.1k
  const Elf_Sym *ESym = getSymbol(Symb);
491
29.1k
  switch (ESym->st_shndx) {
492
29.1k
  case ELF::SHN_COMMON:
493
2.86k
  case ELF::SHN_UNDEF:
494
2.86k
  case ELF::SHN_ABS:
495
2.86k
    return Result;
496
26.2k
  }
497
26.2k
498
26.2k
  const Elf_Ehdr *Header = EF.getHeader();
499
26.2k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
500
26.2k
  if (!SymTabOrErr)
501
0
    return SymTabOrErr.takeError();
502
26.2k
  const Elf_Shdr *SymTab = *SymTabOrErr;
503
26.2k
504
26.2k
  if (Header->e_type == ELF::ET_REL) {
505
5.48k
    auto SectionOrErr = EF.getSection(ESym, SymTab, ShndxTable);
506
5.48k
    if (!SectionOrErr)
507
0
      return SectionOrErr.takeError();
508
5.48k
    const Elf_Shdr *Section = *SectionOrErr;
509
5.48k
    if (Section)
510
5.48k
      Result += Section->sh_addr;
511
5.48k
  }
512
26.2k
513
26.2k
  return Result;
514
26.2k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolAddress(llvm::object::DataRefImpl) const
Line
Count
Source
488
8.27k
ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb) const {
489
8.27k
  uint64_t Result = getSymbolValue(Symb);
490
8.27k
  const Elf_Sym *ESym = getSymbol(Symb);
491
8.27k
  switch (ESym->st_shndx) {
492
8.27k
  case ELF::SHN_COMMON:
493
795
  case ELF::SHN_UNDEF:
494
795
  case ELF::SHN_ABS:
495
795
    return Result;
496
7.48k
  }
497
7.48k
498
7.48k
  const Elf_Ehdr *Header = EF.getHeader();
499
7.48k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
500
7.48k
  if (!SymTabOrErr)
501
0
    return SymTabOrErr.takeError();
502
7.48k
  const Elf_Shdr *SymTab = *SymTabOrErr;
503
7.48k
504
7.48k
  if (Header->e_type == ELF::ET_REL) {
505
1.72k
    auto SectionOrErr = EF.getSection(ESym, SymTab, ShndxTable);
506
1.72k
    if (!SectionOrErr)
507
0
      return SectionOrErr.takeError();
508
1.72k
    const Elf_Shdr *Section = *SectionOrErr;
509
1.72k
    if (Section)
510
1.72k
      Result += Section->sh_addr;
511
1.72k
  }
512
7.48k
513
7.48k
  return Result;
514
7.48k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolAddress(llvm::object::DataRefImpl) const
Line
Count
Source
488
765
ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb) const {
489
765
  uint64_t Result = getSymbolValue(Symb);
490
765
  const Elf_Sym *ESym = getSymbol(Symb);
491
765
  switch (ESym->st_shndx) {
492
765
  case ELF::SHN_COMMON:
493
143
  case ELF::SHN_UNDEF:
494
143
  case ELF::SHN_ABS:
495
143
    return Result;
496
622
  }
497
622
498
622
  const Elf_Ehdr *Header = EF.getHeader();
499
622
  auto SymTabOrErr = EF.getSection(Symb.d.a);
500
622
  if (!SymTabOrErr)
501
0
    return SymTabOrErr.takeError();
502
622
  const Elf_Shdr *SymTab = *SymTabOrErr;
503
622
504
622
  if (Header->e_type == ELF::ET_REL) {
505
244
    auto SectionOrErr = EF.getSection(ESym, SymTab, ShndxTable);
506
244
    if (!SectionOrErr)
507
0
      return SectionOrErr.takeError();
508
244
    const Elf_Shdr *Section = *SectionOrErr;
509
244
    if (Section)
510
244
      Result += Section->sh_addr;
511
244
  }
512
622
513
622
  return Result;
514
622
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolAddress(llvm::object::DataRefImpl) const
Line
Count
Source
488
19.5k
ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb) const {
489
19.5k
  uint64_t Result = getSymbolValue(Symb);
490
19.5k
  const Elf_Sym *ESym = getSymbol(Symb);
491
19.5k
  switch (ESym->st_shndx) {
492
19.5k
  case ELF::SHN_COMMON:
493
1.79k
  case ELF::SHN_UNDEF:
494
1.79k
  case ELF::SHN_ABS:
495
1.79k
    return Result;
496
17.7k
  }
497
17.7k
498
17.7k
  const Elf_Ehdr *Header = EF.getHeader();
499
17.7k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
500
17.7k
  if (!SymTabOrErr)
501
0
    return SymTabOrErr.takeError();
502
17.7k
  const Elf_Shdr *SymTab = *SymTabOrErr;
503
17.7k
504
17.7k
  if (Header->e_type == ELF::ET_REL) {
505
3.36k
    auto SectionOrErr = EF.getSection(ESym, SymTab, ShndxTable);
506
3.36k
    if (!SectionOrErr)
507
0
      return SectionOrErr.takeError();
508
3.36k
    const Elf_Shdr *Section = *SectionOrErr;
509
3.36k
    if (Section)
510
3.36k
      Result += Section->sh_addr;
511
3.36k
  }
512
17.7k
513
17.7k
  return Result;
514
17.7k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolAddress(llvm::object::DataRefImpl) const
Line
Count
Source
488
563
ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb) const {
489
563
  uint64_t Result = getSymbolValue(Symb);
490
563
  const Elf_Sym *ESym = getSymbol(Symb);
491
563
  switch (ESym->st_shndx) {
492
563
  case ELF::SHN_COMMON:
493
124
  case ELF::SHN_UNDEF:
494
124
  case ELF::SHN_ABS:
495
124
    return Result;
496
439
  }
497
439
498
439
  const Elf_Ehdr *Header = EF.getHeader();
499
439
  auto SymTabOrErr = EF.getSection(Symb.d.a);
500
439
  if (!SymTabOrErr)
501
0
    return SymTabOrErr.takeError();
502
439
  const Elf_Shdr *SymTab = *SymTabOrErr;
503
439
504
439
  if (Header->e_type == ELF::ET_REL) {
505
149
    auto SectionOrErr = EF.getSection(ESym, SymTab, ShndxTable);
506
149
    if (!SectionOrErr)
507
0
      return SectionOrErr.takeError();
508
149
    const Elf_Shdr *Section = *SectionOrErr;
509
149
    if (Section)
510
149
      Result += Section->sh_addr;
511
149
  }
512
439
513
439
  return Result;
514
439
}
515
516
template <class ELFT>
517
99
uint32_t ELFObjectFile<ELFT>::getSymbolAlignment(DataRefImpl Symb) const {
518
99
  const Elf_Sym *Sym = getSymbol(Symb);
519
99
  if (Sym->st_shndx == ELF::SHN_COMMON)
520
99
    return Sym->st_value;
521
0
  return 0;
522
0
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
517
6
uint32_t ELFObjectFile<ELFT>::getSymbolAlignment(DataRefImpl Symb) const {
518
6
  const Elf_Sym *Sym = getSymbol(Symb);
519
6
  if (Sym->st_shndx == ELF::SHN_COMMON)
520
6
    return Sym->st_value;
521
0
  return 0;
522
0
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
517
4
uint32_t ELFObjectFile<ELFT>::getSymbolAlignment(DataRefImpl Symb) const {
518
4
  const Elf_Sym *Sym = getSymbol(Symb);
519
4
  if (Sym->st_shndx == ELF::SHN_COMMON)
520
4
    return Sym->st_value;
521
0
  return 0;
522
0
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
517
87
uint32_t ELFObjectFile<ELFT>::getSymbolAlignment(DataRefImpl Symb) const {
518
87
  const Elf_Sym *Sym = getSymbol(Symb);
519
87
  if (Sym->st_shndx == ELF::SHN_COMMON)
520
87
    return Sym->st_value;
521
0
  return 0;
522
0
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
517
2
uint32_t ELFObjectFile<ELFT>::getSymbolAlignment(DataRefImpl Symb) const {
518
2
  const Elf_Sym *Sym = getSymbol(Symb);
519
2
  if (Sym->st_shndx == ELF::SHN_COMMON)
520
2
    return Sym->st_value;
521
0
  return 0;
522
0
}
523
524
template <class ELFT>
525
1.49k
uint16_t ELFObjectFile<ELFT>::getEMachine() const {
526
1.49k
  return EF.getHeader()->e_machine;
527
1.49k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getEMachine() const
Line
Count
Source
525
398
uint16_t ELFObjectFile<ELFT>::getEMachine() const {
526
398
  return EF.getHeader()->e_machine;
527
398
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getEMachine() const
Line
Count
Source
525
73
uint16_t ELFObjectFile<ELFT>::getEMachine() const {
526
73
  return EF.getHeader()->e_machine;
527
73
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getEMachine() const
Line
Count
Source
525
964
uint16_t ELFObjectFile<ELFT>::getEMachine() const {
526
964
  return EF.getHeader()->e_machine;
527
964
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getEMachine() const
Line
Count
Source
525
60
uint16_t ELFObjectFile<ELFT>::getEMachine() const {
526
60
  return EF.getHeader()->e_machine;
527
60
}
528
529
0
template <class ELFT> uint16_t ELFObjectFile<ELFT>::getEType() const {
530
0
  return EF.getHeader()->e_type;
531
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
532
533
template <class ELFT>
534
8.54k
uint64_t ELFObjectFile<ELFT>::getSymbolSize(DataRefImpl Sym) const {
535
8.54k
  return getSymbol(Sym)->st_size;
536
8.54k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolSize(llvm::object::DataRefImpl) const
Line
Count
Source
534
243
uint64_t ELFObjectFile<ELFT>::getSymbolSize(DataRefImpl Sym) const {
535
243
  return getSymbol(Sym)->st_size;
536
243
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolSize(llvm::object::DataRefImpl) const
Line
Count
Source
534
146
uint64_t ELFObjectFile<ELFT>::getSymbolSize(DataRefImpl Sym) const {
535
146
  return getSymbol(Sym)->st_size;
536
146
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolSize(llvm::object::DataRefImpl) const
Line
Count
Source
534
8.10k
uint64_t ELFObjectFile<ELFT>::getSymbolSize(DataRefImpl Sym) const {
535
8.10k
  return getSymbol(Sym)->st_size;
536
8.10k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolSize(llvm::object::DataRefImpl) const
Line
Count
Source
534
55
uint64_t ELFObjectFile<ELFT>::getSymbolSize(DataRefImpl Sym) const {
535
55
  return getSymbol(Sym)->st_size;
536
55
}
537
538
template <class ELFT>
539
142
uint64_t ELFObjectFile<ELFT>::getCommonSymbolSizeImpl(DataRefImpl Symb) const {
540
142
  return getSymbol(Symb)->st_size;
541
142
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getCommonSymbolSizeImpl(llvm::object::DataRefImpl) const
Line
Count
Source
539
13
uint64_t ELFObjectFile<ELFT>::getCommonSymbolSizeImpl(DataRefImpl Symb) const {
540
13
  return getSymbol(Symb)->st_size;
541
13
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getCommonSymbolSizeImpl(llvm::object::DataRefImpl) const
Line
Count
Source
539
5
uint64_t ELFObjectFile<ELFT>::getCommonSymbolSizeImpl(DataRefImpl Symb) const {
540
5
  return getSymbol(Symb)->st_size;
541
5
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getCommonSymbolSizeImpl(llvm::object::DataRefImpl) const
Line
Count
Source
539
121
uint64_t ELFObjectFile<ELFT>::getCommonSymbolSizeImpl(DataRefImpl Symb) const {
540
121
  return getSymbol(Symb)->st_size;
541
121
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getCommonSymbolSizeImpl(llvm::object::DataRefImpl) const
Line
Count
Source
539
3
uint64_t ELFObjectFile<ELFT>::getCommonSymbolSizeImpl(DataRefImpl Symb) const {
540
3
  return getSymbol(Symb)->st_size;
541
3
}
542
543
template <class ELFT>
544
0
uint8_t ELFObjectFile<ELFT>::getSymbolOther(DataRefImpl Symb) const {
545
0
  return getSymbol(Symb)->st_other;
546
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
547
548
template <class ELFT>
549
87
uint8_t ELFObjectFile<ELFT>::getSymbolELFType(DataRefImpl Symb) const {
550
87
  return getSymbol(Symb)->getType();
551
87
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolELFType(llvm::object::DataRefImpl) const
Line
Count
Source
549
8
uint8_t ELFObjectFile<ELFT>::getSymbolELFType(DataRefImpl Symb) const {
550
8
  return getSymbol(Symb)->getType();
551
8
}
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
549
79
uint8_t ELFObjectFile<ELFT>::getSymbolELFType(DataRefImpl Symb) const {
550
79
  return getSymbol(Symb)->getType();
551
79
}
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolELFType(llvm::object::DataRefImpl) const
552
553
template <class ELFT>
554
Expected<SymbolRef::Type>
555
8.16k
ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const {
556
8.16k
  const Elf_Sym *ESym = getSymbol(Symb);
557
8.16k
558
8.16k
  switch (ESym->getType()) {
559
8.16k
  case ELF::STT_NOTYPE:
560
1.12k
    return SymbolRef::ST_Unknown;
561
8.16k
  case ELF::STT_SECTION:
562
1.73k
    return SymbolRef::ST_Debug;
563
8.16k
  case ELF::STT_FILE:
564
102
    return SymbolRef::ST_File;
565
8.16k
  case ELF::STT_FUNC:
566
2.51k
    return SymbolRef::ST_Function;
567
8.16k
  case ELF::STT_OBJECT:
568
2.68k
  case ELF::STT_COMMON:
569
2.68k
  case ELF::STT_TLS:
570
2.68k
    return SymbolRef::ST_Data;
571
2.68k
  default:
572
0
    return SymbolRef::ST_Other;
573
8.16k
  }
574
8.16k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolType(llvm::object::DataRefImpl) const
Line
Count
Source
555
276
ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const {
556
276
  const Elf_Sym *ESym = getSymbol(Symb);
557
276
558
276
  switch (ESym->getType()) {
559
276
  case ELF::STT_NOTYPE:
560
130
    return SymbolRef::ST_Unknown;
561
276
  case ELF::STT_SECTION:
562
60
    return SymbolRef::ST_Debug;
563
276
  case ELF::STT_FILE:
564
16
    return SymbolRef::ST_File;
565
276
  case ELF::STT_FUNC:
566
38
    return SymbolRef::ST_Function;
567
276
  case ELF::STT_OBJECT:
568
32
  case ELF::STT_COMMON:
569
32
  case ELF::STT_TLS:
570
32
    return SymbolRef::ST_Data;
571
32
  default:
572
0
    return SymbolRef::ST_Other;
573
276
  }
574
276
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolType(llvm::object::DataRefImpl) const
Line
Count
Source
555
275
ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const {
556
275
  const Elf_Sym *ESym = getSymbol(Symb);
557
275
558
275
  switch (ESym->getType()) {
559
275
  case ELF::STT_NOTYPE:
560
172
    return SymbolRef::ST_Unknown;
561
275
  case ELF::STT_SECTION:
562
17
    return SymbolRef::ST_Debug;
563
275
  case ELF::STT_FILE:
564
10
    return SymbolRef::ST_File;
565
275
  case ELF::STT_FUNC:
566
36
    return SymbolRef::ST_Function;
567
275
  case ELF::STT_OBJECT:
568
40
  case ELF::STT_COMMON:
569
40
  case ELF::STT_TLS:
570
40
    return SymbolRef::ST_Data;
571
40
  default:
572
0
    return SymbolRef::ST_Other;
573
275
  }
574
275
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolType(llvm::object::DataRefImpl) const
Line
Count
Source
555
7.41k
ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const {
556
7.41k
  const Elf_Sym *ESym = getSymbol(Symb);
557
7.41k
558
7.41k
  switch (ESym->getType()) {
559
7.41k
  case ELF::STT_NOTYPE:
560
712
    return SymbolRef::ST_Unknown;
561
7.41k
  case ELF::STT_SECTION:
562
1.62k
    return SymbolRef::ST_Debug;
563
7.41k
  case ELF::STT_FILE:
564
64
    return SymbolRef::ST_File;
565
7.41k
  case ELF::STT_FUNC:
566
2.41k
    return SymbolRef::ST_Function;
567
7.41k
  case ELF::STT_OBJECT:
568
2.59k
  case ELF::STT_COMMON:
569
2.59k
  case ELF::STT_TLS:
570
2.59k
    return SymbolRef::ST_Data;
571
2.59k
  default:
572
0
    return SymbolRef::ST_Other;
573
7.41k
  }
574
7.41k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolType(llvm::object::DataRefImpl) const
Line
Count
Source
555
199
ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const {
556
199
  const Elf_Sym *ESym = getSymbol(Symb);
557
199
558
199
  switch (ESym->getType()) {
559
199
  case ELF::STT_NOTYPE:
560
111
    return SymbolRef::ST_Unknown;
561
199
  case ELF::STT_SECTION:
562
28
    return SymbolRef::ST_Debug;
563
199
  case ELF::STT_FILE:
564
12
    return SymbolRef::ST_File;
565
199
  case ELF::STT_FUNC:
566
29
    return SymbolRef::ST_Function;
567
199
  case ELF::STT_OBJECT:
568
19
  case ELF::STT_COMMON:
569
19
  case ELF::STT_TLS:
570
19
    return SymbolRef::ST_Data;
571
19
  default:
572
0
    return SymbolRef::ST_Other;
573
199
  }
574
199
}
575
576
template <class ELFT>
577
43.3k
uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
578
43.3k
  const Elf_Sym *ESym = getSymbol(Sym);
579
43.3k
580
43.3k
  uint32_t Result = SymbolRef::SF_None;
581
43.3k
582
43.3k
  if (ESym->getBinding() != ELF::STB_LOCAL)
583
21.2k
    Result |= SymbolRef::SF_Global;
584
43.3k
585
43.3k
  if (ESym->getBinding() == ELF::STB_WEAK)
586
4.00k
    Result |= SymbolRef::SF_Weak;
587
43.3k
588
43.3k
  if (ESym->st_shndx == ELF::SHN_ABS)
589
1.38k
    Result |= SymbolRef::SF_Absolute;
590
43.3k
591
43.3k
  if (ESym->getType() == ELF::STT_FILE || 
ESym->getType() == ELF::STT_SECTION42.4k
)
592
4.55k
    Result |= SymbolRef::SF_FormatSpecific;
593
43.3k
594
43.3k
  auto DotSymtabSecSyms = EF.symbols(DotSymtabSec);
595
43.3k
  if (DotSymtabSecSyms && ESym == (*DotSymtabSecSyms).begin())
596
1.93k
    Result |= SymbolRef::SF_FormatSpecific;
597
43.3k
  auto DotDynSymSecSyms = EF.symbols(DotDynSymSec);
598
43.3k
  if (DotDynSymSecSyms && ESym == (*DotDynSymSecSyms).begin())
599
5
    Result |= SymbolRef::SF_FormatSpecific;
600
43.3k
601
43.3k
  if (EF.getHeader()->e_machine == ELF::EM_ARM) {
602
6.72k
    if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
603
6.72k
      StringRef Name = *NameOrErr;
604
6.72k
      if (Name.startswith("$d") || 
Name.startswith("$t")6.51k
||
605
6.72k
          
Name.startswith("$a")4.46k
)
606
2.97k
        Result |= SymbolRef::SF_FormatSpecific;
607
6.72k
    } else {
608
0
      // TODO: Actually report errors helpfully.
609
0
      consumeError(NameOrErr.takeError());
610
0
    }
611
6.72k
    if (ESym->getType() == ELF::STT_FUNC && 
(ESym->st_value & 1) == 12.90k
)
612
2.19k
      Result |= SymbolRef::SF_Thumb;
613
6.72k
  }
614
43.3k
615
43.3k
  if (ESym->st_shndx == ELF::SHN_UNDEF)
616
3.28k
    Result |= SymbolRef::SF_Undefined;
617
43.3k
618
43.3k
  if (ESym->getType() == ELF::STT_COMMON || ESym->st_shndx == ELF::SHN_COMMON)
619
455
    Result |= SymbolRef::SF_Common;
620
43.3k
621
43.3k
  if (isExportedToOtherDSO(ESym))
622
12.5k
    Result |= SymbolRef::SF_Exported;
623
43.3k
624
43.3k
  if (ESym->getVisibility() == ELF::STV_HIDDEN)
625
10.4k
    Result |= SymbolRef::SF_Hidden;
626
43.3k
627
43.3k
  return Result;
628
43.3k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolFlags(llvm::object::DataRefImpl) const
Line
Count
Source
577
9.19k
uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
578
9.19k
  const Elf_Sym *ESym = getSymbol(Sym);
579
9.19k
580
9.19k
  uint32_t Result = SymbolRef::SF_None;
581
9.19k
582
9.19k
  if (ESym->getBinding() != ELF::STB_LOCAL)
583
3.42k
    Result |= SymbolRef::SF_Global;
584
9.19k
585
9.19k
  if (ESym->getBinding() == ELF::STB_WEAK)
586
14
    Result |= SymbolRef::SF_Weak;
587
9.19k
588
9.19k
  if (ESym->st_shndx == ELF::SHN_ABS)
589
228
    Result |= SymbolRef::SF_Absolute;
590
9.19k
591
9.19k
  if (ESym->getType() == ELF::STT_FILE || 
ESym->getType() == ELF::STT_SECTION9.06k
)
592
821
    Result |= SymbolRef::SF_FormatSpecific;
593
9.19k
594
9.19k
  auto DotSymtabSecSyms = EF.symbols(DotSymtabSec);
595
9.19k
  if (DotSymtabSecSyms && ESym == (*DotSymtabSecSyms).begin())
596
446
    Result |= SymbolRef::SF_FormatSpecific;
597
9.19k
  auto DotDynSymSecSyms = EF.symbols(DotDynSymSec);
598
9.19k
  if (DotDynSymSecSyms && ESym == (*DotDynSymSecSyms).begin())
599
1
    Result |= SymbolRef::SF_FormatSpecific;
600
9.19k
601
9.19k
  if (EF.getHeader()->e_machine == ELF::EM_ARM) {
602
6.70k
    if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
603
6.70k
      StringRef Name = *NameOrErr;
604
6.70k
      if (Name.startswith("$d") || 
Name.startswith("$t")6.49k
||
605
6.70k
          
Name.startswith("$a")4.44k
)
606
2.96k
        Result |= SymbolRef::SF_FormatSpecific;
607
6.70k
    } else {
608
0
      // TODO: Actually report errors helpfully.
609
0
      consumeError(NameOrErr.takeError());
610
0
    }
611
6.70k
    if (ESym->getType() == ELF::STT_FUNC && 
(ESym->st_value & 1) == 12.90k
)
612
2.19k
      Result |= SymbolRef::SF_Thumb;
613
6.70k
  }
614
9.19k
615
9.19k
  if (ESym->st_shndx == ELF::SHN_UNDEF)
616
776
    Result |= SymbolRef::SF_Undefined;
617
9.19k
618
9.19k
  if (ESym->getType() == ELF::STT_COMMON || ESym->st_shndx == ELF::SHN_COMMON)
619
27
    Result |= SymbolRef::SF_Common;
620
9.19k
621
9.19k
  if (isExportedToOtherDSO(ESym))
622
3.41k
    Result |= SymbolRef::SF_Exported;
623
9.19k
624
9.19k
  if (ESym->getVisibility() == ELF::STV_HIDDEN)
625
132
    Result |= SymbolRef::SF_Hidden;
626
9.19k
627
9.19k
  return Result;
628
9.19k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolFlags(llvm::object::DataRefImpl) const
Line
Count
Source
577
1.17k
uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
578
1.17k
  const Elf_Sym *ESym = getSymbol(Sym);
579
1.17k
580
1.17k
  uint32_t Result = SymbolRef::SF_None;
581
1.17k
582
1.17k
  if (ESym->getBinding() != ELF::STB_LOCAL)
583
405
    Result |= SymbolRef::SF_Global;
584
1.17k
585
1.17k
  if (ESym->getBinding() == ELF::STB_WEAK)
586
5
    Result |= SymbolRef::SF_Weak;
587
1.17k
588
1.17k
  if (ESym->st_shndx == ELF::SHN_ABS)
589
68
    Result |= SymbolRef::SF_Absolute;
590
1.17k
591
1.17k
  if (ESym->getType() == ELF::STT_FILE || 
ESym->getType() == ELF::STT_SECTION1.13k
)
592
129
    Result |= SymbolRef::SF_FormatSpecific;
593
1.17k
594
1.17k
  auto DotSymtabSecSyms = EF.symbols(DotSymtabSec);
595
1.17k
  if (DotSymtabSecSyms && ESym == (*DotSymtabSecSyms).begin())
596
87
    Result |= SymbolRef::SF_FormatSpecific;
597
1.17k
  auto DotDynSymSecSyms = EF.symbols(DotDynSymSec);
598
1.17k
  if (DotDynSymSecSyms && ESym == (*DotDynSymSecSyms).begin())
599
0
    Result |= SymbolRef::SF_FormatSpecific;
600
1.17k
601
1.17k
  if (EF.getHeader()->e_machine == ELF::EM_ARM) {
602
21
    if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
603
21
      StringRef Name = *NameOrErr;
604
21
      if (Name.startswith("$d") || Name.startswith("$t") ||
605
21
          
Name.startswith("$a")19
)
606
4
        Result |= SymbolRef::SF_FormatSpecific;
607
21
    } else {
608
0
      // TODO: Actually report errors helpfully.
609
0
      consumeError(NameOrErr.takeError());
610
0
    }
611
21
    if (ESym->getType() == ELF::STT_FUNC && 
(ESym->st_value & 1) == 10
)
612
0
      Result |= SymbolRef::SF_Thumb;
613
21
  }
614
1.17k
615
1.17k
  if (ESym->st_shndx == ELF::SHN_UNDEF)
616
139
    Result |= SymbolRef::SF_Undefined;
617
1.17k
618
1.17k
  if (ESym->getType() == ELF::STT_COMMON || ESym->st_shndx == ELF::SHN_COMMON)
619
17
    Result |= SymbolRef::SF_Common;
620
1.17k
621
1.17k
  if (isExportedToOtherDSO(ESym))
622
405
    Result |= SymbolRef::SF_Exported;
623
1.17k
624
1.17k
  if (ESym->getVisibility() == ELF::STV_HIDDEN)
625
166
    Result |= SymbolRef::SF_Hidden;
626
1.17k
627
1.17k
  return Result;
628
1.17k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolFlags(llvm::object::DataRefImpl) const
Line
Count
Source
577
32.0k
uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
578
32.0k
  const Elf_Sym *ESym = getSymbol(Sym);
579
32.0k
580
32.0k
  uint32_t Result = SymbolRef::SF_None;
581
32.0k
582
32.0k
  if (ESym->getBinding() != ELF::STB_LOCAL)
583
17.0k
    Result |= SymbolRef::SF_Global;
584
32.0k
585
32.0k
  if (ESym->getBinding() == ELF::STB_WEAK)
586
3.98k
    Result |= SymbolRef::SF_Weak;
587
32.0k
588
32.0k
  if (ESym->st_shndx == ELF::SHN_ABS)
589
1.04k
    Result |= SymbolRef::SF_Absolute;
590
32.0k
591
32.0k
  if (ESym->getType() == ELF::STT_FILE || 
ESym->getType() == ELF::STT_SECTION31.3k
)
592
3.46k
    Result |= SymbolRef::SF_FormatSpecific;
593
32.0k
594
32.0k
  auto DotSymtabSecSyms = EF.symbols(DotSymtabSec);
595
32.0k
  if (DotSymtabSecSyms && ESym == (*DotSymtabSecSyms).begin())
596
1.32k
    Result |= SymbolRef::SF_FormatSpecific;
597
32.0k
  auto DotDynSymSecSyms = EF.symbols(DotDynSymSec);
598
32.0k
  if (DotDynSymSecSyms && ESym == (*DotDynSymSecSyms).begin())
599
4
    Result |= SymbolRef::SF_FormatSpecific;
600
32.0k
601
32.0k
  if (EF.getHeader()->e_machine == ELF::EM_ARM) {
602
0
    if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
603
0
      StringRef Name = *NameOrErr;
604
0
      if (Name.startswith("$d") || Name.startswith("$t") ||
605
0
          Name.startswith("$a"))
606
0
        Result |= SymbolRef::SF_FormatSpecific;
607
0
    } else {
608
0
      // TODO: Actually report errors helpfully.
609
0
      consumeError(NameOrErr.takeError());
610
0
    }
611
0
    if (ESym->getType() == ELF::STT_FUNC && (ESym->st_value & 1) == 1)
612
0
      Result |= SymbolRef::SF_Thumb;
613
0
  }
614
32.0k
615
32.0k
  if (ESym->st_shndx == ELF::SHN_UNDEF)
616
2.23k
    Result |= SymbolRef::SF_Undefined;
617
32.0k
618
32.0k
  if (ESym->getType() == ELF::STT_COMMON || ESym->st_shndx == ELF::SHN_COMMON)
619
402
    Result |= SymbolRef::SF_Common;
620
32.0k
621
32.0k
  if (isExportedToOtherDSO(ESym))
622
8.42k
    Result |= SymbolRef::SF_Exported;
623
32.0k
624
32.0k
  if (ESym->getVisibility() == ELF::STV_HIDDEN)
625
10.1k
    Result |= SymbolRef::SF_Hidden;
626
32.0k
627
32.0k
  return Result;
628
32.0k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolFlags(llvm::object::DataRefImpl) const
Line
Count
Source
577
906
uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
578
906
  const Elf_Sym *ESym = getSymbol(Sym);
579
906
580
906
  uint32_t Result = SymbolRef::SF_None;
581
906
582
906
  if (ESym->getBinding() != ELF::STB_LOCAL)
583
349
    Result |= SymbolRef::SF_Global;
584
906
585
906
  if (ESym->getBinding() == ELF::STB_WEAK)
586
3
    Result |= SymbolRef::SF_Weak;
587
906
588
906
  if (ESym->st_shndx == ELF::SHN_ABS)
589
47
    Result |= SymbolRef::SF_Absolute;
590
906
591
906
  if (ESym->getType() == ELF::STT_FILE || 
ESym->getType() == ELF::STT_SECTION874
)
592
134
    Result |= SymbolRef::SF_FormatSpecific;
593
906
594
906
  auto DotSymtabSecSyms = EF.symbols(DotSymtabSec);
595
906
  if (DotSymtabSecSyms && ESym == (*DotSymtabSecSyms).begin())
596
79
    Result |= SymbolRef::SF_FormatSpecific;
597
906
  auto DotDynSymSecSyms = EF.symbols(DotDynSymSec);
598
906
  if (DotDynSymSecSyms && ESym == (*DotDynSymSecSyms).begin())
599
0
    Result |= SymbolRef::SF_FormatSpecific;
600
906
601
906
  if (EF.getHeader()->e_machine == ELF::EM_ARM) {
602
0
    if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
603
0
      StringRef Name = *NameOrErr;
604
0
      if (Name.startswith("$d") || Name.startswith("$t") ||
605
0
          Name.startswith("$a"))
606
0
        Result |= SymbolRef::SF_FormatSpecific;
607
0
    } else {
608
0
      // TODO: Actually report errors helpfully.
609
0
      consumeError(NameOrErr.takeError());
610
0
    }
611
0
    if (ESym->getType() == ELF::STT_FUNC && (ESym->st_value & 1) == 1)
612
0
      Result |= SymbolRef::SF_Thumb;
613
0
  }
614
906
615
906
  if (ESym->st_shndx == ELF::SHN_UNDEF)
616
143
    Result |= SymbolRef::SF_Undefined;
617
906
618
906
  if (ESym->getType() == ELF::STT_COMMON || ESym->st_shndx == ELF::SHN_COMMON)
619
9
    Result |= SymbolRef::SF_Common;
620
906
621
906
  if (isExportedToOtherDSO(ESym))
622
349
    Result |= SymbolRef::SF_Exported;
623
906
624
906
  if (ESym->getVisibility() == ELF::STV_HIDDEN)
625
93
    Result |= SymbolRef::SF_Hidden;
626
906
627
906
  return Result;
628
906
}
629
630
template <class ELFT>
631
Expected<section_iterator>
632
ELFObjectFile<ELFT>::getSymbolSection(const Elf_Sym *ESym,
633
23.1k
                                      const Elf_Shdr *SymTab) const {
634
23.1k
  auto ESecOrErr = EF.getSection(ESym, SymTab, ShndxTable);
635
23.1k
  if (!ESecOrErr)
636
0
    return ESecOrErr.takeError();
637
23.1k
638
23.1k
  const Elf_Shdr *ESec = *ESecOrErr;
639
23.1k
  if (!ESec)
640
1.94k
    return section_end();
641
21.1k
642
21.1k
  DataRefImpl Sec;
643
21.1k
  Sec.p = reinterpret_cast<intptr_t>(ESec);
644
21.1k
  return section_iterator(SectionRef(Sec, this));
645
21.1k
}
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
633
8.31k
                                      const Elf_Shdr *SymTab) const {
634
8.31k
  auto ESecOrErr = EF.getSection(ESym, SymTab, ShndxTable);
635
8.31k
  if (!ESecOrErr)
636
0
    return ESecOrErr.takeError();
637
8.31k
638
8.31k
  const Elf_Shdr *ESec = *ESecOrErr;
639
8.31k
  if (!ESec)
640
398
    return section_end();
641
7.91k
642
7.91k
  DataRefImpl Sec;
643
7.91k
  Sec.p = reinterpret_cast<intptr_t>(ESec);
644
7.91k
  return section_iterator(SectionRef(Sec, this));
645
7.91k
}
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
633
845
                                      const Elf_Shdr *SymTab) const {
634
845
  auto ESecOrErr = EF.getSection(ESym, SymTab, ShndxTable);
635
845
  if (!ESecOrErr)
636
0
    return ESecOrErr.takeError();
637
845
638
845
  const Elf_Shdr *ESec = *ESecOrErr;
639
845
  if (!ESec)
640
109
    return section_end();
641
736
642
736
  DataRefImpl Sec;
643
736
  Sec.p = reinterpret_cast<intptr_t>(ESec);
644
736
  return section_iterator(SectionRef(Sec, this));
645
736
}
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
633
13.3k
                                      const Elf_Shdr *SymTab) const {
634
13.3k
  auto ESecOrErr = EF.getSection(ESym, SymTab, ShndxTable);
635
13.3k
  if (!ESecOrErr)
636
0
    return ESecOrErr.takeError();
637
13.3k
638
13.3k
  const Elf_Shdr *ESec = *ESecOrErr;
639
13.3k
  if (!ESec)
640
1.34k
    return section_end();
641
12.0k
642
12.0k
  DataRefImpl Sec;
643
12.0k
  Sec.p = reinterpret_cast<intptr_t>(ESec);
644
12.0k
  return section_iterator(SectionRef(Sec, this));
645
12.0k
}
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
633
601
                                      const Elf_Shdr *SymTab) const {
634
601
  auto ESecOrErr = EF.getSection(ESym, SymTab, ShndxTable);
635
601
  if (!ESecOrErr)
636
0
    return ESecOrErr.takeError();
637
601
638
601
  const Elf_Shdr *ESec = *ESecOrErr;
639
601
  if (!ESec)
640
94
    return section_end();
641
507
642
507
  DataRefImpl Sec;
643
507
  Sec.p = reinterpret_cast<intptr_t>(ESec);
644
507
  return section_iterator(SectionRef(Sec, this));
645
507
}
646
647
template <class ELFT>
648
Expected<section_iterator>
649
23.1k
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb) const {
650
23.1k
  const Elf_Sym *Sym = getSymbol(Symb);
651
23.1k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
652
23.1k
  if (!SymTabOrErr)
653
0
    return SymTabOrErr.takeError();
654
23.1k
  const Elf_Shdr *SymTab = *SymTabOrErr;
655
23.1k
  return getSymbolSection(Sym, SymTab);
656
23.1k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbolSection(llvm::object::DataRefImpl) const
Line
Count
Source
649
8.31k
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb) const {
650
8.31k
  const Elf_Sym *Sym = getSymbol(Symb);
651
8.31k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
652
8.31k
  if (!SymTabOrErr)
653
0
    return SymTabOrErr.takeError();
654
8.31k
  const Elf_Shdr *SymTab = *SymTabOrErr;
655
8.31k
  return getSymbolSection(Sym, SymTab);
656
8.31k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbolSection(llvm::object::DataRefImpl) const
Line
Count
Source
649
845
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb) const {
650
845
  const Elf_Sym *Sym = getSymbol(Symb);
651
845
  auto SymTabOrErr = EF.getSection(Symb.d.a);
652
845
  if (!SymTabOrErr)
653
0
    return SymTabOrErr.takeError();
654
845
  const Elf_Shdr *SymTab = *SymTabOrErr;
655
845
  return getSymbolSection(Sym, SymTab);
656
845
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbolSection(llvm::object::DataRefImpl) const
Line
Count
Source
649
13.3k
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb) const {
650
13.3k
  const Elf_Sym *Sym = getSymbol(Symb);
651
13.3k
  auto SymTabOrErr = EF.getSection(Symb.d.a);
652
13.3k
  if (!SymTabOrErr)
653
0
    return SymTabOrErr.takeError();
654
13.3k
  const Elf_Shdr *SymTab = *SymTabOrErr;
655
13.3k
  return getSymbolSection(Sym, SymTab);
656
13.3k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbolSection(llvm::object::DataRefImpl) const
Line
Count
Source
649
601
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb) const {
650
601
  const Elf_Sym *Sym = getSymbol(Symb);
651
601
  auto SymTabOrErr = EF.getSection(Symb.d.a);
652
601
  if (!SymTabOrErr)
653
0
    return SymTabOrErr.takeError();
654
601
  const Elf_Shdr *SymTab = *SymTabOrErr;
655
601
  return getSymbolSection(Sym, SymTab);
656
601
}
657
658
template <class ELFT>
659
124k
void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {
660
124k
  const Elf_Shdr *ESec = getSection(Sec);
661
124k
  Sec = toDRI(++ESec);
662
124k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::moveSectionNext(llvm::object::DataRefImpl&) const
Line
Count
Source
659
13.0k
void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {
660
13.0k
  const Elf_Shdr *ESec = getSection(Sec);
661
13.0k
  Sec = toDRI(++ESec);
662
13.0k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::moveSectionNext(llvm::object::DataRefImpl&) const
Line
Count
Source
659
4.83k
void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {
660
4.83k
  const Elf_Shdr *ESec = getSection(Sec);
661
4.83k
  Sec = toDRI(++ESec);
662
4.83k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::moveSectionNext(llvm::object::DataRefImpl&) const
Line
Count
Source
659
102k
void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {
660
102k
  const Elf_Shdr *ESec = getSection(Sec);
661
102k
  Sec = toDRI(++ESec);
662
102k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::moveSectionNext(llvm::object::DataRefImpl&) const
Line
Count
Source
659
4.10k
void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {
660
4.10k
  const Elf_Shdr *ESec = getSection(Sec);
661
4.10k
  Sec = toDRI(++ESec);
662
4.10k
}
663
664
template <class ELFT>
665
std::error_code ELFObjectFile<ELFT>::getSectionName(DataRefImpl Sec,
666
108k
                                                    StringRef &Result) const {
667
108k
  auto Name = EF.getSectionName(&*getSection(Sec));
668
108k
  if (!Name)
669
32
    return errorToErrorCode(Name.takeError());
670
108k
  Result = *Name;
671
108k
  return std::error_code();
672
108k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionName(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
666
7.29k
                                                    StringRef &Result) const {
667
7.29k
  auto Name = EF.getSectionName(&*getSection(Sec));
668
7.29k
  if (!Name)
669
28
    return errorToErrorCode(Name.takeError());
670
7.26k
  Result = *Name;
671
7.26k
  return std::error_code();
672
7.26k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionName(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
666
2.30k
                                                    StringRef &Result) const {
667
2.30k
  auto Name = EF.getSectionName(&*getSection(Sec));
668
2.30k
  if (!Name)
669
0
    return errorToErrorCode(Name.takeError());
670
2.30k
  Result = *Name;
671
2.30k
  return std::error_code();
672
2.30k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionName(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
666
97.1k
                                                    StringRef &Result) const {
667
97.1k
  auto Name = EF.getSectionName(&*getSection(Sec));
668
97.1k
  if (!Name)
669
4
    return errorToErrorCode(Name.takeError());
670
97.1k
  Result = *Name;
671
97.1k
  return std::error_code();
672
97.1k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionName(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
666
2.09k
                                                    StringRef &Result) const {
667
2.09k
  auto Name = EF.getSectionName(&*getSection(Sec));
668
2.09k
  if (!Name)
669
0
    return errorToErrorCode(Name.takeError());
670
2.09k
  Result = *Name;
671
2.09k
  return std::error_code();
672
2.09k
}
673
674
template <class ELFT>
675
22.9k
uint64_t ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec) const {
676
22.9k
  return getSection(Sec)->sh_addr;
677
22.9k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionAddress(llvm::object::DataRefImpl) const
Line
Count
Source
675
4.70k
uint64_t ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec) const {
676
4.70k
  return getSection(Sec)->sh_addr;
677
4.70k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionAddress(llvm::object::DataRefImpl) const
Line
Count
Source
675
1.50k
uint64_t ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec) const {
676
1.50k
  return getSection(Sec)->sh_addr;
677
1.50k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionAddress(llvm::object::DataRefImpl) const
Line
Count
Source
675
15.1k
uint64_t ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec) const {
676
15.1k
  return getSection(Sec)->sh_addr;
677
15.1k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionAddress(llvm::object::DataRefImpl) const
Line
Count
Source
675
1.63k
uint64_t ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec) const {
676
1.63k
  return getSection(Sec)->sh_addr;
677
1.63k
}
678
679
template <class ELFT>
680
3.86k
uint64_t ELFObjectFile<ELFT>::getSectionIndex(DataRefImpl Sec) const {
681
3.86k
  auto SectionsOrErr = EF.sections();
682
3.86k
  handleAllErrors(std::move(SectionsOrErr.takeError()),
683
3.86k
                  [](const ErrorInfoBase &) {
684
0
                    llvm_unreachable("unable to get section index");
685
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
686
3.86k
  const Elf_Shdr *First = SectionsOrErr->begin();
687
3.86k
  return getSection(Sec) - First;
688
3.86k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionIndex(llvm::object::DataRefImpl) const
Line
Count
Source
680
344
uint64_t ELFObjectFile<ELFT>::getSectionIndex(DataRefImpl Sec) const {
681
344
  auto SectionsOrErr = EF.sections();
682
344
  handleAllErrors(std::move(SectionsOrErr.takeError()),
683
344
                  [](const ErrorInfoBase &) {
684
344
                    llvm_unreachable("unable to get section index");
685
344
                  });
686
344
  const Elf_Shdr *First = SectionsOrErr->begin();
687
344
  return getSection(Sec) - First;
688
344
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionIndex(llvm::object::DataRefImpl) const
Line
Count
Source
680
128
uint64_t ELFObjectFile<ELFT>::getSectionIndex(DataRefImpl Sec) const {
681
128
  auto SectionsOrErr = EF.sections();
682
128
  handleAllErrors(std::move(SectionsOrErr.takeError()),
683
128
                  [](const ErrorInfoBase &) {
684
128
                    llvm_unreachable("unable to get section index");
685
128
                  });
686
128
  const Elf_Shdr *First = SectionsOrErr->begin();
687
128
  return getSection(Sec) - First;
688
128
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionIndex(llvm::object::DataRefImpl) const
Line
Count
Source
680
3.24k
uint64_t ELFObjectFile<ELFT>::getSectionIndex(DataRefImpl Sec) const {
681
3.24k
  auto SectionsOrErr = EF.sections();
682
3.24k
  handleAllErrors(std::move(SectionsOrErr.takeError()),
683
3.24k
                  [](const ErrorInfoBase &) {
684
3.24k
                    llvm_unreachable("unable to get section index");
685
3.24k
                  });
686
3.24k
  const Elf_Shdr *First = SectionsOrErr->begin();
687
3.24k
  return getSection(Sec) - First;
688
3.24k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionIndex(llvm::object::DataRefImpl) const
Line
Count
Source
680
152
uint64_t ELFObjectFile<ELFT>::getSectionIndex(DataRefImpl Sec) const {
681
152
  auto SectionsOrErr = EF.sections();
682
152
  handleAllErrors(std::move(SectionsOrErr.takeError()),
683
152
                  [](const ErrorInfoBase &) {
684
152
                    llvm_unreachable("unable to get section index");
685
152
                  });
686
152
  const Elf_Shdr *First = SectionsOrErr->begin();
687
152
  return getSection(Sec) - First;
688
152
}
689
690
template <class ELFT>
691
196k
uint64_t ELFObjectFile<ELFT>::getSectionSize(DataRefImpl Sec) const {
692
196k
  return getSection(Sec)->sh_size;
693
196k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionSize(llvm::object::DataRefImpl) const
Line
Count
Source
691
1.35k
uint64_t ELFObjectFile<ELFT>::getSectionSize(DataRefImpl Sec) const {
692
1.35k
  return getSection(Sec)->sh_size;
693
1.35k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionSize(llvm::object::DataRefImpl) const
Line
Count
Source
691
566
uint64_t ELFObjectFile<ELFT>::getSectionSize(DataRefImpl Sec) const {
692
566
  return getSection(Sec)->sh_size;
693
566
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionSize(llvm::object::DataRefImpl) const
Line
Count
Source
691
194k
uint64_t ELFObjectFile<ELFT>::getSectionSize(DataRefImpl Sec) const {
692
194k
  return getSection(Sec)->sh_size;
693
194k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionSize(llvm::object::DataRefImpl) const
Line
Count
Source
691
596
uint64_t ELFObjectFile<ELFT>::getSectionSize(DataRefImpl Sec) const {
692
596
  return getSection(Sec)->sh_size;
693
596
}
694
695
template <class ELFT>
696
std::error_code
697
ELFObjectFile<ELFT>::getSectionContents(DataRefImpl Sec,
698
13.3k
                                        StringRef &Result) const {
699
13.3k
  const Elf_Shdr *EShdr = getSection(Sec);
700
13.3k
  if (std::error_code EC =
701
16
          checkOffset(getMemoryBufferRef(),
702
16
                      (uintptr_t)base() + EShdr->sh_offset, EShdr->sh_size))
703
16
    return EC;
704
13.3k
  Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
705
13.3k
  return std::error_code();
706
13.3k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionContents(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
698
1.86k
                                        StringRef &Result) const {
699
1.86k
  const Elf_Shdr *EShdr = getSection(Sec);
700
1.86k
  if (std::error_code EC =
701
16
          checkOffset(getMemoryBufferRef(),
702
16
                      (uintptr_t)base() + EShdr->sh_offset, EShdr->sh_size))
703
16
    return EC;
704
1.84k
  Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
705
1.84k
  return std::error_code();
706
1.84k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionContents(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
698
636
                                        StringRef &Result) const {
699
636
  const Elf_Shdr *EShdr = getSection(Sec);
700
636
  if (std::error_code EC =
701
0
          checkOffset(getMemoryBufferRef(),
702
0
                      (uintptr_t)base() + EShdr->sh_offset, EShdr->sh_size))
703
0
    return EC;
704
636
  Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
705
636
  return std::error_code();
706
636
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionContents(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
698
10.1k
                                        StringRef &Result) const {
699
10.1k
  const Elf_Shdr *EShdr = getSection(Sec);
700
10.1k
  if (std::error_code EC =
701
0
          checkOffset(getMemoryBufferRef(),
702
0
                      (uintptr_t)base() + EShdr->sh_offset, EShdr->sh_size))
703
0
    return EC;
704
10.1k
  Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
705
10.1k
  return std::error_code();
706
10.1k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionContents(llvm::object::DataRefImpl, llvm::StringRef&) const
Line
Count
Source
698
662
                                        StringRef &Result) const {
699
662
  const Elf_Shdr *EShdr = getSection(Sec);
700
662
  if (std::error_code EC =
701
0
          checkOffset(getMemoryBufferRef(),
702
0
                      (uintptr_t)base() + EShdr->sh_offset, EShdr->sh_size))
703
0
    return EC;
704
662
  Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
705
662
  return std::error_code();
706
662
}
707
708
template <class ELFT>
709
1.00k
uint64_t ELFObjectFile<ELFT>::getSectionAlignment(DataRefImpl Sec) const {
710
1.00k
  return getSection(Sec)->sh_addralign;
711
1.00k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
709
166
uint64_t ELFObjectFile<ELFT>::getSectionAlignment(DataRefImpl Sec) const {
710
166
  return getSection(Sec)->sh_addralign;
711
166
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
709
160
uint64_t ELFObjectFile<ELFT>::getSectionAlignment(DataRefImpl Sec) const {
710
160
  return getSection(Sec)->sh_addralign;
711
160
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
709
502
uint64_t ELFObjectFile<ELFT>::getSectionAlignment(DataRefImpl Sec) const {
710
502
  return getSection(Sec)->sh_addralign;
711
502
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionAlignment(llvm::object::DataRefImpl) const
Line
Count
Source
709
176
uint64_t ELFObjectFile<ELFT>::getSectionAlignment(DataRefImpl Sec) const {
710
176
  return getSection(Sec)->sh_addralign;
711
176
}
712
713
template <class ELFT>
714
8.46k
bool ELFObjectFile<ELFT>::isSectionCompressed(DataRefImpl Sec) const {
715
8.46k
  return getSection(Sec)->sh_flags & ELF::SHF_COMPRESSED;
716
8.46k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isSectionCompressed(llvm::object::DataRefImpl) const
Line
Count
Source
714
737
bool ELFObjectFile<ELFT>::isSectionCompressed(DataRefImpl Sec) const {
715
737
  return getSection(Sec)->sh_flags & ELF::SHF_COMPRESSED;
716
737
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isSectionCompressed(llvm::object::DataRefImpl) const
Line
Count
Source
714
233
bool ELFObjectFile<ELFT>::isSectionCompressed(DataRefImpl Sec) const {
715
233
  return getSection(Sec)->sh_flags & ELF::SHF_COMPRESSED;
716
233
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isSectionCompressed(llvm::object::DataRefImpl) const
Line
Count
Source
714
7.21k
bool ELFObjectFile<ELFT>::isSectionCompressed(DataRefImpl Sec) const {
715
7.21k
  return getSection(Sec)->sh_flags & ELF::SHF_COMPRESSED;
716
7.21k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isSectionCompressed(llvm::object::DataRefImpl) const
Line
Count
Source
714
287
bool ELFObjectFile<ELFT>::isSectionCompressed(DataRefImpl Sec) const {
715
287
  return getSection(Sec)->sh_flags & ELF::SHF_COMPRESSED;
716
287
}
717
718
template <class ELFT>
719
13.4k
bool ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec) const {
720
13.4k
  return getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR;
721
13.4k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isSectionText(llvm::object::DataRefImpl) const
Line
Count
Source
719
3.72k
bool ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec) const {
720
3.72k
  return getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR;
721
3.72k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isSectionText(llvm::object::DataRefImpl) const
Line
Count
Source
719
1.14k
bool ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec) const {
720
1.14k
  return getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR;
721
1.14k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isSectionText(llvm::object::DataRefImpl) const
Line
Count
Source
719
7.67k
bool ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec) const {
720
7.67k
  return getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR;
721
7.67k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isSectionText(llvm::object::DataRefImpl) const
Line
Count
Source
719
954
bool ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec) const {
720
954
  return getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR;
721
954
}
722
723
template <class ELFT>
724
1.54k
bool ELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec) const {
725
1.54k
  const Elf_Shdr *EShdr = getSection(Sec);
726
1.54k
  return EShdr->sh_type == ELF::SHT_PROGBITS &&
727
1.54k
         
EShdr->sh_flags & ELF::SHF_ALLOC634
&&
728
1.54k
         
!(EShdr->sh_flags & ELF::SHF_EXECINSTR)399
;
729
1.54k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isSectionData(llvm::object::DataRefImpl) const
Line
Count
Source
724
56
bool ELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec) const {
725
56
  const Elf_Shdr *EShdr = getSection(Sec);
726
56
  return EShdr->sh_type == ELF::SHT_PROGBITS &&
727
56
         
EShdr->sh_flags & ELF::SHF_ALLOC19
&&
728
56
         
!(EShdr->sh_flags & ELF::SHF_EXECINSTR)14
;
729
56
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isSectionData(llvm::object::DataRefImpl) const
Line
Count
Source
724
26
bool ELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec) const {
725
26
  const Elf_Shdr *EShdr = getSection(Sec);
726
26
  return EShdr->sh_type == ELF::SHT_PROGBITS &&
727
26
         
EShdr->sh_flags & ELF::SHF_ALLOC8
&&
728
26
         
!(EShdr->sh_flags & ELF::SHF_EXECINSTR)6
;
729
26
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isSectionData(llvm::object::DataRefImpl) const
Line
Count
Source
724
1.38k
bool ELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec) const {
725
1.38k
  const Elf_Shdr *EShdr = getSection(Sec);
726
1.38k
  return EShdr->sh_type == ELF::SHT_PROGBITS &&
727
1.38k
         
EShdr->sh_flags & ELF::SHF_ALLOC584
&&
728
1.38k
         
!(EShdr->sh_flags & ELF::SHF_EXECINSTR)361
;
729
1.38k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isSectionData(llvm::object::DataRefImpl) const
Line
Count
Source
724
81
bool ELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec) const {
725
81
  const Elf_Shdr *EShdr = getSection(Sec);
726
81
  return EShdr->sh_type == ELF::SHT_PROGBITS &&
727
81
         
EShdr->sh_flags & ELF::SHF_ALLOC23
&&
728
81
         
!(EShdr->sh_flags & ELF::SHF_EXECINSTR)18
;
729
81
}
730
731
template <class ELFT>
732
12.2k
bool ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec) const {
733
12.2k
  const Elf_Shdr *EShdr = getSection(Sec);
734
12.2k
  return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
735
12.2k
         
EShdr->sh_type == ELF::SHT_NOBITS3.57k
;
736
12.2k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isSectionBSS(llvm::object::DataRefImpl) const
Line
Count
Source
732
1.28k
bool ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec) const {
733
1.28k
  const Elf_Shdr *EShdr = getSection(Sec);
734
1.28k
  return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
735
1.28k
         
EShdr->sh_type == ELF::SHT_NOBITS446
;
736
1.28k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isSectionBSS(llvm::object::DataRefImpl) const
Line
Count
Source
732
502
bool ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec) const {
733
502
  const Elf_Shdr *EShdr = getSection(Sec);
734
502
  return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
735
502
         
EShdr->sh_type == ELF::SHT_NOBITS217
;
736
502
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isSectionBSS(llvm::object::DataRefImpl) const
Line
Count
Source
732
10.0k
bool ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec) const {
733
10.0k
  const Elf_Shdr *EShdr = getSection(Sec);
734
10.0k
  return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
735
10.0k
         
EShdr->sh_type == ELF::SHT_NOBITS2.73k
;
736
10.0k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isSectionBSS(llvm::object::DataRefImpl) const
Line
Count
Source
732
456
bool ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec) const {
733
456
  const Elf_Shdr *EShdr = getSection(Sec);
734
456
  return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
735
456
         
EShdr->sh_type == ELF::SHT_NOBITS177
;
736
456
}
737
738
template <class ELFT>
739
std::vector<SectionRef>
740
0
ELFObjectFile<ELFT>::dynamic_relocation_sections() const {
741
0
  std::vector<SectionRef> Res;
742
0
  std::vector<uintptr_t> Offsets;
743
0
744
0
  auto SectionsOrErr = EF.sections();
745
0
  if (!SectionsOrErr)
746
0
    return Res;
747
0
748
0
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
749
0
    if (Sec.sh_type != ELF::SHT_DYNAMIC)
750
0
      continue;
751
0
    Elf_Dyn *Dynamic =
752
0
        reinterpret_cast<Elf_Dyn *>((uintptr_t)base() + Sec.sh_offset);
753
0
    for (; Dynamic->d_tag != ELF::DT_NULL; Dynamic++) {
754
0
      if (Dynamic->d_tag == ELF::DT_REL || Dynamic->d_tag == ELF::DT_RELA ||
755
0
          Dynamic->d_tag == ELF::DT_JMPREL) {
756
0
        Offsets.push_back(Dynamic->d_un.d_val);
757
0
      }
758
0
    }
759
0
  }
760
0
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
761
0
    if (is_contained(Offsets, Sec.sh_offset))
762
0
      Res.emplace_back(toDRI(&Sec), this);
763
0
  }
764
0
  return Res;
765
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
766
767
template <class ELFT>
768
15.5k
bool ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec) const {
769
15.5k
  return getSection(Sec)->sh_type == ELF::SHT_NOBITS;
770
15.5k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isSectionVirtual(llvm::object::DataRefImpl) const
Line
Count
Source
768
3.34k
bool ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec) const {
769
3.34k
  return getSection(Sec)->sh_type == ELF::SHT_NOBITS;
770
3.34k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isSectionVirtual(llvm::object::DataRefImpl) const
Line
Count
Source
768
665
bool ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec) const {
769
665
  return getSection(Sec)->sh_type == ELF::SHT_NOBITS;
770
665
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isSectionVirtual(llvm::object::DataRefImpl) const
Line
Count
Source
768
10.8k
bool ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec) const {
769
10.8k
  return getSection(Sec)->sh_type == ELF::SHT_NOBITS;
770
10.8k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isSectionVirtual(llvm::object::DataRefImpl) const
Line
Count
Source
768
711
bool ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec) const {
769
711
  return getSection(Sec)->sh_type == ELF::SHT_NOBITS;
770
711
}
771
772
template <class ELFT>
773
78
bool ELFObjectFile<ELFT>::isBerkeleyText(DataRefImpl Sec) const {
774
78
  return getSection(Sec)->sh_flags & ELF::SHF_ALLOC &&
775
78
         
(32
getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR32
||
776
32
          
!(getSection(Sec)->sh_flags & ELF::SHF_WRITE)20
);
777
78
}
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isBerkeleyText(llvm::object::DataRefImpl) const
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isBerkeleyText(llvm::object::DataRefImpl) const
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isBerkeleyText(llvm::object::DataRefImpl) const
Line
Count
Source
773
78
bool ELFObjectFile<ELFT>::isBerkeleyText(DataRefImpl Sec) const {
774
78
  return getSection(Sec)->sh_flags & ELF::SHF_ALLOC &&
775
78
         
(32
getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR32
||
776
32
          
!(getSection(Sec)->sh_flags & ELF::SHF_WRITE)20
);
777
78
}
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isBerkeleyText(llvm::object::DataRefImpl) const
778
779
template <class ELFT>
780
39
bool ELFObjectFile<ELFT>::isBerkeleyData(DataRefImpl Sec) const {
781
39
  const Elf_Shdr *EShdr = getSection(Sec);
782
39
  return !isBerkeleyText(Sec) && 
EShdr->sh_type != ELF::SHT_NOBITS31
&&
783
39
         
EShdr->sh_flags & ELF::SHF_ALLOC28
;
784
39
}
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isBerkeleyData(llvm::object::DataRefImpl) const
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isBerkeleyData(llvm::object::DataRefImpl) const
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isBerkeleyData(llvm::object::DataRefImpl) const
Line
Count
Source
780
39
bool ELFObjectFile<ELFT>::isBerkeleyData(DataRefImpl Sec) const {
781
39
  const Elf_Shdr *EShdr = getSection(Sec);
782
39
  return !isBerkeleyText(Sec) && 
EShdr->sh_type != ELF::SHT_NOBITS31
&&
783
39
         
EShdr->sh_flags & ELF::SHF_ALLOC28
;
784
39
}
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isBerkeleyData(llvm::object::DataRefImpl) const
785
786
template <class ELFT>
787
relocation_iterator
788
6.55k
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
789
6.55k
  DataRefImpl RelData;
790
6.55k
  auto SectionsOrErr = EF.sections();
791
6.55k
  if (!SectionsOrErr)
792
0
    return relocation_iterator(RelocationRef());
793
6.55k
  uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
794
6.55k
  RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
795
6.55k
  RelData.d.b = 0;
796
6.55k
  return relocation_iterator(RelocationRef(RelData, this));
797
6.55k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::section_rel_begin(llvm::object::DataRefImpl) const
Line
Count
Source
788
916
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
789
916
  DataRefImpl RelData;
790
916
  auto SectionsOrErr = EF.sections();
791
916
  if (!SectionsOrErr)
792
0
    return relocation_iterator(RelocationRef());
793
916
  uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
794
916
  RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
795
916
  RelData.d.b = 0;
796
916
  return relocation_iterator(RelocationRef(RelData, this));
797
916
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::section_rel_begin(llvm::object::DataRefImpl) const
Line
Count
Source
788
232
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
789
232
  DataRefImpl RelData;
790
232
  auto SectionsOrErr = EF.sections();
791
232
  if (!SectionsOrErr)
792
0
    return relocation_iterator(RelocationRef());
793
232
  uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
794
232
  RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
795
232
  RelData.d.b = 0;
796
232
  return relocation_iterator(RelocationRef(RelData, this));
797
232
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::section_rel_begin(llvm::object::DataRefImpl) const
Line
Count
Source
788
5.16k
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
789
5.16k
  DataRefImpl RelData;
790
5.16k
  auto SectionsOrErr = EF.sections();
791
5.16k
  if (!SectionsOrErr)
792
0
    return relocation_iterator(RelocationRef());
793
5.16k
  uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
794
5.16k
  RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
795
5.16k
  RelData.d.b = 0;
796
5.16k
  return relocation_iterator(RelocationRef(RelData, this));
797
5.16k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::section_rel_begin(llvm::object::DataRefImpl) const
Line
Count
Source
788
240
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
789
240
  DataRefImpl RelData;
790
240
  auto SectionsOrErr = EF.sections();
791
240
  if (!SectionsOrErr)
792
0
    return relocation_iterator(RelocationRef());
793
240
  uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
794
240
  RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
795
240
  RelData.d.b = 0;
796
240
  return relocation_iterator(RelocationRef(RelData, this));
797
240
}
798
799
template <class ELFT>
800
relocation_iterator
801
3.27k
ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
802
3.27k
  const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
803
3.27k
  relocation_iterator Begin = section_rel_begin(Sec);
804
3.27k
  if (S->sh_type != ELF::SHT_RELA && 
S->sh_type != ELF::SHT_REL977
)
805
596
    return Begin;
806
2.68k
  DataRefImpl RelData = Begin->getRawDataRefImpl();
807
2.68k
  const Elf_Shdr *RelSec = getRelSection(RelData);
808
2.68k
809
2.68k
  // Error check sh_link here so that getRelocationSymbol can just use it.
810
2.68k
  auto SymSecOrErr = EF.getSection(RelSec->sh_link);
811
2.68k
  if (!SymSecOrErr)
812
0
    report_fatal_error(errorToErrorCode(SymSecOrErr.takeError()).message());
813
2.68k
814
2.68k
  RelData.d.b += S->sh_size / S->sh_entsize;
815
2.68k
  return relocation_iterator(RelocationRef(RelData, this));
816
2.68k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::section_rel_end(llvm::object::DataRefImpl) const
Line
Count
Source
801
458
ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
802
458
  const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
803
458
  relocation_iterator Begin = section_rel_begin(Sec);
804
458
  if (S->sh_type != ELF::SHT_RELA && 
S->sh_type != ELF::SHT_REL408
)
805
131
    return Begin;
806
327
  DataRefImpl RelData = Begin->getRawDataRefImpl();
807
327
  const Elf_Shdr *RelSec = getRelSection(RelData);
808
327
809
327
  // Error check sh_link here so that getRelocationSymbol can just use it.
810
327
  auto SymSecOrErr = EF.getSection(RelSec->sh_link);
811
327
  if (!SymSecOrErr)
812
0
    report_fatal_error(errorToErrorCode(SymSecOrErr.takeError()).message());
813
327
814
327
  RelData.d.b += S->sh_size / S->sh_entsize;
815
327
  return relocation_iterator(RelocationRef(RelData, this));
816
327
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::section_rel_end(llvm::object::DataRefImpl) const
Line
Count
Source
801
116
ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
802
116
  const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
803
116
  relocation_iterator Begin = section_rel_begin(Sec);
804
116
  if (S->sh_type != ELF::SHT_RELA && 
S->sh_type != ELF::SHT_REL82
)
805
12
    return Begin;
806
104
  DataRefImpl RelData = Begin->getRawDataRefImpl();
807
104
  const Elf_Shdr *RelSec = getRelSection(RelData);
808
104
809
104
  // Error check sh_link here so that getRelocationSymbol can just use it.
810
104
  auto SymSecOrErr = EF.getSection(RelSec->sh_link);
811
104
  if (!SymSecOrErr)
812
0
    report_fatal_error(errorToErrorCode(SymSecOrErr.takeError()).message());
813
104
814
104
  RelData.d.b += S->sh_size / S->sh_entsize;
815
104
  return relocation_iterator(RelocationRef(RelData, this));
816
104
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::section_rel_end(llvm::object::DataRefImpl) const
Line
Count
Source
801
2.58k
ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
802
2.58k
  const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
803
2.58k
  relocation_iterator Begin = section_rel_begin(Sec);
804
2.58k
  if (S->sh_type != ELF::SHT_RELA && 
S->sh_type != ELF::SHT_REL467
)
805
441
    return Begin;
806
2.14k
  DataRefImpl RelData = Begin->getRawDataRefImpl();
807
2.14k
  const Elf_Shdr *RelSec = getRelSection(RelData);
808
2.14k
809
2.14k
  // Error check sh_link here so that getRelocationSymbol can just use it.
810
2.14k
  auto SymSecOrErr = EF.getSection(RelSec->sh_link);
811
2.14k
  if (!SymSecOrErr)
812
0
    report_fatal_error(errorToErrorCode(SymSecOrErr.takeError()).message());
813
2.14k
814
2.14k
  RelData.d.b += S->sh_size / S->sh_entsize;
815
2.14k
  return relocation_iterator(RelocationRef(RelData, this));
816
2.14k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::section_rel_end(llvm::object::DataRefImpl) const
Line
Count
Source
801
120
ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
802
120
  const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
803
120
  relocation_iterator Begin = section_rel_begin(Sec);
804
120
  if (S->sh_type != ELF::SHT_RELA && 
S->sh_type != ELF::SHT_REL20
)
805
12
    return Begin;
806
108
  DataRefImpl RelData = Begin->getRawDataRefImpl();
807
108
  const Elf_Shdr *RelSec = getRelSection(RelData);
808
108
809
108
  // Error check sh_link here so that getRelocationSymbol can just use it.
810
108
  auto SymSecOrErr = EF.getSection(RelSec->sh_link);
811
108
  if (!SymSecOrErr)
812
0
    report_fatal_error(errorToErrorCode(SymSecOrErr.takeError()).message());
813
108
814
108
  RelData.d.b += S->sh_size / S->sh_entsize;
815
108
  return relocation_iterator(RelocationRef(RelData, this));
816
108
}
817
818
template <class ELFT>
819
section_iterator
820
15.0k
ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const {
821
15.0k
  if (EF.getHeader()->e_type != ELF::ET_REL)
822
2.17k
    return section_end();
823
12.8k
824
12.8k
  const Elf_Shdr *EShdr = getSection(Sec);
825
12.8k
  uintX_t Type = EShdr->sh_type;
826
12.8k
  if (Type != ELF::SHT_REL && 
Type != ELF::SHT_RELA12.4k
)
827
10.3k
    return section_end();
828
2.56k
829
2.56k
  auto R = EF.getSection(EShdr->sh_info);
830
2.56k
  if (!R)
831
0
    report_fatal_error(errorToErrorCode(R.takeError()).message());
832
2.56k
  return section_iterator(SectionRef(toDRI(*R), this));
833
2.56k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocatedSection(llvm::object::DataRefImpl) const
Line
Count
Source
820
1.99k
ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const {
821
1.99k
  if (EF.getHeader()->e_type != ELF::ET_REL)
822
68
    return section_end();
823
1.93k
824
1.93k
  const Elf_Shdr *EShdr = getSection(Sec);
825
1.93k
  uintX_t Type = EShdr->sh_type;
826
1.93k
  if (Type != ELF::SHT_REL && 
Type != ELF::SHT_RELA1.68k
)
827
1.58k
    return section_end();
828
345
829
345
  auto R = EF.getSection(EShdr->sh_info);
830
345
  if (!R)
831
0
    report_fatal_error(errorToErrorCode(R.takeError()).message());
832
345
  return section_iterator(SectionRef(toDRI(*R), this));
833
345
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocatedSection(llvm::object::DataRefImpl) const
Line
Count
Source
820
1.47k
ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const {
821
1.47k
  if (EF.getHeader()->e_type != ELF::ET_REL)
822
0
    return section_end();
823
1.47k
824
1.47k
  const Elf_Shdr *EShdr = getSection(Sec);
825
1.47k
  uintX_t Type = EShdr->sh_type;
826
1.47k
  if (Type != ELF::SHT_REL && 
Type != ELF::SHT_RELA1.33k
)
827
1.23k
    return section_end();
828
237
829
237
  auto R = EF.getSection(EShdr->sh_info);
830
237
  if (!R)
831
0
    report_fatal_error(errorToErrorCode(R.takeError()).message());
832
237
  return section_iterator(SectionRef(toDRI(*R), this));
833
237
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocatedSection(llvm::object::DataRefImpl) const
Line
Count
Source
820
10.1k
ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const {
821
10.1k
  if (EF.getHeader()->e_type != ELF::ET_REL)
822
2.04k
    return section_end();
823
8.09k
824
8.09k
  const Elf_Shdr *EShdr = getSection(Sec);
825
8.09k
  uintX_t Type = EShdr->sh_type;
826
8.09k
  if (Type != ELF::SHT_REL && 
Type != ELF::SHT_RELA8.08k
)
827
6.35k
    return section_end();
828
1.73k
829
1.73k
  auto R = EF.getSection(EShdr->sh_info);
830
1.73k
  if (!R)
831
0
    report_fatal_error(errorToErrorCode(R.takeError()).message());
832
1.73k
  return section_iterator(SectionRef(toDRI(*R), this));
833
1.73k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocatedSection(llvm::object::DataRefImpl) const
Line
Count
Source
820
1.43k
ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const {
821
1.43k
  if (EF.getHeader()->e_type != ELF::ET_REL)
822
62
    return section_end();
823
1.37k
824
1.37k
  const Elf_Shdr *EShdr = getSection(Sec);
825
1.37k
  uintX_t Type = EShdr->sh_type;
826
1.37k
  if (Type != ELF::SHT_REL && 
Type != ELF::SHT_RELA1.36k
)
827
1.13k
    return section_end();
828
244
829
244
  auto R = EF.getSection(EShdr->sh_info);
830
244
  if (!R)
831
0
    report_fatal_error(errorToErrorCode(R.takeError()).message());
832
244
  return section_iterator(SectionRef(toDRI(*R), this));
833
244
}
834
835
// Relocations
836
template <class ELFT>
837
6.89k
void ELFObjectFile<ELFT>::moveRelocationNext(DataRefImpl &Rel) const {
838
6.89k
  ++Rel.d.b;
839
6.89k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::moveRelocationNext(llvm::object::DataRefImpl&) const
Line
Count
Source
837
752
void ELFObjectFile<ELFT>::moveRelocationNext(DataRefImpl &Rel) const {
838
752
  ++Rel.d.b;
839
752
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::moveRelocationNext(llvm::object::DataRefImpl&) const
Line
Count
Source
837
293
void ELFObjectFile<ELFT>::moveRelocationNext(DataRefImpl &Rel) const {
838
293
  ++Rel.d.b;
839
293
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::moveRelocationNext(llvm::object::DataRefImpl&) const
Line
Count
Source
837
5.59k
void ELFObjectFile<ELFT>::moveRelocationNext(DataRefImpl &Rel) const {
838
5.59k
  ++Rel.d.b;
839
5.59k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::moveRelocationNext(llvm::object::DataRefImpl&) const
Line
Count
Source
837
260
void ELFObjectFile<ELFT>::moveRelocationNext(DataRefImpl &Rel) const {
838
260
  ++Rel.d.b;
839
260
}
840
841
template <class ELFT>
842
symbol_iterator
843
6.45k
ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
844
6.45k
  uint32_t symbolIdx;
845
6.45k
  const Elf_Shdr *sec = getRelSection(Rel);
846
6.45k
  if (sec->sh_type == ELF::SHT_REL)
847
899
    symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL());
848
5.55k
  else
849
5.55k
    symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL());
850
6.45k
  if (!symbolIdx)
851
59
    return symbol_end();
852
6.39k
853
6.39k
  // FIXME: error check symbolIdx
854
6.39k
  DataRefImpl SymbolData;
855
6.39k
  SymbolData.d.a = sec->sh_link;
856
6.39k
  SymbolData.d.b = symbolIdx;
857
6.39k
  return symbol_iterator(SymbolRef(SymbolData, this));
858
6.39k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
843
747
ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
844
747
  uint32_t symbolIdx;
845
747
  const Elf_Shdr *sec = getRelSection(Rel);
846
747
  if (sec->sh_type == ELF::SHT_REL)
847
577
    symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL());
848
170
  else
849
170
    symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL());
850
747
  if (!symbolIdx)
851
0
    return symbol_end();
852
747
853
747
  // FIXME: error check symbolIdx
854
747
  DataRefImpl SymbolData;
855
747
  SymbolData.d.a = sec->sh_link;
856
747
  SymbolData.d.b = symbolIdx;
857
747
  return symbol_iterator(SymbolRef(SymbolData, this));
858
747
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
843
422
ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
844
422
  uint32_t symbolIdx;
845
422
  const Elf_Shdr *sec = getRelSection(Rel);
846
422
  if (sec->sh_type == ELF::SHT_REL)
847
258
    symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL());
848
164
  else
849
164
    symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL());
850
422
  if (!symbolIdx)
851
0
    return symbol_end();
852
422
853
422
  // FIXME: error check symbolIdx
854
422
  DataRefImpl SymbolData;
855
422
  SymbolData.d.a = sec->sh_link;
856
422
  SymbolData.d.b = symbolIdx;
857
422
  return symbol_iterator(SymbolRef(SymbolData, this));
858
422
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
843
4.97k
ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
844
4.97k
  uint32_t symbolIdx;
845
4.97k
  const Elf_Shdr *sec = getRelSection(Rel);
846
4.97k
  if (sec->sh_type == ELF::SHT_REL)
847
46
    symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL());
848
4.92k
  else
849
4.92k
    symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL());
850
4.97k
  if (!symbolIdx)
851
59
    return symbol_end();
852
4.91k
853
4.91k
  // FIXME: error check symbolIdx
854
4.91k
  DataRefImpl SymbolData;
855
4.91k
  SymbolData.d.a = sec->sh_link;
856
4.91k
  SymbolData.d.b = symbolIdx;
857
4.91k
  return symbol_iterator(SymbolRef(SymbolData, this));
858
4.91k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationSymbol(llvm::object::DataRefImpl) const
Line
Count
Source
843
314
ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
844
314
  uint32_t symbolIdx;
845
314
  const Elf_Shdr *sec = getRelSection(Rel);
846
314
  if (sec->sh_type == ELF::SHT_REL)
847
18
    symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL());
848
296
  else
849
296
    symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL());
850
314
  if (!symbolIdx)
851
0
    return symbol_end();
852
314
853
314
  // FIXME: error check symbolIdx
854
314
  DataRefImpl SymbolData;
855
314
  SymbolData.d.a = sec->sh_link;
856
314
  SymbolData.d.b = symbolIdx;
857
314
  return symbol_iterator(SymbolRef(SymbolData, this));
858
314
}
859
860
template <class ELFT>
861
7.38k
uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const {
862
7.38k
  const Elf_Shdr *sec = getRelSection(Rel);
863
7.38k
  if (sec->sh_type == ELF::SHT_REL)
864
1.30k
    return getRel(Rel)->r_offset;
865
6.07k
866
6.07k
  return getRela(Rel)->r_offset;
867
6.07k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationOffset(llvm::object::DataRefImpl) const
Line
Count
Source
861
1.06k
uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const {
862
1.06k
  const Elf_Shdr *sec = getRelSection(Rel);
863
1.06k
  if (sec->sh_type == ELF::SHT_REL)
864
842
    return getRel(Rel)->r_offset;
865
227
866
227
  return getRela(Rel)->r_offset;
867
227
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationOffset(llvm::object::DataRefImpl) const
Line
Count
Source
861
674
uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const {
862
674
  const Elf_Shdr *sec = getRelSection(Rel);
863
674
  if (sec->sh_type == ELF::SHT_REL)
864
370
    return getRel(Rel)->r_offset;
865
304
866
304
  return getRela(Rel)->r_offset;
867
304
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationOffset(llvm::object::DataRefImpl) const
Line
Count
Source
861
5.17k
uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const {
862
5.17k
  const Elf_Shdr *sec = getRelSection(Rel);
863
5.17k
  if (sec->sh_type == ELF::SHT_REL)
864
79
    return getRel(Rel)->r_offset;
865
5.09k
866
5.09k
  return getRela(Rel)->r_offset;
867
5.09k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationOffset(llvm::object::DataRefImpl) const
Line
Count
Source
861
469
uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const {
862
469
  const Elf_Shdr *sec = getRelSection(Rel);
863
469
  if (sec->sh_type == ELF::SHT_REL)
864
18
    return getRel(Rel)->r_offset;
865
451
866
451
  return getRela(Rel)->r_offset;
867
451
}
868
869
template <class ELFT>
870
6.72k
uint64_t ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel) const {
871
6.72k
  const Elf_Shdr *sec = getRelSection(Rel);
872
6.72k
  if (sec->sh_type == ELF::SHT_REL)
873
783
    return getRel(Rel)->getType(EF.isMips64EL());
874
5.94k
  else
875
5.94k
    return getRela(Rel)->getType(EF.isMips64EL());
876
6.72k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationType(llvm::object::DataRefImpl) const
Line
Count
Source
870
724
uint64_t ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel) const {
871
724
  const Elf_Shdr *sec = getRelSection(Rel);
872
724
  if (sec->sh_type == ELF::SHT_REL)
873
545
    return getRel(Rel)->getType(EF.isMips64EL());
874
179
  else
875
179
    return getRela(Rel)->getType(EF.isMips64EL());
876
724
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationType(llvm::object::DataRefImpl) const
Line
Count
Source
870
254
uint64_t ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel) const {
871
254
  const Elf_Shdr *sec = getRelSection(Rel);
872
254
  if (sec->sh_type == ELF::SHT_REL)
873
178
    return getRel(Rel)->getType(EF.isMips64EL());
874
76
  else
875
76
    return getRela(Rel)->getType(EF.isMips64EL());
876
254
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationType(llvm::object::DataRefImpl) const
Line
Count
Source
870
5.53k
uint64_t ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel) const {
871
5.53k
  const Elf_Shdr *sec = getRelSection(Rel);
872
5.53k
  if (sec->sh_type == ELF::SHT_REL)
873
42
    return getRel(Rel)->getType(EF.isMips64EL());
874
5.49k
  else
875
5.49k
    return getRela(Rel)->getType(EF.isMips64EL());
876
5.53k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationType(llvm::object::DataRefImpl) const
Line
Count
Source
870
216
uint64_t ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel) const {
871
216
  const Elf_Shdr *sec = getRelSection(Rel);
872
216
  if (sec->sh_type == ELF::SHT_REL)
873
18
    return getRel(Rel)->getType(EF.isMips64EL());
874
198
  else
875
198
    return getRela(Rel)->getType(EF.isMips64EL());
876
216
}
877
878
template <class ELFT>
879
StringRef ELFObjectFile<ELFT>::getRelocationTypeName(uint32_t Type) const {
880
  return getELFRelocationTypeName(EF.getHeader()->e_machine, Type);
881
}
882
883
template <class ELFT>
884
void ELFObjectFile<ELFT>::getRelocationTypeName(
885
893
    DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
886
893
  uint32_t type = getRelocationType(Rel);
887
893
  EF.getRelocationTypeName(type, Result);
888
893
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationTypeName(llvm::object::DataRefImpl, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
885
278
    DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
886
278
  uint32_t type = getRelocationType(Rel);
887
278
  EF.getRelocationTypeName(type, Result);
888
278
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationTypeName(llvm::object::DataRefImpl, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
885
85
    DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
886
85
  uint32_t type = getRelocationType(Rel);
887
85
  EF.getRelocationTypeName(type, Result);
888
85
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationTypeName(llvm::object::DataRefImpl, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
885
480
    DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
886
480
  uint32_t type = getRelocationType(Rel);
887
480
  EF.getRelocationTypeName(type, Result);
888
480
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationTypeName(llvm::object::DataRefImpl, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
885
50
    DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
886
50
  uint32_t type = getRelocationType(Rel);
887
50
  EF.getRelocationTypeName(type, Result);
888
50
}
889
890
template <class ELFT>
891
Expected<int64_t>
892
4.72k
ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel) const {
893
4.72k
  if (getRelSection(Rel)->sh_type != ELF::SHT_RELA)
894
41
    return createError("Section is not SHT_RELA");
895
4.68k
  return (int64_t)getRela(Rel)->r_addend;
896
4.68k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationAddend(llvm::object::DataRefImpl) const
Line
Count
Source
892
67
ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel) const {
893
67
  if (getRelSection(Rel)->sh_type != ELF::SHT_RELA)
894
21
    return createError("Section is not SHT_RELA");
895
46
  return (int64_t)getRela(Rel)->r_addend;
896
46
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationAddend(llvm::object::DataRefImpl) const
Line
Count
Source
892
45
ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel) const {
893
45
  if (getRelSection(Rel)->sh_type != ELF::SHT_RELA)
894
19
    return createError("Section is not SHT_RELA");
895
26
  return (int64_t)getRela(Rel)->r_addend;
896
26
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationAddend(llvm::object::DataRefImpl) const
Line
Count
Source
892
4.46k
ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel) const {
893
4.46k
  if (getRelSection(Rel)->sh_type != ELF::SHT_RELA)
894
1
    return createError("Section is not SHT_RELA");
895
4.46k
  return (int64_t)getRela(Rel)->r_addend;
896
4.46k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationAddend(llvm::object::DataRefImpl) const
Line
Count
Source
892
148
ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel) const {
893
148
  if (getRelSection(Rel)->sh_type != ELF::SHT_RELA)
894
0
    return createError("Section is not SHT_RELA");
895
148
  return (int64_t)getRela(Rel)->r_addend;
896
148
}
897
898
template <class ELFT>
899
const typename ELFObjectFile<ELFT>::Elf_Rel *
900
2.99k
ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const {
901
2.99k
  assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
902
2.99k
  auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
903
2.99k
  if (!Ret)
904
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
905
2.99k
  return *Ret;
906
2.99k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRel(llvm::object::DataRefImpl) const
Line
Count
Source
900
1.96k
ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const {
901
1.96k
  assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
902
1.96k
  auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
903
1.96k
  if (!Ret)
904
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
905
1.96k
  return *Ret;
906
1.96k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRel(llvm::object::DataRefImpl) const
Line
Count
Source
900
806
ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const {
901
806
  assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
902
806
  auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
903
806
  if (!Ret)
904
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
905
806
  return *Ret;
906
806
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRel(llvm::object::DataRefImpl) const
Line
Count
Source
900
167
ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const {
901
167
  assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
902
167
  auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
903
167
  if (!Ret)
904
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
905
167
  return *Ret;
906
167
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRel(llvm::object::DataRefImpl) const
Line
Count
Source
900
54
ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const {
901
54
  assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
902
54
  auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
903
54
  if (!Ret)
904
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
905
54
  return *Ret;
906
54
}
907
908
template <class ELFT>
909
const typename ELFObjectFile<ELFT>::Elf_Rela *
910
22.9k
ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
911
22.9k
  assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
912
22.9k
  auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
913
22.9k
  if (!Ret)
914
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
915
22.9k
  return *Ret;
916
22.9k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRela(llvm::object::DataRefImpl) const
Line
Count
Source
910
737
ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
911
737
  assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
912
737
  auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
913
737
  if (!Ret)
914
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
915
737
  return *Ret;
916
737
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRela(llvm::object::DataRefImpl) const
Line
Count
Source
910
614
ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
911
614
  assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
912
614
  auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
913
614
  if (!Ret)
914
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
915
614
  return *Ret;
916
614
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRela(llvm::object::DataRefImpl) const
Line
Count
Source
910
20.4k
ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
911
20.4k
  assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
912
20.4k
  auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
913
20.4k
  if (!Ret)
914
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
915
20.4k
  return *Ret;
916
20.4k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRela(llvm::object::DataRefImpl) const
Line
Count
Source
910
1.14k
ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
911
1.14k
  assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
912
1.14k
  auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
913
1.14k
  if (!Ret)
914
0
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
915
1.14k
  return *Ret;
916
1.14k
}
917
918
template <class ELFT>
919
Expected<ELFObjectFile<ELFT>>
920
5.97k
ELFObjectFile<ELFT>::create(MemoryBufferRef Object) {
921
5.97k
  auto EFOrErr = ELFFile<ELFT>::create(Object.getBuffer());
922
5.97k
  if (Error E = EFOrErr.takeError())
923
1
    return std::move(E);
924
5.97k
  auto EF = std::move(*EFOrErr);
925
5.97k
926
5.97k
  auto SectionsOrErr = EF.sections();
927
5.97k
  if (!SectionsOrErr)
928
3
    return SectionsOrErr.takeError();
929
5.97k
930
5.97k
  const Elf_Shdr *DotDynSymSec = nullptr;
931
5.97k
  const Elf_Shdr *DotSymtabSec = nullptr;
932
5.97k
  ArrayRef<Elf_Word> ShndxTable;
933
1.55M
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
934
1.55M
    switch (Sec.sh_type) {
935
1.55M
    case ELF::SHT_DYNSYM: {
936
1.10k
      if (DotDynSymSec)
937
0
        return createError("More than one dynamic symbol table!");
938
1.10k
      DotDynSymSec = &Sec;
939
1.10k
      break;
940
1.10k
    }
941
5.89k
    case ELF::SHT_SYMTAB: {
942
5.89k
      if (DotSymtabSec)
943
0
        return createError("More than one static symbol table!");
944
5.89k
      DotSymtabSec = &Sec;
945
5.89k
      break;
946
5.89k
    }
947
5.89k
    case ELF::SHT_SYMTAB_SHNDX: {
948
20
      auto TableOrErr = EF.getSHNDXTable(Sec);
949
20
      if (!TableOrErr)
950
1
        return TableOrErr.takeError();
951
19
      ShndxTable = *TableOrErr;
952
19
      break;
953
19
    }
954
1.55M
    }
955
1.55M
  }
956
5.97k
  return ELFObjectFile<ELFT>(Object, EF, DotDynSymSec, DotSymtabSec,
957
5.97k
                             ShndxTable);
958
5.97k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::create(llvm::MemoryBufferRef)
Line
Count
Source
920
1.19k
ELFObjectFile<ELFT>::create(MemoryBufferRef Object) {
921
1.19k
  auto EFOrErr = ELFFile<ELFT>::create(Object.getBuffer());
922
1.19k
  if (Error E = EFOrErr.takeError())
923
1
    return std::move(E);
924
1.19k
  auto EF = std::move(*EFOrErr);
925
1.19k
926
1.19k
  auto SectionsOrErr = EF.sections();
927
1.19k
  if (!SectionsOrErr)
928
0
    return SectionsOrErr.takeError();
929
1.19k
930
1.19k
  const Elf_Shdr *DotDynSymSec = nullptr;
931
1.19k
  const Elf_Shdr *DotSymtabSec = nullptr;
932
1.19k
  ArrayRef<Elf_Word> ShndxTable;
933
10.7k
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
934
10.7k
    switch (Sec.sh_type) {
935
10.7k
    case ELF::SHT_DYNSYM: {
936
197
      if (DotDynSymSec)
937
0
        return createError("More than one dynamic symbol table!");
938
197
      DotDynSymSec = &Sec;
939
197
      break;
940
197
    }
941
1.18k
    case ELF::SHT_SYMTAB: {
942
1.18k
      if (DotSymtabSec)
943
0
        return createError("More than one static symbol table!");
944
1.18k
      DotSymtabSec = &Sec;
945
1.18k
      break;
946
1.18k
    }
947
1.18k
    case ELF::SHT_SYMTAB_SHNDX: {
948
0
      auto TableOrErr = EF.getSHNDXTable(Sec);
949
0
      if (!TableOrErr)
950
0
        return TableOrErr.takeError();
951
0
      ShndxTable = *TableOrErr;
952
0
      break;
953
0
    }
954
10.7k
    }
955
10.7k
  }
956
1.19k
  return ELFObjectFile<ELFT>(Object, EF, DotDynSymSec, DotSymtabSec,
957
1.19k
                             ShndxTable);
958
1.19k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::create(llvm::MemoryBufferRef)
Line
Count
Source
920
303
ELFObjectFile<ELFT>::create(MemoryBufferRef Object) {
921
303
  auto EFOrErr = ELFFile<ELFT>::create(Object.getBuffer());
922
303
  if (Error E = EFOrErr.takeError())
923
0
    return std::move(E);
924
303
  auto EF = std::move(*EFOrErr);
925
303
926
303
  auto SectionsOrErr = EF.sections();
927
303
  if (!SectionsOrErr)
928
0
    return SectionsOrErr.takeError();
929
303
930
303
  const Elf_Shdr *DotDynSymSec = nullptr;
931
303
  const Elf_Shdr *DotSymtabSec = nullptr;
932
303
  ArrayRef<Elf_Word> ShndxTable;
933
3.56k
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
934
3.56k
    switch (Sec.sh_type) {
935
3.56k
    case ELF::SHT_DYNSYM: {
936
74
      if (DotDynSymSec)
937
0
        return createError("More than one dynamic symbol table!");
938
74
      DotDynSymSec = &Sec;
939
74
      break;
940
74
    }
941
303
    case ELF::SHT_SYMTAB: {
942
303
      if (DotSymtabSec)
943
0
        return createError("More than one static symbol table!");
944
303
      DotSymtabSec = &Sec;
945
303
      break;
946
303
    }
947
303
    case ELF::SHT_SYMTAB_SHNDX: {
948
0
      auto TableOrErr = EF.getSHNDXTable(Sec);
949
0
      if (!TableOrErr)
950
0
        return TableOrErr.takeError();
951
0
      ShndxTable = *TableOrErr;
952
0
      break;
953
0
    }
954
3.56k
    }
955
3.56k
  }
956
303
  return ELFObjectFile<ELFT>(Object, EF, DotDynSymSec, DotSymtabSec,
957
303
                             ShndxTable);
958
303
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::create(llvm::MemoryBufferRef)
Line
Count
Source
920
4.23k
ELFObjectFile<ELFT>::create(MemoryBufferRef Object) {
921
4.23k
  auto EFOrErr = ELFFile<ELFT>::create(Object.getBuffer());
922
4.23k
  if (Error E = EFOrErr.takeError())
923
0
    return std::move(E);
924
4.23k
  auto EF = std::move(*EFOrErr);
925
4.23k
926
4.23k
  auto SectionsOrErr = EF.sections();
927
4.23k
  if (!SectionsOrErr)
928
3
    return SectionsOrErr.takeError();
929
4.22k
930
4.22k
  const Elf_Shdr *DotDynSymSec = nullptr;
931
4.22k
  const Elf_Shdr *DotSymtabSec = nullptr;
932
4.22k
  ArrayRef<Elf_Word> ShndxTable;
933
1.53M
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
934
1.53M
    switch (Sec.sh_type) {
935
1.53M
    case ELF::SHT_DYNSYM: {
936
776
      if (DotDynSymSec)
937
0
        return createError("More than one dynamic symbol table!");
938
776
      DotDynSymSec = &Sec;
939
776
      break;
940
776
    }
941
4.15k
    case ELF::SHT_SYMTAB: {
942
4.15k
      if (DotSymtabSec)
943
0
        return createError("More than one static symbol table!");
944
4.15k
      DotSymtabSec = &Sec;
945
4.15k
      break;
946
4.15k
    }
947
4.15k
    case ELF::SHT_SYMTAB_SHNDX: {
948
20
      auto TableOrErr = EF.getSHNDXTable(Sec);
949
20
      if (!TableOrErr)
950
1
        return TableOrErr.takeError();
951
19
      ShndxTable = *TableOrErr;
952
19
      break;
953
19
    }
954
1.53M
    }
955
1.53M
  }
956
4.22k
  return ELFObjectFile<ELFT>(Object, EF, DotDynSymSec, DotSymtabSec,
957
4.22k
                             ShndxTable);
958
4.22k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::create(llvm::MemoryBufferRef)
Line
Count
Source
920
253
ELFObjectFile<ELFT>::create(MemoryBufferRef Object) {
921
253
  auto EFOrErr = ELFFile<ELFT>::create(Object.getBuffer());
922
253
  if (Error E = EFOrErr.takeError())
923
0
    return std::move(E);
924
253
  auto EF = std::move(*EFOrErr);
925
253
926
253
  auto SectionsOrErr = EF.sections();
927
253
  if (!SectionsOrErr)
928
0
    return SectionsOrErr.takeError();
929
253
930
253
  const Elf_Shdr *DotDynSymSec = nullptr;
931
253
  const Elf_Shdr *DotSymtabSec = nullptr;
932
253
  ArrayRef<Elf_Word> ShndxTable;
933
2.80k
  for (const Elf_Shdr &Sec : *SectionsOrErr) {
934
2.80k
    switch (Sec.sh_type) {
935
2.80k
    case ELF::SHT_DYNSYM: {
936
62
      if (DotDynSymSec)
937
0
        return createError("More than one dynamic symbol table!");
938
62
      DotDynSymSec = &Sec;
939
62
      break;
940
62
    }
941
252
    case ELF::SHT_SYMTAB: {
942
252
      if (DotSymtabSec)
943
0
        return createError("More than one static symbol table!");
944
252
      DotSymtabSec = &Sec;
945
252
      break;
946
252
    }
947
252
    case ELF::SHT_SYMTAB_SHNDX: {
948
0
      auto TableOrErr = EF.getSHNDXTable(Sec);
949
0
      if (!TableOrErr)
950
0
        return TableOrErr.takeError();
951
0
      ShndxTable = *TableOrErr;
952
0
      break;
953
0
    }
954
2.80k
    }
955
2.80k
  }
956
253
  return ELFObjectFile<ELFT>(Object, EF, DotDynSymSec, DotSymtabSec,
957
253
                             ShndxTable);
958
253
}
959
960
template <class ELFT>
961
ELFObjectFile<ELFT>::ELFObjectFile(MemoryBufferRef Object, ELFFile<ELFT> EF,
962
                                   const Elf_Shdr *DotDynSymSec,
963
                                   const Elf_Shdr *DotSymtabSec,
964
                                   ArrayRef<Elf_Word> ShndxTable)
965
    : ELFObjectFileBase(
966
          getELFType(ELFT::TargetEndianness == support::little, ELFT::Is64Bits),
967
          Object),
968
      EF(EF), DotDynSymSec(DotDynSymSec), DotSymtabSec(DotSymtabSec),
969
17.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
969
3.57k
      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
969
909
      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
969
12.6k
      ShndxTable(ShndxTable) {}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::ELFObjectFile(llvm::MemoryBufferRef, llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >, llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*, llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*, llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)0, 1ul> >)
Line
Count
Source
969
759
      ShndxTable(ShndxTable) {}
970
971
template <class ELFT>
972
ELFObjectFile<ELFT>::ELFObjectFile(ELFObjectFile<ELFT> &&Other)
973
    : ELFObjectFile(Other.Data, Other.EF, Other.DotDynSymSec,
974
11.9k
                    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
974
2.38k
                    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
974
606
                    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
974
8.45k
                    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
974
506
                    Other.DotSymtabSec, Other.ShndxTable) {}
975
976
template <class ELFT>
977
3.13k
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin() const {
978
3.13k
  DataRefImpl Sym = toDRI(DotSymtabSec, 0);
979
3.13k
  return basic_symbol_iterator(SymbolRef(Sym, this));
980
3.13k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::symbol_begin() const
Line
Count
Source
977
631
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin() const {
978
631
  DataRefImpl Sym = toDRI(DotSymtabSec, 0);
979
631
  return basic_symbol_iterator(SymbolRef(Sym, this));
980
631
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::symbol_begin() const
Line
Count
Source
977
291
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin() const {
978
291
  DataRefImpl Sym = toDRI(DotSymtabSec, 0);
979
291
  return basic_symbol_iterator(SymbolRef(Sym, this));
980
291
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::symbol_begin() const
Line
Count
Source
977
2.07k
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin() const {
978
2.07k
  DataRefImpl Sym = toDRI(DotSymtabSec, 0);
979
2.07k
  return basic_symbol_iterator(SymbolRef(Sym, this));
980
2.07k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::symbol_begin() const
Line
Count
Source
977
139
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin() const {
978
139
  DataRefImpl Sym = toDRI(DotSymtabSec, 0);
979
139
  return basic_symbol_iterator(SymbolRef(Sym, this));
980
139
}
981
982
template <class ELFT>
983
7.87k
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
984
7.87k
  const Elf_Shdr *SymTab = DotSymtabSec;
985
7.87k
  if (!SymTab)
986
15
    return symbol_begin();
987
7.86k
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
988
7.86k
  return basic_symbol_iterator(SymbolRef(Sym, this));
989
7.86k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::symbol_end() const
Line
Count
Source
983
956
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
984
956
  const Elf_Shdr *SymTab = DotSymtabSec;
985
956
  if (!SymTab)
986
1
    return symbol_begin();
987
955
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
988
955
  return basic_symbol_iterator(SymbolRef(Sym, this));
989
955
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::symbol_end() const
Line
Count
Source
983
402
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
984
402
  const Elf_Shdr *SymTab = DotSymtabSec;
985
402
  if (!SymTab)
986
0
    return symbol_begin();
987
402
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
988
402
  return basic_symbol_iterator(SymbolRef(Sym, this));
989
402
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::symbol_end() const
Line
Count
Source
983
6.17k
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
984
6.17k
  const Elf_Shdr *SymTab = DotSymtabSec;
985
6.17k
  if (!SymTab)
986
14
    return symbol_begin();
987
6.16k
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
988
6.16k
  return basic_symbol_iterator(SymbolRef(Sym, this));
989
6.16k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::symbol_end() const
Line
Count
Source
983
344
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
984
344
  const Elf_Shdr *SymTab = DotSymtabSec;
985
344
  if (!SymTab)
986
0
    return symbol_begin();
987
344
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
988
344
  return basic_symbol_iterator(SymbolRef(Sym, this));
989
344
}
990
991
template <class ELFT>
992
254
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_begin() const {
993
254
  DataRefImpl Sym = toDRI(DotDynSymSec, 0);
994
254
  return symbol_iterator(SymbolRef(Sym, this));
995
254
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::dynamic_symbol_begin() const
Line
Count
Source
992
204
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_begin() const {
993
204
  DataRefImpl Sym = toDRI(DotDynSymSec, 0);
994
204
  return symbol_iterator(SymbolRef(Sym, this));
995
204
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::dynamic_symbol_begin() const
Line
Count
Source
992
8
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_begin() const {
993
8
  DataRefImpl Sym = toDRI(DotDynSymSec, 0);
994
8
  return symbol_iterator(SymbolRef(Sym, this));
995
8
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::dynamic_symbol_begin() const
Line
Count
Source
992
40
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_begin() const {
993
40
  DataRefImpl Sym = toDRI(DotDynSymSec, 0);
994
40
  return symbol_iterator(SymbolRef(Sym, this));
995
40
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::dynamic_symbol_begin() const
Line
Count
Source
992
2
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_begin() const {
993
2
  DataRefImpl Sym = toDRI(DotDynSymSec, 0);
994
2
  return symbol_iterator(SymbolRef(Sym, this));
995
2
}
996
997
template <class ELFT>
998
131
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_end() const {
999
131
  const Elf_Shdr *SymTab = DotDynSymSec;
1000
131
  if (!SymTab)
1001
123
    return dynamic_symbol_begin();
1002
8
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
1003
8
  return basic_symbol_iterator(SymbolRef(Sym, this));
1004
8
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::dynamic_symbol_end() const
Line
Count
Source
998
103
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_end() const {
999
103
  const Elf_Shdr *SymTab = DotDynSymSec;
1000
103
  if (!SymTab)
1001
101
    return dynamic_symbol_begin();
1002
2
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
1003
2
  return basic_symbol_iterator(SymbolRef(Sym, this));
1004
2
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::dynamic_symbol_end() const
Line
Count
Source
998
4
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_end() const {
999
4
  const Elf_Shdr *SymTab = DotDynSymSec;
1000
4
  if (!SymTab)
1001
4
    return dynamic_symbol_begin();
1002
0
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
1003
0
  return basic_symbol_iterator(SymbolRef(Sym, this));
1004
0
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::dynamic_symbol_end() const
Line
Count
Source
998
23
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_end() const {
999
23
  const Elf_Shdr *SymTab = DotDynSymSec;
1000
23
  if (!SymTab)
1001
17
    return dynamic_symbol_begin();
1002
6
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
1003
6
  return basic_symbol_iterator(SymbolRef(Sym, this));
1004
6
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::dynamic_symbol_end() const
Line
Count
Source
998
1
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_end() const {
999
1
  const Elf_Shdr *SymTab = DotDynSymSec;
1000
1
  if (!SymTab)
1001
1
    return dynamic_symbol_begin();
1002
0
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
1003
0
  return basic_symbol_iterator(SymbolRef(Sym, this));
1004
0
}
1005
1006
template <class ELFT>
1007
6.68k
section_iterator ELFObjectFile<ELFT>::section_begin() const {
1008
6.68k
  auto SectionsOrErr = EF.sections();
1009
6.68k
  if (!SectionsOrErr)
1010
0
    return section_iterator(SectionRef());
1011
6.68k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).begin()), this));
1012
6.68k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::section_begin() const
Line
Count
Source
1007
1.49k
section_iterator ELFObjectFile<ELFT>::section_begin() const {
1008
1.49k
  auto SectionsOrErr = EF.sections();
1009
1.49k
  if (!SectionsOrErr)
1010
0
    return section_iterator(SectionRef());
1011
1.49k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).begin()), this));
1012
1.49k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::section_begin() const
Line
Count
Source
1007
375
section_iterator ELFObjectFile<ELFT>::section_begin() const {
1008
375
  auto SectionsOrErr = EF.sections();
1009
375
  if (!SectionsOrErr)
1010
0
    return section_iterator(SectionRef());
1011
375
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).begin()), this));
1012
375
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::section_begin() const
Line
Count
Source
1007
4.46k
section_iterator ELFObjectFile<ELFT>::section_begin() const {
1008
4.46k
  auto SectionsOrErr = EF.sections();
1009
4.46k
  if (!SectionsOrErr)
1010
0
    return section_iterator(SectionRef());
1011
4.46k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).begin()), this));
1012
4.46k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::section_begin() const
Line
Count
Source
1007
344
section_iterator ELFObjectFile<ELFT>::section_begin() const {
1008
344
  auto SectionsOrErr = EF.sections();
1009
344
  if (!SectionsOrErr)
1010
0
    return section_iterator(SectionRef());
1011
344
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).begin()), this));
1012
344
}
1013
1014
template <class ELFT>
1015
61.2k
section_iterator ELFObjectFile<ELFT>::section_end() const {
1016
61.2k
  auto SectionsOrErr = EF.sections();
1017
61.2k
  if (!SectionsOrErr)
1018
0
    return section_iterator(SectionRef());
1019
61.2k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).end()), this));
1020
61.2k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::section_end() const
Line
Count
Source
1015
13.6k
section_iterator ELFObjectFile<ELFT>::section_end() const {
1016
13.6k
  auto SectionsOrErr = EF.sections();
1017
13.6k
  if (!SectionsOrErr)
1018
0
    return section_iterator(SectionRef());
1019
13.6k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).end()), this));
1020
13.6k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::section_end() const
Line
Count
Source
1015
3.27k
section_iterator ELFObjectFile<ELFT>::section_end() const {
1016
3.27k
  auto SectionsOrErr = EF.sections();
1017
3.27k
  if (!SectionsOrErr)
1018
0
    return section_iterator(SectionRef());
1019
3.27k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).end()), this));
1020
3.27k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::section_end() const
Line
Count
Source
1015
41.4k
section_iterator ELFObjectFile<ELFT>::section_end() const {
1016
41.4k
  auto SectionsOrErr = EF.sections();
1017
41.4k
  if (!SectionsOrErr)
1018
0
    return section_iterator(SectionRef());
1019
41.4k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).end()), this));
1020
41.4k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::section_end() const
Line
Count
Source
1015
2.90k
section_iterator ELFObjectFile<ELFT>::section_end() const {
1016
2.90k
  auto SectionsOrErr = EF.sections();
1017
2.90k
  if (!SectionsOrErr)
1018
0
    return section_iterator(SectionRef());
1019
2.90k
  return section_iterator(SectionRef(toDRI((*SectionsOrErr).end()), this));
1020
2.90k
}
1021
1022
template <class ELFT>
1023
8.77k
uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
1024
8.77k
  return ELFT::Is64Bits ? 
87.06k
:
41.70k
;
1025
8.77k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getBytesInAddress() const
Line
Count
Source
1023
1.15k
uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
1024
1.15k
  return ELFT::Is64Bits ? 
80
: 4;
1025
1.15k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getBytesInAddress() const
Line
Count
Source
1023
554
uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
1024
554
  return ELFT::Is64Bits ? 
80
: 4;
1025
554
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getBytesInAddress() const
Line
Count
Source
1023
6.71k
uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
1024
6.71k
  return ELFT::Is64Bits ? 8 : 
40
;
1025
6.71k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getBytesInAddress() const
Line
Count
Source
1023
356
uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
1024
356
  return ELFT::Is64Bits ? 8 : 
40
;
1025
356
}
1026
1027
template <class ELFT>
1028
4.59k
StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
1029
4.59k
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1030
4.59k
  switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1031
4.59k
  case ELF::ELFCLASS32:
1032
1.36k
    switch (EF.getHeader()->e_machine) {
1033
1.36k
    case ELF::EM_386:
1034
270
      return "ELF32-i386";
1035
1.36k
    case ELF::EM_IAMCU:
1036
4
      return "ELF32-iamcu";
1037
1.36k
    case ELF::EM_X86_64:
1038
8
      return "ELF32-x86-64";
1039
1.36k
    case ELF::EM_ARM:
1040
463
      return (IsLittleEndian ? 
"ELF32-arm-little"452
:
"ELF32-arm-big"11
);
1041
1.36k
    case ELF::EM_AVR:
1042
0
      return "ELF32-avr";
1043
1.36k
    case ELF::EM_HEXAGON:
1044
120
      return "ELF32-hexagon";
1045
1.36k
    case ELF::EM_LANAI:
1046
4
      return "ELF32-lanai";
1047
1.36k
    case ELF::EM_MIPS:
1048
426
      return "ELF32-mips";
1049
1.36k
    case ELF::EM_MSP430:
1050
4
      return "ELF32-msp430";
1051
1.36k
    case ELF::EM_PPC:
1052
17
      return "ELF32-ppc";
1053
1.36k
    case ELF::EM_RISCV:
1054
0
      return "ELF32-riscv";
1055
1.36k
    case ELF::EM_SPARC:
1056
9
    case ELF::EM_SPARC32PLUS:
1057
9
      return "ELF32-sparc";
1058
36
    case ELF::EM_AMDGPU:
1059
36
      return "ELF32-amdgpu";
1060
9
    default:
1061
2
      return "ELF32-unknown";
1062
0
    }
1063
3.23k
  case ELF::ELFCLASS64:
1064
3.23k
    switch (EF.getHeader()->e_machine) {
1065
3.23k
    case ELF::EM_386:
1066
0
      return "ELF64-i386";
1067
3.23k
    case ELF::EM_X86_64:
1068
1.90k
      return "ELF64-x86-64";
1069
3.23k
    case ELF::EM_AARCH64:
1070
824
      return (IsLittleEndian ? 
"ELF64-aarch64-little"816
:
"ELF64-aarch64-big"8
);
1071
3.23k
    case ELF::EM_PPC64:
1072
176
      return "ELF64-ppc64";
1073
3.23k
    case ELF::EM_RISCV:
1074
0
      return "ELF64-riscv";
1075
3.23k
    case ELF::EM_S390:
1076
10
      return "ELF64-s390";
1077
3.23k
    case ELF::EM_SPARCV9:
1078
14
      return "ELF64-sparc";
1079
3.23k
    case ELF::EM_MIPS:
1080
158
      return "ELF64-mips";
1081
3.23k
    case ELF::EM_AMDGPU:
1082
124
      return "ELF64-amdgpu";
1083
3.23k
    case ELF::EM_BPF:
1084
18
      return "ELF64-BPF";
1085
3.23k
    default:
1086
3
      return "ELF64-unknown";
1087
0
    }
1088
0
  default:
1089
0
    // FIXME: Proper error handling.
1090
0
    report_fatal_error("Invalid ELFCLASS!");
1091
4.59k
  }
1092
4.59k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getFileFormatName() const
Line
Count
Source
1028
1.06k
StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
1029
1.06k
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1030
1.06k
  switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1031
1.06k
  case ELF::ELFCLASS32:
1032
1.06k
    switch (EF.getHeader()->e_machine) {
1033
1.06k
    case ELF::EM_386:
1034
270
      return "ELF32-i386";
1035
1.06k
    case ELF::EM_IAMCU:
1036
4
      return "ELF32-iamcu";
1037
1.06k
    case ELF::EM_X86_64:
1038
7
      return "ELF32-x86-64";
1039
1.06k
    case ELF::EM_ARM:
1040
452
      return (IsLittleEndian ? "ELF32-arm-little" : 
"ELF32-arm-big"0
);
1041
1.06k
    case ELF::EM_AVR:
1042
0
      return "ELF32-avr";
1043
1.06k
    case ELF::EM_HEXAGON:
1044
120
      return "ELF32-hexagon";
1045
1.06k
    case ELF::EM_LANAI:
1046
1
      return "ELF32-lanai";
1047
1.06k
    case ELF::EM_MIPS:
1048
169
      return "ELF32-mips";
1049
1.06k
    case ELF::EM_MSP430:
1050
4
      return "ELF32-msp430";
1051
1.06k
    case ELF::EM_PPC:
1052
1
      return "ELF32-ppc";
1053
1.06k
    case ELF::EM_RISCV:
1054
0
      return "ELF32-riscv";
1055
1.06k
    case ELF::EM_SPARC:
1056
2
    case ELF::EM_SPARC32PLUS:
1057
2
      return "ELF32-sparc";
1058
36
    case ELF::EM_AMDGPU:
1059
36
      return "ELF32-amdgpu";
1060
2
    default:
1061
2
      return "ELF32-unknown";
1062
0
    }
1063
0
  case ELF::ELFCLASS64:
1064
0
    switch (EF.getHeader()->e_machine) {
1065
0
    case ELF::EM_386:
1066
0
      return "ELF64-i386";
1067
0
    case ELF::EM_X86_64:
1068
0
      return "ELF64-x86-64";
1069
0
    case ELF::EM_AARCH64:
1070
0
      return (IsLittleEndian ? "ELF64-aarch64-little" : "ELF64-aarch64-big");
1071
0
    case ELF::EM_PPC64:
1072
0
      return "ELF64-ppc64";
1073
0
    case ELF::EM_RISCV:
1074
0
      return "ELF64-riscv";
1075
0
    case ELF::EM_S390:
1076
0
      return "ELF64-s390";
1077
0
    case ELF::EM_SPARCV9:
1078
0
      return "ELF64-sparc";
1079
0
    case ELF::EM_MIPS:
1080
0
      return "ELF64-mips";
1081
0
    case ELF::EM_AMDGPU:
1082
0
      return "ELF64-amdgpu";
1083
0
    case ELF::EM_BPF:
1084
0
      return "ELF64-BPF";
1085
0
    default:
1086
0
      return "ELF64-unknown";
1087
0
    }
1088
0
  default:
1089
0
    // FIXME: Proper error handling.
1090
0
    report_fatal_error("Invalid ELFCLASS!");
1091
1.06k
  }
1092
1.06k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getFileFormatName() const
Line
Count
Source
1028
295
StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
1029
295
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1030
295
  switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1031
295
  case ELF::ELFCLASS32:
1032
295
    switch (EF.getHeader()->e_machine) {
1033
295
    case ELF::EM_386:
1034
0
      return "ELF32-i386";
1035
295
    case ELF::EM_IAMCU:
1036
0
      return "ELF32-iamcu";
1037
295
    case ELF::EM_X86_64:
1038
1
      return "ELF32-x86-64";
1039
295
    case ELF::EM_ARM:
1040
11
      return (IsLittleEndian ? 
"ELF32-arm-little"0
: "ELF32-arm-big");
1041
295
    case ELF::EM_AVR:
1042
0
      return "ELF32-avr";
1043
295
    case ELF::EM_HEXAGON:
1044
0
      return "ELF32-hexagon";
1045
295
    case ELF::EM_LANAI:
1046
3
      return "ELF32-lanai";
1047
295
    case ELF::EM_MIPS:
1048
257
      return "ELF32-mips";
1049
295
    case ELF::EM_MSP430:
1050
0
      return "ELF32-msp430";
1051
295
    case ELF::EM_PPC:
1052
16
      return "ELF32-ppc";
1053
295
    case ELF::EM_RISCV:
1054
0
      return "ELF32-riscv";
1055
295
    case ELF::EM_SPARC:
1056
7
    case ELF::EM_SPARC32PLUS:
1057
7
      return "ELF32-sparc";
1058
7
    case ELF::EM_AMDGPU:
1059
0
      return "ELF32-amdgpu";
1060
7
    default:
1061
0
      return "ELF32-unknown";
1062
0
    }
1063
0
  case ELF::ELFCLASS64:
1064
0
    switch (EF.getHeader()->e_machine) {
1065
0
    case ELF::EM_386:
1066
0
      return "ELF64-i386";
1067
0
    case ELF::EM_X86_64:
1068
0
      return "ELF64-x86-64";
1069
0
    case ELF::EM_AARCH64:
1070
0
      return (IsLittleEndian ? "ELF64-aarch64-little" : "ELF64-aarch64-big");
1071
0
    case ELF::EM_PPC64:
1072
0
      return "ELF64-ppc64";
1073
0
    case ELF::EM_RISCV:
1074
0
      return "ELF64-riscv";
1075
0
    case ELF::EM_S390:
1076
0
      return "ELF64-s390";
1077
0
    case ELF::EM_SPARCV9:
1078
0
      return "ELF64-sparc";
1079
0
    case ELF::EM_MIPS:
1080
0
      return "ELF64-mips";
1081
0
    case ELF::EM_AMDGPU:
1082
0
      return "ELF64-amdgpu";
1083
0
    case ELF::EM_BPF:
1084
0
      return "ELF64-BPF";
1085
0
    default:
1086
0
      return "ELF64-unknown";
1087
0
    }
1088
0
  default:
1089
0
    // FIXME: Proper error handling.
1090
0
    report_fatal_error("Invalid ELFCLASS!");
1091
295
  }
1092
295
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getFileFormatName() const
Line
Count
Source
1028
3.01k
StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
1029
3.01k
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1030
3.01k
  switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1031
3.01k
  case ELF::ELFCLASS32:
1032
0
    switch (EF.getHeader()->e_machine) {
1033
0
    case ELF::EM_386:
1034
0
      return "ELF32-i386";
1035
0
    case ELF::EM_IAMCU:
1036
0
      return "ELF32-iamcu";
1037
0
    case ELF::EM_X86_64:
1038
0
      return "ELF32-x86-64";
1039
0
    case ELF::EM_ARM:
1040
0
      return (IsLittleEndian ? "ELF32-arm-little" : "ELF32-arm-big");
1041
0
    case ELF::EM_AVR:
1042
0
      return "ELF32-avr";
1043
0
    case ELF::EM_HEXAGON:
1044
0
      return "ELF32-hexagon";
1045
0
    case ELF::EM_LANAI:
1046
0
      return "ELF32-lanai";
1047
0
    case ELF::EM_MIPS:
1048
0
      return "ELF32-mips";
1049
0
    case ELF::EM_MSP430:
1050
0
      return "ELF32-msp430";
1051
0
    case ELF::EM_PPC:
1052
0
      return "ELF32-ppc";
1053
0
    case ELF::EM_RISCV:
1054
0
      return "ELF32-riscv";
1055
0
    case ELF::EM_SPARC:
1056
0
    case ELF::EM_SPARC32PLUS:
1057
0
      return "ELF32-sparc";
1058
0
    case ELF::EM_AMDGPU:
1059
0
      return "ELF32-amdgpu";
1060
0
    default:
1061
0
      return "ELF32-unknown";
1062
0
    }
1063
3.01k
  case ELF::ELFCLASS64:
1064
3.01k
    switch (EF.getHeader()->e_machine) {
1065
3.01k
    case ELF::EM_386:
1066
0
      return "ELF64-i386";
1067
3.01k
    case ELF::EM_X86_64:
1068
1.90k
      return "ELF64-x86-64";
1069
3.01k
    case ELF::EM_AARCH64:
1070
816
      return (IsLittleEndian ? "ELF64-aarch64-little" : 
"ELF64-aarch64-big"0
);
1071
3.01k
    case ELF::EM_PPC64:
1072
86
      return "ELF64-ppc64";
1073
3.01k
    case ELF::EM_RISCV:
1074
0
      return "ELF64-riscv";
1075
3.01k
    case ELF::EM_S390:
1076
0
      return "ELF64-s390";
1077
3.01k
    case ELF::EM_SPARCV9:
1078
0
      return "ELF64-sparc";
1079
3.01k
    case ELF::EM_MIPS:
1080
67
      return "ELF64-mips";
1081
3.01k
    case ELF::EM_AMDGPU:
1082
124
      return "ELF64-amdgpu";
1083
3.01k
    case ELF::EM_BPF:
1084
16
      return "ELF64-BPF";
1085
3.01k
    default:
1086
3
      return "ELF64-unknown";
1087
0
    }
1088
0
  default:
1089
0
    // FIXME: Proper error handling.
1090
0
    report_fatal_error("Invalid ELFCLASS!");
1091
3.01k
  }
1092
3.01k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getFileFormatName() const
Line
Count
Source
1028
217
StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
1029
217
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1030
217
  switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1031
217
  case ELF::ELFCLASS32:
1032
0
    switch (EF.getHeader()->e_machine) {
1033
0
    case ELF::EM_386:
1034
0
      return "ELF32-i386";
1035
0
    case ELF::EM_IAMCU:
1036
0
      return "ELF32-iamcu";
1037
0
    case ELF::EM_X86_64:
1038
0
      return "ELF32-x86-64";
1039
0
    case ELF::EM_ARM:
1040
0
      return (IsLittleEndian ? "ELF32-arm-little" : "ELF32-arm-big");
1041
0
    case ELF::EM_AVR:
1042
0
      return "ELF32-avr";
1043
0
    case ELF::EM_HEXAGON:
1044
0
      return "ELF32-hexagon";
1045
0
    case ELF::EM_LANAI:
1046
0
      return "ELF32-lanai";
1047
0
    case ELF::EM_MIPS:
1048
0
      return "ELF32-mips";
1049
0
    case ELF::EM_MSP430:
1050
0
      return "ELF32-msp430";
1051
0
    case ELF::EM_PPC:
1052
0
      return "ELF32-ppc";
1053
0
    case ELF::EM_RISCV:
1054
0
      return "ELF32-riscv";
1055
0
    case ELF::EM_SPARC:
1056
0
    case ELF::EM_SPARC32PLUS:
1057
0
      return "ELF32-sparc";
1058
0
    case ELF::EM_AMDGPU:
1059
0
      return "ELF32-amdgpu";
1060
0
    default:
1061
0
      return "ELF32-unknown";
1062
0
    }
1063
217
  case ELF::ELFCLASS64:
1064
217
    switch (EF.getHeader()->e_machine) {
1065
217
    case ELF::EM_386:
1066
0
      return "ELF64-i386";
1067
217
    case ELF::EM_X86_64:
1068
2
      return "ELF64-x86-64";
1069
217
    case ELF::EM_AARCH64:
1070
8
      return (IsLittleEndian ? 
"ELF64-aarch64-little"0
: "ELF64-aarch64-big");
1071
217
    case ELF::EM_PPC64:
1072
90
      return "ELF64-ppc64";
1073
217
    case ELF::EM_RISCV:
1074
0
      return "ELF64-riscv";
1075
217
    case ELF::EM_S390:
1076
10
      return "ELF64-s390";
1077
217
    case ELF::EM_SPARCV9:
1078
14
      return "ELF64-sparc";
1079
217
    case ELF::EM_MIPS:
1080
91
      return "ELF64-mips";
1081
217
    case ELF::EM_AMDGPU:
1082
0
      return "ELF64-amdgpu";
1083
217
    case ELF::EM_BPF:
1084
2
      return "ELF64-BPF";
1085
217
    default:
1086
0
      return "ELF64-unknown";
1087
0
    }
1088
0
  default:
1089
0
    // FIXME: Proper error handling.
1090
0
    report_fatal_error("Invalid ELFCLASS!");
1091
217
  }
1092
217
}
1093
1094
334k
template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::getArch() const {
1095
334k
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1096
334k
  switch (EF.getHeader()->e_machine) {
1097
334k
  case ELF::EM_386:
1098
126k
  case ELF::EM_IAMCU:
1099
126k
    return Triple::x86;
1100
126k
  case ELF::EM_X86_64:
1101
32.3k
    return Triple::x86_64;
1102
126k
  case ELF::EM_AARCH64:
1103
31.7k
    return IsLittleEndian ? 
Triple::aarch6431.6k
:
Triple::aarch64_be49
;
1104
126k
  case ELF::EM_ARM:
1105
52.4k
    return Triple::arm;
1106
126k
  case ELF::EM_AVR:
1107
0
    return Triple::avr;
1108
126k
  case ELF::EM_HEXAGON:
1109
19.2k
    return Triple::hexagon;
1110
126k
  case ELF::EM_LANAI:
1111
10
    return Triple::lanai;
1112
126k
  case ELF::EM_MIPS:
1113
15.5k
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1114
15.5k
    case ELF::ELFCLASS32:
1115
13.1k
      return IsLittleEndian ? 
Triple::mipsel3.05k
:
Triple::mips10.1k
;
1116
15.5k
    case ELF::ELFCLASS64:
1117
2.39k
      return IsLittleEndian ? 
Triple::mips64el1.03k
:
Triple::mips641.36k
;
1118
15.5k
    default:
1119
0
      report_fatal_error("Invalid ELFCLASS!");
1120
0
    }
1121
550
  case ELF::EM_MSP430:
1122
550
    return Triple::msp430;
1123
306
  case ELF::EM_PPC:
1124
306
    return Triple::ppc;
1125
48.6k
  case ELF::EM_PPC64:
1126
48.6k
    return IsLittleEndian ? 
Triple::ppc64le28.4k
:
Triple::ppc6420.1k
;
1127
0
  case ELF::EM_RISCV:
1128
0
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1129
0
    case ELF::ELFCLASS32:
1130
0
      return Triple::riscv32;
1131
0
    case ELF::ELFCLASS64:
1132
0
      return Triple::riscv64;
1133
0
    default:
1134
0
      report_fatal_error("Invalid ELFCLASS!");
1135
0
    }
1136
267
  case ELF::EM_S390:
1137
267
    return Triple::systemz;
1138
0
1139
195
  case ELF::EM_SPARC:
1140
195
  case ELF::EM_SPARC32PLUS:
1141
195
    return IsLittleEndian ? 
Triple::sparcel26
:
Triple::sparc169
;
1142
202
  case ELF::EM_SPARCV9:
1143
202
    return Triple::sparcv9;
1144
195
1145
2.94k
  case ELF::EM_AMDGPU: {
1146
2.94k
    if (!IsLittleEndian)
1147
0
      return Triple::UnknownArch;
1148
2.94k
1149
2.94k
    unsigned MACH = EF.getHeader()->e_flags & ELF::EF_AMDGPU_MACH;
1150
2.94k
    if (MACH >= ELF::EF_AMDGPU_MACH_R600_FIRST &&
1151
2.94k
        
MACH <= ELF::EF_AMDGPU_MACH_R600_LAST2.88k
)
1152
105
      return Triple::r600;
1153
2.83k
    if (MACH >= ELF::EF_AMDGPU_MACH_AMDGCN_FIRST &&
1154
2.83k
        
MACH <= ELF::EF_AMDGPU_MACH_AMDGCN_LAST2.78k
)
1155
2.78k
      return Triple::amdgcn;
1156
55
1157
55
    return Triple::UnknownArch;
1158
55
  }
1159
55
1160
3.19k
  case ELF::EM_BPF:
1161
3.19k
    return IsLittleEndian ? 
Triple::bpfel2.80k
:
Triple::bpfeb398
;
1162
55
1163
55
  default:
1164
2
    return Triple::UnknownArch;
1165
334k
  }
1166
334k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getArch() const
Line
Count
Source
1094
201k
template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::getArch() const {
1095
201k
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1096
201k
  switch (EF.getHeader()->e_machine) {
1097
201k
  case ELF::EM_386:
1098
126k
  case ELF::EM_IAMCU:
1099
126k
    return Triple::x86;
1100
126k
  case ELF::EM_X86_64:
1101
28
    return Triple::x86_64;
1102
126k
  case ELF::EM_AARCH64:
1103
0
    return IsLittleEndian ? Triple::aarch64 : Triple::aarch64_be;
1104
126k
  case ELF::EM_ARM:
1105
52.4k
    return Triple::arm;
1106
126k
  case ELF::EM_AVR:
1107
0
    return Triple::avr;
1108
126k
  case ELF::EM_HEXAGON:
1109
19.1k
    return Triple::hexagon;
1110
126k
  case ELF::EM_LANAI:
1111
3
    return Triple::lanai;
1112
126k
  case ELF::EM_MIPS:
1113
3.05k
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1114
3.05k
    case ELF::ELFCLASS32:
1115
3.05k
      return IsLittleEndian ? Triple::mipsel : 
Triple::mips0
;
1116
3.05k
    case ELF::ELFCLASS64:
1117
0
      return IsLittleEndian ? Triple::mips64el : Triple::mips64;
1118
3.05k
    default:
1119
0
      report_fatal_error("Invalid ELFCLASS!");
1120
0
    }
1121
550
  case ELF::EM_MSP430:
1122
550
    return Triple::msp430;
1123
3
  case ELF::EM_PPC:
1124
3
    return Triple::ppc;
1125
0
  case ELF::EM_PPC64:
1126
0
    return IsLittleEndian ? Triple::ppc64le : Triple::ppc64;
1127
0
  case ELF::EM_RISCV:
1128
0
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1129
0
    case ELF::ELFCLASS32:
1130
0
      return Triple::riscv32;
1131
0
    case ELF::ELFCLASS64:
1132
0
      return Triple::riscv64;
1133
0
    default:
1134
0
      report_fatal_error("Invalid ELFCLASS!");
1135
0
    }
1136
0
  case ELF::EM_S390:
1137
0
    return Triple::systemz;
1138
0
1139
26
  case ELF::EM_SPARC:
1140
26
  case ELF::EM_SPARC32PLUS:
1141
26
    return IsLittleEndian ? Triple::sparcel : 
Triple::sparc0
;
1142
26
  case ELF::EM_SPARCV9:
1143
0
    return Triple::sparcv9;
1144
26
1145
108
  case ELF::EM_AMDGPU: {
1146
108
    if (!IsLittleEndian)
1147
0
      return Triple::UnknownArch;
1148
108
1149
108
    unsigned MACH = EF.getHeader()->e_flags & ELF::EF_AMDGPU_MACH;
1150
108
    if (MACH >= ELF::EF_AMDGPU_MACH_R600_FIRST &&
1151
108
        
MACH <= ELF::EF_AMDGPU_MACH_R600_LAST105
)
1152
105
      return Triple::r600;
1153
3
    if (MACH >= ELF::EF_AMDGPU_MACH_AMDGCN_FIRST &&
1154
3
        
MACH <= ELF::EF_AMDGPU_MACH_AMDGCN_LAST0
)
1155
0
      return Triple::amdgcn;
1156
3
1157
3
    return Triple::UnknownArch;
1158
3
  }
1159
3
1160
3
  case ELF::EM_BPF:
1161
0
    return IsLittleEndian ? Triple::bpfel : Triple::bpfeb;
1162
3
1163
3
  default:
1164
2
    return Triple::UnknownArch;
1165
201k
  }
1166
201k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getArch() const
Line
Count
Source
1094
10.6k
template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::getArch() const {
1095
10.6k
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1096
10.6k
  switch (EF.getHeader()->e_machine) {
1097
10.6k
  case ELF::EM_386:
1098
0
  case ELF::EM_IAMCU:
1099
0
    return Triple::x86;
1100
3
  case ELF::EM_X86_64:
1101
3
    return Triple::x86_64;
1102
0
  case ELF::EM_AARCH64:
1103
0
    return IsLittleEndian ? Triple::aarch64 : Triple::aarch64_be;
1104
25
  case ELF::EM_ARM:
1105
25
    return Triple::arm;
1106
0
  case ELF::EM_AVR:
1107
0
    return Triple::avr;
1108
0
  case ELF::EM_HEXAGON:
1109
0
    return Triple::hexagon;
1110
7
  case ELF::EM_LANAI:
1111
7
    return Triple::lanai;
1112
10.1k
  case ELF::EM_MIPS:
1113
10.1k
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1114
10.1k
    case ELF::ELFCLASS32:
1115
10.1k
      return IsLittleEndian ? 
Triple::mipsel0
: Triple::mips;
1116
10.1k
    case ELF::ELFCLASS64:
1117
0
      return IsLittleEndian ? Triple::mips64el : Triple::mips64;
1118
10.1k
    default:
1119
0
      report_fatal_error("Invalid ELFCLASS!");
1120
0
    }
1121
0
  case ELF::EM_MSP430:
1122
0
    return Triple::msp430;
1123
303
  case ELF::EM_PPC:
1124
303
    return Triple::ppc;
1125
0
  case ELF::EM_PPC64:
1126
0
    return IsLittleEndian ? Triple::ppc64le : Triple::ppc64;
1127
0
  case ELF::EM_RISCV:
1128
0
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1129
0
    case ELF::ELFCLASS32:
1130
0
      return Triple::riscv32;
1131
0
    case ELF::ELFCLASS64:
1132
0
      return Triple::riscv64;
1133
0
    default:
1134
0
      report_fatal_error("Invalid ELFCLASS!");
1135
0
    }
1136
0
  case ELF::EM_S390:
1137
0
    return Triple::systemz;
1138
0
1139
169
  case ELF::EM_SPARC:
1140
169
  case ELF::EM_SPARC32PLUS:
1141
169
    return IsLittleEndian ? 
Triple::sparcel0
: Triple::sparc;
1142
169
  case ELF::EM_SPARCV9:
1143
0
    return Triple::sparcv9;
1144
169
1145
169
  case ELF::EM_AMDGPU: {
1146
0
    if (!IsLittleEndian)
1147
0
      return Triple::UnknownArch;
1148
0
1149
0
    unsigned MACH = EF.getHeader()->e_flags & ELF::EF_AMDGPU_MACH;
1150
0
    if (MACH >= ELF::EF_AMDGPU_MACH_R600_FIRST &&
1151
0
        MACH <= ELF::EF_AMDGPU_MACH_R600_LAST)
1152
0
      return Triple::r600;
1153
0
    if (MACH >= ELF::EF_AMDGPU_MACH_AMDGCN_FIRST &&
1154
0
        MACH <= ELF::EF_AMDGPU_MACH_AMDGCN_LAST)
1155
0
      return Triple::amdgcn;
1156
0
1157
0
    return Triple::UnknownArch;
1158
0
  }
1159
0
1160
0
  case ELF::EM_BPF:
1161
0
    return IsLittleEndian ? Triple::bpfel : Triple::bpfeb;
1162
0
1163
0
  default:
1164
0
    return Triple::UnknownArch;
1165
10.6k
  }
1166
10.6k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getArch() const
Line
Count
Source
1094
99.0k
template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::getArch() const {
1095
99.0k
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1096
99.0k
  switch (EF.getHeader()->e_machine) {
1097
99.0k
  case ELF::EM_386:
1098
0
  case ELF::EM_IAMCU:
1099
0
    return Triple::x86;
1100
32.3k
  case ELF::EM_X86_64:
1101
32.3k
    return Triple::x86_64;
1102
31.6k
  case ELF::EM_AARCH64:
1103
31.6k
    return IsLittleEndian ? Triple::aarch64 : 
Triple::aarch64_be0
;
1104
3
  case ELF::EM_ARM:
1105
3
    return Triple::arm;
1106
0
  case ELF::EM_AVR:
1107
0
    return Triple::avr;
1108
6
  case ELF::EM_HEXAGON:
1109
6
    return Triple::hexagon;
1110
0
  case ELF::EM_LANAI:
1111
0
    return Triple::lanai;
1112
1.03k
  case ELF::EM_MIPS:
1113
1.03k
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1114
1.03k
    case ELF::ELFCLASS32:
1115
0
      return IsLittleEndian ? Triple::mipsel : Triple::mips;
1116
1.03k
    case ELF::ELFCLASS64:
1117
1.03k
      return IsLittleEndian ? Triple::mips64el : 
Triple::mips640
;
1118
1.03k
    default:
1119
0
      report_fatal_error("Invalid ELFCLASS!");
1120
0
    }
1121
0
  case ELF::EM_MSP430:
1122
0
    return Triple::msp430;
1123
0
  case ELF::EM_PPC:
1124
0
    return Triple::ppc;
1125
28.4k
  case ELF::EM_PPC64:
1126
28.4k
    return IsLittleEndian ? Triple::ppc64le : 
Triple::ppc640
;
1127
0
  case ELF::EM_RISCV:
1128
0
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1129
0
    case ELF::ELFCLASS32:
1130
0
      return Triple::riscv32;
1131
0
    case ELF::ELFCLASS64:
1132
0
      return Triple::riscv64;
1133
0
    default:
1134
0
      report_fatal_error("Invalid ELFCLASS!");
1135
0
    }
1136
0
  case ELF::EM_S390:
1137
0
    return Triple::systemz;
1138
0
1139
0
  case ELF::EM_SPARC:
1140
0
  case ELF::EM_SPARC32PLUS:
1141
0
    return IsLittleEndian ? Triple::sparcel : Triple::sparc;
1142
0
  case ELF::EM_SPARCV9:
1143
0
    return Triple::sparcv9;
1144
0
1145
2.83k
  case ELF::EM_AMDGPU: {
1146
2.83k
    if (!IsLittleEndian)
1147
0
      return Triple::UnknownArch;
1148
2.83k
1149
2.83k
    unsigned MACH = EF.getHeader()->e_flags & ELF::EF_AMDGPU_MACH;
1150
2.83k
    if (MACH >= ELF::EF_AMDGPU_MACH_R600_FIRST &&
1151
2.83k
        
MACH <= ELF::EF_AMDGPU_MACH_R600_LAST2.78k
)
1152
0
      return Triple::r600;
1153
2.83k
    if (MACH >= ELF::EF_AMDGPU_MACH_AMDGCN_FIRST &&
1154
2.83k
        
MACH <= ELF::EF_AMDGPU_MACH_AMDGCN_LAST2.78k
)
1155
2.78k
      return Triple::amdgcn;
1156
52
1157
52
    return Triple::UnknownArch;
1158
52
  }
1159
52
1160
2.80k
  case ELF::EM_BPF:
1161
2.80k
    return IsLittleEndian ? Triple::bpfel : 
Triple::bpfeb0
;
1162
52
1163
52
  default:
1164
0
    return Triple::UnknownArch;
1165
99.0k
  }
1166
99.0k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getArch() const
Line
Count
Source
1094
22.4k
template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::getArch() const {
1095
22.4k
  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
1096
22.4k
  switch (EF.getHeader()->e_machine) {
1097
22.4k
  case ELF::EM_386:
1098
0
  case ELF::EM_IAMCU:
1099
0
    return Triple::x86;
1100
6
  case ELF::EM_X86_64:
1101
6
    return Triple::x86_64;
1102
49
  case ELF::EM_AARCH64:
1103
49
    return IsLittleEndian ? 
Triple::aarch640
: Triple::aarch64_be;
1104
0
  case ELF::EM_ARM:
1105
0
    return Triple::arm;
1106
0
  case ELF::EM_AVR:
1107
0
    return Triple::avr;
1108
0
  case ELF::EM_HEXAGON:
1109
0
    return Triple::hexagon;
1110
0
  case ELF::EM_LANAI:
1111
0
    return Triple::lanai;
1112
1.36k
  case ELF::EM_MIPS:
1113
1.36k
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1114
1.36k
    case ELF::ELFCLASS32:
1115
0
      return IsLittleEndian ? Triple::mipsel : Triple::mips;
1116
1.36k
    case ELF::ELFCLASS64:
1117
1.36k
      return IsLittleEndian ? 
Triple::mips64el0
: Triple::mips64;
1118
1.36k
    default:
1119
0
      report_fatal_error("Invalid ELFCLASS!");
1120
0
    }
1121
0
  case ELF::EM_MSP430:
1122
0
    return Triple::msp430;
1123
0
  case ELF::EM_PPC:
1124
0
    return Triple::ppc;
1125
20.1k
  case ELF::EM_PPC64:
1126
20.1k
    return IsLittleEndian ? 
Triple::ppc64le0
: Triple::ppc64;
1127
0
  case ELF::EM_RISCV:
1128
0
    switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
1129
0
    case ELF::ELFCLASS32:
1130
0
      return Triple::riscv32;
1131
0
    case ELF::ELFCLASS64:
1132
0
      return Triple::riscv64;
1133
0
    default:
1134
0
      report_fatal_error("Invalid ELFCLASS!");
1135
0
    }
1136
267
  case ELF::EM_S390:
1137
267
    return Triple::systemz;
1138
0
1139
0
  case ELF::EM_SPARC:
1140
0
  case ELF::EM_SPARC32PLUS:
1141
0
    return IsLittleEndian ? Triple::sparcel : Triple::sparc;
1142
202
  case ELF::EM_SPARCV9:
1143
202
    return Triple::sparcv9;
1144
0
1145
0
  case ELF::EM_AMDGPU: {
1146
0
    if (!IsLittleEndian)
1147
0
      return Triple::UnknownArch;
1148
0
1149
0
    unsigned MACH = EF.getHeader()->e_flags & ELF::EF_AMDGPU_MACH;
1150
0
    if (MACH >= ELF::EF_AMDGPU_MACH_R600_FIRST &&
1151
0
        MACH <= ELF::EF_AMDGPU_MACH_R600_LAST)
1152
0
      return Triple::r600;
1153
0
    if (MACH >= ELF::EF_AMDGPU_MACH_AMDGCN_FIRST &&
1154
0
        MACH <= ELF::EF_AMDGPU_MACH_AMDGCN_LAST)
1155
0
      return Triple::amdgcn;
1156
0
1157
0
    return Triple::UnknownArch;
1158
0
  }
1159
0
1160
398
  case ELF::EM_BPF:
1161
398
    return IsLittleEndian ? 
Triple::bpfel0
: Triple::bpfeb;
1162
0
1163
0
  default:
1164
0
    return Triple::UnknownArch;
1165
22.4k
  }
1166
22.4k
}
1167
1168
template <class ELFT>
1169
10
Expected<uint64_t> ELFObjectFile<ELFT>::getStartAddress() const {
1170
10
  return EF.getHeader()->e_entry;
1171
10
}
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
1169
10
Expected<uint64_t> ELFObjectFile<ELFT>::getStartAddress() const {
1170
10
  return EF.getHeader()->e_entry;
1171
10
}
Unexecuted instantiation: llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getStartAddress() const
1172
1173
template <class ELFT>
1174
ELFObjectFileBase::elf_symbol_iterator_range
1175
131
ELFObjectFile<ELFT>::getDynamicSymbolIterators() const {
1176
131
  return make_range(dynamic_symbol_begin(), dynamic_symbol_end());
1177
131
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getDynamicSymbolIterators() const
Line
Count
Source
1175
103
ELFObjectFile<ELFT>::getDynamicSymbolIterators() const {
1176
103
  return make_range(dynamic_symbol_begin(), dynamic_symbol_end());
1177
103
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getDynamicSymbolIterators() const
Line
Count
Source
1175
4
ELFObjectFile<ELFT>::getDynamicSymbolIterators() const {
1176
4
  return make_range(dynamic_symbol_begin(), dynamic_symbol_end());
1177
4
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getDynamicSymbolIterators() const
Line
Count
Source
1175
23
ELFObjectFile<ELFT>::getDynamicSymbolIterators() const {
1176
23
  return make_range(dynamic_symbol_begin(), dynamic_symbol_end());
1177
23
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getDynamicSymbolIterators() const
Line
Count
Source
1175
1
ELFObjectFile<ELFT>::getDynamicSymbolIterators() const {
1176
1
  return make_range(dynamic_symbol_begin(), dynamic_symbol_end());
1177
1
}
1178
1179
1.70k
template <class ELFT> bool ELFObjectFile<ELFT>::isRelocatableObject() const {
1180
1.70k
  return EF.getHeader()->e_type == ELF::ET_REL;
1181
1.70k
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isRelocatableObject() const
Line
Count
Source
1179
755
template <class ELFT> bool ELFObjectFile<ELFT>::isRelocatableObject() const {
1180
755
  return EF.getHeader()->e_type == ELF::ET_REL;
1181
755
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isRelocatableObject() const
Line
Count
Source
1179
180
template <class ELFT> bool ELFObjectFile<ELFT>::isRelocatableObject() const {
1180
180
  return EF.getHeader()->e_type == ELF::ET_REL;
1181
180
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isRelocatableObject() const
Line
Count
Source
1179
760
template <class ELFT> bool ELFObjectFile<ELFT>::isRelocatableObject() const {
1180
760
  return EF.getHeader()->e_type == ELF::ET_REL;
1181
760
}
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isRelocatableObject() const
Line
Count
Source
1179
12
template <class ELFT> bool ELFObjectFile<ELFT>::isRelocatableObject() const {
1180
12
  return EF.getHeader()->e_type == ELF::ET_REL;
1181
12
}
1182
1183
} // end namespace object
1184
} // end namespace llvm
1185
1186
#endif // LLVM_OBJECT_ELFOBJECTFILE_H