Coverage Report

Created: 2018-09-23 16:00

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/Object/ELF.h
Line
Count
Source (jump to first uncovered line)
1
//===- ELF.h - ELF object file implementation -------------------*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This file declares the ELFFile template class.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_OBJECT_ELF_H
15
#define LLVM_OBJECT_ELF_H
16
17
#include "llvm/ADT/ArrayRef.h"
18
#include "llvm/ADT/SmallVector.h"
19
#include "llvm/ADT/StringRef.h"
20
#include "llvm/BinaryFormat/ELF.h"
21
#include "llvm/Object/ELFTypes.h"
22
#include "llvm/Object/Error.h"
23
#include "llvm/Support/Endian.h"
24
#include "llvm/Support/Error.h"
25
#include <cassert>
26
#include <cstddef>
27
#include <cstdint>
28
#include <limits>
29
#include <utility>
30
31
namespace llvm {
32
namespace object {
33
34
StringRef getELFRelocationTypeName(uint32_t Machine, uint32_t Type);
35
uint32_t getELFRelrRelocationType(uint32_t Machine);
36
StringRef getELFSectionTypeName(uint32_t Machine, uint32_t Type);
37
38
// Subclasses of ELFFile may need this for template instantiation
39
inline std::pair<unsigned char, unsigned char>
40
8.66k
getElfArchType(StringRef Object) {
41
8.66k
  if (Object.size() < ELF::EI_NIDENT)
42
0
    return std::make_pair((uint8_t)ELF::ELFCLASSNONE,
43
0
                          (uint8_t)ELF::ELFDATANONE);
44
8.66k
  return std::make_pair((uint8_t)Object[ELF::EI_CLASS],
45
8.66k
                        (uint8_t)Object[ELF::EI_DATA]);
46
8.66k
}
47
48
42
static inline Error createError(StringRef Err) {
49
42
  return make_error<StringError>(Err, object_error::parse_failed);
50
42
}
ELF.cpp:llvm::object::createError(llvm::StringRef)
Line
Count
Source
48
9
static inline Error createError(StringRef Err) {
49
9
  return make_error<StringError>(Err, object_error::parse_failed);
50
9
}
ELFObjectFile.cpp:llvm::object::createError(llvm::StringRef)
Line
Count
Source
48
33
static inline Error createError(StringRef Err) {
49
33
  return make_error<StringError>(Err, object_error::parse_failed);
50
33
}
51
52
template <class ELFT>
53
class ELFFile {
54
public:
55
  LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
56
  using uintX_t = typename ELFT::uint;
57
  using Elf_Ehdr = typename ELFT::Ehdr;
58
  using Elf_Shdr = typename ELFT::Shdr;
59
  using Elf_Sym = typename ELFT::Sym;
60
  using Elf_Dyn = typename ELFT::Dyn;
61
  using Elf_Phdr = typename ELFT::Phdr;
62
  using Elf_Rel = typename ELFT::Rel;
63
  using Elf_Rela = typename ELFT::Rela;
64
  using Elf_Relr = typename ELFT::Relr;
65
  using Elf_Verdef = typename ELFT::Verdef;
66
  using Elf_Verdaux = typename ELFT::Verdaux;
67
  using Elf_Verneed = typename ELFT::Verneed;
68
  using Elf_Vernaux = typename ELFT::Vernaux;
69
  using Elf_Versym = typename ELFT::Versym;
70
  using Elf_Hash = typename ELFT::Hash;
71
  using Elf_GnuHash = typename ELFT::GnuHash;
72
  using Elf_Nhdr = typename ELFT::Nhdr;
73
  using Elf_Note = typename ELFT::Note;
74
  using Elf_Note_Iterator = typename ELFT::NoteIterator;
75
  using Elf_Dyn_Range = typename ELFT::DynRange;
76
  using Elf_Shdr_Range = typename ELFT::ShdrRange;
77
  using Elf_Sym_Range = typename ELFT::SymRange;
78
  using Elf_Rel_Range = typename ELFT::RelRange;
79
  using Elf_Rela_Range = typename ELFT::RelaRange;
80
  using Elf_Relr_Range = typename ELFT::RelrRange;
81
  using Elf_Phdr_Range = typename ELFT::PhdrRange;
82
83
42.0M
  const uint8_t *base() const {
84
42.0M
    return reinterpret_cast<const uint8_t *>(Buf.data());
85
42.0M
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::base() const
Line
Count
Source
83
1.66M
  const uint8_t *base() const {
84
1.66M
    return reinterpret_cast<const uint8_t *>(Buf.data());
85
1.66M
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::base() const
Line
Count
Source
83
592k
  const uint8_t *base() const {
84
592k
    return reinterpret_cast<const uint8_t *>(Buf.data());
85
592k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::base() const
Line
Count
Source
83
24.5M
  const uint8_t *base() const {
84
24.5M
    return reinterpret_cast<const uint8_t *>(Buf.data());
85
24.5M
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::base() const
Line
Count
Source
83
15.2M
  const uint8_t *base() const {
84
15.2M
    return reinterpret_cast<const uint8_t *>(Buf.data());
85
15.2M
  }
86
87
4.12k
  size_t getBufSize() const { return Buf.size(); }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getBufSize() const
Line
Count
Source
87
736
  size_t getBufSize() const { return Buf.size(); }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getBufSize() const
Line
Count
Source
87
264
  size_t getBufSize() const { return Buf.size(); }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getBufSize() const
Line
Count
Source
87
2.92k
  size_t getBufSize() const { return Buf.size(); }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getBufSize() const
Line
Count
Source
87
204
  size_t getBufSize() const { return Buf.size(); }
88
89
private:
90
  StringRef Buf;
91
92
  ELFFile(StringRef Object);
93
94
public:
95
38.6M
  const Elf_Ehdr *getHeader() const {
96
38.6M
    return reinterpret_cast<const Elf_Ehdr *>(base());
97
38.6M
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getHeader() const
Line
Count
Source
95
1.40M
  const Elf_Ehdr *getHeader() const {
96
1.40M
    return reinterpret_cast<const Elf_Ehdr *>(base());
97
1.40M
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getHeader() const
Line
Count
Source
95
557k
  const Elf_Ehdr *getHeader() const {
96
557k
    return reinterpret_cast<const Elf_Ehdr *>(base());
97
557k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getHeader() const
Line
Count
Source
95
21.4M
  const Elf_Ehdr *getHeader() const {
96
21.4M
    return reinterpret_cast<const Elf_Ehdr *>(base());
97
21.4M
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getHeader() const
Line
Count
Source
95
15.2M
  const Elf_Ehdr *getHeader() const {
96
15.2M
    return reinterpret_cast<const Elf_Ehdr *>(base());
97
15.2M
  }
98
99
  template <typename T>
100
  Expected<const T *> getEntry(uint32_t Section, uint32_t Entry) const;
101
  template <typename T>
102
  Expected<const T *> getEntry(const Elf_Shdr *Section, uint32_t Entry) const;
103
104
  Expected<StringRef> getStringTable(const Elf_Shdr *Section) const;
105
  Expected<StringRef> getStringTableForSymtab(const Elf_Shdr &Section) const;
106
  Expected<StringRef> getStringTableForSymtab(const Elf_Shdr &Section,
107
                                              Elf_Shdr_Range Sections) const;
108
109
  Expected<ArrayRef<Elf_Word>> getSHNDXTable(const Elf_Shdr &Section) const;
110
  Expected<ArrayRef<Elf_Word>> getSHNDXTable(const Elf_Shdr &Section,
111
                                             Elf_Shdr_Range Sections) const;
112
113
  StringRef getRelocationTypeName(uint32_t Type) const;
114
  void getRelocationTypeName(uint32_t Type,
115
                             SmallVectorImpl<char> &Result) const;
116
  uint32_t getRelrRelocationType() const;
117
118
  const char *getDynamicTagAsString(unsigned Arch, uint64_t Type) const;
119
  const char *getDynamicTagAsString(uint64_t Type) const;
120
121
  /// Get the symbol for a given relocation.
122
  Expected<const Elf_Sym *> getRelocationSymbol(const Elf_Rel *Rel,
123
                                                const Elf_Shdr *SymTab) const;
124
125
  static Expected<ELFFile> create(StringRef Object);
126
127
24.6k
  bool isMipsELF64() const {
128
24.6k
    return getHeader()->e_machine == ELF::EM_MIPS &&
129
24.6k
           
getHeader()->getFileClass() == ELF::ELFCLASS642.69k
;
130
24.6k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isMipsELF64() const
Line
Count
Source
127
5.03k
  bool isMipsELF64() const {
128
5.03k
    return getHeader()->e_machine == ELF::EM_MIPS &&
129
5.03k
           
getHeader()->getFileClass() == ELF::ELFCLASS64725
;
130
5.03k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isMipsELF64() const
Line
Count
Source
127
1.42k
  bool isMipsELF64() const {
128
1.42k
    return getHeader()->e_machine == ELF::EM_MIPS &&
129
1.42k
           
getHeader()->getFileClass() == ELF::ELFCLASS641.13k
;
130
1.42k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isMipsELF64() const
Line
Count
Source
127
15.2k
  bool isMipsELF64() const {
128
15.2k
    return getHeader()->e_machine == ELF::EM_MIPS &&
129
15.2k
           
getHeader()->getFileClass() == ELF::ELFCLASS64438
;
130
15.2k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isMipsELF64() const
Line
Count
Source
127
2.90k
  bool isMipsELF64() const {
128
2.90k
    return getHeader()->e_machine == ELF::EM_MIPS &&
129
2.90k
           
getHeader()->getFileClass() == ELF::ELFCLASS64395
;
130
2.90k
  }
131
132
20.0k
  bool isMips64EL() const {
133
20.0k
    return isMipsELF64() &&
134
20.0k
           
getHeader()->getDataEncoding() == ELF::ELFDATA2LSB638
;
135
20.0k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isMips64EL() const
Line
Count
Source
132
3.75k
  bool isMips64EL() const {
133
3.75k
    return isMipsELF64() &&
134
3.75k
           
getHeader()->getDataEncoding() == ELF::ELFDATA2LSB0
;
135
3.75k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isMips64EL() const
Line
Count
Source
132
1.09k
  bool isMips64EL() const {
133
1.09k
    return isMipsELF64() &&
134
1.09k
           
getHeader()->getDataEncoding() == ELF::ELFDATA2LSB0
;
135
1.09k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isMips64EL() const
Line
Count
Source
132
13.1k
  bool isMips64EL() const {
133
13.1k
    return isMipsELF64() &&
134
13.1k
           
getHeader()->getDataEncoding() == ELF::ELFDATA2LSB346
;
135
13.1k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isMips64EL() const
Line
Count
Source
132
2.07k
  bool isMips64EL() const {
133
2.07k
    return isMipsELF64() &&
134
2.07k
           
getHeader()->getDataEncoding() == ELF::ELFDATA2LSB292
;
135
2.07k
  }
136
137
  Expected<Elf_Shdr_Range> sections() const;
138
139
  Expected<Elf_Dyn_Range> dynamicEntries() const;
140
141
  Expected<const uint8_t *> toMappedAddr(uint64_t VAddr) const;
142
143
105k
  Expected<Elf_Sym_Range> symbols(const Elf_Shdr *Sec) const {
144
105k
    if (!Sec)
145
18.0k
      return makeArrayRef<Elf_Sym>(nullptr, nullptr);
146
87.2k
    return getSectionContentsAsArray<Elf_Sym>(Sec);
147
87.2k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::symbols(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*) const
Line
Count
Source
143
28.0k
  Expected<Elf_Sym_Range> symbols(const Elf_Shdr *Sec) const {
144
28.0k
    if (!Sec)
145
7.77k
      return makeArrayRef<Elf_Sym>(nullptr, nullptr);
146
20.2k
    return getSectionContentsAsArray<Elf_Sym>(Sec);
147
20.2k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::symbols(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*) const
Line
Count
Source
143
3.44k
  Expected<Elf_Sym_Range> symbols(const Elf_Shdr *Sec) const {
144
3.44k
    if (!Sec)
145
872
      return makeArrayRef<Elf_Sym>(nullptr, nullptr);
146
2.57k
    return getSectionContentsAsArray<Elf_Sym>(Sec);
147
2.57k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::symbols(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*) const
Line
Count
Source
143
71.3k
  Expected<Elf_Sym_Range> symbols(const Elf_Shdr *Sec) const {
144
71.3k
    if (!Sec)
145
8.80k
      return makeArrayRef<Elf_Sym>(nullptr, nullptr);
146
62.5k
    return getSectionContentsAsArray<Elf_Sym>(Sec);
147
62.5k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::symbols(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*) const
Line
Count
Source
143
2.43k
  Expected<Elf_Sym_Range> symbols(const Elf_Shdr *Sec) const {
144
2.43k
    if (!Sec)
145
595
      return makeArrayRef<Elf_Sym>(nullptr, nullptr);
146
1.84k
    return getSectionContentsAsArray<Elf_Sym>(Sec);
147
1.84k
  }
148
149
1.67k
  Expected<Elf_Rela_Range> relas(const Elf_Shdr *Sec) const {
150
1.67k
    return getSectionContentsAsArray<Elf_Rela>(Sec);
151
1.67k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::relas(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*) const
Line
Count
Source
149
5
  Expected<Elf_Rela_Range> relas(const Elf_Shdr *Sec) const {
150
5
    return getSectionContentsAsArray<Elf_Rela>(Sec);
151
5
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::relas(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*) const
Line
Count
Source
149
28
  Expected<Elf_Rela_Range> relas(const Elf_Shdr *Sec) const {
150
28
    return getSectionContentsAsArray<Elf_Rela>(Sec);
151
28
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::relas(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*) const
Line
Count
Source
149
1.46k
  Expected<Elf_Rela_Range> relas(const Elf_Shdr *Sec) const {
150
1.46k
    return getSectionContentsAsArray<Elf_Rela>(Sec);
151
1.46k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::relas(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*) const
Line
Count
Source
149
178
  Expected<Elf_Rela_Range> relas(const Elf_Shdr *Sec) const {
150
178
    return getSectionContentsAsArray<Elf_Rela>(Sec);
151
178
  }
152
153
620
  Expected<Elf_Rel_Range> rels(const Elf_Shdr *Sec) const {
154
620
    return getSectionContentsAsArray<Elf_Rel>(Sec);
155
620
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::rels(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*) const
Line
Count
Source
153
488
  Expected<Elf_Rel_Range> rels(const Elf_Shdr *Sec) const {
154
488
    return getSectionContentsAsArray<Elf_Rel>(Sec);
155
488
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::rels(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*) const
Line
Count
Source
153
102
  Expected<Elf_Rel_Range> rels(const Elf_Shdr *Sec) const {
154
102
    return getSectionContentsAsArray<Elf_Rel>(Sec);
155
102
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::rels(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*) const
Line
Count
Source
153
22
  Expected<Elf_Rel_Range> rels(const Elf_Shdr *Sec) const {
154
22
    return getSectionContentsAsArray<Elf_Rel>(Sec);
155
22
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::rels(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*) const
Line
Count
Source
153
8
  Expected<Elf_Rel_Range> rels(const Elf_Shdr *Sec) const {
154
8
    return getSectionContentsAsArray<Elf_Rel>(Sec);
155
8
  }
156
157
13
  Expected<Elf_Relr_Range> relrs(const Elf_Shdr *Sec) const {
158
13
    return getSectionContentsAsArray<Elf_Relr>(Sec);
159
13
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::relrs(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*) const
Line
Count
Source
157
7
  Expected<Elf_Relr_Range> relrs(const Elf_Shdr *Sec) const {
158
7
    return getSectionContentsAsArray<Elf_Relr>(Sec);
159
7
  }
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::relrs(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*) const
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::relrs(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*) const
Line
Count
Source
157
6
  Expected<Elf_Relr_Range> relrs(const Elf_Shdr *Sec) const {
158
6
    return getSectionContentsAsArray<Elf_Relr>(Sec);
159
6
  }
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::relrs(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*) const
160
161
  Expected<std::vector<Elf_Rela>> decode_relrs(Elf_Relr_Range relrs) const;
162
163
  Expected<std::vector<Elf_Rela>> android_relas(const Elf_Shdr *Sec) const;
164
165
  /// Iterate over program header table.
166
2.75k
  Expected<Elf_Phdr_Range> program_headers() const {
167
2.75k
    if (getHeader()->e_phnum && 
getHeader()->e_phentsize != sizeof(Elf_Phdr)1.41k
)
168
2
      return createError("invalid e_phentsize");
169
2.75k
    if (getHeader()->e_phoff +
170
2.75k
            (getHeader()->e_phnum * getHeader()->e_phentsize) >
171
2.75k
        getBufSize())
172
1
      return createError("program headers longer than binary");
173
2.75k
    auto *Begin =
174
2.75k
        reinterpret_cast<const Elf_Phdr *>(base() + getHeader()->e_phoff);
175
2.75k
    return makeArrayRef(Begin, Begin + getHeader()->e_phnum);
176
2.75k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::program_headers() const
Line
Count
Source
166
540
  Expected<Elf_Phdr_Range> program_headers() const {
167
540
    if (getHeader()->e_phnum && 
getHeader()->e_phentsize != sizeof(Elf_Phdr)182
)
168
0
      return createError("invalid e_phentsize");
169
540
    if (getHeader()->e_phoff +
170
540
            (getHeader()->e_phnum * getHeader()->e_phentsize) >
171
540
        getBufSize())
172
0
      return createError("program headers longer than binary");
173
540
    auto *Begin =
174
540
        reinterpret_cast<const Elf_Phdr *>(base() + getHeader()->e_phoff);
175
540
    return makeArrayRef(Begin, Begin + getHeader()->e_phnum);
176
540
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::program_headers() const
Line
Count
Source
166
172
  Expected<Elf_Phdr_Range> program_headers() const {
167
172
    if (getHeader()->e_phnum && 
getHeader()->e_phentsize != sizeof(Elf_Phdr)67
)
168
0
      return createError("invalid e_phentsize");
169
172
    if (getHeader()->e_phoff +
170
172
            (getHeader()->e_phnum * getHeader()->e_phentsize) >
171
172
        getBufSize())
172
0
      return createError("program headers longer than binary");
173
172
    auto *Begin =
174
172
        reinterpret_cast<const Elf_Phdr *>(base() + getHeader()->e_phoff);
175
172
    return makeArrayRef(Begin, Begin + getHeader()->e_phnum);
176
172
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::program_headers() const
Line
Count
Source
166
1.90k
  Expected<Elf_Phdr_Range> program_headers() const {
167
1.90k
    if (getHeader()->e_phnum && 
getHeader()->e_phentsize != sizeof(Elf_Phdr)1.11k
)
168
2
      return createError("invalid e_phentsize");
169
1.90k
    if (getHeader()->e_phoff +
170
1.90k
            (getHeader()->e_phnum * getHeader()->e_phentsize) >
171
1.90k
        getBufSize())
172
1
      return createError("program headers longer than binary");
173
1.90k
    auto *Begin =
174
1.90k
        reinterpret_cast<const Elf_Phdr *>(base() + getHeader()->e_phoff);
175
1.90k
    return makeArrayRef(Begin, Begin + getHeader()->e_phnum);
176
1.90k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::program_headers() const
Line
Count
Source
166
142
  Expected<Elf_Phdr_Range> program_headers() const {
167
142
    if (getHeader()->e_phnum && 
getHeader()->e_phentsize != sizeof(Elf_Phdr)52
)
168
0
      return createError("invalid e_phentsize");
169
142
    if (getHeader()->e_phoff +
170
142
            (getHeader()->e_phnum * getHeader()->e_phentsize) >
171
142
        getBufSize())
172
0
      return createError("program headers longer than binary");
173
142
    auto *Begin =
174
142
        reinterpret_cast<const Elf_Phdr *>(base() + getHeader()->e_phoff);
175
142
    return makeArrayRef(Begin, Begin + getHeader()->e_phnum);
176
142
  }
177
178
  /// Get an iterator over notes in a program header.
179
  ///
180
  /// The program header must be of type \c PT_NOTE.
181
  ///
182
  /// \param Phdr the program header to iterate over.
183
  /// \param Err [out] an error to support fallible iteration, which should
184
  ///  be checked after iteration ends.
185
0
  Elf_Note_Iterator notes_begin(const Elf_Phdr &Phdr, Error &Err) const {
186
0
    if (Phdr.p_type != ELF::PT_NOTE) {
187
0
      Err = createError("attempt to iterate notes of non-note program header");
188
0
      return Elf_Note_Iterator(Err);
189
0
    }
190
0
    if (Phdr.p_offset + Phdr.p_filesz > getBufSize()) {
191
0
      Err = createError("invalid program header offset/size");
192
0
      return Elf_Note_Iterator(Err);
193
0
    }
194
0
    return Elf_Note_Iterator(base() + Phdr.p_offset, Phdr.p_filesz, Err);
195
0
  }
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::notes_begin(llvm::object::Elf_Phdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const&, llvm::Error&) const
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::notes_begin(llvm::object::Elf_Phdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const&, llvm::Error&) const
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::notes_begin(llvm::object::Elf_Phdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const&, llvm::Error&) const
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::notes_begin(llvm::object::Elf_Phdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const&, llvm::Error&) const
196
197
  /// Get an iterator over notes in a section.
198
  ///
199
  /// The section must be of type \c SHT_NOTE.
200
  ///
201
  /// \param Shdr the section to iterate over.
202
  /// \param Err [out] an error to support fallible iteration, which should
203
  ///  be checked after iteration ends.
204
28
  Elf_Note_Iterator notes_begin(const Elf_Shdr &Shdr, Error &Err) const {
205
28
    if (Shdr.sh_type != ELF::SHT_NOTE) {
206
0
      Err = createError("attempt to iterate notes of non-note section");
207
0
      return Elf_Note_Iterator(Err);
208
0
    }
209
28
    if (Shdr.sh_offset + Shdr.sh_size > getBufSize()) {
210
0
      Err = createError("invalid section offset/size");
211
0
      return Elf_Note_Iterator(Err);
212
0
    }
213
28
    return Elf_Note_Iterator(base() + Shdr.sh_offset, Shdr.sh_size, Err);
214
28
  }
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::notes_begin(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const&, llvm::Error&) const
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::notes_begin(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const&, llvm::Error&) const
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::notes_begin(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const&, llvm::Error&) const
Line
Count
Source
204
28
  Elf_Note_Iterator notes_begin(const Elf_Shdr &Shdr, Error &Err) const {
205
28
    if (Shdr.sh_type != ELF::SHT_NOTE) {
206
0
      Err = createError("attempt to iterate notes of non-note section");
207
0
      return Elf_Note_Iterator(Err);
208
0
    }
209
28
    if (Shdr.sh_offset + Shdr.sh_size > getBufSize()) {
210
0
      Err = createError("invalid section offset/size");
211
0
      return Elf_Note_Iterator(Err);
212
0
    }
213
28
    return Elf_Note_Iterator(base() + Shdr.sh_offset, Shdr.sh_size, Err);
214
28
  }
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::notes_begin(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const&, llvm::Error&) const
215
216
  /// Get the end iterator for notes.
217
28
  Elf_Note_Iterator notes_end() const {
218
28
    return Elf_Note_Iterator();
219
28
  }
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::notes_end() const
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::notes_end() const
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::notes_end() const
Line
Count
Source
217
28
  Elf_Note_Iterator notes_end() const {
218
28
    return Elf_Note_Iterator();
219
28
  }
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::notes_end() const
220
221
  /// Get an iterator range over notes of a program header.
222
  ///
223
  /// The program header must be of type \c PT_NOTE.
224
  ///
225
  /// \param Phdr the program header to iterate over.
226
  /// \param Err [out] an error to support fallible iteration, which should
227
  ///  be checked after iteration ends.
228
  iterator_range<Elf_Note_Iterator> notes(const Elf_Phdr &Phdr,
229
0
                                          Error &Err) const {
230
0
    return make_range(notes_begin(Phdr, Err), notes_end());
231
0
  }
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::notes(llvm::object::Elf_Phdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const&, llvm::Error&) const
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::notes(llvm::object::Elf_Phdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const&, llvm::Error&) const
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::notes(llvm::object::Elf_Phdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const&, llvm::Error&) const
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::notes(llvm::object::Elf_Phdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const&, llvm::Error&) const
232
233
  /// Get an iterator range over notes of a section.
234
  ///
235
  /// The section must be of type \c SHT_NOTE.
236
  ///
237
  /// \param Shdr the section to iterate over.
238
  /// \param Err [out] an error to support fallible iteration, which should
239
  ///  be checked after iteration ends.
240
  iterator_range<Elf_Note_Iterator> notes(const Elf_Shdr &Shdr,
241
28
                                          Error &Err) const {
242
28
    return make_range(notes_begin(Shdr, Err), notes_end());
243
28
  }
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::notes(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const&, llvm::Error&) const
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::notes(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const&, llvm::Error&) const
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::notes(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const&, llvm::Error&) const
Line
Count
Source
241
28
                                          Error &Err) const {
242
28
    return make_range(notes_begin(Shdr, Err), notes_end());
243
28
  }
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::notes(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const&, llvm::Error&) const
244
245
  Expected<StringRef> getSectionStringTable(Elf_Shdr_Range Sections) const;
246
  Expected<uint32_t> getSectionIndex(const Elf_Sym *Sym, Elf_Sym_Range Syms,
247
                                     ArrayRef<Elf_Word> ShndxTable) const;
248
  Expected<const Elf_Shdr *> getSection(const Elf_Sym *Sym,
249
                                        const Elf_Shdr *SymTab,
250
                                        ArrayRef<Elf_Word> ShndxTable) const;
251
  Expected<const Elf_Shdr *> getSection(const Elf_Sym *Sym,
252
                                        Elf_Sym_Range Symtab,
253
                                        ArrayRef<Elf_Word> ShndxTable) const;
254
  Expected<const Elf_Shdr *> getSection(uint32_t Index) const;
255
  Expected<const Elf_Shdr *> getSection(const StringRef SectionName) const;
256
257
  Expected<const Elf_Sym *> getSymbol(const Elf_Shdr *Sec,
258
                                      uint32_t Index) const;
259
260
  Expected<StringRef> getSectionName(const Elf_Shdr *Section) const;
261
  Expected<StringRef> getSectionName(const Elf_Shdr *Section,
262
                                     StringRef DotShstrtab) const;
263
  template <typename T>
264
  Expected<ArrayRef<T>> getSectionContentsAsArray(const Elf_Shdr *Sec) const;
265
  Expected<ArrayRef<uint8_t>> getSectionContents(const Elf_Shdr *Sec) const;
266
};
267
268
using ELF32LEFile = ELFFile<ELF32LE>;
269
using ELF64LEFile = ELFFile<ELF64LE>;
270
using ELF32BEFile = ELFFile<ELF32BE>;
271
using ELF64BEFile = ELFFile<ELF64BE>;
272
273
template <class ELFT>
274
inline Expected<const typename ELFT::Shdr *>
275
413k
getSection(typename ELFT::ShdrRange Sections, uint32_t Index) {
276
413k
  if (Index >= Sections.size())
277
1
    return createError("invalid section index");
278
413k
  return &Sections[Index];
279
413k
}
llvm::Expected<llvm::object::ELFType<(llvm::support::endianness)1, false>::Shdr const*> llvm::object::getSection<llvm::object::ELFType<(llvm::support::endianness)1, false> >(llvm::object::ELFType<(llvm::support::endianness)1, false>::ShdrRange, unsigned int)
Line
Count
Source
275
115k
getSection(typename ELFT::ShdrRange Sections, uint32_t Index) {
276
115k
  if (Index >= Sections.size())
277
0
    return createError("invalid section index");
278
115k
  return &Sections[Index];
279
115k
}
llvm::Expected<llvm::object::ELFType<(llvm::support::endianness)0, false>::Shdr const*> llvm::object::getSection<llvm::object::ELFType<(llvm::support::endianness)0, false> >(llvm::object::ELFType<(llvm::support::endianness)0, false>::ShdrRange, unsigned int)
Line
Count
Source
275
11.3k
getSection(typename ELFT::ShdrRange Sections, uint32_t Index) {
276
11.3k
  if (Index >= Sections.size())
277
0
    return createError("invalid section index");
278
11.3k
  return &Sections[Index];
279
11.3k
}
llvm::Expected<llvm::object::ELFType<(llvm::support::endianness)1, true>::Shdr const*> llvm::object::getSection<llvm::object::ELFType<(llvm::support::endianness)1, true> >(llvm::object::ELFType<(llvm::support::endianness)1, true>::ShdrRange, unsigned int)
Line
Count
Source
275
278k
getSection(typename ELFT::ShdrRange Sections, uint32_t Index) {
276
278k
  if (Index >= Sections.size())
277
1
    return createError("invalid section index");
278
278k
  return &Sections[Index];
279
278k
}
llvm::Expected<llvm::object::ELFType<(llvm::support::endianness)0, true>::Shdr const*> llvm::object::getSection<llvm::object::ELFType<(llvm::support::endianness)0, true> >(llvm::object::ELFType<(llvm::support::endianness)0, true>::ShdrRange, unsigned int)
Line
Count
Source
275
8.41k
getSection(typename ELFT::ShdrRange Sections, uint32_t Index) {
276
8.41k
  if (Index >= Sections.size())
277
0
    return createError("invalid section index");
278
8.41k
  return &Sections[Index];
279
8.41k
}
280
281
template <class ELFT>
282
inline Expected<uint32_t>
283
getExtendedSymbolTableIndex(const typename ELFT::Sym *Sym,
284
                            const typename ELFT::Sym *FirstSym,
285
538
                            ArrayRef<typename ELFT::Word> ShndxTable) {
286
538
  assert(Sym->st_shndx == ELF::SHN_XINDEX);
287
538
  unsigned Index = Sym - FirstSym;
288
538
  if (Index >= ShndxTable.size())
289
1
    return createError("index past the end of the symbol table");
290
537
291
537
  // The size of the table was checked in getSHNDXTable.
292
537
  return ShndxTable[Index];
293
537
}
Unexecuted instantiation: llvm::Expected<unsigned int> llvm::object::getExtendedSymbolTableIndex<llvm::object::ELFType<(llvm::support::endianness)1, false> >(llvm::object::ELFType<(llvm::support::endianness)1, false>::Sym const*, llvm::object::ELFType<(llvm::support::endianness)1, false>::Sym const*, llvm::ArrayRef<llvm::object::ELFType<(llvm::support::endianness)1, false>::Word>)
Unexecuted instantiation: llvm::Expected<unsigned int> llvm::object::getExtendedSymbolTableIndex<llvm::object::ELFType<(llvm::support::endianness)0, false> >(llvm::object::ELFType<(llvm::support::endianness)0, false>::Sym const*, llvm::object::ELFType<(llvm::support::endianness)0, false>::Sym const*, llvm::ArrayRef<llvm::object::ELFType<(llvm::support::endianness)0, false>::Word>)
llvm::Expected<unsigned int> llvm::object::getExtendedSymbolTableIndex<llvm::object::ELFType<(llvm::support::endianness)1, true> >(llvm::object::ELFType<(llvm::support::endianness)1, true>::Sym const*, llvm::object::ELFType<(llvm::support::endianness)1, true>::Sym const*, llvm::ArrayRef<llvm::object::ELFType<(llvm::support::endianness)1, true>::Word>)
Line
Count
Source
285
538
                            ArrayRef<typename ELFT::Word> ShndxTable) {
286
538
  assert(Sym->st_shndx == ELF::SHN_XINDEX);
287
538
  unsigned Index = Sym - FirstSym;
288
538
  if (Index >= ShndxTable.size())
289
1
    return createError("index past the end of the symbol table");
290
537
291
537
  // The size of the table was checked in getSHNDXTable.
292
537
  return ShndxTable[Index];
293
537
}
Unexecuted instantiation: llvm::Expected<unsigned int> llvm::object::getExtendedSymbolTableIndex<llvm::object::ELFType<(llvm::support::endianness)0, true> >(llvm::object::ELFType<(llvm::support::endianness)0, true>::Sym const*, llvm::object::ELFType<(llvm::support::endianness)0, true>::Sym const*, llvm::ArrayRef<llvm::object::ELFType<(llvm::support::endianness)0, true>::Word>)
294
295
template <class ELFT>
296
Expected<uint32_t>
297
ELFFile<ELFT>::getSectionIndex(const Elf_Sym *Sym, Elf_Sym_Range Syms,
298
105k
                               ArrayRef<Elf_Word> ShndxTable) const {
299
105k
  uint32_t Index = Sym->st_shndx;
300
105k
  if (Index == ELF::SHN_XINDEX) {
301
267
    auto ErrorOrIndex = getExtendedSymbolTableIndex<ELFT>(
302
267
        Sym, Syms.begin(), ShndxTable);
303
267
    if (!ErrorOrIndex)
304
0
      return ErrorOrIndex.takeError();
305
267
    return *ErrorOrIndex;
306
267
  }
307
105k
  if (Index == ELF::SHN_UNDEF || 
Index >= ELF::SHN_LORESERVE100k
)
308
5.86k
    return 0;
309
99.4k
  return Index;
310
99.4k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionIndex(llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*, llvm::ArrayRef<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > >, llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)1, 1ul> >) const
Line
Count
Source
298
11.7k
                               ArrayRef<Elf_Word> ShndxTable) const {
299
11.7k
  uint32_t Index = Sym->st_shndx;
300
11.7k
  if (Index == ELF::SHN_XINDEX) {
301
0
    auto ErrorOrIndex = getExtendedSymbolTableIndex<ELFT>(
302
0
        Sym, Syms.begin(), ShndxTable);
303
0
    if (!ErrorOrIndex)
304
0
      return ErrorOrIndex.takeError();
305
0
    return *ErrorOrIndex;
306
0
  }
307
11.7k
  if (Index == ELF::SHN_UNDEF || 
Index >= ELF::SHN_LORESERVE10.9k
)
308
1.04k
    return 0;
309
10.7k
  return Index;
310
10.7k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionIndex(llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*, llvm::ArrayRef<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > >, llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)0, 1ul> >) const
Line
Count
Source
298
1.56k
                               ArrayRef<Elf_Word> ShndxTable) const {
299
1.56k
  uint32_t Index = Sym->st_shndx;
300
1.56k
  if (Index == ELF::SHN_XINDEX) {
301
0
    auto ErrorOrIndex = getExtendedSymbolTableIndex<ELFT>(
302
0
        Sym, Syms.begin(), ShndxTable);
303
0
    if (!ErrorOrIndex)
304
0
      return ErrorOrIndex.takeError();
305
0
    return *ErrorOrIndex;
306
0
  }
307
1.56k
  if (Index == ELF::SHN_UNDEF || 
Index >= ELF::SHN_LORESERVE1.25k
)
308
355
    return 0;
309
1.21k
  return Index;
310
1.21k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionIndex(llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*, llvm::ArrayRef<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > >, llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)1, 1ul> >) const
Line
Count
Source
298
81.1k
                               ArrayRef<Elf_Word> ShndxTable) const {
299
81.1k
  uint32_t Index = Sym->st_shndx;
300
81.1k
  if (Index == ELF::SHN_XINDEX) {
301
267
    auto ErrorOrIndex = getExtendedSymbolTableIndex<ELFT>(
302
267
        Sym, Syms.begin(), ShndxTable);
303
267
    if (!ErrorOrIndex)
304
0
      return ErrorOrIndex.takeError();
305
267
    return *ErrorOrIndex;
306
267
  }
307
80.8k
  if (Index == ELF::SHN_UNDEF || 
Index >= ELF::SHN_LORESERVE77.3k
)
308
4.21k
    return 0;
309
76.6k
  return Index;
310
76.6k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionIndex(llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*, llvm::ArrayRef<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > >, llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)0, 1ul> >) const
Line
Count
Source
298
11.1k
                               ArrayRef<Elf_Word> ShndxTable) const {
299
11.1k
  uint32_t Index = Sym->st_shndx;
300
11.1k
  if (Index == ELF::SHN_XINDEX) {
301
0
    auto ErrorOrIndex = getExtendedSymbolTableIndex<ELFT>(
302
0
        Sym, Syms.begin(), ShndxTable);
303
0
    if (!ErrorOrIndex)
304
0
      return ErrorOrIndex.takeError();
305
0
    return *ErrorOrIndex;
306
0
  }
307
11.1k
  if (Index == ELF::SHN_UNDEF || 
Index >= ELF::SHN_LORESERVE10.9k
)
308
250
    return 0;
309
10.8k
  return Index;
310
10.8k
}
311
312
template <class ELFT>
313
Expected<const typename ELFT::Shdr *>
314
ELFFile<ELFT>::getSection(const Elf_Sym *Sym, const Elf_Shdr *SymTab,
315
19.1k
                          ArrayRef<Elf_Word> ShndxTable) const {
316
19.1k
  auto SymsOrErr = symbols(SymTab);
317
19.1k
  if (!SymsOrErr)
318
0
    return SymsOrErr.takeError();
319
19.1k
  return getSection(Sym, *SymsOrErr, ShndxTable);
320
19.1k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSection(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*, llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)1, 1ul> >) const
Line
Count
Source
315
9.60k
                          ArrayRef<Elf_Word> ShndxTable) const {
316
9.60k
  auto SymsOrErr = symbols(SymTab);
317
9.60k
  if (!SymsOrErr)
318
0
    return SymsOrErr.takeError();
319
9.60k
  return getSection(Sym, *SymsOrErr, ShndxTable);
320
9.60k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSection(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*, llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)0, 1ul> >) const
Line
Count
Source
315
911
                          ArrayRef<Elf_Word> ShndxTable) const {
316
911
  auto SymsOrErr = symbols(SymTab);
317
911
  if (!SymsOrErr)
318
0
    return SymsOrErr.takeError();
319
911
  return getSection(Sym, *SymsOrErr, ShndxTable);
320
911
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSection(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*, llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)1, 1ul> >) const
Line
Count
Source
315
7.92k
                          ArrayRef<Elf_Word> ShndxTable) const {
316
7.92k
  auto SymsOrErr = symbols(SymTab);
317
7.92k
  if (!SymsOrErr)
318
0
    return SymsOrErr.takeError();
319
7.92k
  return getSection(Sym, *SymsOrErr, ShndxTable);
320
7.92k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSection(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*, llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)0, 1ul> >) const
Line
Count
Source
315
696
                          ArrayRef<Elf_Word> ShndxTable) const {
316
696
  auto SymsOrErr = symbols(SymTab);
317
696
  if (!SymsOrErr)
318
0
    return SymsOrErr.takeError();
319
696
  return getSection(Sym, *SymsOrErr, ShndxTable);
320
696
}
321
322
template <class ELFT>
323
Expected<const typename ELFT::Shdr *>
324
ELFFile<ELFT>::getSection(const Elf_Sym *Sym, Elf_Sym_Range Symbols,
325
19.1k
                          ArrayRef<Elf_Word> ShndxTable) const {
326
19.1k
  auto IndexOrErr = getSectionIndex(Sym, Symbols, ShndxTable);
327
19.1k
  if (!IndexOrErr)
328
0
    return IndexOrErr.takeError();
329
19.1k
  uint32_t Index = *IndexOrErr;
330
19.1k
  if (Index == 0)
331
1.10k
    return nullptr;
332
18.0k
  return getSection(Index);
333
18.0k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSection(llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*, llvm::ArrayRef<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > >, llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)1, 1ul> >) const
Line
Count
Source
325
9.60k
                          ArrayRef<Elf_Word> ShndxTable) const {
326
9.60k
  auto IndexOrErr = getSectionIndex(Sym, Symbols, ShndxTable);
327
9.60k
  if (!IndexOrErr)
328
0
    return IndexOrErr.takeError();
329
9.60k
  uint32_t Index = *IndexOrErr;
330
9.60k
  if (Index == 0)
331
457
    return nullptr;
332
9.14k
  return getSection(Index);
333
9.14k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSection(llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*, llvm::ArrayRef<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > >, llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)0, 1ul> >) const
Line
Count
Source
325
911
                          ArrayRef<Elf_Word> ShndxTable) const {
326
911
  auto IndexOrErr = getSectionIndex(Sym, Symbols, ShndxTable);
327
911
  if (!IndexOrErr)
328
0
    return IndexOrErr.takeError();
329
911
  uint32_t Index = *IndexOrErr;
330
911
  if (Index == 0)
331
100
    return nullptr;
332
811
  return getSection(Index);
333
811
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSection(llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*, llvm::ArrayRef<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > >, llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)1, 1ul> >) const
Line
Count
Source
325
7.92k
                          ArrayRef<Elf_Word> ShndxTable) const {
326
7.92k
  auto IndexOrErr = getSectionIndex(Sym, Symbols, ShndxTable);
327
7.92k
  if (!IndexOrErr)
328
0
    return IndexOrErr.takeError();
329
7.92k
  uint32_t Index = *IndexOrErr;
330
7.92k
  if (Index == 0)
331
492
    return nullptr;
332
7.42k
  return getSection(Index);
333
7.42k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSection(llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*, llvm::ArrayRef<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > >, llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)0, 1ul> >) const
Line
Count
Source
325
696
                          ArrayRef<Elf_Word> ShndxTable) const {
326
696
  auto IndexOrErr = getSectionIndex(Sym, Symbols, ShndxTable);
327
696
  if (!IndexOrErr)
328
0
    return IndexOrErr.takeError();
329
696
  uint32_t Index = *IndexOrErr;
330
696
  if (Index == 0)
331
53
    return nullptr;
332
643
  return getSection(Index);
333
643
}
334
335
template <class ELFT>
336
inline Expected<const typename ELFT::Sym *>
337
77
getSymbol(typename ELFT::SymRange Symbols, uint32_t Index) {
338
77
  if (Index >= Symbols.size())
339
0
    return createError("invalid symbol index");
340
77
  return &Symbols[Index];
341
77
}
llvm::Expected<llvm::object::ELFType<(llvm::support::endianness)1, false>::Sym const*> llvm::object::getSymbol<llvm::object::ELFType<(llvm::support::endianness)1, false> >(llvm::object::ELFType<(llvm::support::endianness)1, false>::SymRange, unsigned int)
Line
Count
Source
337
2
getSymbol(typename ELFT::SymRange Symbols, uint32_t Index) {
338
2
  if (Index >= Symbols.size())
339
0
    return createError("invalid symbol index");
340
2
  return &Symbols[Index];
341
2
}
Unexecuted instantiation: llvm::Expected<llvm::object::ELFType<(llvm::support::endianness)0, false>::Sym const*> llvm::object::getSymbol<llvm::object::ELFType<(llvm::support::endianness)0, false> >(llvm::object::ELFType<(llvm::support::endianness)0, false>::SymRange, unsigned int)
llvm::Expected<llvm::object::ELFType<(llvm::support::endianness)1, true>::Sym const*> llvm::object::getSymbol<llvm::object::ELFType<(llvm::support::endianness)1, true> >(llvm::object::ELFType<(llvm::support::endianness)1, true>::SymRange, unsigned int)
Line
Count
Source
337
75
getSymbol(typename ELFT::SymRange Symbols, uint32_t Index) {
338
75
  if (Index >= Symbols.size())
339
0
    return createError("invalid symbol index");
340
75
  return &Symbols[Index];
341
75
}
Unexecuted instantiation: llvm::Expected<llvm::object::ELFType<(llvm::support::endianness)0, true>::Sym const*> llvm::object::getSymbol<llvm::object::ELFType<(llvm::support::endianness)0, true> >(llvm::object::ELFType<(llvm::support::endianness)0, true>::SymRange, unsigned int)
342
343
template <class ELFT>
344
Expected<const typename ELFT::Sym *>
345
5
ELFFile<ELFT>::getSymbol(const Elf_Shdr *Sec, uint32_t Index) const {
346
5
  auto SymtabOrErr = symbols(Sec);
347
5
  if (!SymtabOrErr)
348
0
    return SymtabOrErr.takeError();
349
5
  return object::getSymbol<ELFT>(*SymtabOrErr, Index);
350
5
}
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbol(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*, unsigned int) const
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbol(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*, unsigned int) const
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbol(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*, unsigned int) const
Line
Count
Source
345
5
ELFFile<ELFT>::getSymbol(const Elf_Shdr *Sec, uint32_t Index) const {
346
5
  auto SymtabOrErr = symbols(Sec);
347
5
  if (!SymtabOrErr)
348
0
    return SymtabOrErr.takeError();
349
5
  return object::getSymbol<ELFT>(*SymtabOrErr, Index);
350
5
}
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbol(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*, unsigned int) const
351
352
template <class ELFT>
353
template <typename T>
354
Expected<ArrayRef<T>>
355
1.43M
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
1.43M
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 11.34M
)
357
1
    return createError("invalid sh_entsize");
358
1.43M
359
1.43M
  uintX_t Offset = Sec->sh_offset;
360
1.43M
  uintX_t Size = Sec->sh_size;
361
1.43M
362
1.43M
  if (Size % sizeof(T))
363
1
    return createError("size is not a multiple of sh_entsize");
364
1.43M
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
1.43M
      
Offset + Size > Buf.size()1.43M
)
366
5
    return createError("invalid section offset");
367
1.43M
368
1.43M
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
1.43M
371
1.43M
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
1.43M
  return makeArrayRef(Start, Size / sizeof(T));
373
1.43M
}
llvm::Expected<llvm::ArrayRef<char> > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionContentsAsArray<char>(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*) const
Line
Count
Source
355
25.3k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
25.3k
  if (Sec->sh_entsize != sizeof(T) && sizeof(T) != 1)
357
0
    return createError("invalid sh_entsize");
358
25.3k
359
25.3k
  uintX_t Offset = Sec->sh_offset;
360
25.3k
  uintX_t Size = Sec->sh_size;
361
25.3k
362
25.3k
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
25.3k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
25.3k
      
Offset + Size > Buf.size()25.3k
)
366
1
    return createError("invalid section offset");
367
25.3k
368
25.3k
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
25.3k
371
25.3k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
25.3k
  return makeArrayRef(Start, Size / sizeof(T));
373
25.3k
}
llvm::Expected<llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)1, 1ul> > > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionContentsAsArray<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)1, 1ul> >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*) const
Line
Count
Source
355
9
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
9
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
9
359
9
  uintX_t Offset = Sec->sh_offset;
360
9
  uintX_t Size = Sec->sh_size;
361
9
362
9
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
9
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
9
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
9
368
9
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
9
371
9
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
9
  return makeArrayRef(Start, Size / sizeof(T));
373
9
}
llvm::Expected<llvm::ArrayRef<llvm::object::Elf_Dyn_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > > > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionContentsAsArray<llvm::object::Elf_Dyn_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*) const
Line
Count
Source
355
58
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
58
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
58
359
58
  uintX_t Offset = Sec->sh_offset;
360
58
  uintX_t Size = Sec->sh_size;
361
58
362
58
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
58
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
58
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
58
368
58
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
58
371
58
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
58
  return makeArrayRef(Start, Size / sizeof(T));
373
58
}
llvm::Expected<llvm::ArrayRef<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > > > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionContentsAsArray<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*) const
Line
Count
Source
355
20.2k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
20.2k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
20.2k
359
20.2k
  uintX_t Offset = Sec->sh_offset;
360
20.2k
  uintX_t Size = Sec->sh_size;
361
20.2k
362
20.2k
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
20.2k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
20.2k
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
20.2k
368
20.2k
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
20.2k
371
20.2k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
20.2k
  return makeArrayRef(Start, Size / sizeof(T));
373
20.2k
}
llvm::Expected<llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, true> > > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionContentsAsArray<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, true> >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*) const
Line
Count
Source
355
5
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
5
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
5
359
5
  uintX_t Offset = Sec->sh_offset;
360
5
  uintX_t Size = Sec->sh_size;
361
5
362
5
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
5
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
5
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
5
368
5
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
5
371
5
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
5
  return makeArrayRef(Start, Size / sizeof(T));
373
5
}
llvm::Expected<llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, false> > > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionContentsAsArray<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, false> >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*) const
Line
Count
Source
355
488
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
488
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
488
359
488
  uintX_t Offset = Sec->sh_offset;
360
488
  uintX_t Size = Sec->sh_size;
361
488
362
488
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
488
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
488
      Offset + Size > Buf.size())
366
1
    return createError("invalid section offset");
367
487
368
487
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
487
371
487
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
487
  return makeArrayRef(Start, Size / sizeof(T));
373
487
}
llvm::Expected<llvm::ArrayRef<unsigned char> > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionContentsAsArray<unsigned char>(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*) const
Line
Count
Source
355
1.97k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
1.97k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 11.96k
)
357
0
    return createError("invalid sh_entsize");
358
1.97k
359
1.97k
  uintX_t Offset = Sec->sh_offset;
360
1.97k
  uintX_t Size = Sec->sh_size;
361
1.97k
362
1.97k
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
1.97k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
1.97k
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
1.97k
368
1.97k
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
1.97k
371
1.97k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
1.97k
  return makeArrayRef(Start, Size / sizeof(T));
373
1.97k
}
llvm::Expected<llvm::ArrayRef<char> > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionContentsAsArray<char>(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*) const
Line
Count
Source
355
4.28k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
4.28k
  if (Sec->sh_entsize != sizeof(T) && sizeof(T) != 1)
357
0
    return createError("invalid sh_entsize");
358
4.28k
359
4.28k
  uintX_t Offset = Sec->sh_offset;
360
4.28k
  uintX_t Size = Sec->sh_size;
361
4.28k
362
4.28k
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
4.28k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
4.28k
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
4.28k
368
4.28k
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
4.28k
371
4.28k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
4.28k
  return makeArrayRef(Start, Size / sizeof(T));
373
4.28k
}
Unexecuted instantiation: llvm::Expected<llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)0, 1ul> > > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionContentsAsArray<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)0, 1ul> >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*) const
llvm::Expected<llvm::ArrayRef<llvm::object::Elf_Dyn_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > > > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionContentsAsArray<llvm::object::Elf_Dyn_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*) const
Line
Count
Source
355
24
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
24
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
24
359
24
  uintX_t Offset = Sec->sh_offset;
360
24
  uintX_t Size = Sec->sh_size;
361
24
362
24
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
24
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
24
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
24
368
24
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
24
371
24
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
24
  return makeArrayRef(Start, Size / sizeof(T));
373
24
}
llvm::Expected<llvm::ArrayRef<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > > > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionContentsAsArray<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*) const
Line
Count
Source
355
2.57k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
2.57k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
2.57k
359
2.57k
  uintX_t Offset = Sec->sh_offset;
360
2.57k
  uintX_t Size = Sec->sh_size;
361
2.57k
362
2.57k
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
2.57k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
2.57k
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
2.57k
368
2.57k
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
2.57k
371
2.57k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
2.57k
  return makeArrayRef(Start, Size / sizeof(T));
373
2.57k
}
llvm::Expected<llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, true> > > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionContentsAsArray<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, true> >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*) const
Line
Count
Source
355
28
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
28
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
28
359
28
  uintX_t Offset = Sec->sh_offset;
360
28
  uintX_t Size = Sec->sh_size;
361
28
362
28
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
28
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
28
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
28
368
28
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
28
371
28
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
28
  return makeArrayRef(Start, Size / sizeof(T));
373
28
}
llvm::Expected<llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, false> > > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionContentsAsArray<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, false> >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*) const
Line
Count
Source
355
102
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
102
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
102
359
102
  uintX_t Offset = Sec->sh_offset;
360
102
  uintX_t Size = Sec->sh_size;
361
102
362
102
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
102
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
102
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
102
368
102
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
102
371
102
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
102
  return makeArrayRef(Start, Size / sizeof(T));
373
102
}
llvm::Expected<llvm::ArrayRef<unsigned char> > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionContentsAsArray<unsigned char>(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*) const
Line
Count
Source
355
1.01k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
1.01k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 11.00k
)
357
0
    return createError("invalid sh_entsize");
358
1.01k
359
1.01k
  uintX_t Offset = Sec->sh_offset;
360
1.01k
  uintX_t Size = Sec->sh_size;
361
1.01k
362
1.01k
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
1.01k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
1.01k
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
1.01k
368
1.01k
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
1.01k
371
1.01k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
1.01k
  return makeArrayRef(Start, Size / sizeof(T));
373
1.01k
}
llvm::Expected<llvm::ArrayRef<char> > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionContentsAsArray<char>(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*) const
Line
Count
Source
355
977k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
977k
  if (Sec->sh_entsize != sizeof(T) && sizeof(T) != 1)
357
0
    return createError("invalid sh_entsize");
358
977k
359
977k
  uintX_t Offset = Sec->sh_offset;
360
977k
  uintX_t Size = Sec->sh_size;
361
977k
362
977k
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
977k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
977k
      Offset + Size > Buf.size())
366
1
    return createError("invalid section offset");
367
977k
368
977k
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
977k
371
977k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
977k
  return makeArrayRef(Start, Size / sizeof(T));
373
977k
}
llvm::Expected<llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)1, 1ul> > > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionContentsAsArray<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)1, 1ul> >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*) const
Line
Count
Source
355
136
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
136
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
136
359
136
  uintX_t Offset = Sec->sh_offset;
360
136
  uintX_t Size = Sec->sh_size;
361
136
362
136
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
136
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
136
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
136
368
136
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
136
371
136
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
136
  return makeArrayRef(Start, Size / sizeof(T));
373
136
}
llvm::Expected<llvm::ArrayRef<llvm::object::Elf_Dyn_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > > > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionContentsAsArray<llvm::object::Elf_Dyn_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*) const
Line
Count
Source
355
240
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
240
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
240
359
240
  uintX_t Offset = Sec->sh_offset;
360
240
  uintX_t Size = Sec->sh_size;
361
240
362
240
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
240
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
240
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
240
368
240
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
240
371
240
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
240
  return makeArrayRef(Start, Size / sizeof(T));
373
240
}
llvm::Expected<llvm::ArrayRef<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > > > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionContentsAsArray<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*) const
Line
Count
Source
355
62.5k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
62.5k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
1
    return createError("invalid sh_entsize");
358
62.5k
359
62.5k
  uintX_t Offset = Sec->sh_offset;
360
62.5k
  uintX_t Size = Sec->sh_size;
361
62.5k
362
62.5k
  if (Size % sizeof(T))
363
1
    return createError("size is not a multiple of sh_entsize");
364
62.5k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
62.5k
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
62.5k
368
62.5k
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
62.5k
371
62.5k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
62.5k
  return makeArrayRef(Start, Size / sizeof(T));
373
62.5k
}
llvm::Expected<llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, true> > > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionContentsAsArray<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, true> >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*) const
Line
Count
Source
355
1.46k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
1.46k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
1.46k
359
1.46k
  uintX_t Offset = Sec->sh_offset;
360
1.46k
  uintX_t Size = Sec->sh_size;
361
1.46k
362
1.46k
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
1.46k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
1.46k
      Offset + Size > Buf.size())
366
1
    return createError("invalid section offset");
367
1.46k
368
1.46k
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
1.46k
371
1.46k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
1.46k
  return makeArrayRef(Start, Size / sizeof(T));
373
1.46k
}
llvm::Expected<llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, false> > > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionContentsAsArray<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, false> >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*) const
Line
Count
Source
355
22
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
22
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
22
359
22
  uintX_t Offset = Sec->sh_offset;
360
22
  uintX_t Size = Sec->sh_size;
361
22
362
22
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
22
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
22
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
22
368
22
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
22
371
22
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
22
  return makeArrayRef(Start, Size / sizeof(T));
373
22
}
llvm::Expected<llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned long long, (llvm::support::endianness)1, 1ul> > > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionContentsAsArray<llvm::support::detail::packed_endian_specific_integral<unsigned long long, (llvm::support::endianness)1, 1ul> >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*) const
Line
Count
Source
355
6
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
6
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
6
359
6
  uintX_t Offset = Sec->sh_offset;
360
6
  uintX_t Size = Sec->sh_size;
361
6
362
6
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
6
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
6
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
6
368
6
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
6
371
6
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
6
  return makeArrayRef(Start, Size / sizeof(T));
373
6
}
llvm::Expected<llvm::ArrayRef<unsigned char> > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionContentsAsArray<unsigned char>(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*) const
Line
Count
Source
355
335k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
335k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 1335k
)
357
0
    return createError("invalid sh_entsize");
358
335k
359
335k
  uintX_t Offset = Sec->sh_offset;
360
335k
  uintX_t Size = Sec->sh_size;
361
335k
362
335k
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
335k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
335k
      Offset + Size > Buf.size())
366
1
    return createError("invalid section offset");
367
335k
368
335k
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
335k
371
335k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
335k
  return makeArrayRef(Start, Size / sizeof(T));
373
335k
}
llvm::Expected<llvm::ArrayRef<char> > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionContentsAsArray<char>(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*) const
Line
Count
Source
355
3.55k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
3.55k
  if (Sec->sh_entsize != sizeof(T) && sizeof(T) != 1)
357
0
    return createError("invalid sh_entsize");
358
3.55k
359
3.55k
  uintX_t Offset = Sec->sh_offset;
360
3.55k
  uintX_t Size = Sec->sh_size;
361
3.55k
362
3.55k
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
3.55k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
3.55k
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
3.55k
368
3.55k
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
3.55k
371
3.55k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
3.55k
  return makeArrayRef(Start, Size / sizeof(T));
373
3.55k
}
llvm::Expected<llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)0, 1ul> > > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionContentsAsArray<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)0, 1ul> >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*) const
Line
Count
Source
355
1
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
1
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
1
359
1
  uintX_t Offset = Sec->sh_offset;
360
1
  uintX_t Size = Sec->sh_size;
361
1
362
1
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
1
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
1
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
1
368
1
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
1
371
1
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
1
  return makeArrayRef(Start, Size / sizeof(T));
373
1
}
llvm::Expected<llvm::ArrayRef<llvm::object::Elf_Dyn_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > > > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionContentsAsArray<llvm::object::Elf_Dyn_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*) const
Line
Count
Source
355
17
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
17
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
17
359
17
  uintX_t Offset = Sec->sh_offset;
360
17
  uintX_t Size = Sec->sh_size;
361
17
362
17
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
17
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
17
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
17
368
17
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
17
371
17
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
17
  return makeArrayRef(Start, Size / sizeof(T));
373
17
}
llvm::Expected<llvm::ArrayRef<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > > > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionContentsAsArray<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*) const
Line
Count
Source
355
1.84k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
1.84k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
1.84k
359
1.84k
  uintX_t Offset = Sec->sh_offset;
360
1.84k
  uintX_t Size = Sec->sh_size;
361
1.84k
362
1.84k
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
1.84k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
1.84k
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
1.84k
368
1.84k
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
1.84k
371
1.84k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
1.84k
  return makeArrayRef(Start, Size / sizeof(T));
373
1.84k
}
llvm::Expected<llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, true> > > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionContentsAsArray<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, true> >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*) const
Line
Count
Source
355
178
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
178
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
178
359
178
  uintX_t Offset = Sec->sh_offset;
360
178
  uintX_t Size = Sec->sh_size;
361
178
362
178
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
178
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
178
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
178
368
178
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
178
371
178
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
178
  return makeArrayRef(Start, Size / sizeof(T));
373
178
}
llvm::Expected<llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, false> > > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionContentsAsArray<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, false> >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*) const
Line
Count
Source
355
8
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
8
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
8
359
8
  uintX_t Offset = Sec->sh_offset;
360
8
  uintX_t Size = Sec->sh_size;
361
8
362
8
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
8
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
8
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
8
368
8
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
8
371
8
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
8
  return makeArrayRef(Start, Size / sizeof(T));
373
8
}
Unexecuted instantiation: llvm::Expected<llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned long long, (llvm::support::endianness)0, 1ul> > > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionContentsAsArray<llvm::support::detail::packed_endian_specific_integral<unsigned long long, (llvm::support::endianness)0, 1ul> >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*) const
llvm::Expected<llvm::ArrayRef<unsigned char> > llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionContentsAsArray<unsigned char>(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*) const
Line
Count
Source
355
474
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
474
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 1416
)
357
0
    return createError("invalid sh_entsize");
358
474
359
474
  uintX_t Offset = Sec->sh_offset;
360
474
  uintX_t Size = Sec->sh_size;
361
474
362
474
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
474
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
474
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
474
368
474
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
474
371
474
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
474
  return makeArrayRef(Start, Size / sizeof(T));
373
474
}
374
375
template <class ELFT>
376
Expected<ArrayRef<uint8_t>>
377
338k
ELFFile<ELFT>::getSectionContents(const Elf_Shdr *Sec) const {
378
338k
  return getSectionContentsAsArray<uint8_t>(Sec);
379
338k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionContents(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*) const
Line
Count
Source
377
1.97k
ELFFile<ELFT>::getSectionContents(const Elf_Shdr *Sec) const {
378
1.97k
  return getSectionContentsAsArray<uint8_t>(Sec);
379
1.97k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionContents(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*) const
Line
Count
Source
377
1.01k
ELFFile<ELFT>::getSectionContents(const Elf_Shdr *Sec) const {
378
1.01k
  return getSectionContentsAsArray<uint8_t>(Sec);
379
1.01k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionContents(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*) const
Line
Count
Source
377
335k
ELFFile<ELFT>::getSectionContents(const Elf_Shdr *Sec) const {
378
335k
  return getSectionContentsAsArray<uint8_t>(Sec);
379
335k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionContents(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*) const
Line
Count
Source
377
474
ELFFile<ELFT>::getSectionContents(const Elf_Shdr *Sec) const {
378
474
  return getSectionContentsAsArray<uint8_t>(Sec);
379
474
}
380
381
template <class ELFT>
382
5.00k
StringRef ELFFile<ELFT>::getRelocationTypeName(uint32_t Type) const {
383
5.00k
  return getELFRelocationTypeName(getHeader()->e_machine, Type);
384
5.00k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationTypeName(unsigned int) const
Line
Count
Source
382
1.27k
StringRef ELFFile<ELFT>::getRelocationTypeName(uint32_t Type) const {
383
1.27k
  return getELFRelocationTypeName(getHeader()->e_machine, Type);
384
1.27k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationTypeName(unsigned int) const
Line
Count
Source
382
329
StringRef ELFFile<ELFT>::getRelocationTypeName(uint32_t Type) const {
383
329
  return getELFRelocationTypeName(getHeader()->e_machine, Type);
384
329
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationTypeName(unsigned int) const
Line
Count
Source
382
2.36k
StringRef ELFFile<ELFT>::getRelocationTypeName(uint32_t Type) const {
383
2.36k
  return getELFRelocationTypeName(getHeader()->e_machine, Type);
384
2.36k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationTypeName(unsigned int) const
Line
Count
Source
382
1.03k
StringRef ELFFile<ELFT>::getRelocationTypeName(uint32_t Type) const {
383
1.03k
  return getELFRelocationTypeName(getHeader()->e_machine, Type);
384
1.03k
}
385
386
template <class ELFT>
387
void ELFFile<ELFT>::getRelocationTypeName(uint32_t Type,
388
4.61k
                                          SmallVectorImpl<char> &Result) const {
389
4.61k
  if (!isMipsELF64()) {
390
4.41k
    StringRef Name = getRelocationTypeName(Type);
391
4.41k
    Result.append(Name.begin(), Name.end());
392
4.41k
  } else {
393
195
    // The Mips N64 ABI allows up to three operations to be specified per
394
195
    // relocation record. Unfortunately there's no easy way to test for the
395
195
    // presence of N64 ELFs as they have no special flag that identifies them
396
195
    // as being N64. We can safely assume at the moment that all Mips
397
195
    // ELFCLASS64 ELFs are N64. New Mips64 ABIs should provide enough
398
195
    // information to disambiguate between old vs new ABIs.
399
195
    uint8_t Type1 = (Type >> 0) & 0xFF;
400
195
    uint8_t Type2 = (Type >> 8) & 0xFF;
401
195
    uint8_t Type3 = (Type >> 16) & 0xFF;
402
195
403
195
    // Concat all three relocation type names.
404
195
    StringRef Name = getRelocationTypeName(Type1);
405
195
    Result.append(Name.begin(), Name.end());
406
195
407
195
    Name = getRelocationTypeName(Type2);
408
195
    Result.append(1, '/');
409
195
    Result.append(Name.begin(), Name.end());
410
195
411
195
    Name = getRelocationTypeName(Type3);
412
195
    Result.append(1, '/');
413
195
    Result.append(Name.begin(), Name.end());
414
195
  }
415
4.61k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationTypeName(unsigned int, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
388
1.27k
                                          SmallVectorImpl<char> &Result) const {
389
1.27k
  if (!isMipsELF64()) {
390
1.27k
    StringRef Name = getRelocationTypeName(Type);
391
1.27k
    Result.append(Name.begin(), Name.end());
392
1.27k
  } else {
393
0
    // The Mips N64 ABI allows up to three operations to be specified per
394
0
    // relocation record. Unfortunately there's no easy way to test for the
395
0
    // presence of N64 ELFs as they have no special flag that identifies them
396
0
    // as being N64. We can safely assume at the moment that all Mips
397
0
    // ELFCLASS64 ELFs are N64. New Mips64 ABIs should provide enough
398
0
    // information to disambiguate between old vs new ABIs.
399
0
    uint8_t Type1 = (Type >> 0) & 0xFF;
400
0
    uint8_t Type2 = (Type >> 8) & 0xFF;
401
0
    uint8_t Type3 = (Type >> 16) & 0xFF;
402
0
403
0
    // Concat all three relocation type names.
404
0
    StringRef Name = getRelocationTypeName(Type1);
405
0
    Result.append(Name.begin(), Name.end());
406
0
407
0
    Name = getRelocationTypeName(Type2);
408
0
    Result.append(1, '/');
409
0
    Result.append(Name.begin(), Name.end());
410
0
411
0
    Name = getRelocationTypeName(Type3);
412
0
    Result.append(1, '/');
413
0
    Result.append(Name.begin(), Name.end());
414
0
  }
415
1.27k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationTypeName(unsigned int, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
388
329
                                          SmallVectorImpl<char> &Result) const {
389
329
  if (!isMipsELF64()) {
390
329
    StringRef Name = getRelocationTypeName(Type);
391
329
    Result.append(Name.begin(), Name.end());
392
329
  } else {
393
0
    // The Mips N64 ABI allows up to three operations to be specified per
394
0
    // relocation record. Unfortunately there's no easy way to test for the
395
0
    // presence of N64 ELFs as they have no special flag that identifies them
396
0
    // as being N64. We can safely assume at the moment that all Mips
397
0
    // ELFCLASS64 ELFs are N64. New Mips64 ABIs should provide enough
398
0
    // information to disambiguate between old vs new ABIs.
399
0
    uint8_t Type1 = (Type >> 0) & 0xFF;
400
0
    uint8_t Type2 = (Type >> 8) & 0xFF;
401
0
    uint8_t Type3 = (Type >> 16) & 0xFF;
402
0
403
0
    // Concat all three relocation type names.
404
0
    StringRef Name = getRelocationTypeName(Type1);
405
0
    Result.append(Name.begin(), Name.end());
406
0
407
0
    Name = getRelocationTypeName(Type2);
408
0
    Result.append(1, '/');
409
0
    Result.append(Name.begin(), Name.end());
410
0
411
0
    Name = getRelocationTypeName(Type3);
412
0
    Result.append(1, '/');
413
0
    Result.append(Name.begin(), Name.end());
414
0
  }
415
329
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationTypeName(unsigned int, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
388
2.18k
                                          SmallVectorImpl<char> &Result) const {
389
2.18k
  if (!isMipsELF64()) {
390
2.09k
    StringRef Name = getRelocationTypeName(Type);
391
2.09k
    Result.append(Name.begin(), Name.end());
392
2.09k
  } else {
393
92
    // The Mips N64 ABI allows up to three operations to be specified per
394
92
    // relocation record. Unfortunately there's no easy way to test for the
395
92
    // presence of N64 ELFs as they have no special flag that identifies them
396
92
    // as being N64. We can safely assume at the moment that all Mips
397
92
    // ELFCLASS64 ELFs are N64. New Mips64 ABIs should provide enough
398
92
    // information to disambiguate between old vs new ABIs.
399
92
    uint8_t Type1 = (Type >> 0) & 0xFF;
400
92
    uint8_t Type2 = (Type >> 8) & 0xFF;
401
92
    uint8_t Type3 = (Type >> 16) & 0xFF;
402
92
403
92
    // Concat all three relocation type names.
404
92
    StringRef Name = getRelocationTypeName(Type1);
405
92
    Result.append(Name.begin(), Name.end());
406
92
407
92
    Name = getRelocationTypeName(Type2);
408
92
    Result.append(1, '/');
409
92
    Result.append(Name.begin(), Name.end());
410
92
411
92
    Name = getRelocationTypeName(Type3);
412
92
    Result.append(1, '/');
413
92
    Result.append(Name.begin(), Name.end());
414
92
  }
415
2.18k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationTypeName(unsigned int, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
388
824
                                          SmallVectorImpl<char> &Result) const {
389
824
  if (!isMipsELF64()) {
390
721
    StringRef Name = getRelocationTypeName(Type);
391
721
    Result.append(Name.begin(), Name.end());
392
721
  } else {
393
103
    // The Mips N64 ABI allows up to three operations to be specified per
394
103
    // relocation record. Unfortunately there's no easy way to test for the
395
103
    // presence of N64 ELFs as they have no special flag that identifies them
396
103
    // as being N64. We can safely assume at the moment that all Mips
397
103
    // ELFCLASS64 ELFs are N64. New Mips64 ABIs should provide enough
398
103
    // information to disambiguate between old vs new ABIs.
399
103
    uint8_t Type1 = (Type >> 0) & 0xFF;
400
103
    uint8_t Type2 = (Type >> 8) & 0xFF;
401
103
    uint8_t Type3 = (Type >> 16) & 0xFF;
402
103
403
103
    // Concat all three relocation type names.
404
103
    StringRef Name = getRelocationTypeName(Type1);
405
103
    Result.append(Name.begin(), Name.end());
406
103
407
103
    Name = getRelocationTypeName(Type2);
408
103
    Result.append(1, '/');
409
103
    Result.append(Name.begin(), Name.end());
410
103
411
103
    Name = getRelocationTypeName(Type3);
412
103
    Result.append(1, '/');
413
103
    Result.append(Name.begin(), Name.end());
414
103
  }
415
824
}
416
417
template <class ELFT>
418
7
uint32_t ELFFile<ELFT>::getRelrRelocationType() const {
419
7
  return getELFRelrRelocationType(getHeader()->e_machine);
420
7
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelrRelocationType() const
Line
Count
Source
418
4
uint32_t ELFFile<ELFT>::getRelrRelocationType() const {
419
4
  return getELFRelrRelocationType(getHeader()->e_machine);
420
4
}
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelrRelocationType() const
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelrRelocationType() const
Line
Count
Source
418
3
uint32_t ELFFile<ELFT>::getRelrRelocationType() const {
419
3
  return getELFRelrRelocationType(getHeader()->e_machine);
420
3
}
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelrRelocationType() const
421
422
template <class ELFT>
423
Expected<const typename ELFT::Sym *>
424
ELFFile<ELFT>::getRelocationSymbol(const Elf_Rel *Rel,
425
3.79k
                                   const Elf_Shdr *SymTab) const {
426
3.79k
  uint32_t Index = Rel->getSymbol(isMips64EL());
427
3.79k
  if (Index == 0)
428
578
    return nullptr;
429
3.21k
  return getEntry<Elf_Sym>(SymTab, Index);
430
3.21k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationSymbol(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, false> const*, llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*) const
Line
Count
Source
425
1.01k
                                   const Elf_Shdr *SymTab) const {
426
1.01k
  uint32_t Index = Rel->getSymbol(isMips64EL());
427
1.01k
  if (Index == 0)
428
190
    return nullptr;
429
827
  return getEntry<Elf_Sym>(SymTab, Index);
430
827
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationSymbol(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, false> const*, llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*) const
Line
Count
Source
425
266
                                   const Elf_Shdr *SymTab) const {
426
266
  uint32_t Index = Rel->getSymbol(isMips64EL());
427
266
  if (Index == 0)
428
81
    return nullptr;
429
185
  return getEntry<Elf_Sym>(SymTab, Index);
430
185
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationSymbol(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, false> const*, llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*) const
Line
Count
Source
425
1.73k
                                   const Elf_Shdr *SymTab) const {
426
1.73k
  uint32_t Index = Rel->getSymbol(isMips64EL());
427
1.73k
  if (Index == 0)
428
213
    return nullptr;
429
1.52k
  return getEntry<Elf_Sym>(SymTab, Index);
430
1.52k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationSymbol(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, false> const*, llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*) const
Line
Count
Source
425
777
                                   const Elf_Shdr *SymTab) const {
426
777
  uint32_t Index = Rel->getSymbol(isMips64EL());
427
777
  if (Index == 0)
428
94
    return nullptr;
429
683
  return getEntry<Elf_Sym>(SymTab, Index);
430
683
}
431
432
template <class ELFT>
433
Expected<StringRef>
434
969k
ELFFile<ELFT>::getSectionStringTable(Elf_Shdr_Range Sections) const {
435
969k
  uint32_t Index = getHeader()->e_shstrndx;
436
969k
  if (Index == ELF::SHN_XINDEX)
437
522k
    Index = Sections[0].sh_link;
438
969k
439
969k
  if (!Index) // no section string table.
440
12
    return "";
441
969k
  if (Index >= Sections.size())
442
0
    return createError("invalid section index");
443
969k
  return getStringTable(&Sections[Index]);
444
969k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionStringTable(llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > >) const
Line
Count
Source
434
9.41k
ELFFile<ELFT>::getSectionStringTable(Elf_Shdr_Range Sections) const {
435
9.41k
  uint32_t Index = getHeader()->e_shstrndx;
436
9.41k
  if (Index == ELF::SHN_XINDEX)
437
0
    Index = Sections[0].sh_link;
438
9.41k
439
9.41k
  if (!Index) // no section string table.
440
4
    return "";
441
9.41k
  if (Index >= Sections.size())
442
0
    return createError("invalid section index");
443
9.41k
  return getStringTable(&Sections[Index]);
444
9.41k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionStringTable(llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > >) const
Line
Count
Source
434
3.09k
ELFFile<ELFT>::getSectionStringTable(Elf_Shdr_Range Sections) const {
435
3.09k
  uint32_t Index = getHeader()->e_shstrndx;
436
3.09k
  if (Index == ELF::SHN_XINDEX)
437
0
    Index = Sections[0].sh_link;
438
3.09k
439
3.09k
  if (!Index) // no section string table.
440
0
    return "";
441
3.09k
  if (Index >= Sections.size())
442
0
    return createError("invalid section index");
443
3.09k
  return getStringTable(&Sections[Index]);
444
3.09k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionStringTable(llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > >) const
Line
Count
Source
434
955k
ELFFile<ELFT>::getSectionStringTable(Elf_Shdr_Range Sections) const {
435
955k
  uint32_t Index = getHeader()->e_shstrndx;
436
955k
  if (Index == ELF::SHN_XINDEX)
437
522k
    Index = Sections[0].sh_link;
438
955k
439
955k
  if (!Index) // no section string table.
440
8
    return "";
441
955k
  if (Index >= Sections.size())
442
0
    return createError("invalid section index");
443
955k
  return getStringTable(&Sections[Index]);
444
955k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionStringTable(llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > >) const
Line
Count
Source
434
2.35k
ELFFile<ELFT>::getSectionStringTable(Elf_Shdr_Range Sections) const {
435
2.35k
  uint32_t Index = getHeader()->e_shstrndx;
436
2.35k
  if (Index == ELF::SHN_XINDEX)
437
0
    Index = Sections[0].sh_link;
438
2.35k
439
2.35k
  if (!Index) // no section string table.
440
0
    return "";
441
2.35k
  if (Index >= Sections.size())
442
0
    return createError("invalid section index");
443
2.35k
  return getStringTable(&Sections[Index]);
444
2.35k
}
445
446
784k
template <class ELFT> ELFFile<ELFT>::ELFFile(StringRef Object) : Buf(Object) {}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::ELFFile(llvm::StringRef)
Line
Count
Source
446
8.40k
template <class ELFT> ELFFile<ELFT>::ELFFile(StringRef Object) : Buf(Object) {}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::ELFFile(llvm::StringRef)
Line
Count
Source
446
4.11k
template <class ELFT> ELFFile<ELFT>::ELFFile(StringRef Object) : Buf(Object) {}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::ELFFile(llvm::StringRef)
Line
Count
Source
446
759k
template <class ELFT> ELFFile<ELFT>::ELFFile(StringRef Object) : Buf(Object) {}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::ELFFile(llvm::StringRef)
Line
Count
Source
446
12.3k
template <class ELFT> ELFFile<ELFT>::ELFFile(StringRef Object) : Buf(Object) {}
447
448
template <class ELFT>
449
784k
Expected<ELFFile<ELFT>> ELFFile<ELFT>::create(StringRef Object) {
450
784k
  if (sizeof(Elf_Ehdr) > Object.size())
451
1
    return createError("Invalid buffer");
452
784k
  return ELFFile(Object);
453
784k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::create(llvm::StringRef)
Line
Count
Source
449
8.41k
Expected<ELFFile<ELFT>> ELFFile<ELFT>::create(StringRef Object) {
450
8.41k
  if (sizeof(Elf_Ehdr) > Object.size())
451
1
    return createError("Invalid buffer");
452
8.40k
  return ELFFile(Object);
453
8.40k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::create(llvm::StringRef)
Line
Count
Source
449
4.11k
Expected<ELFFile<ELFT>> ELFFile<ELFT>::create(StringRef Object) {
450
4.11k
  if (sizeof(Elf_Ehdr) > Object.size())
451
0
    return createError("Invalid buffer");
452
4.11k
  return ELFFile(Object);
453
4.11k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::create(llvm::StringRef)
Line
Count
Source
449
759k
Expected<ELFFile<ELFT>> ELFFile<ELFT>::create(StringRef Object) {
450
759k
  if (sizeof(Elf_Ehdr) > Object.size())
451
0
    return createError("Invalid buffer");
452
759k
  return ELFFile(Object);
453
759k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::create(llvm::StringRef)
Line
Count
Source
449
12.3k
Expected<ELFFile<ELFT>> ELFFile<ELFT>::create(StringRef Object) {
450
12.3k
  if (sizeof(Elf_Ehdr) > Object.size())
451
0
    return createError("Invalid buffer");
452
12.3k
  return ELFFile(Object);
453
12.3k
}
454
455
template <class ELFT>
456
1.48M
Expected<typename ELFT::ShdrRange> ELFFile<ELFT>::sections() const {
457
1.48M
  const uintX_t SectionTableOffset = getHeader()->e_shoff;
458
1.48M
  if (SectionTableOffset == 0)
459
26
    return ArrayRef<Elf_Shdr>();
460
1.48M
461
1.48M
  if (getHeader()->e_shentsize != sizeof(Elf_Shdr))
462
1
    return createError(
463
1
        "invalid section header entry size (e_shentsize) in ELF header");
464
1.48M
465
1.48M
  const uint64_t FileSize = Buf.size();
466
1.48M
467
1.48M
  if (SectionTableOffset + sizeof(Elf_Shdr) > FileSize)
468
1
    return createError("section header table goes past the end of the file");
469
1.48M
470
1.48M
  // Invalid address alignment of section headers
471
1.48M
  if (SectionTableOffset & (alignof(Elf_Shdr) - 1))
472
0
    return createError("invalid alignment of section headers");
473
1.48M
474
1.48M
  const Elf_Shdr *First =
475
1.48M
      reinterpret_cast<const Elf_Shdr *>(base() + SectionTableOffset);
476
1.48M
477
1.48M
  uintX_t NumSections = getHeader()->e_shnum;
478
1.48M
  if (NumSections == 0)
479
849k
    NumSections = First->sh_size;
480
1.48M
481
1.48M
  if (NumSections > UINT64_MAX / sizeof(Elf_Shdr))
482
1
    return createError("section table goes past the end of file");
483
1.48M
484
1.48M
  const uint64_t SectionTableSize = NumSections * sizeof(Elf_Shdr);
485
1.48M
486
1.48M
  // Section table goes past end of file!
487
1.48M
  if (SectionTableOffset + SectionTableSize > FileSize)
488
0
    return createError("section table goes past the end of file");
489
1.48M
490
1.48M
  return makeArrayRef(First, NumSections);
491
1.48M
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::sections() const
Line
Count
Source
456
149k
Expected<typename ELFT::ShdrRange> ELFFile<ELFT>::sections() const {
457
149k
  const uintX_t SectionTableOffset = getHeader()->e_shoff;
458
149k
  if (SectionTableOffset == 0)
459
0
    return ArrayRef<Elf_Shdr>();
460
149k
461
149k
  if (getHeader()->e_shentsize != sizeof(Elf_Shdr))
462
0
    return createError(
463
0
        "invalid section header entry size (e_shentsize) in ELF header");
464
149k
465
149k
  const uint64_t FileSize = Buf.size();
466
149k
467
149k
  if (SectionTableOffset + sizeof(Elf_Shdr) > FileSize)
468
0
    return createError("section header table goes past the end of the file");
469
149k
470
149k
  // Invalid address alignment of section headers
471
149k
  if (SectionTableOffset & (alignof(Elf_Shdr) - 1))
472
0
    return createError("invalid alignment of section headers");
473
149k
474
149k
  const Elf_Shdr *First =
475
149k
      reinterpret_cast<const Elf_Shdr *>(base() + SectionTableOffset);
476
149k
477
149k
  uintX_t NumSections = getHeader()->e_shnum;
478
149k
  if (NumSections == 0)
479
0
    NumSections = First->sh_size;
480
149k
481
149k
  if (NumSections > UINT64_MAX / sizeof(Elf_Shdr))
482
0
    return createError("section table goes past the end of file");
483
149k
484
149k
  const uint64_t SectionTableSize = NumSections * sizeof(Elf_Shdr);
485
149k
486
149k
  // Section table goes past end of file!
487
149k
  if (SectionTableOffset + SectionTableSize > FileSize)
488
0
    return createError("section table goes past the end of file");
489
149k
490
149k
  return makeArrayRef(First, NumSections);
491
149k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::sections() const
Line
Count
Source
456
19.7k
Expected<typename ELFT::ShdrRange> ELFFile<ELFT>::sections() const {
457
19.7k
  const uintX_t SectionTableOffset = getHeader()->e_shoff;
458
19.7k
  if (SectionTableOffset == 0)
459
0
    return ArrayRef<Elf_Shdr>();
460
19.7k
461
19.7k
  if (getHeader()->e_shentsize != sizeof(Elf_Shdr))
462
0
    return createError(
463
0
        "invalid section header entry size (e_shentsize) in ELF header");
464
19.7k
465
19.7k
  const uint64_t FileSize = Buf.size();
466
19.7k
467
19.7k
  if (SectionTableOffset + sizeof(Elf_Shdr) > FileSize)
468
0
    return createError("section header table goes past the end of the file");
469
19.7k
470
19.7k
  // Invalid address alignment of section headers
471
19.7k
  if (SectionTableOffset & (alignof(Elf_Shdr) - 1))
472
0
    return createError("invalid alignment of section headers");
473
19.7k
474
19.7k
  const Elf_Shdr *First =
475
19.7k
      reinterpret_cast<const Elf_Shdr *>(base() + SectionTableOffset);
476
19.7k
477
19.7k
  uintX_t NumSections = getHeader()->e_shnum;
478
19.7k
  if (NumSections == 0)
479
0
    NumSections = First->sh_size;
480
19.7k
481
19.7k
  if (NumSections > UINT64_MAX / sizeof(Elf_Shdr))
482
0
    return createError("section table goes past the end of file");
483
19.7k
484
19.7k
  const uint64_t SectionTableSize = NumSections * sizeof(Elf_Shdr);
485
19.7k
486
19.7k
  // Section table goes past end of file!
487
19.7k
  if (SectionTableOffset + SectionTableSize > FileSize)
488
0
    return createError("section table goes past the end of file");
489
19.7k
490
19.7k
  return makeArrayRef(First, NumSections);
491
19.7k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::sections() const
Line
Count
Source
456
1.29M
Expected<typename ELFT::ShdrRange> ELFFile<ELFT>::sections() const {
457
1.29M
  const uintX_t SectionTableOffset = getHeader()->e_shoff;
458
1.29M
  if (SectionTableOffset == 0)
459
26
    return ArrayRef<Elf_Shdr>();
460
1.29M
461
1.29M
  if (getHeader()->e_shentsize != sizeof(Elf_Shdr))
462
1
    return createError(
463
1
        "invalid section header entry size (e_shentsize) in ELF header");
464
1.29M
465
1.29M
  const uint64_t FileSize = Buf.size();
466
1.29M
467
1.29M
  if (SectionTableOffset + sizeof(Elf_Shdr) > FileSize)
468
1
    return createError("section header table goes past the end of the file");
469
1.29M
470
1.29M
  // Invalid address alignment of section headers
471
1.29M
  if (SectionTableOffset & (alignof(Elf_Shdr) - 1))
472
0
    return createError("invalid alignment of section headers");
473
1.29M
474
1.29M
  const Elf_Shdr *First =
475
1.29M
      reinterpret_cast<const Elf_Shdr *>(base() + SectionTableOffset);
476
1.29M
477
1.29M
  uintX_t NumSections = getHeader()->e_shnum;
478
1.29M
  if (NumSections == 0)
479
849k
    NumSections = First->sh_size;
480
1.29M
481
1.29M
  if (NumSections > UINT64_MAX / sizeof(Elf_Shdr))
482
1
    return createError("section table goes past the end of file");
483
1.29M
484
1.29M
  const uint64_t SectionTableSize = NumSections * sizeof(Elf_Shdr);
485
1.29M
486
1.29M
  // Section table goes past end of file!
487
1.29M
  if (SectionTableOffset + SectionTableSize > FileSize)
488
0
    return createError("section table goes past the end of file");
489
1.29M
490
1.29M
  return makeArrayRef(First, NumSections);
491
1.29M
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::sections() const
Line
Count
Source
456
14.8k
Expected<typename ELFT::ShdrRange> ELFFile<ELFT>::sections() const {
457
14.8k
  const uintX_t SectionTableOffset = getHeader()->e_shoff;
458
14.8k
  if (SectionTableOffset == 0)
459
0
    return ArrayRef<Elf_Shdr>();
460
14.8k
461
14.8k
  if (getHeader()->e_shentsize != sizeof(Elf_Shdr))
462
0
    return createError(
463
0
        "invalid section header entry size (e_shentsize) in ELF header");
464
14.8k
465
14.8k
  const uint64_t FileSize = Buf.size();
466
14.8k
467
14.8k
  if (SectionTableOffset + sizeof(Elf_Shdr) > FileSize)
468
0
    return createError("section header table goes past the end of the file");
469
14.8k
470
14.8k
  // Invalid address alignment of section headers
471
14.8k
  if (SectionTableOffset & (alignof(Elf_Shdr) - 1))
472
0
    return createError("invalid alignment of section headers");
473
14.8k
474
14.8k
  const Elf_Shdr *First =
475
14.8k
      reinterpret_cast<const Elf_Shdr *>(base() + SectionTableOffset);
476
14.8k
477
14.8k
  uintX_t NumSections = getHeader()->e_shnum;
478
14.8k
  if (NumSections == 0)
479
0
    NumSections = First->sh_size;
480
14.8k
481
14.8k
  if (NumSections > UINT64_MAX / sizeof(Elf_Shdr))
482
0
    return createError("section table goes past the end of file");
483
14.8k
484
14.8k
  const uint64_t SectionTableSize = NumSections * sizeof(Elf_Shdr);
485
14.8k
486
14.8k
  // Section table goes past end of file!
487
14.8k
  if (SectionTableOffset + SectionTableSize > FileSize)
488
0
    return createError("section table goes past the end of file");
489
14.8k
490
14.8k
  return makeArrayRef(First, NumSections);
491
14.8k
}
492
493
template <class ELFT>
494
template <typename T>
495
Expected<const T *> ELFFile<ELFT>::getEntry(uint32_t Section,
496
187k
                                            uint32_t Entry) const {
497
187k
  auto SecOrErr = getSection(Section);
498
187k
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
187k
  return getEntry<T>(*SecOrErr, Entry);
501
187k
}
llvm::Expected<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getEntry<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > >(unsigned int, unsigned int) const
Line
Count
Source
496
54.1k
                                            uint32_t Entry) const {
497
54.1k
  auto SecOrErr = getSection(Section);
498
54.1k
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
54.1k
  return getEntry<T>(*SecOrErr, Entry);
501
54.1k
}
llvm::Expected<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, false> const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getEntry<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, false> >(unsigned int, unsigned int) const
Line
Count
Source
496
1.66k
                                            uint32_t Entry) const {
497
1.66k
  auto SecOrErr = getSection(Section);
498
1.66k
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
1.66k
  return getEntry<T>(*SecOrErr, Entry);
501
1.66k
}
llvm::Expected<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, true> const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getEntry<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, true> >(unsigned int, unsigned int) const
Line
Count
Source
496
713
                                            uint32_t Entry) const {
497
713
  auto SecOrErr = getSection(Section);
498
713
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
713
  return getEntry<T>(*SecOrErr, Entry);
501
713
}
llvm::Expected<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getEntry<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > >(unsigned int, unsigned int) const
Line
Count
Source
496
4.77k
                                            uint32_t Entry) const {
497
4.77k
  auto SecOrErr = getSection(Section);
498
4.77k
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
4.77k
  return getEntry<T>(*SecOrErr, Entry);
501
4.77k
}
llvm::Expected<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, false> const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getEntry<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, false> >(unsigned int, unsigned int) const
Line
Count
Source
496
568
                                            uint32_t Entry) const {
497
568
  auto SecOrErr = getSection(Section);
498
568
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
568
  return getEntry<T>(*SecOrErr, Entry);
501
568
}
llvm::Expected<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, true> const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getEntry<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, true> >(unsigned int, unsigned int) const
Line
Count
Source
496
384
                                            uint32_t Entry) const {
497
384
  auto SecOrErr = getSection(Section);
498
384
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
384
  return getEntry<T>(*SecOrErr, Entry);
501
384
}
llvm::Expected<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getEntry<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > >(unsigned int, unsigned int) const
Line
Count
Source
496
103k
                                            uint32_t Entry) const {
497
103k
  auto SecOrErr = getSection(Section);
498
103k
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
103k
  return getEntry<T>(*SecOrErr, Entry);
501
103k
}
llvm::Expected<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, false> const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getEntry<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, false> >(unsigned int, unsigned int) const
Line
Count
Source
496
77
                                            uint32_t Entry) const {
497
77
  auto SecOrErr = getSection(Section);
498
77
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
77
  return getEntry<T>(*SecOrErr, Entry);
501
77
}
llvm::Expected<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, true> const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getEntry<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, true> >(unsigned int, unsigned int) const
Line
Count
Source
496
17.8k
                                            uint32_t Entry) const {
497
17.8k
  auto SecOrErr = getSection(Section);
498
17.8k
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
17.8k
  return getEntry<T>(*SecOrErr, Entry);
501
17.8k
}
llvm::Expected<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getEntry<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > >(unsigned int, unsigned int) const
Line
Count
Source
496
3.03k
                                            uint32_t Entry) const {
497
3.03k
  auto SecOrErr = getSection(Section);
498
3.03k
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
3.03k
  return getEntry<T>(*SecOrErr, Entry);
501
3.03k
}
llvm::Expected<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, false> const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getEntry<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, false> >(unsigned int, unsigned int) const
Line
Count
Source
496
48
                                            uint32_t Entry) const {
497
48
  auto SecOrErr = getSection(Section);
498
48
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
48
  return getEntry<T>(*SecOrErr, Entry);
501
48
}
llvm::Expected<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, true> const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getEntry<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, true> >(unsigned int, unsigned int) const
Line
Count
Source
496
866
                                            uint32_t Entry) const {
497
866
  auto SecOrErr = getSection(Section);
498
866
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
866
  return getEntry<T>(*SecOrErr, Entry);
501
866
}
502
503
template <class ELFT>
504
template <typename T>
505
Expected<const T *> ELFFile<ELFT>::getEntry(const Elf_Shdr *Section,
506
190k
                                            uint32_t Entry) const {
507
190k
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
190k
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
190k
  if (Pos + sizeof(T) > Buf.size())
511
1
    return createError("invalid section offset");
512
190k
  return reinterpret_cast<const T *>(base() + Pos);
513
190k
}
llvm::Expected<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getEntry<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*, unsigned int) const
Line
Count
Source
506
55.0k
                                            uint32_t Entry) const {
507
55.0k
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
55.0k
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
55.0k
  if (Pos + sizeof(T) > Buf.size())
511
0
    return createError("invalid section offset");
512
55.0k
  return reinterpret_cast<const T *>(base() + Pos);
513
55.0k
}
llvm::Expected<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getEntry<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*, unsigned int) const
Line
Count
Source
506
4.95k
                                            uint32_t Entry) const {
507
4.95k
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
4.95k
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
4.95k
  if (Pos + sizeof(T) > Buf.size())
511
0
    return createError("invalid section offset");
512
4.95k
  return reinterpret_cast<const T *>(base() + Pos);
513
4.95k
}
llvm::Expected<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getEntry<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*, unsigned int) const
Line
Count
Source
506
104k
                                            uint32_t Entry) const {
507
104k
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
104k
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
104k
  if (Pos + sizeof(T) > Buf.size())
511
1
    return createError("invalid section offset");
512
104k
  return reinterpret_cast<const T *>(base() + Pos);
513
104k
}
llvm::Expected<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getEntry<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*, unsigned int) const
Line
Count
Source
506
3.72k
                                            uint32_t Entry) const {
507
3.72k
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
3.72k
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
3.72k
  if (Pos + sizeof(T) > Buf.size())
511
0
    return createError("invalid section offset");
512
3.72k
  return reinterpret_cast<const T *>(base() + Pos);
513
3.72k
}
llvm::Expected<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, false> const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getEntry<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, false> >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*, unsigned int) const
Line
Count
Source
506
1.66k
                                            uint32_t Entry) const {
507
1.66k
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
1.66k
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
1.66k
  if (Pos + sizeof(T) > Buf.size())
511
0
    return createError("invalid section offset");
512
1.66k
  return reinterpret_cast<const T *>(base() + Pos);
513
1.66k
}
llvm::Expected<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, true> const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getEntry<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, true> >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*, unsigned int) const
Line
Count
Source
506
713
                                            uint32_t Entry) const {
507
713
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
713
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
713
  if (Pos + sizeof(T) > Buf.size())
511
0
    return createError("invalid section offset");
512
713
  return reinterpret_cast<const T *>(base() + Pos);
513
713
}
llvm::Expected<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, false> const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getEntry<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, false> >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*, unsigned int) const
Line
Count
Source
506
568
                                            uint32_t Entry) const {
507
568
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
568
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
568
  if (Pos + sizeof(T) > Buf.size())
511
0
    return createError("invalid section offset");
512
568
  return reinterpret_cast<const T *>(base() + Pos);
513
568
}
llvm::Expected<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, true> const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getEntry<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, true> >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*, unsigned int) const
Line
Count
Source
506
384
                                            uint32_t Entry) const {
507
384
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
384
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
384
  if (Pos + sizeof(T) > Buf.size())
511
0
    return createError("invalid section offset");
512
384
  return reinterpret_cast<const T *>(base() + Pos);
513
384
}
llvm::Expected<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, false> const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getEntry<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, false> >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*, unsigned int) const
Line
Count
Source
506
77
                                            uint32_t Entry) const {
507
77
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
77
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
77
  if (Pos + sizeof(T) > Buf.size())
511
0
    return createError("invalid section offset");
512
77
  return reinterpret_cast<const T *>(base() + Pos);
513
77
}
llvm::Expected<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, true> const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getEntry<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, true> >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*, unsigned int) const
Line
Count
Source
506
17.8k
                                            uint32_t Entry) const {
507
17.8k
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
17.8k
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
17.8k
  if (Pos + sizeof(T) > Buf.size())
511
0
    return createError("invalid section offset");
512
17.8k
  return reinterpret_cast<const T *>(base() + Pos);
513
17.8k
}
llvm::Expected<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, false> const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getEntry<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, false> >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*, unsigned int) const
Line
Count
Source
506
48
                                            uint32_t Entry) const {
507
48
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
48
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
48
  if (Pos + sizeof(T) > Buf.size())
511
0
    return createError("invalid section offset");
512
48
  return reinterpret_cast<const T *>(base() + Pos);
513
48
}
llvm::Expected<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, true> const*> llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getEntry<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, true> >(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*, unsigned int) const
Line
Count
Source
506
866
                                            uint32_t Entry) const {
507
866
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
866
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
866
  if (Pos + sizeof(T) > Buf.size())
511
0
    return createError("invalid section offset");
512
866
  return reinterpret_cast<const T *>(base() + Pos);
513
866
}
514
515
template <class ELFT>
516
Expected<const typename ELFT::Shdr *>
517
406k
ELFFile<ELFT>::getSection(uint32_t Index) const {
518
406k
  auto TableOrErr = sections();
519
406k
  if (!TableOrErr)
520
0
    return TableOrErr.takeError();
521
406k
  return object::getSection<ELFT>(*TableOrErr, Index);
522
406k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSection(unsigned int) const
Line
Count
Source
517
114k
ELFFile<ELFT>::getSection(uint32_t Index) const {
518
114k
  auto TableOrErr = sections();
519
114k
  if (!TableOrErr)
520
0
    return TableOrErr.takeError();
521
114k
  return object::getSection<ELFT>(*TableOrErr, Index);
522
114k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSection(unsigned int) const
Line
Count
Source
517
10.9k
ELFFile<ELFT>::getSection(uint32_t Index) const {
518
10.9k
  auto TableOrErr = sections();
519
10.9k
  if (!TableOrErr)
520
0
    return TableOrErr.takeError();
521
10.9k
  return object::getSection<ELFT>(*TableOrErr, Index);
522
10.9k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSection(unsigned int) const
Line
Count
Source
517
273k
ELFFile<ELFT>::getSection(uint32_t Index) const {
518
273k
  auto TableOrErr = sections();
519
273k
  if (!TableOrErr)
520
0
    return TableOrErr.takeError();
521
273k
  return object::getSection<ELFT>(*TableOrErr, Index);
522
273k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSection(unsigned int) const
Line
Count
Source
517
7.71k
ELFFile<ELFT>::getSection(uint32_t Index) const {
518
7.71k
  auto TableOrErr = sections();
519
7.71k
  if (!TableOrErr)
520
0
    return TableOrErr.takeError();
521
7.71k
  return object::getSection<ELFT>(*TableOrErr, Index);
522
7.71k
}
523
524
template <class ELFT>
525
Expected<const typename ELFT::Shdr *>
526
0
ELFFile<ELFT>::getSection(const StringRef SectionName) const {
527
0
  auto TableOrErr = sections();
528
0
  if (!TableOrErr)
529
0
    return TableOrErr.takeError();
530
0
  for (auto &Sec : *TableOrErr) {
531
0
    auto SecNameOrErr = getSectionName(&Sec);
532
0
    if (!SecNameOrErr)
533
0
      return SecNameOrErr.takeError();
534
0
    if (*SecNameOrErr == SectionName)
535
0
      return &Sec;
536
0
  }
537
0
  return createError("invalid section name");
538
0
}
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSection(llvm::StringRef) const
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSection(llvm::StringRef) const
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSection(llvm::StringRef) const
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSection(llvm::StringRef) const
539
540
template <class ELFT>
541
Expected<StringRef>
542
1.01M
ELFFile<ELFT>::getStringTable(const Elf_Shdr *Section) const {
543
1.01M
  if (Section->sh_type != ELF::SHT_STRTAB)
544
1
    return createError("invalid sh_type for string table, expected SHT_STRTAB");
545
1.01M
  auto V = getSectionContentsAsArray<char>(Section);
546
1.01M
  if (!V)
547
2
    return V.takeError();
548
1.01M
  ArrayRef<char> Data = *V;
549
1.01M
  if (Data.empty())
550
1
    return createError("empty string table");
551
1.01M
  if (Data.back() != '\0')
552
1
    return createError("string table non-null terminated");
553
1.01M
  return StringRef(Data.begin(), Data.size());
554
1.01M
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getStringTable(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*) const
Line
Count
Source
542
25.3k
ELFFile<ELFT>::getStringTable(const Elf_Shdr *Section) const {
543
25.3k
  if (Section->sh_type != ELF::SHT_STRTAB)
544
0
    return createError("invalid sh_type for string table, expected SHT_STRTAB");
545
25.3k
  auto V = getSectionContentsAsArray<char>(Section);
546
25.3k
  if (!V)
547
1
    return V.takeError();
548
25.3k
  ArrayRef<char> Data = *V;
549
25.3k
  if (Data.empty())
550
0
    return createError("empty string table");
551
25.3k
  if (Data.back() != '\0')
552
0
    return createError("string table non-null terminated");
553
25.3k
  return StringRef(Data.begin(), Data.size());
554
25.3k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getStringTable(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*) const
Line
Count
Source
542
4.28k
ELFFile<ELFT>::getStringTable(const Elf_Shdr *Section) const {
543
4.28k
  if (Section->sh_type != ELF::SHT_STRTAB)
544
0
    return createError("invalid sh_type for string table, expected SHT_STRTAB");
545
4.28k
  auto V = getSectionContentsAsArray<char>(Section);
546
4.28k
  if (!V)
547
0
    return V.takeError();
548
4.28k
  ArrayRef<char> Data = *V;
549
4.28k
  if (Data.empty())
550
0
    return createError("empty string table");
551
4.28k
  if (Data.back() != '\0')
552
0
    return createError("string table non-null terminated");
553
4.28k
  return StringRef(Data.begin(), Data.size());
554
4.28k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getStringTable(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*) const
Line
Count
Source
542
977k
ELFFile<ELFT>::getStringTable(const Elf_Shdr *Section) const {
543
977k
  if (Section->sh_type != ELF::SHT_STRTAB)
544
1
    return createError("invalid sh_type for string table, expected SHT_STRTAB");
545
977k
  auto V = getSectionContentsAsArray<char>(Section);
546
977k
  if (!V)
547
1
    return V.takeError();
548
977k
  ArrayRef<char> Data = *V;
549
977k
  if (Data.empty())
550
1
    return createError("empty string table");
551
977k
  if (Data.back() != '\0')
552
1
    return createError("string table non-null terminated");
553
977k
  return StringRef(Data.begin(), Data.size());
554
977k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getStringTable(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*) const
Line
Count
Source
542
3.55k
ELFFile<ELFT>::getStringTable(const Elf_Shdr *Section) const {
543
3.55k
  if (Section->sh_type != ELF::SHT_STRTAB)
544
0
    return createError("invalid sh_type for string table, expected SHT_STRTAB");
545
3.55k
  auto V = getSectionContentsAsArray<char>(Section);
546
3.55k
  if (!V)
547
0
    return V.takeError();
548
3.55k
  ArrayRef<char> Data = *V;
549
3.55k
  if (Data.empty())
550
0
    return createError("empty string table");
551
3.55k
  if (Data.back() != '\0')
552
0
    return createError("string table non-null terminated");
553
3.55k
  return StringRef(Data.begin(), Data.size());
554
3.55k
}
555
556
template <class ELFT>
557
Expected<ArrayRef<typename ELFT::Word>>
558
33
ELFFile<ELFT>::getSHNDXTable(const Elf_Shdr &Section) const {
559
33
  auto SectionsOrErr = sections();
560
33
  if (!SectionsOrErr)
561
0
    return SectionsOrErr.takeError();
562
33
  return getSHNDXTable(Section, *SectionsOrErr);
563
33
}
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSHNDXTable(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const&) const
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSHNDXTable(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const&) const
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSHNDXTable(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const&) const
Line
Count
Source
558
33
ELFFile<ELFT>::getSHNDXTable(const Elf_Shdr &Section) const {
559
33
  auto SectionsOrErr = sections();
560
33
  if (!SectionsOrErr)
561
0
    return SectionsOrErr.takeError();
562
33
  return getSHNDXTable(Section, *SectionsOrErr);
563
33
}
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSHNDXTable(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const&) const
564
565
template <class ELFT>
566
Expected<ArrayRef<typename ELFT::Word>>
567
ELFFile<ELFT>::getSHNDXTable(const Elf_Shdr &Section,
568
38
                             Elf_Shdr_Range Sections) const {
569
38
  assert(Section.sh_type == ELF::SHT_SYMTAB_SHNDX);
570
38
  auto VOrErr = getSectionContentsAsArray<Elf_Word>(&Section);
571
38
  if (!VOrErr)
572
0
    return VOrErr.takeError();
573
38
  ArrayRef<Elf_Word> V = *VOrErr;
574
38
  auto SymTableOrErr = object::getSection<ELFT>(Sections, Section.sh_link);
575
38
  if (!SymTableOrErr)
576
0
    return SymTableOrErr.takeError();
577
38
  const Elf_Shdr &SymTable = **SymTableOrErr;
578
38
  if (SymTable.sh_type != ELF::SHT_SYMTAB &&
579
38
      
SymTable.sh_type != ELF::SHT_DYNSYM0
)
580
0
    return createError("invalid sh_type");
581
38
  if (V.size() != (SymTable.sh_size / sizeof(Elf_Sym)))
582
1
    return createError("invalid section contents size");
583
37
  return V;
584
37
}
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSHNDXTable(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const&, llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > >) const
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSHNDXTable(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const&, llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > >) const
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSHNDXTable(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const&, llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > >) const
Line
Count
Source
568
38
                             Elf_Shdr_Range Sections) const {
569
38
  assert(Section.sh_type == ELF::SHT_SYMTAB_SHNDX);
570
38
  auto VOrErr = getSectionContentsAsArray<Elf_Word>(&Section);
571
38
  if (!VOrErr)
572
0
    return VOrErr.takeError();
573
38
  ArrayRef<Elf_Word> V = *VOrErr;
574
38
  auto SymTableOrErr = object::getSection<ELFT>(Sections, Section.sh_link);
575
38
  if (!SymTableOrErr)
576
0
    return SymTableOrErr.takeError();
577
38
  const Elf_Shdr &SymTable = **SymTableOrErr;
578
38
  if (SymTable.sh_type != ELF::SHT_SYMTAB &&
579
38
      
SymTable.sh_type != ELF::SHT_DYNSYM0
)
580
0
    return createError("invalid sh_type");
581
38
  if (V.size() != (SymTable.sh_size / sizeof(Elf_Sym)))
582
1
    return createError("invalid section contents size");
583
37
  return V;
584
37
}
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSHNDXTable(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const&, llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > >) const
585
586
template <class ELFT>
587
Expected<StringRef>
588
4.05k
ELFFile<ELFT>::getStringTableForSymtab(const Elf_Shdr &Sec) const {
589
4.05k
  auto SectionsOrErr = sections();
590
4.05k
  if (!SectionsOrErr)
591
0
    return SectionsOrErr.takeError();
592
4.05k
  return getStringTableForSymtab(Sec, *SectionsOrErr);
593
4.05k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getStringTableForSymtab(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const&) const
Line
Count
Source
588
866
ELFFile<ELFT>::getStringTableForSymtab(const Elf_Shdr &Sec) const {
589
866
  auto SectionsOrErr = sections();
590
866
  if (!SectionsOrErr)
591
0
    return SectionsOrErr.takeError();
592
866
  return getStringTableForSymtab(Sec, *SectionsOrErr);
593
866
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getStringTableForSymtab(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const&) const
Line
Count
Source
588
236
ELFFile<ELFT>::getStringTableForSymtab(const Elf_Shdr &Sec) const {
589
236
  auto SectionsOrErr = sections();
590
236
  if (!SectionsOrErr)
591
0
    return SectionsOrErr.takeError();
592
236
  return getStringTableForSymtab(Sec, *SectionsOrErr);
593
236
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getStringTableForSymtab(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const&) const
Line
Count
Source
588
2.37k
ELFFile<ELFT>::getStringTableForSymtab(const Elf_Shdr &Sec) const {
589
2.37k
  auto SectionsOrErr = sections();
590
2.37k
  if (!SectionsOrErr)
591
0
    return SectionsOrErr.takeError();
592
2.37k
  return getStringTableForSymtab(Sec, *SectionsOrErr);
593
2.37k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getStringTableForSymtab(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const&) const
Line
Count
Source
588
574
ELFFile<ELFT>::getStringTableForSymtab(const Elf_Shdr &Sec) const {
589
574
  auto SectionsOrErr = sections();
590
574
  if (!SectionsOrErr)
591
0
    return SectionsOrErr.takeError();
592
574
  return getStringTableForSymtab(Sec, *SectionsOrErr);
593
574
}
594
595
template <class ELFT>
596
Expected<StringRef>
597
ELFFile<ELFT>::getStringTableForSymtab(const Elf_Shdr &Sec,
598
7.29k
                                       Elf_Shdr_Range Sections) const {
599
7.29k
600
7.29k
  if (Sec.sh_type != ELF::SHT_SYMTAB && 
Sec.sh_type != ELF::SHT_DYNSYM1.33k
)
601
0
    return createError(
602
0
        "invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM");
603
7.29k
  auto SectionOrErr = object::getSection<ELFT>(Sections, Sec.sh_link);
604
7.29k
  if (!SectionOrErr)
605
1
    return SectionOrErr.takeError();
606
7.29k
  return getStringTable(*SectionOrErr);
607
7.29k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getStringTableForSymtab(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const&, llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > >) const
Line
Count
Source
598
1.27k
                                       Elf_Shdr_Range Sections) const {
599
1.27k
600
1.27k
  if (Sec.sh_type != ELF::SHT_SYMTAB && 
Sec.sh_type != ELF::SHT_DYNSYM232
)
601
0
    return createError(
602
0
        "invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM");
603
1.27k
  auto SectionOrErr = object::getSection<ELFT>(Sections, Sec.sh_link);
604
1.27k
  if (!SectionOrErr)
605
0
    return SectionOrErr.takeError();
606
1.27k
  return getStringTable(*SectionOrErr);
607
1.27k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getStringTableForSymtab(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const&, llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > >) const
Line
Count
Source
598
417
                                       Elf_Shdr_Range Sections) const {
599
417
600
417
  if (Sec.sh_type != ELF::SHT_SYMTAB && 
Sec.sh_type != ELF::SHT_DYNSYM102
)
601
0
    return createError(
602
0
        "invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM");
603
417
  auto SectionOrErr = object::getSection<ELFT>(Sections, Sec.sh_link);
604
417
  if (!SectionOrErr)
605
0
    return SectionOrErr.takeError();
606
417
  return getStringTable(*SectionOrErr);
607
417
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getStringTableForSymtab(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const&, llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > >) const
Line
Count
Source
598
4.90k
                                       Elf_Shdr_Range Sections) const {
599
4.90k
600
4.90k
  if (Sec.sh_type != ELF::SHT_SYMTAB && 
Sec.sh_type != ELF::SHT_DYNSYM924
)
601
0
    return createError(
602
0
        "invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM");
603
4.90k
  auto SectionOrErr = object::getSection<ELFT>(Sections, Sec.sh_link);
604
4.90k
  if (!SectionOrErr)
605
1
    return SectionOrErr.takeError();
606
4.90k
  return getStringTable(*SectionOrErr);
607
4.90k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getStringTableForSymtab(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const&, llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > >) const
Line
Count
Source
598
701
                                       Elf_Shdr_Range Sections) const {
599
701
600
701
  if (Sec.sh_type != ELF::SHT_SYMTAB && 
Sec.sh_type != ELF::SHT_DYNSYM76
)
601
0
    return createError(
602
0
        "invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM");
603
701
  auto SectionOrErr = object::getSection<ELFT>(Sections, Sec.sh_link);
604
701
  if (!SectionOrErr)
605
0
    return SectionOrErr.takeError();
606
701
  return getStringTable(*SectionOrErr);
607
701
}
608
609
template <class ELFT>
610
Expected<StringRef>
611
967k
ELFFile<ELFT>::getSectionName(const Elf_Shdr *Section) const {
612
967k
  auto SectionsOrErr = sections();
613
967k
  if (!SectionsOrErr)
614
0
    return SectionsOrErr.takeError();
615
967k
  auto Table = getSectionStringTable(*SectionsOrErr);
616
967k
  if (!Table)
617
5
    return Table.takeError();
618
967k
  return getSectionName(Section, *Table);
619
967k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionName(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*) const
Line
Count
Source
611
9.07k
ELFFile<ELFT>::getSectionName(const Elf_Shdr *Section) const {
612
9.07k
  auto SectionsOrErr = sections();
613
9.07k
  if (!SectionsOrErr)
614
0
    return SectionsOrErr.takeError();
615
9.07k
  auto Table = getSectionStringTable(*SectionsOrErr);
616
9.07k
  if (!Table)
617
1
    return Table.takeError();
618
9.07k
  return getSectionName(Section, *Table);
619
9.07k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionName(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*) const
Line
Count
Source
611
2.93k
ELFFile<ELFT>::getSectionName(const Elf_Shdr *Section) const {
612
2.93k
  auto SectionsOrErr = sections();
613
2.93k
  if (!SectionsOrErr)
614
0
    return SectionsOrErr.takeError();
615
2.93k
  auto Table = getSectionStringTable(*SectionsOrErr);
616
2.93k
  if (!Table)
617
0
    return Table.takeError();
618
2.93k
  return getSectionName(Section, *Table);
619
2.93k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionName(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*) const
Line
Count
Source
611
952k
ELFFile<ELFT>::getSectionName(const Elf_Shdr *Section) const {
612
952k
  auto SectionsOrErr = sections();
613
952k
  if (!SectionsOrErr)
614
0
    return SectionsOrErr.takeError();
615
952k
  auto Table = getSectionStringTable(*SectionsOrErr);
616
952k
  if (!Table)
617
4
    return Table.takeError();
618
952k
  return getSectionName(Section, *Table);
619
952k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionName(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*) const
Line
Count
Source
611
2.24k
ELFFile<ELFT>::getSectionName(const Elf_Shdr *Section) const {
612
2.24k
  auto SectionsOrErr = sections();
613
2.24k
  if (!SectionsOrErr)
614
0
    return SectionsOrErr.takeError();
615
2.24k
  auto Table = getSectionStringTable(*SectionsOrErr);
616
2.24k
  if (!Table)
617
0
    return Table.takeError();
618
2.24k
  return getSectionName(Section, *Table);
619
2.24k
}
620
621
template <class ELFT>
622
Expected<StringRef> ELFFile<ELFT>::getSectionName(const Elf_Shdr *Section,
623
1.30M
                                                  StringRef DotShstrtab) const {
624
1.30M
  uint32_t Offset = Section->sh_name;
625
1.30M
  if (Offset == 0)
626
3.85k
    return StringRef();
627
1.30M
  if (Offset >= DotShstrtab.size())
628
30
    return createError("invalid string offset");
629
1.30M
  return StringRef(DotShstrtab.data() + Offset);
630
1.30M
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSectionName(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false> > const*, llvm::StringRef) const
Line
Count
Source
623
10.5k
                                                  StringRef DotShstrtab) const {
624
10.5k
  uint32_t Offset = Section->sh_name;
625
10.5k
  if (Offset == 0)
626
748
    return StringRef();
627
9.80k
  if (Offset >= DotShstrtab.size())
628
28
    return createError("invalid string offset");
629
9.77k
  return StringRef(DotShstrtab.data() + Offset);
630
9.77k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionName(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*, llvm::StringRef) const
Line
Count
Source
623
3.85k
                                                  StringRef DotShstrtab) const {
624
3.85k
  uint32_t Offset = Section->sh_name;
625
3.85k
  if (Offset == 0)
626
212
    return StringRef();
627
3.63k
  if (Offset >= DotShstrtab.size())
628
0
    return createError("invalid string offset");
629
3.63k
  return StringRef(DotShstrtab.data() + Offset);
630
3.63k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionName(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*, llvm::StringRef) const
Line
Count
Source
623
1.28M
                                                  StringRef DotShstrtab) const {
624
1.28M
  uint32_t Offset = Section->sh_name;
625
1.28M
  if (Offset == 0)
626
2.76k
    return StringRef();
627
1.28M
  if (Offset >= DotShstrtab.size())
628
2
    return createError("invalid string offset");
629
1.28M
  return StringRef(DotShstrtab.data() + Offset);
630
1.28M
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSectionName(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true> > const*, llvm::StringRef) const
Line
Count
Source
623
2.69k
                                                  StringRef DotShstrtab) const {
624
2.69k
  uint32_t Offset = Section->sh_name;
625
2.69k
  if (Offset == 0)
626
137
    return StringRef();
627
2.55k
  if (Offset >= DotShstrtab.size())
628
0
    return createError("invalid string offset");
629
2.55k
  return StringRef(DotShstrtab.data() + Offset);
630
2.55k
}
631
632
/// This function returns the hash value for a symbol in the .dynsym section
633
/// Name of the API remains consistent as specified in the libelf
634
/// REF : http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#hash
635
inline unsigned hashSysV(StringRef SymbolName) {
636
  unsigned h = 0, g;
637
  for (char C : SymbolName) {
638
    h = (h << 4) + C;
639
    g = h & 0xf0000000L;
640
    if (g != 0)
641
      h ^= g >> 24;
642
    h &= ~g;
643
  }
644
  return h;
645
}
646
647
} // end namespace object
648
} // end namespace llvm
649
650
#endif // LLVM_OBJECT_ELF_H