Coverage Report

Created: 2018-11-12 17:33

/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.96k
getElfArchType(StringRef Object) {
41
8.96k
  if (Object.size() < ELF::EI_NIDENT)
42
0
    return std::make_pair((uint8_t)ELF::ELFCLASSNONE,
43
0
                          (uint8_t)ELF::ELFDATANONE);
44
8.96k
  return std::make_pair((uint8_t)Object[ELF::EI_CLASS],
45
8.96k
                        (uint8_t)Object[ELF::EI_DATA]);
46
8.96k
}
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.67M
  const uint8_t *base() const {
84
1.67M
    return reinterpret_cast<const uint8_t *>(Buf.data());
85
1.67M
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::base() const
Line
Count
Source
83
595k
  const uint8_t *base() const {
84
595k
    return reinterpret_cast<const uint8_t *>(Buf.data());
85
595k
  }
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.21k
  size_t getBufSize() const { return Buf.size(); }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getBufSize() const
Line
Count
Source
87
761
  size_t getBufSize() const { return Buf.size(); }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getBufSize() const
Line
Count
Source
87
265
  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.98k
  size_t getBufSize() const { return Buf.size(); }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getBufSize() const
Line
Count
Source
87
205
  size_t getBufSize() const { return Buf.size(); }
88
89
private:
90
  StringRef Buf;
91
92
  ELFFile(StringRef Object);
93
94
public:
95
38.5M
  const Elf_Ehdr *getHeader() const {
96
38.5M
    return reinterpret_cast<const Elf_Ehdr *>(base());
97
38.5M
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getHeader() const
Line
Count
Source
95
1.41M
  const Elf_Ehdr *getHeader() const {
96
1.41M
    return reinterpret_cast<const Elf_Ehdr *>(base());
97
1.41M
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getHeader() const
Line
Count
Source
95
559k
  const Elf_Ehdr *getHeader() const {
96
559k
    return reinterpret_cast<const Elf_Ehdr *>(base());
97
559k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getHeader() const
Line
Count
Source
95
21.3M
  const Elf_Ehdr *getHeader() const {
96
21.3M
    return reinterpret_cast<const Elf_Ehdr *>(base());
97
21.3M
  }
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
26.0k
  bool isMipsELF64() const {
128
26.0k
    return getHeader()->e_machine == ELF::EM_MIPS &&
129
26.0k
           
getHeader()->getFileClass() == ELF::ELFCLASS642.77k
;
130
26.0k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isMipsELF64() const
Line
Count
Source
127
5.11k
  bool isMipsELF64() const {
128
5.11k
    return getHeader()->e_machine == ELF::EM_MIPS &&
129
5.11k
           
getHeader()->getFileClass() == ELF::ELFCLASS64725
;
130
5.11k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isMipsELF64() const
Line
Count
Source
127
1.49k
  bool isMipsELF64() const {
128
1.49k
    return getHeader()->e_machine == ELF::EM_MIPS &&
129
1.49k
           
getHeader()->getFileClass() == ELF::ELFCLASS641.20k
;
130
1.49k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isMipsELF64() const
Line
Count
Source
127
16.4k
  bool isMipsELF64() const {
128
16.4k
    return getHeader()->e_machine == ELF::EM_MIPS &&
129
16.4k
           
getHeader()->getFileClass() == ELF::ELFCLASS64438
;
130
16.4k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isMipsELF64() const
Line
Count
Source
127
2.93k
  bool isMipsELF64() const {
128
2.93k
    return getHeader()->e_machine == ELF::EM_MIPS &&
129
2.93k
           
getHeader()->getFileClass() == ELF::ELFCLASS64411
;
130
2.93k
  }
131
132
21.3k
  bool isMips64EL() const {
133
21.3k
    return isMipsELF64() &&
134
21.3k
           
getHeader()->getDataEncoding() == ELF::ELFDATA2LSB654
;
135
21.3k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isMips64EL() const
Line
Count
Source
132
3.82k
  bool isMips64EL() const {
133
3.82k
    return isMipsELF64() &&
134
3.82k
           
getHeader()->getDataEncoding() == ELF::ELFDATA2LSB0
;
135
3.82k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isMips64EL() const
Line
Count
Source
132
1.15k
  bool isMips64EL() const {
133
1.15k
    return isMipsELF64() &&
134
1.15k
           
getHeader()->getDataEncoding() == ELF::ELFDATA2LSB0
;
135
1.15k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isMips64EL() const
Line
Count
Source
132
14.2k
  bool isMips64EL() const {
133
14.2k
    return isMipsELF64() &&
134
14.2k
           
getHeader()->getDataEncoding() == ELF::ELFDATA2LSB346
;
135
14.2k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isMips64EL() const
Line
Count
Source
132
2.11k
  bool isMips64EL() const {
133
2.11k
    return isMipsELF64() &&
134
2.11k
           
getHeader()->getDataEncoding() == ELF::ELFDATA2LSB308
;
135
2.11k
  }
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
108k
  Expected<Elf_Sym_Range> symbols(const Elf_Shdr *Sec) const {
144
108k
    if (!Sec)
145
18.9k
      return makeArrayRef<Elf_Sym>(nullptr, nullptr);
146
89.5k
    return getSectionContentsAsArray<Elf_Sym>(Sec);
147
89.5k
  }
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.2k
  Expected<Elf_Sym_Range> symbols(const Elf_Shdr *Sec) const {
144
28.2k
    if (!Sec)
145
7.84k
      return makeArrayRef<Elf_Sym>(nullptr, nullptr);
146
20.4k
    return getSectionContentsAsArray<Elf_Sym>(Sec);
147
20.4k
  }
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.49k
  Expected<Elf_Sym_Range> symbols(const Elf_Shdr *Sec) const {
144
3.49k
    if (!Sec)
145
884
      return makeArrayRef<Elf_Sym>(nullptr, nullptr);
146
2.61k
    return getSectionContentsAsArray<Elf_Sym>(Sec);
147
2.61k
  }
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
74.0k
  Expected<Elf_Sym_Range> symbols(const Elf_Shdr *Sec) const {
144
74.0k
    if (!Sec)
145
9.59k
      return makeArrayRef<Elf_Sym>(nullptr, nullptr);
146
64.4k
    return getSectionContentsAsArray<Elf_Sym>(Sec);
147
64.4k
  }
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.67k
  Expected<Elf_Sym_Range> symbols(const Elf_Shdr *Sec) const {
144
2.67k
    if (!Sec)
145
658
      return makeArrayRef<Elf_Sym>(nullptr, nullptr);
146
2.02k
    return getSectionContentsAsArray<Elf_Sym>(Sec);
147
2.02k
  }
148
149
1.73k
  Expected<Elf_Rela_Range> relas(const Elf_Shdr *Sec) const {
150
1.73k
    return getSectionContentsAsArray<Elf_Rela>(Sec);
151
1.73k
  }
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
6
  Expected<Elf_Rela_Range> relas(const Elf_Shdr *Sec) const {
150
6
    return getSectionContentsAsArray<Elf_Rela>(Sec);
151
6
  }
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.51k
  Expected<Elf_Rela_Range> relas(const Elf_Shdr *Sec) const {
150
1.51k
    return getSectionContentsAsArray<Elf_Rela>(Sec);
151
1.51k
  }
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
195
  Expected<Elf_Rela_Range> relas(const Elf_Shdr *Sec) const {
150
195
    return getSectionContentsAsArray<Elf_Rela>(Sec);
151
195
  }
152
153
626
  Expected<Elf_Rel_Range> rels(const Elf_Shdr *Sec) const {
154
626
    return getSectionContentsAsArray<Elf_Rel>(Sec);
155
626
  }
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
490
  Expected<Elf_Rel_Range> rels(const Elf_Shdr *Sec) const {
154
490
    return getSectionContentsAsArray<Elf_Rel>(Sec);
155
490
  }
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
106
  Expected<Elf_Rel_Range> rels(const Elf_Shdr *Sec) const {
154
106
    return getSectionContentsAsArray<Elf_Rel>(Sec);
155
106
  }
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.84k
  Expected<Elf_Phdr_Range> program_headers() const {
167
2.84k
    if (getHeader()->e_phnum && 
getHeader()->e_phentsize != sizeof(Elf_Phdr)1.43k
)
168
2
      return createError("invalid e_phentsize");
169
2.83k
    if (getHeader()->e_phoff +
170
2.83k
            (getHeader()->e_phnum * getHeader()->e_phentsize) >
171
2.83k
        getBufSize())
172
1
      return createError("program headers longer than binary");
173
2.83k
    auto *Begin =
174
2.83k
        reinterpret_cast<const Elf_Phdr *>(base() + getHeader()->e_phoff);
175
2.83k
    return makeArrayRef(Begin, Begin + getHeader()->e_phnum);
176
2.83k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::program_headers() const
Line
Count
Source
166
565
  Expected<Elf_Phdr_Range> program_headers() const {
167
565
    if (getHeader()->e_phnum && 
getHeader()->e_phentsize != sizeof(Elf_Phdr)190
)
168
0
      return createError("invalid e_phentsize");
169
565
    if (getHeader()->e_phoff +
170
565
            (getHeader()->e_phnum * getHeader()->e_phentsize) >
171
565
        getBufSize())
172
0
      return createError("program headers longer than binary");
173
565
    auto *Begin =
174
565
        reinterpret_cast<const Elf_Phdr *>(base() + getHeader()->e_phoff);
175
565
    return makeArrayRef(Begin, Begin + getHeader()->e_phnum);
176
565
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::program_headers() const
Line
Count
Source
166
173
  Expected<Elf_Phdr_Range> program_headers() const {
167
173
    if (getHeader()->e_phnum && 
getHeader()->e_phentsize != sizeof(Elf_Phdr)67
)
168
0
      return createError("invalid e_phentsize");
169
173
    if (getHeader()->e_phoff +
170
173
            (getHeader()->e_phnum * getHeader()->e_phentsize) >
171
173
        getBufSize())
172
0
      return createError("program headers longer than binary");
173
173
    auto *Begin =
174
173
        reinterpret_cast<const Elf_Phdr *>(base() + getHeader()->e_phoff);
175
173
    return makeArrayRef(Begin, Begin + getHeader()->e_phnum);
176
173
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::program_headers() const
Line
Count
Source
166
1.95k
  Expected<Elf_Phdr_Range> program_headers() const {
167
1.95k
    if (getHeader()->e_phnum && 
getHeader()->e_phentsize != sizeof(Elf_Phdr)1.12k
)
168
2
      return createError("invalid e_phentsize");
169
1.95k
    if (getHeader()->e_phoff +
170
1.95k
            (getHeader()->e_phnum * getHeader()->e_phentsize) >
171
1.95k
        getBufSize())
172
1
      return createError("program headers longer than binary");
173
1.95k
    auto *Begin =
174
1.95k
        reinterpret_cast<const Elf_Phdr *>(base() + getHeader()->e_phoff);
175
1.95k
    return makeArrayRef(Begin, Begin + getHeader()->e_phnum);
176
1.95k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::program_headers() const
Line
Count
Source
166
143
  Expected<Elf_Phdr_Range> program_headers() const {
167
143
    if (getHeader()->e_phnum && 
getHeader()->e_phentsize != sizeof(Elf_Phdr)53
)
168
0
      return createError("invalid e_phentsize");
169
143
    if (getHeader()->e_phoff +
170
143
            (getHeader()->e_phnum * getHeader()->e_phentsize) >
171
143
        getBufSize())
172
0
      return createError("program headers longer than binary");
173
143
    auto *Begin =
174
143
        reinterpret_cast<const Elf_Phdr *>(base() + getHeader()->e_phoff);
175
143
    return makeArrayRef(Begin, Begin + getHeader()->e_phnum);
176
143
  }
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
34
  Elf_Note_Iterator notes_begin(const Elf_Shdr &Shdr, Error &Err) const {
205
34
    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
34
    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
34
    return Elf_Note_Iterator(base() + Shdr.sh_offset, Shdr.sh_size, Err);
214
34
  }
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
34
  Elf_Note_Iterator notes_begin(const Elf_Shdr &Shdr, Error &Err) const {
205
34
    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
34
    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
34
    return Elf_Note_Iterator(base() + Shdr.sh_offset, Shdr.sh_size, Err);
214
34
  }
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
34
  Elf_Note_Iterator notes_end() const {
218
34
    return Elf_Note_Iterator();
219
34
  }
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
34
  Elf_Note_Iterator notes_end() const {
218
34
    return Elf_Note_Iterator();
219
34
  }
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
34
                                          Error &Err) const {
242
34
    return make_range(notes_begin(Shdr, Err), notes_end());
243
34
  }
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
34
                                          Error &Err) const {
242
34
    return make_range(notes_begin(Shdr, Err), notes_end());
243
34
  }
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
427k
getSection(typename ELFT::ShdrRange Sections, uint32_t Index) {
276
427k
  if (Index >= Sections.size())
277
1
    return createError("invalid section index");
278
427k
  return &Sections[Index];
279
427k
}
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
116k
getSection(typename ELFT::ShdrRange Sections, uint32_t Index) {
276
116k
  if (Index >= Sections.size())
277
0
    return createError("invalid section index");
278
116k
  return &Sections[Index];
279
116k
}
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.5k
getSection(typename ELFT::ShdrRange Sections, uint32_t Index) {
276
11.5k
  if (Index >= Sections.size())
277
0
    return createError("invalid section index");
278
11.5k
  return &Sections[Index];
279
11.5k
}
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
290k
getSection(typename ELFT::ShdrRange Sections, uint32_t Index) {
276
290k
  if (Index >= Sections.size())
277
1
    return createError("invalid section index");
278
290k
  return &Sections[Index];
279
290k
}
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
9.28k
getSection(typename ELFT::ShdrRange Sections, uint32_t Index) {
276
9.28k
  if (Index >= Sections.size())
277
0
    return createError("invalid section index");
278
9.28k
  return &Sections[Index];
279
9.28k
}
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
107k
                               ArrayRef<Elf_Word> ShndxTable) const {
299
107k
  uint32_t Index = Sym->st_shndx;
300
107k
  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
106k
  if (Index == ELF::SHN_UNDEF || 
Index >= ELF::SHN_LORESERVE101k
)
308
6.09k
    return 0;
309
100k
  return Index;
310
100k
}
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.9k
                               ArrayRef<Elf_Word> ShndxTable) const {
299
11.9k
  uint32_t Index = Sym->st_shndx;
300
11.9k
  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.9k
  if (Index == ELF::SHN_UNDEF || 
Index >= ELF::SHN_LORESERVE11.0k
)
308
1.06k
    return 0;
309
10.8k
  return Index;
310
10.8k
}
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.59k
                               ArrayRef<Elf_Word> ShndxTable) const {
299
1.59k
  uint32_t Index = Sym->st_shndx;
300
1.59k
  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.59k
  if (Index == ELF::SHN_UNDEF || 
Index >= ELF::SHN_LORESERVE1.27k
)
308
355
    return 0;
309
1.24k
  return Index;
310
1.24k
}
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
82.3k
                               ArrayRef<Elf_Word> ShndxTable) const {
299
82.3k
  uint32_t Index = Sym->st_shndx;
300
82.3k
  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
82.1k
  if (Index == ELF::SHN_UNDEF || 
Index >= ELF::SHN_LORESERVE78.5k
)
308
4.34k
    return 0;
309
77.7k
  return Index;
310
77.7k
}
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.3k
                               ArrayRef<Elf_Word> ShndxTable) const {
299
11.3k
  uint32_t Index = Sym->st_shndx;
300
11.3k
  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.3k
  if (Index == ELF::SHN_UNDEF || 
Index >= ELF::SHN_LORESERVE11.0k
)
308
335
    return 0;
309
10.9k
  return Index;
310
10.9k
}
311
312
template <class ELFT>
313
Expected<const typename ELFT::Shdr *>
314
ELFFile<ELFT>::getSection(const Elf_Sym *Sym, const Elf_Shdr *SymTab,
315
20.2k
                          ArrayRef<Elf_Word> ShndxTable) const {
316
20.2k
  auto SymsOrErr = symbols(SymTab);
317
20.2k
  if (!SymsOrErr)
318
0
    return SymsOrErr.takeError();
319
20.2k
  return getSection(Sym, *SymsOrErr, ShndxTable);
320
20.2k
}
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.69k
                          ArrayRef<Elf_Word> ShndxTable) const {
316
9.69k
  auto SymsOrErr = symbols(SymTab);
317
9.69k
  if (!SymsOrErr)
318
0
    return SymsOrErr.takeError();
319
9.69k
  return getSection(Sym, *SymsOrErr, ShndxTable);
320
9.69k
}
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
939
                          ArrayRef<Elf_Word> ShndxTable) const {
316
939
  auto SymsOrErr = symbols(SymTab);
317
939
  if (!SymsOrErr)
318
0
    return SymsOrErr.takeError();
319
939
  return getSection(Sym, *SymsOrErr, ShndxTable);
320
939
}
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
8.88k
                          ArrayRef<Elf_Word> ShndxTable) const {
316
8.88k
  auto SymsOrErr = symbols(SymTab);
317
8.88k
  if (!SymsOrErr)
318
0
    return SymsOrErr.takeError();
319
8.88k
  return getSection(Sym, *SymsOrErr, ShndxTable);
320
8.88k
}
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
773
                          ArrayRef<Elf_Word> ShndxTable) const {
316
773
  auto SymsOrErr = symbols(SymTab);
317
773
  if (!SymsOrErr)
318
0
    return SymsOrErr.takeError();
319
773
  return getSection(Sym, *SymsOrErr, ShndxTable);
320
773
}
321
322
template <class ELFT>
323
Expected<const typename ELFT::Shdr *>
324
ELFFile<ELFT>::getSection(const Elf_Sym *Sym, Elf_Sym_Range Symbols,
325
20.2k
                          ArrayRef<Elf_Word> ShndxTable) const {
326
20.2k
  auto IndexOrErr = getSectionIndex(Sym, Symbols, ShndxTable);
327
20.2k
  if (!IndexOrErr)
328
0
    return IndexOrErr.takeError();
329
20.2k
  uint32_t Index = *IndexOrErr;
330
20.2k
  if (Index == 0)
331
1.13k
    return nullptr;
332
19.1k
  return getSection(Index);
333
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::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.69k
                          ArrayRef<Elf_Word> ShndxTable) const {
326
9.69k
  auto IndexOrErr = getSectionIndex(Sym, Symbols, ShndxTable);
327
9.69k
  if (!IndexOrErr)
328
0
    return IndexOrErr.takeError();
329
9.69k
  uint32_t Index = *IndexOrErr;
330
9.69k
  if (Index == 0)
331
460
    return nullptr;
332
9.23k
  return getSection(Index);
333
9.23k
}
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
939
                          ArrayRef<Elf_Word> ShndxTable) const {
326
939
  auto IndexOrErr = getSectionIndex(Sym, Symbols, ShndxTable);
327
939
  if (!IndexOrErr)
328
0
    return IndexOrErr.takeError();
329
939
  uint32_t Index = *IndexOrErr;
330
939
  if (Index == 0)
331
100
    return nullptr;
332
839
  return getSection(Index);
333
839
}
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
8.88k
                          ArrayRef<Elf_Word> ShndxTable) const {
326
8.88k
  auto IndexOrErr = getSectionIndex(Sym, Symbols, ShndxTable);
327
8.88k
  if (!IndexOrErr)
328
0
    return IndexOrErr.takeError();
329
8.88k
  uint32_t Index = *IndexOrErr;
330
8.88k
  if (Index == 0)
331
506
    return nullptr;
332
8.38k
  return getSection(Index);
333
8.38k
}
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
773
                          ArrayRef<Elf_Word> ShndxTable) const {
326
773
  auto IndexOrErr = getSectionIndex(Sym, Symbols, ShndxTable);
327
773
  if (!IndexOrErr)
328
0
    return IndexOrErr.takeError();
329
773
  uint32_t Index = *IndexOrErr;
330
773
  if (Index == 0)
331
65
    return nullptr;
332
708
  return getSection(Index);
333
708
}
334
335
template <class ELFT>
336
inline Expected<const typename ELFT::Sym *>
337
76
getSymbol(typename ELFT::SymRange Symbols, uint32_t Index) {
338
76
  if (Index >= Symbols.size())
339
0
    return createError("invalid symbol index");
340
76
  return &Symbols[Index];
341
76
}
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
74
getSymbol(typename ELFT::SymRange Symbols, uint32_t Index) {
338
74
  if (Index >= Symbols.size())
339
0
    return createError("invalid symbol index");
340
74
  return &Symbols[Index];
341
74
}
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.44M
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
1.44M
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 11.35M
)
357
1
    return createError("invalid sh_entsize");
358
1.44M
359
1.44M
  uintX_t Offset = Sec->sh_offset;
360
1.44M
  uintX_t Size = Sec->sh_size;
361
1.44M
362
1.44M
  if (Size % sizeof(T))
363
1
    return createError("size is not a multiple of sh_entsize");
364
1.44M
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
1.44M
      
Offset + Size > Buf.size()1.44M
)
366
5
    return createError("invalid section offset");
367
1.44M
368
1.44M
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
1.44M
371
1.44M
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
1.44M
  return makeArrayRef(Start, Size / sizeof(T));
373
1.44M
}
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.7k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
25.7k
  if (Sec->sh_entsize != sizeof(T) && sizeof(T) != 1)
357
0
    return createError("invalid sh_entsize");
358
25.7k
359
25.7k
  uintX_t Offset = Sec->sh_offset;
360
25.7k
  uintX_t Size = Sec->sh_size;
361
25.7k
362
25.7k
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
25.7k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
25.7k
      
Offset + Size > Buf.size()25.7k
)
366
1
    return createError("invalid section offset");
367
25.7k
368
25.7k
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
25.7k
371
25.7k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
25.7k
  return makeArrayRef(Start, Size / sizeof(T));
373
25.7k
}
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
59
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
59
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
59
359
59
  uintX_t Offset = Sec->sh_offset;
360
59
  uintX_t Size = Sec->sh_size;
361
59
362
59
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
59
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
59
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
59
368
59
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
59
371
59
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
59
  return makeArrayRef(Start, Size / sizeof(T));
373
59
}
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.4k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
20.4k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
20.4k
359
20.4k
  uintX_t Offset = Sec->sh_offset;
360
20.4k
  uintX_t Size = Sec->sh_size;
361
20.4k
362
20.4k
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
20.4k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
20.4k
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
20.4k
368
20.4k
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
20.4k
371
20.4k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
20.4k
  return makeArrayRef(Start, Size / sizeof(T));
373
20.4k
}
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
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<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
490
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
490
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
490
359
490
  uintX_t Offset = Sec->sh_offset;
360
490
  uintX_t Size = Sec->sh_size;
361
490
362
490
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
490
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
490
      Offset + Size > Buf.size())
366
1
    return createError("invalid section offset");
367
489
368
489
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
489
371
489
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
489
  return makeArrayRef(Start, Size / sizeof(T));
373
489
}
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.99k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
1.99k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 11.97k
)
357
0
    return createError("invalid sh_entsize");
358
1.99k
359
1.99k
  uintX_t Offset = Sec->sh_offset;
360
1.99k
  uintX_t Size = Sec->sh_size;
361
1.99k
362
1.99k
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
1.99k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
1.99k
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
1.99k
368
1.99k
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
1.99k
371
1.99k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
1.99k
  return makeArrayRef(Start, Size / sizeof(T));
373
1.99k
}
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.41k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
4.41k
  if (Sec->sh_entsize != sizeof(T) && sizeof(T) != 1)
357
0
    return createError("invalid sh_entsize");
358
4.41k
359
4.41k
  uintX_t Offset = Sec->sh_offset;
360
4.41k
  uintX_t Size = Sec->sh_size;
361
4.41k
362
4.41k
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
4.41k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
4.41k
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
4.41k
368
4.41k
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
4.41k
371
4.41k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
4.41k
  return makeArrayRef(Start, Size / sizeof(T));
373
4.41k
}
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.61k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
2.61k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
2.61k
359
2.61k
  uintX_t Offset = Sec->sh_offset;
360
2.61k
  uintX_t Size = Sec->sh_size;
361
2.61k
362
2.61k
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
2.61k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
2.61k
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
2.61k
368
2.61k
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
2.61k
371
2.61k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
2.61k
  return makeArrayRef(Start, Size / sizeof(T));
373
2.61k
}
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
106
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
106
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
106
359
106
  uintX_t Offset = Sec->sh_offset;
360
106
  uintX_t Size = Sec->sh_size;
361
106
362
106
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
106
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
106
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
106
368
106
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
106
371
106
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
106
  return makeArrayRef(Start, Size / sizeof(T));
373
106
}
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
979k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
979k
  if (Sec->sh_entsize != sizeof(T) && sizeof(T) != 1)
357
0
    return createError("invalid sh_entsize");
358
979k
359
979k
  uintX_t Offset = Sec->sh_offset;
360
979k
  uintX_t Size = Sec->sh_size;
361
979k
362
979k
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
979k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
979k
      Offset + Size > Buf.size())
366
1
    return createError("invalid section offset");
367
979k
368
979k
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
979k
371
979k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
979k
  return makeArrayRef(Start, Size / sizeof(T));
373
979k
}
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
135
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
135
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
135
359
135
  uintX_t Offset = Sec->sh_offset;
360
135
  uintX_t Size = Sec->sh_size;
361
135
362
135
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
135
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
135
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
135
368
135
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
135
371
135
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
135
  return makeArrayRef(Start, Size / sizeof(T));
373
135
}
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
244
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
244
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
244
359
244
  uintX_t Offset = Sec->sh_offset;
360
244
  uintX_t Size = Sec->sh_size;
361
244
362
244
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
244
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
244
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
244
368
244
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
244
371
244
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
244
  return makeArrayRef(Start, Size / sizeof(T));
373
244
}
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
64.4k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
64.4k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
1
    return createError("invalid sh_entsize");
358
64.4k
359
64.4k
  uintX_t Offset = Sec->sh_offset;
360
64.4k
  uintX_t Size = Sec->sh_size;
361
64.4k
362
64.4k
  if (Size % sizeof(T))
363
1
    return createError("size is not a multiple of sh_entsize");
364
64.4k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
64.4k
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
64.4k
368
64.4k
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
64.4k
371
64.4k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
64.4k
  return makeArrayRef(Start, Size / sizeof(T));
373
64.4k
}
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.51k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
1.51k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
1.51k
359
1.51k
  uintX_t Offset = Sec->sh_offset;
360
1.51k
  uintX_t Size = Sec->sh_size;
361
1.51k
362
1.51k
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
1.51k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
1.51k
      Offset + Size > Buf.size())
366
1
    return createError("invalid section offset");
367
1.50k
368
1.50k
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
1.50k
371
1.50k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
1.50k
  return makeArrayRef(Start, Size / sizeof(T));
373
1.50k
}
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.79k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
3.79k
  if (Sec->sh_entsize != sizeof(T) && sizeof(T) != 1)
357
0
    return createError("invalid sh_entsize");
358
3.79k
359
3.79k
  uintX_t Offset = Sec->sh_offset;
360
3.79k
  uintX_t Size = Sec->sh_size;
361
3.79k
362
3.79k
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
3.79k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
3.79k
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
3.79k
368
3.79k
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
3.79k
371
3.79k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
3.79k
  return makeArrayRef(Start, Size / sizeof(T));
373
3.79k
}
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
2.02k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
2.02k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
2.02k
359
2.02k
  uintX_t Offset = Sec->sh_offset;
360
2.02k
  uintX_t Size = Sec->sh_size;
361
2.02k
362
2.02k
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
2.02k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
2.02k
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
2.02k
368
2.02k
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
2.02k
371
2.02k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
2.02k
  return makeArrayRef(Start, Size / sizeof(T));
373
2.02k
}
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
195
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
195
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
357
0
    return createError("invalid sh_entsize");
358
195
359
195
  uintX_t Offset = Sec->sh_offset;
360
195
  uintX_t Size = Sec->sh_size;
361
195
362
195
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
195
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
195
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
195
368
195
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
195
371
195
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
195
  return makeArrayRef(Start, Size / sizeof(T));
373
195
}
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
500
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
356
500
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 1442
)
357
0
    return createError("invalid sh_entsize");
358
500
359
500
  uintX_t Offset = Sec->sh_offset;
360
500
  uintX_t Size = Sec->sh_size;
361
500
362
500
  if (Size % sizeof(T))
363
0
    return createError("size is not a multiple of sh_entsize");
364
500
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365
500
      Offset + Size > Buf.size())
366
0
    return createError("invalid section offset");
367
500
368
500
  if (Offset % alignof(T))
369
0
    return createError("unaligned data");
370
500
371
500
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372
500
  return makeArrayRef(Start, Size / sizeof(T));
373
500
}
374
375
template <class ELFT>
376
Expected<ArrayRef<uint8_t>>
377
339k
ELFFile<ELFT>::getSectionContents(const Elf_Shdr *Sec) const {
378
339k
  return getSectionContentsAsArray<uint8_t>(Sec);
379
339k
}
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.99k
ELFFile<ELFT>::getSectionContents(const Elf_Shdr *Sec) const {
378
1.99k
  return getSectionContentsAsArray<uint8_t>(Sec);
379
1.99k
}
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
500
ELFFile<ELFT>::getSectionContents(const Elf_Shdr *Sec) const {
378
500
  return getSectionContentsAsArray<uint8_t>(Sec);
379
500
}
380
381
template <class ELFT>
382
5.03k
StringRef ELFFile<ELFT>::getRelocationTypeName(uint32_t Type) const {
383
5.03k
  return getELFRelocationTypeName(getHeader()->e_machine, Type);
384
5.03k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationTypeName(unsigned int) const
Line
Count
Source
382
1.28k
StringRef ELFFile<ELFT>::getRelocationTypeName(uint32_t Type) const {
383
1.28k
  return getELFRelocationTypeName(getHeader()->e_machine, Type);
384
1.28k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationTypeName(unsigned int) const
Line
Count
Source
382
340
StringRef ELFFile<ELFT>::getRelocationTypeName(uint32_t Type) const {
383
340
  return getELFRelocationTypeName(getHeader()->e_machine, Type);
384
340
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationTypeName(unsigned int) const
Line
Count
Source
382
2.38k
StringRef ELFFile<ELFT>::getRelocationTypeName(uint32_t Type) const {
383
2.38k
  return getELFRelocationTypeName(getHeader()->e_machine, Type);
384
2.38k
}
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.64k
                                          SmallVectorImpl<char> &Result) const {
389
4.64k
  if (!isMipsELF64()) {
390
4.45k
    StringRef Name = getRelocationTypeName(Type);
391
4.45k
    Result.append(Name.begin(), Name.end());
392
4.45k
  } 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.64k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationTypeName(unsigned int, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
388
1.28k
                                          SmallVectorImpl<char> &Result) const {
389
1.28k
  if (!isMipsELF64()) {
390
1.28k
    StringRef Name = getRelocationTypeName(Type);
391
1.28k
    Result.append(Name.begin(), Name.end());
392
1.28k
  } 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.28k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationTypeName(unsigned int, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
388
340
                                          SmallVectorImpl<char> &Result) const {
389
340
  if (!isMipsELF64()) {
390
340
    StringRef Name = getRelocationTypeName(Type);
391
340
    Result.append(Name.begin(), Name.end());
392
340
  } 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
340
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationTypeName(unsigned int, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
388
2.20k
                                          SmallVectorImpl<char> &Result) const {
389
2.20k
  if (!isMipsELF64()) {
390
2.10k
    StringRef Name = getRelocationTypeName(Type);
391
2.10k
    Result.append(Name.begin(), Name.end());
392
2.10k
  } 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.20k
}
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.82k
                                   const Elf_Shdr *SymTab) const {
426
3.82k
  uint32_t Index = Rel->getSymbol(isMips64EL());
427
3.82k
  if (Index == 0)
428
583
    return nullptr;
429
3.23k
  return getEntry<Elf_Sym>(SymTab, Index);
430
3.23k
}
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.02k
                                   const Elf_Shdr *SymTab) const {
426
1.02k
  uint32_t Index = Rel->getSymbol(isMips64EL());
427
1.02k
  if (Index == 0)
428
190
    return nullptr;
429
835
  return getEntry<Elf_Sym>(SymTab, Index);
430
835
}
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
277
                                   const Elf_Shdr *SymTab) const {
426
277
  uint32_t Index = Rel->getSymbol(isMips64EL());
427
277
  if (Index == 0)
428
81
    return nullptr;
429
196
  return getEntry<Elf_Sym>(SymTab, Index);
430
196
}
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.74k
                                   const Elf_Shdr *SymTab) const {
426
1.74k
  uint32_t Index = Rel->getSymbol(isMips64EL());
427
1.74k
  if (Index == 0)
428
218
    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
971k
ELFFile<ELFT>::getSectionStringTable(Elf_Shdr_Range Sections) const {
435
971k
  uint32_t Index = getHeader()->e_shstrndx;
436
971k
  if (Index == ELF::SHN_XINDEX)
437
522k
    Index = Sections[0].sh_link;
438
971k
439
971k
  if (!Index) // no section string table.
440
12
    return "";
441
971k
  if (Index >= Sections.size())
442
0
    return createError("invalid section index");
443
971k
  return getStringTable(&Sections[Index]);
444
971k
}
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.71k
ELFFile<ELFT>::getSectionStringTable(Elf_Shdr_Range Sections) const {
435
9.71k
  uint32_t Index = getHeader()->e_shstrndx;
436
9.71k
  if (Index == ELF::SHN_XINDEX)
437
0
    Index = Sections[0].sh_link;
438
9.71k
439
9.71k
  if (!Index) // no section string table.
440
4
    return "";
441
9.71k
  if (Index >= Sections.size())
442
0
    return createError("invalid section index");
443
9.71k
  return getStringTable(&Sections[Index]);
444
9.71k
}
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.21k
ELFFile<ELFT>::getSectionStringTable(Elf_Shdr_Range Sections) const {
435
3.21k
  uint32_t Index = getHeader()->e_shstrndx;
436
3.21k
  if (Index == ELF::SHN_XINDEX)
437
0
    Index = Sections[0].sh_link;
438
3.21k
439
3.21k
  if (!Index) // no section string table.
440
0
    return "";
441
3.21k
  if (Index >= Sections.size())
442
0
    return createError("invalid section index");
443
3.21k
  return getStringTable(&Sections[Index]);
444
3.21k
}
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
956k
ELFFile<ELFT>::getSectionStringTable(Elf_Shdr_Range Sections) const {
435
956k
  uint32_t Index = getHeader()->e_shstrndx;
436
956k
  if (Index == ELF::SHN_XINDEX)
437
522k
    Index = Sections[0].sh_link;
438
956k
439
956k
  if (!Index) // no section string table.
440
8
    return "";
441
956k
  if (Index >= Sections.size())
442
0
    return createError("invalid section index");
443
956k
  return getStringTable(&Sections[Index]);
444
956k
}
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.51k
ELFFile<ELFT>::getSectionStringTable(Elf_Shdr_Range Sections) const {
435
2.51k
  uint32_t Index = getHeader()->e_shstrndx;
436
2.51k
  if (Index == ELF::SHN_XINDEX)
437
0
    Index = Sections[0].sh_link;
438
2.51k
439
2.51k
  if (!Index) // no section string table.
440
0
    return "";
441
2.51k
  if (Index >= Sections.size())
442
0
    return createError("invalid section index");
443
2.51k
  return getStringTable(&Sections[Index]);
444
2.51k
}
445
446
786k
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.56k
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.12k
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
760k
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.7k
template <class ELFT> ELFFile<ELFT>::ELFFile(StringRef Object) : Buf(Object) {}
447
448
template <class ELFT>
449
786k
Expected<ELFFile<ELFT>> ELFFile<ELFT>::create(StringRef Object) {
450
786k
  if (sizeof(Elf_Ehdr) > Object.size())
451
1
    return createError("Invalid buffer");
452
786k
  return ELFFile(Object);
453
786k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::create(llvm::StringRef)
Line
Count
Source
449
8.57k
Expected<ELFFile<ELFT>> ELFFile<ELFT>::create(StringRef Object) {
450
8.57k
  if (sizeof(Elf_Ehdr) > Object.size())
451
1
    return createError("Invalid buffer");
452
8.56k
  return ELFFile(Object);
453
8.56k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::create(llvm::StringRef)
Line
Count
Source
449
4.12k
Expected<ELFFile<ELFT>> ELFFile<ELFT>::create(StringRef Object) {
450
4.12k
  if (sizeof(Elf_Ehdr) > Object.size())
451
0
    return createError("Invalid buffer");
452
4.12k
  return ELFFile(Object);
453
4.12k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::create(llvm::StringRef)
Line
Count
Source
449
760k
Expected<ELFFile<ELFT>> ELFFile<ELFT>::create(StringRef Object) {
450
760k
  if (sizeof(Elf_Ehdr) > Object.size())
451
0
    return createError("Invalid buffer");
452
760k
  return ELFFile(Object);
453
760k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::create(llvm::StringRef)
Line
Count
Source
449
12.7k
Expected<ELFFile<ELFT>> ELFFile<ELFT>::create(StringRef Object) {
450
12.7k
  if (sizeof(Elf_Ehdr) > Object.size())
451
0
    return createError("Invalid buffer");
452
12.7k
  return ELFFile(Object);
453
12.7k
}
454
455
template <class ELFT>
456
1.50M
Expected<typename ELFT::ShdrRange> ELFFile<ELFT>::sections() const {
457
1.50M
  const uintX_t SectionTableOffset = getHeader()->e_shoff;
458
1.50M
  if (SectionTableOffset == 0)
459
26
    return ArrayRef<Elf_Shdr>();
460
1.50M
461
1.50M
  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.50M
465
1.50M
  const uint64_t FileSize = Buf.size();
466
1.50M
467
1.50M
  if (SectionTableOffset + sizeof(Elf_Shdr) > FileSize)
468
1
    return createError("section header table goes past the end of the file");
469
1.50M
470
1.50M
  // Invalid address alignment of section headers
471
1.50M
  if (SectionTableOffset & (alignof(Elf_Shdr) - 1))
472
0
    return createError("invalid alignment of section headers");
473
1.50M
474
1.50M
  const Elf_Shdr *First =
475
1.50M
      reinterpret_cast<const Elf_Shdr *>(base() + SectionTableOffset);
476
1.50M
477
1.50M
  uintX_t NumSections = getHeader()->e_shnum;
478
1.50M
  if (NumSections == 0)
479
849k
    NumSections = First->sh_size;
480
1.50M
481
1.50M
  if (NumSections > UINT64_MAX / sizeof(Elf_Shdr))
482
1
    return createError("section table goes past the end of file");
483
1.50M
484
1.50M
  const uint64_t SectionTableSize = NumSections * sizeof(Elf_Shdr);
485
1.50M
486
1.50M
  // Section table goes past end of file!
487
1.50M
  if (SectionTableOffset + SectionTableSize > FileSize)
488
0
    return createError("section table goes past the end of file");
489
1.50M
490
1.50M
  return makeArrayRef(First, NumSections);
491
1.50M
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::sections() const
Line
Count
Source
456
151k
Expected<typename ELFT::ShdrRange> ELFFile<ELFT>::sections() const {
457
151k
  const uintX_t SectionTableOffset = getHeader()->e_shoff;
458
151k
  if (SectionTableOffset == 0)
459
0
    return ArrayRef<Elf_Shdr>();
460
151k
461
151k
  if (getHeader()->e_shentsize != sizeof(Elf_Shdr))
462
0
    return createError(
463
0
        "invalid section header entry size (e_shentsize) in ELF header");
464
151k
465
151k
  const uint64_t FileSize = Buf.size();
466
151k
467
151k
  if (SectionTableOffset + sizeof(Elf_Shdr) > FileSize)
468
0
    return createError("section header table goes past the end of the file");
469
151k
470
151k
  // Invalid address alignment of section headers
471
151k
  if (SectionTableOffset & (alignof(Elf_Shdr) - 1))
472
0
    return createError("invalid alignment of section headers");
473
151k
474
151k
  const Elf_Shdr *First =
475
151k
      reinterpret_cast<const Elf_Shdr *>(base() + SectionTableOffset);
476
151k
477
151k
  uintX_t NumSections = getHeader()->e_shnum;
478
151k
  if (NumSections == 0)
479
0
    NumSections = First->sh_size;
480
151k
481
151k
  if (NumSections > UINT64_MAX / sizeof(Elf_Shdr))
482
0
    return createError("section table goes past the end of file");
483
151k
484
151k
  const uint64_t SectionTableSize = NumSections * sizeof(Elf_Shdr);
485
151k
486
151k
  // Section table goes past end of file!
487
151k
  if (SectionTableOffset + SectionTableSize > FileSize)
488
0
    return createError("section table goes past the end of file");
489
151k
490
151k
  return makeArrayRef(First, NumSections);
491
151k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::sections() const
Line
Count
Source
456
20.3k
Expected<typename ELFT::ShdrRange> ELFFile<ELFT>::sections() const {
457
20.3k
  const uintX_t SectionTableOffset = getHeader()->e_shoff;
458
20.3k
  if (SectionTableOffset == 0)
459
0
    return ArrayRef<Elf_Shdr>();
460
20.3k
461
20.3k
  if (getHeader()->e_shentsize != sizeof(Elf_Shdr))
462
0
    return createError(
463
0
        "invalid section header entry size (e_shentsize) in ELF header");
464
20.3k
465
20.3k
  const uint64_t FileSize = Buf.size();
466
20.3k
467
20.3k
  if (SectionTableOffset + sizeof(Elf_Shdr) > FileSize)
468
0
    return createError("section header table goes past the end of the file");
469
20.3k
470
20.3k
  // Invalid address alignment of section headers
471
20.3k
  if (SectionTableOffset & (alignof(Elf_Shdr) - 1))
472
0
    return createError("invalid alignment of section headers");
473
20.3k
474
20.3k
  const Elf_Shdr *First =
475
20.3k
      reinterpret_cast<const Elf_Shdr *>(base() + SectionTableOffset);
476
20.3k
477
20.3k
  uintX_t NumSections = getHeader()->e_shnum;
478
20.3k
  if (NumSections == 0)
479
0
    NumSections = First->sh_size;
480
20.3k
481
20.3k
  if (NumSections > UINT64_MAX / sizeof(Elf_Shdr))
482
0
    return createError("section table goes past the end of file");
483
20.3k
484
20.3k
  const uint64_t SectionTableSize = NumSections * sizeof(Elf_Shdr);
485
20.3k
486
20.3k
  // Section table goes past end of file!
487
20.3k
  if (SectionTableOffset + SectionTableSize > FileSize)
488
0
    return createError("section table goes past the end of file");
489
20.3k
490
20.3k
  return makeArrayRef(First, NumSections);
491
20.3k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::sections() const
Line
Count
Source
456
1.31M
Expected<typename ELFT::ShdrRange> ELFFile<ELFT>::sections() const {
457
1.31M
  const uintX_t SectionTableOffset = getHeader()->e_shoff;
458
1.31M
  if (SectionTableOffset == 0)
459
26
    return ArrayRef<Elf_Shdr>();
460
1.31M
461
1.31M
  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.31M
465
1.31M
  const uint64_t FileSize = Buf.size();
466
1.31M
467
1.31M
  if (SectionTableOffset + sizeof(Elf_Shdr) > FileSize)
468
1
    return createError("section header table goes past the end of the file");
469
1.31M
470
1.31M
  // Invalid address alignment of section headers
471
1.31M
  if (SectionTableOffset & (alignof(Elf_Shdr) - 1))
472
0
    return createError("invalid alignment of section headers");
473
1.31M
474
1.31M
  const Elf_Shdr *First =
475
1.31M
      reinterpret_cast<const Elf_Shdr *>(base() + SectionTableOffset);
476
1.31M
477
1.31M
  uintX_t NumSections = getHeader()->e_shnum;
478
1.31M
  if (NumSections == 0)
479
849k
    NumSections = First->sh_size;
480
1.31M
481
1.31M
  if (NumSections > UINT64_MAX / sizeof(Elf_Shdr))
482
1
    return createError("section table goes past the end of file");
483
1.31M
484
1.31M
  const uint64_t SectionTableSize = NumSections * sizeof(Elf_Shdr);
485
1.31M
486
1.31M
  // Section table goes past end of file!
487
1.31M
  if (SectionTableOffset + SectionTableSize > FileSize)
488
0
    return createError("section table goes past the end of file");
489
1.31M
490
1.31M
  return makeArrayRef(First, NumSections);
491
1.31M
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::sections() const
Line
Count
Source
456
16.3k
Expected<typename ELFT::ShdrRange> ELFFile<ELFT>::sections() const {
457
16.3k
  const uintX_t SectionTableOffset = getHeader()->e_shoff;
458
16.3k
  if (SectionTableOffset == 0)
459
0
    return ArrayRef<Elf_Shdr>();
460
16.3k
461
16.3k
  if (getHeader()->e_shentsize != sizeof(Elf_Shdr))
462
0
    return createError(
463
0
        "invalid section header entry size (e_shentsize) in ELF header");
464
16.3k
465
16.3k
  const uint64_t FileSize = Buf.size();
466
16.3k
467
16.3k
  if (SectionTableOffset + sizeof(Elf_Shdr) > FileSize)
468
0
    return createError("section header table goes past the end of the file");
469
16.3k
470
16.3k
  // Invalid address alignment of section headers
471
16.3k
  if (SectionTableOffset & (alignof(Elf_Shdr) - 1))
472
0
    return createError("invalid alignment of section headers");
473
16.3k
474
16.3k
  const Elf_Shdr *First =
475
16.3k
      reinterpret_cast<const Elf_Shdr *>(base() + SectionTableOffset);
476
16.3k
477
16.3k
  uintX_t NumSections = getHeader()->e_shnum;
478
16.3k
  if (NumSections == 0)
479
0
    NumSections = First->sh_size;
480
16.3k
481
16.3k
  if (NumSections > UINT64_MAX / sizeof(Elf_Shdr))
482
0
    return createError("section table goes past the end of file");
483
16.3k
484
16.3k
  const uint64_t SectionTableSize = NumSections * sizeof(Elf_Shdr);
485
16.3k
486
16.3k
  // Section table goes past end of file!
487
16.3k
  if (SectionTableOffset + SectionTableSize > FileSize)
488
0
    return createError("section table goes past the end of file");
489
16.3k
490
16.3k
  return makeArrayRef(First, NumSections);
491
16.3k
}
492
493
template <class ELFT>
494
template <typename T>
495
Expected<const T *> ELFFile<ELFT>::getEntry(uint32_t Section,
496
193k
                                            uint32_t Entry) const {
497
193k
  auto SecOrErr = getSection(Section);
498
193k
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
193k
  return getEntry<T>(*SecOrErr, Entry);
501
193k
}
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.5k
                                            uint32_t Entry) const {
497
54.5k
  auto SecOrErr = getSection(Section);
498
54.5k
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
54.5k
  return getEntry<T>(*SecOrErr, Entry);
501
54.5k
}
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.73k
                                            uint32_t Entry) const {
497
1.73k
  auto SecOrErr = getSection(Section);
498
1.73k
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
1.73k
  return getEntry<T>(*SecOrErr, Entry);
501
1.73k
}
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
729
                                            uint32_t Entry) const {
497
729
  auto SecOrErr = getSection(Section);
498
729
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
729
  return getEntry<T>(*SecOrErr, Entry);
501
729
}
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.81k
                                            uint32_t Entry) const {
497
4.81k
  auto SecOrErr = getSection(Section);
498
4.81k
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
4.81k
  return getEntry<T>(*SecOrErr, Entry);
501
4.81k
}
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
598
                                            uint32_t Entry) const {
497
598
  auto SecOrErr = getSection(Section);
498
598
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
598
  return getEntry<T>(*SecOrErr, Entry);
501
598
}
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
410
                                            uint32_t Entry) const {
497
410
  auto SecOrErr = getSection(Section);
498
410
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
410
  return getEntry<T>(*SecOrErr, Entry);
501
410
}
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
106k
                                            uint32_t Entry) const {
497
106k
  auto SecOrErr = getSection(Section);
498
106k
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
106k
  return getEntry<T>(*SecOrErr, Entry);
501
106k
}
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
101
                                            uint32_t Entry) const {
497
101
  auto SecOrErr = getSection(Section);
498
101
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
101
  return getEntry<T>(*SecOrErr, Entry);
501
101
}
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
20.1k
                                            uint32_t Entry) const {
497
20.1k
  auto SecOrErr = getSection(Section);
498
20.1k
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
20.1k
  return getEntry<T>(*SecOrErr, Entry);
501
20.1k
}
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.39k
                                            uint32_t Entry) const {
497
3.39k
  auto SecOrErr = getSection(Section);
498
3.39k
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
3.39k
  return getEntry<T>(*SecOrErr, Entry);
501
3.39k
}
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
54
                                            uint32_t Entry) const {
497
54
  auto SecOrErr = getSection(Section);
498
54
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
54
  return getEntry<T>(*SecOrErr, Entry);
501
54
}
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
930
                                            uint32_t Entry) const {
497
930
  auto SecOrErr = getSection(Section);
498
930
  if (!SecOrErr)
499
0
    return SecOrErr.takeError();
500
930
  return getEntry<T>(*SecOrErr, Entry);
501
930
}
502
503
template <class ELFT>
504
template <typename T>
505
Expected<const T *> ELFFile<ELFT>::getEntry(const Elf_Shdr *Section,
506
196k
                                            uint32_t Entry) const {
507
196k
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
196k
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
196k
  if (Pos + sizeof(T) > Buf.size())
511
1
    return createError("invalid section offset");
512
196k
  return reinterpret_cast<const T *>(base() + Pos);
513
196k
}
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.4k
                                            uint32_t Entry) const {
507
55.4k
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
55.4k
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
55.4k
  if (Pos + sizeof(T) > Buf.size())
511
0
    return createError("invalid section offset");
512
55.4k
  return reinterpret_cast<const T *>(base() + Pos);
513
55.4k
}
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
5.01k
                                            uint32_t Entry) const {
507
5.01k
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
5.01k
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
5.01k
  if (Pos + sizeof(T) > Buf.size())
511
0
    return createError("invalid section offset");
512
5.01k
  return reinterpret_cast<const T *>(base() + Pos);
513
5.01k
}
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
107k
                                            uint32_t Entry) const {
507
107k
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
107k
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
107k
  if (Pos + sizeof(T) > Buf.size())
511
1
    return createError("invalid section offset");
512
107k
  return reinterpret_cast<const T *>(base() + Pos);
513
107k
}
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
4.08k
                                            uint32_t Entry) const {
507
4.08k
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
4.08k
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
4.08k
  if (Pos + sizeof(T) > Buf.size())
511
0
    return createError("invalid section offset");
512
4.08k
  return reinterpret_cast<const T *>(base() + Pos);
513
4.08k
}
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.73k
                                            uint32_t Entry) const {
507
1.73k
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
1.73k
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
1.73k
  if (Pos + sizeof(T) > Buf.size())
511
0
    return createError("invalid section offset");
512
1.73k
  return reinterpret_cast<const T *>(base() + Pos);
513
1.73k
}
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
729
                                            uint32_t Entry) const {
507
729
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
729
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
729
  if (Pos + sizeof(T) > Buf.size())
511
0
    return createError("invalid section offset");
512
729
  return reinterpret_cast<const T *>(base() + Pos);
513
729
}
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
598
                                            uint32_t Entry) const {
507
598
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
598
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
598
  if (Pos + sizeof(T) > Buf.size())
511
0
    return createError("invalid section offset");
512
598
  return reinterpret_cast<const T *>(base() + Pos);
513
598
}
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
410
                                            uint32_t Entry) const {
507
410
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
410
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
410
  if (Pos + sizeof(T) > Buf.size())
511
0
    return createError("invalid section offset");
512
410
  return reinterpret_cast<const T *>(base() + Pos);
513
410
}
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
101
                                            uint32_t Entry) const {
507
101
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
101
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
101
  if (Pos + sizeof(T) > Buf.size())
511
0
    return createError("invalid section offset");
512
101
  return reinterpret_cast<const T *>(base() + Pos);
513
101
}
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
20.1k
                                            uint32_t Entry) const {
507
20.1k
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
20.1k
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
20.1k
  if (Pos + sizeof(T) > Buf.size())
511
0
    return createError("invalid section offset");
512
20.1k
  return reinterpret_cast<const T *>(base() + Pos);
513
20.1k
}
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
54
                                            uint32_t Entry) const {
507
54
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
54
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
54
  if (Pos + sizeof(T) > Buf.size())
511
0
    return createError("invalid section offset");
512
54
  return reinterpret_cast<const T *>(base() + Pos);
513
54
}
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
930
                                            uint32_t Entry) const {
507
930
  if (sizeof(T) != Section->sh_entsize)
508
0
    return createError("invalid sh_entsize");
509
930
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510
930
  if (Pos + sizeof(T) > Buf.size())
511
0
    return createError("invalid section offset");
512
930
  return reinterpret_cast<const T *>(base() + Pos);
513
930
}
514
515
template <class ELFT>
516
Expected<const typename ELFT::Shdr *>
517
420k
ELFFile<ELFT>::getSection(uint32_t Index) const {
518
420k
  auto TableOrErr = sections();
519
420k
  if (!TableOrErr)
520
0
    return TableOrErr.takeError();
521
420k
  return object::getSection<ELFT>(*TableOrErr, Index);
522
420k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSection(unsigned int) const
Line
Count
Source
517
115k
ELFFile<ELFT>::getSection(uint32_t Index) const {
518
115k
  auto TableOrErr = sections();
519
115k
  if (!TableOrErr)
520
0
    return TableOrErr.takeError();
521
115k
  return object::getSection<ELFT>(*TableOrErr, Index);
522
115k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSection(unsigned int) const
Line
Count
Source
517
11.1k
ELFFile<ELFT>::getSection(uint32_t Index) const {
518
11.1k
  auto TableOrErr = sections();
519
11.1k
  if (!TableOrErr)
520
0
    return TableOrErr.takeError();
521
11.1k
  return object::getSection<ELFT>(*TableOrErr, Index);
522
11.1k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSection(unsigned int) const
Line
Count
Source
517
285k
ELFFile<ELFT>::getSection(uint32_t Index) const {
518
285k
  auto TableOrErr = sections();
519
285k
  if (!TableOrErr)
520
0
    return TableOrErr.takeError();
521
285k
  return object::getSection<ELFT>(*TableOrErr, Index);
522
285k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSection(unsigned int) const
Line
Count
Source
517
8.56k
ELFFile<ELFT>::getSection(uint32_t Index) const {
518
8.56k
  auto TableOrErr = sections();
519
8.56k
  if (!TableOrErr)
520
0
    return TableOrErr.takeError();
521
8.56k
  return object::getSection<ELFT>(*TableOrErr, Index);
522
8.56k
}
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.7k
ELFFile<ELFT>::getStringTable(const Elf_Shdr *Section) const {
543
25.7k
  if (Section->sh_type != ELF::SHT_STRTAB)
544
0
    return createError("invalid sh_type for string table, expected SHT_STRTAB");
545
25.7k
  auto V = getSectionContentsAsArray<char>(Section);
546
25.7k
  if (!V)
547
1
    return V.takeError();
548
25.7k
  ArrayRef<char> Data = *V;
549
25.7k
  if (Data.empty())
550
0
    return createError("empty string table");
551
25.7k
  if (Data.back() != '\0')
552
0
    return createError("string table non-null terminated");
553
25.7k
  return StringRef(Data.begin(), Data.size());
554
25.7k
}
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.41k
ELFFile<ELFT>::getStringTable(const Elf_Shdr *Section) const {
543
4.41k
  if (Section->sh_type != ELF::SHT_STRTAB)
544
0
    return createError("invalid sh_type for string table, expected SHT_STRTAB");
545
4.41k
  auto V = getSectionContentsAsArray<char>(Section);
546
4.41k
  if (!V)
547
0
    return V.takeError();
548
4.41k
  ArrayRef<char> Data = *V;
549
4.41k
  if (Data.empty())
550
0
    return createError("empty string table");
551
4.41k
  if (Data.back() != '\0')
552
0
    return createError("string table non-null terminated");
553
4.41k
  return StringRef(Data.begin(), Data.size());
554
4.41k
}
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
979k
ELFFile<ELFT>::getStringTable(const Elf_Shdr *Section) const {
543
979k
  if (Section->sh_type != ELF::SHT_STRTAB)
544
1
    return createError("invalid sh_type for string table, expected SHT_STRTAB");
545
979k
  auto V = getSectionContentsAsArray<char>(Section);
546
979k
  if (!V)
547
1
    return V.takeError();
548
979k
  ArrayRef<char> Data = *V;
549
979k
  if (Data.empty())
550
1
    return createError("empty string table");
551
979k
  if (Data.back() != '\0')
552
1
    return createError("string table non-null terminated");
553
979k
  return StringRef(Data.begin(), Data.size());
554
979k
}
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.79k
ELFFile<ELFT>::getStringTable(const Elf_Shdr *Section) const {
543
3.79k
  if (Section->sh_type != ELF::SHT_STRTAB)
544
0
    return createError("invalid sh_type for string table, expected SHT_STRTAB");
545
3.79k
  auto V = getSectionContentsAsArray<char>(Section);
546
3.79k
  if (!V)
547
0
    return V.takeError();
548
3.79k
  ArrayRef<char> Data = *V;
549
3.79k
  if (Data.empty())
550
0
    return createError("empty string table");
551
3.79k
  if (Data.back() != '\0')
552
0
    return createError("string table non-null terminated");
553
3.79k
  return StringRef(Data.begin(), Data.size());
554
3.79k
}
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.11k
ELFFile<ELFT>::getStringTableForSymtab(const Elf_Shdr &Sec) const {
589
4.11k
  auto SectionsOrErr = sections();
590
4.11k
  if (!SectionsOrErr)
591
0
    return SectionsOrErr.takeError();
592
4.11k
  return getStringTableForSymtab(Sec, *SectionsOrErr);
593
4.11k
}
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
884
ELFFile<ELFT>::getStringTableForSymtab(const Elf_Shdr &Sec) const {
589
884
  auto SectionsOrErr = sections();
590
884
  if (!SectionsOrErr)
591
0
    return SectionsOrErr.takeError();
592
884
  return getStringTableForSymtab(Sec, *SectionsOrErr);
593
884
}
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
245
ELFFile<ELFT>::getStringTableForSymtab(const Elf_Shdr &Sec) const {
589
245
  auto SectionsOrErr = sections();
590
245
  if (!SectionsOrErr)
591
0
    return SectionsOrErr.takeError();
592
245
  return getStringTableForSymtab(Sec, *SectionsOrErr);
593
245
}
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.41k
ELFFile<ELFT>::getStringTableForSymtab(const Elf_Shdr &Sec) const {
589
2.41k
  auto SectionsOrErr = sections();
590
2.41k
  if (!SectionsOrErr)
591
0
    return SectionsOrErr.takeError();
592
2.41k
  return getStringTableForSymtab(Sec, *SectionsOrErr);
593
2.41k
}
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.45k
                                       Elf_Shdr_Range Sections) const {
599
7.45k
600
7.45k
  if (Sec.sh_type != ELF::SHT_SYMTAB && 
Sec.sh_type != ELF::SHT_DYNSYM1.34k
)
601
0
    return createError(
602
0
        "invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM");
603
7.45k
  auto SectionOrErr = object::getSection<ELFT>(Sections, Sec.sh_link);
604
7.45k
  if (!SectionOrErr)
605
1
    return SectionOrErr.takeError();
606
7.45k
  return getStringTable(*SectionOrErr);
607
7.45k
}
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.30k
                                       Elf_Shdr_Range Sections) const {
599
1.30k
600
1.30k
  if (Sec.sh_type != ELF::SHT_SYMTAB && 
Sec.sh_type != ELF::SHT_DYNSYM233
)
601
0
    return createError(
602
0
        "invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM");
603
1.30k
  auto SectionOrErr = object::getSection<ELFT>(Sections, Sec.sh_link);
604
1.30k
  if (!SectionOrErr)
605
0
    return SectionOrErr.takeError();
606
1.30k
  return getStringTable(*SectionOrErr);
607
1.30k
}
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
426
                                       Elf_Shdr_Range Sections) const {
599
426
600
426
  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
426
  auto SectionOrErr = object::getSection<ELFT>(Sections, Sec.sh_link);
604
426
  if (!SectionOrErr)
605
0
    return SectionOrErr.takeError();
606
426
  return getStringTable(*SectionOrErr);
607
426
}
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.99k
                                       Elf_Shdr_Range Sections) const {
599
4.99k
600
4.99k
  if (Sec.sh_type != ELF::SHT_SYMTAB && 
Sec.sh_type != ELF::SHT_DYNSYM930
)
601
0
    return createError(
602
0
        "invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM");
603
4.99k
  auto SectionOrErr = object::getSection<ELFT>(Sections, Sec.sh_link);
604
4.99k
  if (!SectionOrErr)
605
1
    return SectionOrErr.takeError();
606
4.99k
  return getStringTable(*SectionOrErr);
607
4.99k
}
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
727
                                       Elf_Shdr_Range Sections) const {
599
727
600
727
  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
727
  auto SectionOrErr = object::getSection<ELFT>(Sections, Sec.sh_link);
604
727
  if (!SectionOrErr)
605
0
    return SectionOrErr.takeError();
606
727
  return getStringTable(*SectionOrErr);
607
727
}
608
609
template <class ELFT>
610
Expected<StringRef>
611
968k
ELFFile<ELFT>::getSectionName(const Elf_Shdr *Section) const {
612
968k
  auto SectionsOrErr = sections();
613
968k
  if (!SectionsOrErr)
614
0
    return SectionsOrErr.takeError();
615
968k
  auto Table = getSectionStringTable(*SectionsOrErr);
616
968k
  if (!Table)
617
5
    return Table.takeError();
618
968k
  return getSectionName(Section, *Table);
619
968k
}
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.35k
ELFFile<ELFT>::getSectionName(const Elf_Shdr *Section) const {
612
9.35k
  auto SectionsOrErr = sections();
613
9.35k
  if (!SectionsOrErr)
614
0
    return SectionsOrErr.takeError();
615
9.35k
  auto Table = getSectionStringTable(*SectionsOrErr);
616
9.35k
  if (!Table)
617
1
    return Table.takeError();
618
9.35k
  return getSectionName(Section, *Table);
619
9.35k
}
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
3.06k
ELFFile<ELFT>::getSectionName(const Elf_Shdr *Section) const {
612
3.06k
  auto SectionsOrErr = sections();
613
3.06k
  if (!SectionsOrErr)
614
0
    return SectionsOrErr.takeError();
615
3.06k
  auto Table = getSectionStringTable(*SectionsOrErr);
616
3.06k
  if (!Table)
617
0
    return Table.takeError();
618
3.06k
  return getSectionName(Section, *Table);
619
3.06k
}
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
954k
ELFFile<ELFT>::getSectionName(const Elf_Shdr *Section) const {
612
954k
  auto SectionsOrErr = sections();
613
954k
  if (!SectionsOrErr)
614
0
    return SectionsOrErr.takeError();
615
954k
  auto Table = getSectionStringTable(*SectionsOrErr);
616
954k
  if (!Table)
617
4
    return Table.takeError();
618
954k
  return getSectionName(Section, *Table);
619
954k
}
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.38k
ELFFile<ELFT>::getSectionName(const Elf_Shdr *Section) const {
612
2.38k
  auto SectionsOrErr = sections();
613
2.38k
  if (!SectionsOrErr)
614
0
    return SectionsOrErr.takeError();
615
2.38k
  auto Table = getSectionStringTable(*SectionsOrErr);
616
2.38k
  if (!Table)
617
0
    return Table.takeError();
618
2.38k
  return getSectionName(Section, *Table);
619
2.38k
}
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.98k
    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.8k
                                                  StringRef DotShstrtab) const {
624
10.8k
  uint32_t Offset = Section->sh_name;
625
10.8k
  if (Offset == 0)
626
766
    return StringRef();
627
10.0k
  if (Offset >= DotShstrtab.size())
628
28
    return createError("invalid string offset");
629
10.0k
  return StringRef(DotShstrtab.data() + Offset);
630
10.0k
}
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.97k
                                                  StringRef DotShstrtab) const {
624
3.97k
  uint32_t Offset = Section->sh_name;
625
3.97k
  if (Offset == 0)
626
219
    return StringRef();
627
3.75k
  if (Offset >= DotShstrtab.size())
628
0
    return createError("invalid string offset");
629
3.75k
  return StringRef(DotShstrtab.data() + Offset);
630
3.75k
}
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.84k
    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.87k
                                                  StringRef DotShstrtab) const {
624
2.87k
  uint32_t Offset = Section->sh_name;
625
2.87k
  if (Offset == 0)
626
149
    return StringRef();
627
2.72k
  if (Offset >= DotShstrtab.size())
628
0
    return createError("invalid string offset");
629
2.72k
  return StringRef(DotShstrtab.data() + Offset);
630
2.72k
}
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