Coverage Report

Created: 2019-02-20 00:17

/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
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file declares the ELFFile template class.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_OBJECT_ELF_H
14
#define LLVM_OBJECT_ELF_H
15
16
#include "llvm/ADT/ArrayRef.h"
17
#include "llvm/ADT/SmallVector.h"
18
#include "llvm/ADT/StringRef.h"
19
#include "llvm/BinaryFormat/ELF.h"
20
#include "llvm/Object/ELFTypes.h"
21
#include "llvm/Object/Error.h"
22
#include "llvm/Support/Endian.h"
23
#include "llvm/Support/Error.h"
24
#include <cassert>
25
#include <cstddef>
26
#include <cstdint>
27
#include <limits>
28
#include <utility>
29
30
namespace llvm {
31
namespace object {
32
33
StringRef getELFRelocationTypeName(uint32_t Machine, uint32_t Type);
34
uint32_t getELFRelativeRelocationType(uint32_t Machine);
35
StringRef getELFSectionTypeName(uint32_t Machine, uint32_t Type);
36
37
// Subclasses of ELFFile may need this for template instantiation
38
inline std::pair<unsigned char, unsigned char>
39
9.58k
getElfArchType(StringRef Object) {
40
9.58k
  if (Object.size() < ELF::EI_NIDENT)
41
0
    return std::make_pair((uint8_t)ELF::ELFCLASSNONE,
42
0
                          (uint8_t)ELF::ELFDATANONE);
43
9.58k
  return std::make_pair((uint8_t)Object[ELF::EI_CLASS],
44
9.58k
                        (uint8_t)Object[ELF::EI_DATA]);
45
9.58k
}
46
47
44
static inline Error createError(StringRef Err) {
48
44
  return make_error<StringError>(Err, object_error::parse_failed);
49
44
}
ELF.cpp:llvm::object::createError(llvm::StringRef)
Line
Count
Source
47
11
static inline Error createError(StringRef Err) {
48
11
  return make_error<StringError>(Err, object_error::parse_failed);
49
11
}
ELFObjectFile.cpp:llvm::object::createError(llvm::StringRef)
Line
Count
Source
47
33
static inline Error createError(StringRef Err) {
48
33
  return make_error<StringError>(Err, object_error::parse_failed);
49
33
}
50
51
template <class ELFT>
52
class ELFFile {
53
public:
54
  LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
55
  using uintX_t = typename ELFT::uint;
56
  using Elf_Ehdr = typename ELFT::Ehdr;
57
  using Elf_Shdr = typename ELFT::Shdr;
58
  using Elf_Sym = typename ELFT::Sym;
59
  using Elf_Dyn = typename ELFT::Dyn;
60
  using Elf_Phdr = typename ELFT::Phdr;
61
  using Elf_Rel = typename ELFT::Rel;
62
  using Elf_Rela = typename ELFT::Rela;
63
  using Elf_Relr = typename ELFT::Relr;
64
  using Elf_Verdef = typename ELFT::Verdef;
65
  using Elf_Verdaux = typename ELFT::Verdaux;
66
  using Elf_Verneed = typename ELFT::Verneed;
67
  using Elf_Vernaux = typename ELFT::Vernaux;
68
  using Elf_Versym = typename ELFT::Versym;
69
  using Elf_Hash = typename ELFT::Hash;
70
  using Elf_GnuHash = typename ELFT::GnuHash;
71
  using Elf_Nhdr = typename ELFT::Nhdr;
72
  using Elf_Note = typename ELFT::Note;
73
  using Elf_Note_Iterator = typename ELFT::NoteIterator;
74
  using Elf_Dyn_Range = typename ELFT::DynRange;
75
  using Elf_Shdr_Range = typename ELFT::ShdrRange;
76
  using Elf_Sym_Range = typename ELFT::SymRange;
77
  using Elf_Rel_Range = typename ELFT::RelRange;
78
  using Elf_Rela_Range = typename ELFT::RelaRange;
79
  using Elf_Relr_Range = typename ELFT::RelrRange;
80
  using Elf_Phdr_Range = typename ELFT::PhdrRange;
81
82
10.7M
  const uint8_t *base() const {
83
10.7M
    return reinterpret_cast<const uint8_t *>(Buf.data());
84
10.7M
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::base() const
Line
Count
Source
82
988k
  const uint8_t *base() const {
83
988k
    return reinterpret_cast<const uint8_t *>(Buf.data());
84
988k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::base() const
Line
Count
Source
82
142k
  const uint8_t *base() const {
83
142k
    return reinterpret_cast<const uint8_t *>(Buf.data());
84
142k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::base() const
Line
Count
Source
82
9.50M
  const uint8_t *base() const {
83
9.50M
    return reinterpret_cast<const uint8_t *>(Buf.data());
84
9.50M
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::base() const
Line
Count
Source
82
125k
  const uint8_t *base() const {
83
125k
    return reinterpret_cast<const uint8_t *>(Buf.data());
84
125k
  }
85
86
9.31k
  size_t getBufSize() const { return Buf.size(); }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getBufSize() const
Line
Count
Source
86
1.32k
  size_t getBufSize() const { return Buf.size(); }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getBufSize() const
Line
Count
Source
86
456
  size_t getBufSize() const { return Buf.size(); }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getBufSize() const
Line
Count
Source
86
7.09k
  size_t getBufSize() const { return Buf.size(); }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getBufSize() const
Line
Count
Source
86
432
  size_t getBufSize() const { return Buf.size(); }
87
88
private:
89
  StringRef Buf;
90
91
  ELFFile(StringRef Object);
92
93
public:
94
7.19M
  const Elf_Ehdr *getHeader() const {
95
7.19M
    return reinterpret_cast<const Elf_Ehdr *>(base());
96
7.19M
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getHeader() const
Line
Count
Source
94
723k
  const Elf_Ehdr *getHeader() const {
95
723k
    return reinterpret_cast<const Elf_Ehdr *>(base());
96
723k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getHeader() const
Line
Count
Source
94
104k
  const Elf_Ehdr *getHeader() const {
95
104k
    return reinterpret_cast<const Elf_Ehdr *>(base());
96
104k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getHeader() const
Line
Count
Source
94
6.27M
  const Elf_Ehdr *getHeader() const {
95
6.27M
    return reinterpret_cast<const Elf_Ehdr *>(base());
96
6.27M
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getHeader() const
Line
Count
Source
94
94.1k
  const Elf_Ehdr *getHeader() const {
95
94.1k
    return reinterpret_cast<const Elf_Ehdr *>(base());
96
94.1k
  }
97
98
  template <typename T>
99
  Expected<const T *> getEntry(uint32_t Section, uint32_t Entry) const;
100
  template <typename T>
101
  Expected<const T *> getEntry(const Elf_Shdr *Section, uint32_t Entry) const;
102
103
  Expected<StringRef> getStringTable(const Elf_Shdr *Section) const;
104
  Expected<StringRef> getStringTableForSymtab(const Elf_Shdr &Section) const;
105
  Expected<StringRef> getStringTableForSymtab(const Elf_Shdr &Section,
106
                                              Elf_Shdr_Range Sections) const;
107
108
  Expected<ArrayRef<Elf_Word>> getSHNDXTable(const Elf_Shdr &Section) const;
109
  Expected<ArrayRef<Elf_Word>> getSHNDXTable(const Elf_Shdr &Section,
110
                                             Elf_Shdr_Range Sections) const;
111
112
  StringRef getRelocationTypeName(uint32_t Type) const;
113
  void getRelocationTypeName(uint32_t Type,
114
                             SmallVectorImpl<char> &Result) const;
115
  uint32_t getRelativeRelocationType() const;
116
117
  const char *getDynamicTagAsString(unsigned Arch, uint64_t Type) const;
118
  const char *getDynamicTagAsString(uint64_t Type) const;
119
120
  /// Get the symbol for a given relocation.
121
  Expected<const Elf_Sym *> getRelocationSymbol(const Elf_Rel *Rel,
122
                                                const Elf_Shdr *SymTab) const;
123
124
  static Expected<ELFFile> create(StringRef Object);
125
126
27.1k
  bool isMipsELF64() const {
127
27.1k
    return getHeader()->e_machine == ELF::EM_MIPS &&
128
27.1k
           
getHeader()->getFileClass() == ELF::ELFCLASS643.17k
;
129
27.1k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isMipsELF64() const
Line
Count
Source
126
5.24k
  bool isMipsELF64() const {
127
5.24k
    return getHeader()->e_machine == ELF::EM_MIPS &&
128
5.24k
           
getHeader()->getFileClass() == ELF::ELFCLASS64745
;
129
5.24k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isMipsELF64() const
Line
Count
Source
126
1.81k
  bool isMipsELF64() const {
127
1.81k
    return getHeader()->e_machine == ELF::EM_MIPS &&
128
1.81k
           
getHeader()->getFileClass() == ELF::ELFCLASS641.48k
;
129
1.81k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isMipsELF64() const
Line
Count
Source
126
16.9k
  bool isMipsELF64() const {
127
16.9k
    return getHeader()->e_machine == ELF::EM_MIPS &&
128
16.9k
           
getHeader()->getFileClass() == ELF::ELFCLASS64438
;
129
16.9k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isMipsELF64() const
Line
Count
Source
126
3.08k
  bool isMipsELF64() const {
127
3.08k
    return getHeader()->e_machine == ELF::EM_MIPS &&
128
3.08k
           
getHeader()->getFileClass() == ELF::ELFCLASS64504
;
129
3.08k
  }
130
131
22.2k
  bool isMips64EL() const {
132
22.2k
    return isMipsELF64() &&
133
22.2k
           
getHeader()->getDataEncoding() == ELF::ELFDATA2LSB732
;
134
22.2k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::isMips64EL() const
Line
Count
Source
131
3.93k
  bool isMips64EL() const {
132
3.93k
    return isMipsELF64() &&
133
3.93k
           
getHeader()->getDataEncoding() == ELF::ELFDATA2LSB0
;
134
3.93k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::isMips64EL() const
Line
Count
Source
131
1.42k
  bool isMips64EL() const {
132
1.42k
    return isMipsELF64() &&
133
1.42k
           
getHeader()->getDataEncoding() == ELF::ELFDATA2LSB0
;
134
1.42k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::isMips64EL() const
Line
Count
Source
131
14.6k
  bool isMips64EL() const {
132
14.6k
    return isMipsELF64() &&
133
14.6k
           
getHeader()->getDataEncoding() == ELF::ELFDATA2LSB346
;
134
14.6k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::isMips64EL() const
Line
Count
Source
131
2.24k
  bool isMips64EL() const {
132
2.24k
    return isMipsELF64() &&
133
2.24k
           
getHeader()->getDataEncoding() == ELF::ELFDATA2LSB386
;
134
2.24k
  }
135
136
  Expected<Elf_Shdr_Range> sections() const;
137
138
  Expected<Elf_Dyn_Range> dynamicEntries() const;
139
140
  Expected<const uint8_t *> toMappedAddr(uint64_t VAddr) const;
141
142
121k
  Expected<Elf_Sym_Range> symbols(const Elf_Shdr *Sec) const {
143
121k
    if (!Sec)
144
19.1k
      return makeArrayRef<Elf_Sym>(nullptr, nullptr);
145
101k
    return getSectionContentsAsArray<Elf_Sym>(Sec);
146
101k
  }
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
142
29.6k
  Expected<Elf_Sym_Range> symbols(const Elf_Shdr *Sec) const {
143
29.6k
    if (!Sec)
144
7.93k
      return makeArrayRef<Elf_Sym>(nullptr, nullptr);
145
21.7k
    return getSectionContentsAsArray<Elf_Sym>(Sec);
146
21.7k
  }
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
142
3.68k
  Expected<Elf_Sym_Range> symbols(const Elf_Shdr *Sec) const {
143
3.68k
    if (!Sec)
144
903
      return makeArrayRef<Elf_Sym>(nullptr, nullptr);
145
2.78k
    return getSectionContentsAsArray<Elf_Sym>(Sec);
146
2.78k
  }
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
142
84.7k
  Expected<Elf_Sym_Range> symbols(const Elf_Shdr *Sec) const {
143
84.7k
    if (!Sec)
144
9.63k
      return makeArrayRef<Elf_Sym>(nullptr, nullptr);
145
75.1k
    return getSectionContentsAsArray<Elf_Sym>(Sec);
146
75.1k
  }
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
142
2.89k
  Expected<Elf_Sym_Range> symbols(const Elf_Shdr *Sec) const {
143
2.89k
    if (!Sec)
144
667
      return makeArrayRef<Elf_Sym>(nullptr, nullptr);
145
2.23k
    return getSectionContentsAsArray<Elf_Sym>(Sec);
146
2.23k
  }
147
148
1.92k
  Expected<Elf_Rela_Range> relas(const Elf_Shdr *Sec) const {
149
1.92k
    return getSectionContentsAsArray<Elf_Rela>(Sec);
150
1.92k
  }
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
148
9
  Expected<Elf_Rela_Range> relas(const Elf_Shdr *Sec) const {
149
9
    return getSectionContentsAsArray<Elf_Rela>(Sec);
150
9
  }
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
148
30
  Expected<Elf_Rela_Range> relas(const Elf_Shdr *Sec) const {
149
30
    return getSectionContentsAsArray<Elf_Rela>(Sec);
150
30
  }
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
148
1.68k
  Expected<Elf_Rela_Range> relas(const Elf_Shdr *Sec) const {
149
1.68k
    return getSectionContentsAsArray<Elf_Rela>(Sec);
150
1.68k
  }
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
148
203
  Expected<Elf_Rela_Range> relas(const Elf_Shdr *Sec) const {
149
203
    return getSectionContentsAsArray<Elf_Rela>(Sec);
150
203
  }
151
152
668
  Expected<Elf_Rel_Range> rels(const Elf_Shdr *Sec) const {
153
668
    return getSectionContentsAsArray<Elf_Rel>(Sec);
154
668
  }
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
152
516
  Expected<Elf_Rel_Range> rels(const Elf_Shdr *Sec) const {
153
516
    return getSectionContentsAsArray<Elf_Rel>(Sec);
154
516
  }
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
152
116
  Expected<Elf_Rel_Range> rels(const Elf_Shdr *Sec) const {
153
116
    return getSectionContentsAsArray<Elf_Rel>(Sec);
154
116
  }
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
152
28
  Expected<Elf_Rel_Range> rels(const Elf_Shdr *Sec) const {
153
28
    return getSectionContentsAsArray<Elf_Rel>(Sec);
154
28
  }
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
152
8
  Expected<Elf_Rel_Range> rels(const Elf_Shdr *Sec) const {
153
8
    return getSectionContentsAsArray<Elf_Rel>(Sec);
154
8
  }
155
156
13
  Expected<Elf_Relr_Range> relrs(const Elf_Shdr *Sec) const {
157
13
    return getSectionContentsAsArray<Elf_Relr>(Sec);
158
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
156
7
  Expected<Elf_Relr_Range> relrs(const Elf_Shdr *Sec) const {
157
7
    return getSectionContentsAsArray<Elf_Relr>(Sec);
158
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
156
6
  Expected<Elf_Relr_Range> relrs(const Elf_Shdr *Sec) const {
157
6
    return getSectionContentsAsArray<Elf_Relr>(Sec);
158
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
159
160
  Expected<std::vector<Elf_Rela>> decode_relrs(Elf_Relr_Range relrs) const;
161
162
  Expected<std::vector<Elf_Rela>> android_relas(const Elf_Shdr *Sec) const;
163
164
  /// Iterate over program header table.
165
7.80k
  Expected<Elf_Phdr_Range> program_headers() const {
166
7.80k
    if (getHeader()->e_phnum && 
getHeader()->e_phentsize != sizeof(Elf_Phdr)5.89k
)
167
2
      return createError("invalid e_phentsize");
168
7.80k
    if (getHeader()->e_phoff +
169
7.80k
            (getHeader()->e_phnum * getHeader()->e_phentsize) >
170
7.80k
        getBufSize())
171
1
      return createError("program headers longer than binary");
172
7.80k
    auto *Begin =
173
7.80k
        reinterpret_cast<const Elf_Phdr *>(base() + getHeader()->e_phoff);
174
7.80k
    return makeArrayRef(Begin, Begin + getHeader()->e_phnum);
175
7.80k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::program_headers() const
Line
Count
Source
165
1.11k
  Expected<Elf_Phdr_Range> program_headers() const {
166
1.11k
    if (getHeader()->e_phnum && 
getHeader()->e_phentsize != sizeof(Elf_Phdr)709
)
167
0
      return createError("invalid e_phentsize");
168
1.11k
    if (getHeader()->e_phoff +
169
1.11k
            (getHeader()->e_phnum * getHeader()->e_phentsize) >
170
1.11k
        getBufSize())
171
0
      return createError("program headers longer than binary");
172
1.11k
    auto *Begin =
173
1.11k
        reinterpret_cast<const Elf_Phdr *>(base() + getHeader()->e_phoff);
174
1.11k
    return makeArrayRef(Begin, Begin + getHeader()->e_phnum);
175
1.11k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::program_headers() const
Line
Count
Source
165
364
  Expected<Elf_Phdr_Range> program_headers() const {
166
364
    if (getHeader()->e_phnum && 
getHeader()->e_phentsize != sizeof(Elf_Phdr)256
)
167
0
      return createError("invalid e_phentsize");
168
364
    if (getHeader()->e_phoff +
169
364
            (getHeader()->e_phnum * getHeader()->e_phentsize) >
170
364
        getBufSize())
171
0
      return createError("program headers longer than binary");
172
364
    auto *Begin =
173
364
        reinterpret_cast<const Elf_Phdr *>(base() + getHeader()->e_phoff);
174
364
    return makeArrayRef(Begin, Begin + getHeader()->e_phnum);
175
364
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::program_headers() const
Line
Count
Source
165
5.95k
  Expected<Elf_Phdr_Range> program_headers() const {
166
5.95k
    if (getHeader()->e_phnum && 
getHeader()->e_phentsize != sizeof(Elf_Phdr)4.65k
)
167
2
      return createError("invalid e_phentsize");
168
5.95k
    if (getHeader()->e_phoff +
169
5.95k
            (getHeader()->e_phnum * getHeader()->e_phentsize) >
170
5.95k
        getBufSize())
171
1
      return createError("program headers longer than binary");
172
5.95k
    auto *Begin =
173
5.95k
        reinterpret_cast<const Elf_Phdr *>(base() + getHeader()->e_phoff);
174
5.95k
    return makeArrayRef(Begin, Begin + getHeader()->e_phnum);
175
5.95k
  }
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::program_headers() const
Line
Count
Source
165
368
  Expected<Elf_Phdr_Range> program_headers() const {
166
368
    if (getHeader()->e_phnum && 
getHeader()->e_phentsize != sizeof(Elf_Phdr)275
)
167
0
      return createError("invalid e_phentsize");
168
368
    if (getHeader()->e_phoff +
169
368
            (getHeader()->e_phnum * getHeader()->e_phentsize) >
170
368
        getBufSize())
171
0
      return createError("program headers longer than binary");
172
368
    auto *Begin =
173
368
        reinterpret_cast<const Elf_Phdr *>(base() + getHeader()->e_phoff);
174
368
    return makeArrayRef(Begin, Begin + getHeader()->e_phnum);
175
368
  }
176
177
  /// Get an iterator over notes in a program header.
178
  ///
179
  /// The program header must be of type \c PT_NOTE.
180
  ///
181
  /// \param Phdr the program header to iterate over.
182
  /// \param Err [out] an error to support fallible iteration, which should
183
  ///  be checked after iteration ends.
184
9
  Elf_Note_Iterator notes_begin(const Elf_Phdr &Phdr, Error &Err) const {
185
9
    if (Phdr.p_type != ELF::PT_NOTE) {
186
0
      Err = createError("attempt to iterate notes of non-note program header");
187
0
      return Elf_Note_Iterator(Err);
188
0
    }
189
9
    if (Phdr.p_offset + Phdr.p_filesz > getBufSize()) {
190
0
      Err = createError("invalid program header offset/size");
191
0
      return Elf_Note_Iterator(Err);
192
0
    }
193
9
    return Elf_Note_Iterator(base() + Phdr.p_offset, Phdr.p_filesz, Err);
194
9
  }
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
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
Line
Count
Source
184
9
  Elf_Note_Iterator notes_begin(const Elf_Phdr &Phdr, Error &Err) const {
185
9
    if (Phdr.p_type != ELF::PT_NOTE) {
186
0
      Err = createError("attempt to iterate notes of non-note program header");
187
0
      return Elf_Note_Iterator(Err);
188
0
    }
189
9
    if (Phdr.p_offset + Phdr.p_filesz > getBufSize()) {
190
0
      Err = createError("invalid program header offset/size");
191
0
      return Elf_Note_Iterator(Err);
192
0
    }
193
9
    return Elf_Note_Iterator(base() + Phdr.p_offset, Phdr.p_filesz, Err);
194
9
  }
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
195
196
  /// Get an iterator over notes in a section.
197
  ///
198
  /// The section must be of type \c SHT_NOTE.
199
  ///
200
  /// \param Shdr the section to iterate over.
201
  /// \param Err [out] an error to support fallible iteration, which should
202
  ///  be checked after iteration ends.
203
55
  Elf_Note_Iterator notes_begin(const Elf_Shdr &Shdr, Error &Err) const {
204
55
    if (Shdr.sh_type != ELF::SHT_NOTE) {
205
0
      Err = createError("attempt to iterate notes of non-note section");
206
0
      return Elf_Note_Iterator(Err);
207
0
    }
208
55
    if (Shdr.sh_offset + Shdr.sh_size > getBufSize()) {
209
0
      Err = createError("invalid section offset/size");
210
0
      return Elf_Note_Iterator(Err);
211
0
    }
212
55
    return Elf_Note_Iterator(base() + Shdr.sh_offset, Shdr.sh_size, Err);
213
55
  }
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
203
55
  Elf_Note_Iterator notes_begin(const Elf_Shdr &Shdr, Error &Err) const {
204
55
    if (Shdr.sh_type != ELF::SHT_NOTE) {
205
0
      Err = createError("attempt to iterate notes of non-note section");
206
0
      return Elf_Note_Iterator(Err);
207
0
    }
208
55
    if (Shdr.sh_offset + Shdr.sh_size > getBufSize()) {
209
0
      Err = createError("invalid section offset/size");
210
0
      return Elf_Note_Iterator(Err);
211
0
    }
212
55
    return Elf_Note_Iterator(base() + Shdr.sh_offset, Shdr.sh_size, Err);
213
55
  }
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
214
215
  /// Get the end iterator for notes.
216
64
  Elf_Note_Iterator notes_end() const {
217
64
    return Elf_Note_Iterator();
218
64
  }
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
216
64
  Elf_Note_Iterator notes_end() const {
217
64
    return Elf_Note_Iterator();
218
64
  }
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::notes_end() const
219
220
  /// Get an iterator range over notes of a program header.
221
  ///
222
  /// The program header must be of type \c PT_NOTE.
223
  ///
224
  /// \param Phdr the program header to iterate over.
225
  /// \param Err [out] an error to support fallible iteration, which should
226
  ///  be checked after iteration ends.
227
  iterator_range<Elf_Note_Iterator> notes(const Elf_Phdr &Phdr,
228
9
                                          Error &Err) const {
229
9
    return make_range(notes_begin(Phdr, Err), notes_end());
230
9
  }
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
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
Line
Count
Source
228
9
                                          Error &Err) const {
229
9
    return make_range(notes_begin(Phdr, Err), notes_end());
230
9
  }
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
231
232
  /// Get an iterator range over notes of a section.
233
  ///
234
  /// The section must be of type \c SHT_NOTE.
235
  ///
236
  /// \param Shdr the section to iterate over.
237
  /// \param Err [out] an error to support fallible iteration, which should
238
  ///  be checked after iteration ends.
239
  iterator_range<Elf_Note_Iterator> notes(const Elf_Shdr &Shdr,
240
55
                                          Error &Err) const {
241
55
    return make_range(notes_begin(Shdr, Err), notes_end());
242
55
  }
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
240
55
                                          Error &Err) const {
241
55
    return make_range(notes_begin(Shdr, Err), notes_end());
242
55
  }
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
243
244
  Expected<StringRef> getSectionStringTable(Elf_Shdr_Range Sections) const;
245
  Expected<uint32_t> getSectionIndex(const Elf_Sym *Sym, Elf_Sym_Range Syms,
246
                                     ArrayRef<Elf_Word> ShndxTable) const;
247
  Expected<const Elf_Shdr *> getSection(const Elf_Sym *Sym,
248
                                        const Elf_Shdr *SymTab,
249
                                        ArrayRef<Elf_Word> ShndxTable) const;
250
  Expected<const Elf_Shdr *> getSection(const Elf_Sym *Sym,
251
                                        Elf_Sym_Range Symtab,
252
                                        ArrayRef<Elf_Word> ShndxTable) const;
253
  Expected<const Elf_Shdr *> getSection(uint32_t Index) const;
254
  Expected<const Elf_Shdr *> getSection(const StringRef SectionName) const;
255
256
  Expected<const Elf_Sym *> getSymbol(const Elf_Shdr *Sec,
257
                                      uint32_t Index) const;
258
259
  Expected<StringRef> getSectionName(const Elf_Shdr *Section) const;
260
  Expected<StringRef> getSectionName(const Elf_Shdr *Section,
261
                                     StringRef DotShstrtab) const;
262
  template <typename T>
263
  Expected<ArrayRef<T>> getSectionContentsAsArray(const Elf_Shdr *Sec) const;
264
  Expected<ArrayRef<uint8_t>> getSectionContents(const Elf_Shdr *Sec) const;
265
};
266
267
using ELF32LEFile = ELFFile<ELF32LE>;
268
using ELF64LEFile = ELFFile<ELF64LE>;
269
using ELF32BEFile = ELFFile<ELF32BE>;
270
using ELF64BEFile = ELFFile<ELF64BE>;
271
272
template <class ELFT>
273
inline Expected<const typename ELFT::Shdr *>
274
469k
getSection(typename ELFT::ShdrRange Sections, uint32_t Index) {
275
469k
  if (Index >= Sections.size())
276
1
    return createError("invalid section index");
277
469k
  return &Sections[Index];
278
469k
}
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
274
121k
getSection(typename ELFT::ShdrRange Sections, uint32_t Index) {
275
121k
  if (Index >= Sections.size())
276
0
    return createError("invalid section index");
277
121k
  return &Sections[Index];
278
121k
}
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
274
13.2k
getSection(typename ELFT::ShdrRange Sections, uint32_t Index) {
275
13.2k
  if (Index >= Sections.size())
276
0
    return createError("invalid section index");
277
13.2k
  return &Sections[Index];
278
13.2k
}
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
274
324k
getSection(typename ELFT::ShdrRange Sections, uint32_t Index) {
275
324k
  if (Index >= Sections.size())
276
1
    return createError("invalid section index");
277
324k
  return &Sections[Index];
278
324k
}
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
274
10.6k
getSection(typename ELFT::ShdrRange Sections, uint32_t Index) {
275
10.6k
  if (Index >= Sections.size())
276
0
    return createError("invalid section index");
277
10.6k
  return &Sections[Index];
278
10.6k
}
279
280
template <class ELFT>
281
inline Expected<uint32_t>
282
getExtendedSymbolTableIndex(const typename ELFT::Sym *Sym,
283
                            const typename ELFT::Sym *FirstSym,
284
538
                            ArrayRef<typename ELFT::Word> ShndxTable) {
285
538
  assert(Sym->st_shndx == ELF::SHN_XINDEX);
286
538
  unsigned Index = Sym - FirstSym;
287
538
  if (Index >= ShndxTable.size())
288
1
    return createError("index past the end of the symbol table");
289
537
290
537
  // The size of the table was checked in getSHNDXTable.
291
537
  return ShndxTable[Index];
292
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
284
538
                            ArrayRef<typename ELFT::Word> ShndxTable) {
285
538
  assert(Sym->st_shndx == ELF::SHN_XINDEX);
286
538
  unsigned Index = Sym - FirstSym;
287
538
  if (Index >= ShndxTable.size())
288
1
    return createError("index past the end of the symbol table");
289
537
290
537
  // The size of the table was checked in getSHNDXTable.
291
537
  return ShndxTable[Index];
292
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>)
293
294
template <class ELFT>
295
Expected<uint32_t>
296
ELFFile<ELFT>::getSectionIndex(const Elf_Sym *Sym, Elf_Sym_Range Syms,
297
117k
                               ArrayRef<Elf_Word> ShndxTable) const {
298
117k
  uint32_t Index = Sym->st_shndx;
299
117k
  if (Index == ELF::SHN_XINDEX) {
300
267
    auto ErrorOrIndex = getExtendedSymbolTableIndex<ELFT>(
301
267
        Sym, Syms.begin(), ShndxTable);
302
267
    if (!ErrorOrIndex)
303
0
      return ErrorOrIndex.takeError();
304
267
    return *ErrorOrIndex;
305
267
  }
306
116k
  if (Index == ELF::SHN_UNDEF || 
Index >= ELF::SHN_LORESERVE111k
)
307
7.34k
    return 0;
308
109k
  return Index;
309
109k
}
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
297
12.9k
                               ArrayRef<Elf_Word> ShndxTable) const {
298
12.9k
  uint32_t Index = Sym->st_shndx;
299
12.9k
  if (Index == ELF::SHN_XINDEX) {
300
0
    auto ErrorOrIndex = getExtendedSymbolTableIndex<ELFT>(
301
0
        Sym, Syms.begin(), ShndxTable);
302
0
    if (!ErrorOrIndex)
303
0
      return ErrorOrIndex.takeError();
304
0
    return *ErrorOrIndex;
305
0
  }
306
12.9k
  if (Index == ELF::SHN_UNDEF || 
Index >= ELF::SHN_LORESERVE12.0k
)
307
1.18k
    return 0;
308
11.7k
  return Index;
309
11.7k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSectionIndex(llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > const*, llvm::ArrayRef<llvm::object::Elf_Sym_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false> > >, llvm::ArrayRef<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)0, 1ul> >) const
Line
Count
Source
297
1.85k
                               ArrayRef<Elf_Word> ShndxTable) const {
298
1.85k
  uint32_t Index = Sym->st_shndx;
299
1.85k
  if (Index == ELF::SHN_XINDEX) {
300
0
    auto ErrorOrIndex = getExtendedSymbolTableIndex<ELFT>(
301
0
        Sym, Syms.begin(), ShndxTable);
302
0
    if (!ErrorOrIndex)
303
0
      return ErrorOrIndex.takeError();
304
0
    return *ErrorOrIndex;
305
0
  }
306
1.85k
  if (Index == ELF::SHN_UNDEF || 
Index >= ELF::SHN_LORESERVE1.48k
)
307
399
    return 0;
308
1.45k
  return Index;
309
1.45k
}
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
297
90.9k
                               ArrayRef<Elf_Word> ShndxTable) const {
298
90.9k
  uint32_t Index = Sym->st_shndx;
299
90.9k
  if (Index == ELF::SHN_XINDEX) {
300
267
    auto ErrorOrIndex = getExtendedSymbolTableIndex<ELFT>(
301
267
        Sym, Syms.begin(), ShndxTable);
302
267
    if (!ErrorOrIndex)
303
0
      return ErrorOrIndex.takeError();
304
267
    return *ErrorOrIndex;
305
267
  }
306
90.7k
  if (Index == ELF::SHN_UNDEF || 
Index >= ELF::SHN_LORESERVE86.4k
)
307
5.37k
    return 0;
308
85.3k
  return Index;
309
85.3k
}
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
297
11.4k
                               ArrayRef<Elf_Word> ShndxTable) const {
298
11.4k
  uint32_t Index = Sym->st_shndx;
299
11.4k
  if (Index == ELF::SHN_XINDEX) {
300
0
    auto ErrorOrIndex = getExtendedSymbolTableIndex<ELFT>(
301
0
        Sym, Syms.begin(), ShndxTable);
302
0
    if (!ErrorOrIndex)
303
0
      return ErrorOrIndex.takeError();
304
0
    return *ErrorOrIndex;
305
0
  }
306
11.4k
  if (Index == ELF::SHN_UNDEF || 
Index >= ELF::SHN_LORESERVE11.1k
)
307
380
    return 0;
308
11.1k
  return Index;
309
11.1k
}
310
311
template <class ELFT>
312
Expected<const typename ELFT::Shdr *>
313
ELFFile<ELFT>::getSection(const Elf_Sym *Sym, const Elf_Shdr *SymTab,
314
29.7k
                          ArrayRef<Elf_Word> ShndxTable) const {
315
29.7k
  auto SymsOrErr = symbols(SymTab);
316
29.7k
  if (!SymsOrErr)
317
0
    return SymsOrErr.takeError();
318
29.7k
  return getSection(Sym, *SymsOrErr, ShndxTable);
319
29.7k
}
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
314
10.6k
                          ArrayRef<Elf_Word> ShndxTable) const {
315
10.6k
  auto SymsOrErr = symbols(SymTab);
316
10.6k
  if (!SymsOrErr)
317
0
    return SymsOrErr.takeError();
318
10.6k
  return getSection(Sym, *SymsOrErr, ShndxTable);
319
10.6k
}
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
314
1.11k
                          ArrayRef<Elf_Word> ShndxTable) const {
315
1.11k
  auto SymsOrErr = symbols(SymTab);
316
1.11k
  if (!SymsOrErr)
317
0
    return SymsOrErr.takeError();
318
1.11k
  return getSection(Sym, *SymsOrErr, ShndxTable);
319
1.11k
}
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
314
17.0k
                          ArrayRef<Elf_Word> ShndxTable) const {
315
17.0k
  auto SymsOrErr = symbols(SymTab);
316
17.0k
  if (!SymsOrErr)
317
0
    return SymsOrErr.takeError();
318
17.0k
  return getSection(Sym, *SymsOrErr, ShndxTable);
319
17.0k
}
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
314
911
                          ArrayRef<Elf_Word> ShndxTable) const {
315
911
  auto SymsOrErr = symbols(SymTab);
316
911
  if (!SymsOrErr)
317
0
    return SymsOrErr.takeError();
318
911
  return getSection(Sym, *SymsOrErr, ShndxTable);
319
911
}
320
321
template <class ELFT>
322
Expected<const typename ELFT::Shdr *>
323
ELFFile<ELFT>::getSection(const Elf_Sym *Sym, Elf_Sym_Range Symbols,
324
29.7k
                          ArrayRef<Elf_Word> ShndxTable) const {
325
29.7k
  auto IndexOrErr = getSectionIndex(Sym, Symbols, ShndxTable);
326
29.7k
  if (!IndexOrErr)
327
0
    return IndexOrErr.takeError();
328
29.7k
  uint32_t Index = *IndexOrErr;
329
29.7k
  if (Index == 0)
330
2.11k
    return nullptr;
331
27.6k
  return getSection(Index);
332
27.6k
}
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
324
10.6k
                          ArrayRef<Elf_Word> ShndxTable) const {
325
10.6k
  auto IndexOrErr = getSectionIndex(Sym, Symbols, ShndxTable);
326
10.6k
  if (!IndexOrErr)
327
0
    return IndexOrErr.takeError();
328
10.6k
  uint32_t Index = *IndexOrErr;
329
10.6k
  if (Index == 0)
330
557
    return nullptr;
331
10.0k
  return getSection(Index);
332
10.0k
}
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
324
1.11k
                          ArrayRef<Elf_Word> ShndxTable) const {
325
1.11k
  auto IndexOrErr = getSectionIndex(Sym, Symbols, ShndxTable);
326
1.11k
  if (!IndexOrErr)
327
0
    return IndexOrErr.takeError();
328
1.11k
  uint32_t Index = *IndexOrErr;
329
1.11k
  if (Index == 0)
330
109
    return nullptr;
331
1.00k
  return getSection(Index);
332
1.00k
}
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
324
17.0k
                          ArrayRef<Elf_Word> ShndxTable) const {
325
17.0k
  auto IndexOrErr = getSectionIndex(Sym, Symbols, ShndxTable);
326
17.0k
  if (!IndexOrErr)
327
0
    return IndexOrErr.takeError();
328
17.0k
  uint32_t Index = *IndexOrErr;
329
17.0k
  if (Index == 0)
330
1.35k
    return nullptr;
331
15.7k
  return getSection(Index);
332
15.7k
}
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
324
911
                          ArrayRef<Elf_Word> ShndxTable) const {
325
911
  auto IndexOrErr = getSectionIndex(Sym, Symbols, ShndxTable);
326
911
  if (!IndexOrErr)
327
0
    return IndexOrErr.takeError();
328
911
  uint32_t Index = *IndexOrErr;
329
911
  if (Index == 0)
330
94
    return nullptr;
331
817
  return getSection(Index);
332
817
}
333
334
template <class ELFT>
335
inline Expected<const typename ELFT::Sym *>
336
78
getSymbol(typename ELFT::SymRange Symbols, uint32_t Index) {
337
78
  if (Index >= Symbols.size())
338
0
    return createError("invalid symbol index");
339
78
  return &Symbols[Index];
340
78
}
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
336
2
getSymbol(typename ELFT::SymRange Symbols, uint32_t Index) {
337
2
  if (Index >= Symbols.size())
338
0
    return createError("invalid symbol index");
339
2
  return &Symbols[Index];
340
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
336
76
getSymbol(typename ELFT::SymRange Symbols, uint32_t Index) {
337
76
  if (Index >= Symbols.size())
338
0
    return createError("invalid symbol index");
339
76
  return &Symbols[Index];
340
76
}
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)
341
342
template <class ELFT>
343
Expected<const typename ELFT::Sym *>
344
5
ELFFile<ELFT>::getSymbol(const Elf_Shdr *Sec, uint32_t Index) const {
345
5
  auto SymtabOrErr = symbols(Sec);
346
5
  if (!SymtabOrErr)
347
0
    return SymtabOrErr.takeError();
348
5
  return object::getSymbol<ELFT>(*SymtabOrErr, Index);
349
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
344
5
ELFFile<ELFT>::getSymbol(const Elf_Shdr *Sec, uint32_t Index) const {
345
5
  auto SymtabOrErr = symbols(Sec);
346
5
  if (!SymtabOrErr)
347
0
    return SymtabOrErr.takeError();
348
5
  return object::getSymbol<ELFT>(*SymtabOrErr, Index);
349
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
350
351
template <class ELFT>
352
template <typename T>
353
Expected<ArrayRef<T>>
354
1.46M
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
1.46M
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 11.35M
)
356
1
    return createError("invalid sh_entsize");
357
1.46M
358
1.46M
  uintX_t Offset = Sec->sh_offset;
359
1.46M
  uintX_t Size = Sec->sh_size;
360
1.46M
361
1.46M
  if (Size % sizeof(T))
362
1
    return createError("size is not a multiple of sh_entsize");
363
1.46M
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
1.46M
      
Offset + Size > Buf.size()1.46M
)
365
5
    return createError("invalid section offset");
366
1.46M
367
1.46M
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
1.46M
370
1.46M
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
1.46M
  return makeArrayRef(Start, Size / sizeof(T));
372
1.46M
}
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
354
26.9k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
26.9k
  if (Sec->sh_entsize != sizeof(T) && sizeof(T) != 1)
356
0
    return createError("invalid sh_entsize");
357
26.9k
358
26.9k
  uintX_t Offset = Sec->sh_offset;
359
26.9k
  uintX_t Size = Sec->sh_size;
360
26.9k
361
26.9k
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
26.9k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
26.9k
      
Offset + Size > Buf.size()26.9k
)
365
1
    return createError("invalid section offset");
366
26.9k
367
26.9k
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
26.9k
370
26.9k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
26.9k
  return makeArrayRef(Start, Size / sizeof(T));
372
26.9k
}
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
354
9
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
9
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
356
0
    return createError("invalid sh_entsize");
357
9
358
9
  uintX_t Offset = Sec->sh_offset;
359
9
  uintX_t Size = Sec->sh_size;
360
9
361
9
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
9
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
9
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
9
367
9
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
9
370
9
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
9
  return makeArrayRef(Start, Size / sizeof(T));
372
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
354
60
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
60
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
356
0
    return createError("invalid sh_entsize");
357
60
358
60
  uintX_t Offset = Sec->sh_offset;
359
60
  uintX_t Size = Sec->sh_size;
360
60
361
60
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
60
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
60
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
60
367
60
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
60
370
60
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
60
  return makeArrayRef(Start, Size / sizeof(T));
372
60
}
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
354
21.7k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
21.7k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
356
0
    return createError("invalid sh_entsize");
357
21.7k
358
21.7k
  uintX_t Offset = Sec->sh_offset;
359
21.7k
  uintX_t Size = Sec->sh_size;
360
21.7k
361
21.7k
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
21.7k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
21.7k
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
21.7k
367
21.7k
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
21.7k
370
21.7k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
21.7k
  return makeArrayRef(Start, Size / sizeof(T));
372
21.7k
}
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
354
9
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
9
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
356
0
    return createError("invalid sh_entsize");
357
9
358
9
  uintX_t Offset = Sec->sh_offset;
359
9
  uintX_t Size = Sec->sh_size;
360
9
361
9
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
9
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
9
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
9
367
9
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
9
370
9
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
9
  return makeArrayRef(Start, Size / sizeof(T));
372
9
}
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
354
516
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
516
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
356
0
    return createError("invalid sh_entsize");
357
516
358
516
  uintX_t Offset = Sec->sh_offset;
359
516
  uintX_t Size = Sec->sh_size;
360
516
361
516
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
516
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
516
      Offset + Size > Buf.size())
365
1
    return createError("invalid section offset");
366
515
367
515
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
515
370
515
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
515
  return makeArrayRef(Start, Size / sizeof(T));
372
515
}
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
354
2.13k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
2.13k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 12.11k
)
356
0
    return createError("invalid sh_entsize");
357
2.13k
358
2.13k
  uintX_t Offset = Sec->sh_offset;
359
2.13k
  uintX_t Size = Sec->sh_size;
360
2.13k
361
2.13k
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
2.13k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
2.13k
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
2.13k
367
2.13k
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
2.13k
370
2.13k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
2.13k
  return makeArrayRef(Start, Size / sizeof(T));
372
2.13k
}
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
354
4.73k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
4.73k
  if (Sec->sh_entsize != sizeof(T) && sizeof(T) != 1)
356
0
    return createError("invalid sh_entsize");
357
4.73k
358
4.73k
  uintX_t Offset = Sec->sh_offset;
359
4.73k
  uintX_t Size = Sec->sh_size;
360
4.73k
361
4.73k
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
4.73k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
4.73k
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
4.73k
367
4.73k
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
4.73k
370
4.73k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
4.73k
  return makeArrayRef(Start, Size / sizeof(T));
372
4.73k
}
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
354
24
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
24
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
356
0
    return createError("invalid sh_entsize");
357
24
358
24
  uintX_t Offset = Sec->sh_offset;
359
24
  uintX_t Size = Sec->sh_size;
360
24
361
24
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
24
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
24
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
24
367
24
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
24
370
24
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
24
  return makeArrayRef(Start, Size / sizeof(T));
372
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
354
2.78k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
2.78k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
356
0
    return createError("invalid sh_entsize");
357
2.78k
358
2.78k
  uintX_t Offset = Sec->sh_offset;
359
2.78k
  uintX_t Size = Sec->sh_size;
360
2.78k
361
2.78k
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
2.78k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
2.78k
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
2.78k
367
2.78k
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
2.78k
370
2.78k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
2.78k
  return makeArrayRef(Start, Size / sizeof(T));
372
2.78k
}
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
354
30
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
30
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
356
0
    return createError("invalid sh_entsize");
357
30
358
30
  uintX_t Offset = Sec->sh_offset;
359
30
  uintX_t Size = Sec->sh_size;
360
30
361
30
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
30
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
30
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
30
367
30
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
30
370
30
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
30
  return makeArrayRef(Start, Size / sizeof(T));
372
30
}
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
354
116
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
116
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
356
0
    return createError("invalid sh_entsize");
357
116
358
116
  uintX_t Offset = Sec->sh_offset;
359
116
  uintX_t Size = Sec->sh_size;
360
116
361
116
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
116
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
116
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
116
367
116
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
116
370
116
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
116
  return makeArrayRef(Start, Size / sizeof(T));
372
116
}
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
354
1.09k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
1.09k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 11.08k
)
356
0
    return createError("invalid sh_entsize");
357
1.09k
358
1.09k
  uintX_t Offset = Sec->sh_offset;
359
1.09k
  uintX_t Size = Sec->sh_size;
360
1.09k
361
1.09k
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
1.09k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
1.09k
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
1.09k
367
1.09k
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
1.09k
370
1.09k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
1.09k
  return makeArrayRef(Start, Size / sizeof(T));
372
1.09k
}
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
354
983k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
983k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 1983k
)
356
0
    return createError("invalid sh_entsize");
357
983k
358
983k
  uintX_t Offset = Sec->sh_offset;
359
983k
  uintX_t Size = Sec->sh_size;
360
983k
361
983k
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
983k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
983k
      Offset + Size > Buf.size())
365
1
    return createError("invalid section offset");
366
983k
367
983k
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
983k
370
983k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
983k
  return makeArrayRef(Start, Size / sizeof(T));
372
983k
}
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
354
145
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
145
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
356
0
    return createError("invalid sh_entsize");
357
145
358
145
  uintX_t Offset = Sec->sh_offset;
359
145
  uintX_t Size = Sec->sh_size;
360
145
361
145
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
145
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
145
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
145
367
145
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
145
370
145
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
145
  return makeArrayRef(Start, Size / sizeof(T));
372
145
}
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
354
264
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
264
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
356
0
    return createError("invalid sh_entsize");
357
264
358
264
  uintX_t Offset = Sec->sh_offset;
359
264
  uintX_t Size = Sec->sh_size;
360
264
361
264
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
264
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
264
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
264
367
264
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
264
370
264
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
264
  return makeArrayRef(Start, Size / sizeof(T));
372
264
}
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
354
75.1k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
75.1k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
356
1
    return createError("invalid sh_entsize");
357
75.1k
358
75.1k
  uintX_t Offset = Sec->sh_offset;
359
75.1k
  uintX_t Size = Sec->sh_size;
360
75.1k
361
75.1k
  if (Size % sizeof(T))
362
1
    return createError("size is not a multiple of sh_entsize");
363
75.1k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
75.1k
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
75.1k
367
75.1k
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
75.1k
370
75.1k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
75.1k
  return makeArrayRef(Start, Size / sizeof(T));
372
75.1k
}
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
354
1.68k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
1.68k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
356
0
    return createError("invalid sh_entsize");
357
1.68k
358
1.68k
  uintX_t Offset = Sec->sh_offset;
359
1.68k
  uintX_t Size = Sec->sh_size;
360
1.68k
361
1.68k
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
1.68k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
1.68k
      Offset + Size > Buf.size())
365
1
    return createError("invalid section offset");
366
1.68k
367
1.68k
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
1.68k
370
1.68k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
1.68k
  return makeArrayRef(Start, Size / sizeof(T));
372
1.68k
}
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
354
28
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
28
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
356
0
    return createError("invalid sh_entsize");
357
28
358
28
  uintX_t Offset = Sec->sh_offset;
359
28
  uintX_t Size = Sec->sh_size;
360
28
361
28
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
28
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
28
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
28
367
28
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
28
370
28
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
28
  return makeArrayRef(Start, Size / sizeof(T));
372
28
}
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
354
6
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
6
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
356
0
    return createError("invalid sh_entsize");
357
6
358
6
  uintX_t Offset = Sec->sh_offset;
359
6
  uintX_t Size = Sec->sh_size;
360
6
361
6
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
6
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
6
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
6
367
6
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
6
370
6
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
6
  return makeArrayRef(Start, Size / sizeof(T));
372
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
354
336k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
336k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 1335k
)
356
0
    return createError("invalid sh_entsize");
357
336k
358
336k
  uintX_t Offset = Sec->sh_offset;
359
336k
  uintX_t Size = Sec->sh_size;
360
336k
361
336k
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
336k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
336k
      Offset + Size > Buf.size())
365
1
    return createError("invalid section offset");
366
336k
367
336k
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
336k
370
336k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
336k
  return makeArrayRef(Start, Size / sizeof(T));
372
336k
}
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
354
4.27k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
4.27k
  if (Sec->sh_entsize != sizeof(T) && sizeof(T) != 1)
356
0
    return createError("invalid sh_entsize");
357
4.27k
358
4.27k
  uintX_t Offset = Sec->sh_offset;
359
4.27k
  uintX_t Size = Sec->sh_size;
360
4.27k
361
4.27k
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
4.27k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
4.27k
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
4.27k
367
4.27k
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
4.27k
370
4.27k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
4.27k
  return makeArrayRef(Start, Size / sizeof(T));
372
4.27k
}
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
354
1
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
1
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
356
0
    return createError("invalid sh_entsize");
357
1
358
1
  uintX_t Offset = Sec->sh_offset;
359
1
  uintX_t Size = Sec->sh_size;
360
1
361
1
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
1
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
1
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
1
367
1
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
1
370
1
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
1
  return makeArrayRef(Start, Size / sizeof(T));
372
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
354
18
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
18
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
356
0
    return createError("invalid sh_entsize");
357
18
358
18
  uintX_t Offset = Sec->sh_offset;
359
18
  uintX_t Size = Sec->sh_size;
360
18
361
18
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
18
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
18
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
18
367
18
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
18
370
18
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
18
  return makeArrayRef(Start, Size / sizeof(T));
372
18
}
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
354
2.23k
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
2.23k
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
356
0
    return createError("invalid sh_entsize");
357
2.23k
358
2.23k
  uintX_t Offset = Sec->sh_offset;
359
2.23k
  uintX_t Size = Sec->sh_size;
360
2.23k
361
2.23k
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
2.23k
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
2.23k
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
2.23k
367
2.23k
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
2.23k
370
2.23k
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
2.23k
  return makeArrayRef(Start, Size / sizeof(T));
372
2.23k
}
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
354
203
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
203
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
356
0
    return createError("invalid sh_entsize");
357
203
358
203
  uintX_t Offset = Sec->sh_offset;
359
203
  uintX_t Size = Sec->sh_size;
360
203
361
203
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
203
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
203
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
203
367
203
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
203
370
203
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
203
  return makeArrayRef(Start, Size / sizeof(T));
372
203
}
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
354
8
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
8
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 10
)
356
0
    return createError("invalid sh_entsize");
357
8
358
8
  uintX_t Offset = Sec->sh_offset;
359
8
  uintX_t Size = Sec->sh_size;
360
8
361
8
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
8
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
8
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
8
367
8
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
8
370
8
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
8
  return makeArrayRef(Start, Size / sizeof(T));
372
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
354
528
ELFFile<ELFT>::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
355
528
  if (Sec->sh_entsize != sizeof(T) && 
sizeof(T) != 1468
)
356
0
    return createError("invalid sh_entsize");
357
528
358
528
  uintX_t Offset = Sec->sh_offset;
359
528
  uintX_t Size = Sec->sh_size;
360
528
361
528
  if (Size % sizeof(T))
362
0
    return createError("size is not a multiple of sh_entsize");
363
528
  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
364
528
      Offset + Size > Buf.size())
365
0
    return createError("invalid section offset");
366
528
367
528
  if (Offset % alignof(T))
368
0
    return createError("unaligned data");
369
528
370
528
  const T *Start = reinterpret_cast<const T *>(base() + Offset);
371
528
  return makeArrayRef(Start, Size / sizeof(T));
372
528
}
373
374
template <class ELFT>
375
Expected<ArrayRef<uint8_t>>
376
339k
ELFFile<ELFT>::getSectionContents(const Elf_Shdr *Sec) const {
377
339k
  return getSectionContentsAsArray<uint8_t>(Sec);
378
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
376
2.13k
ELFFile<ELFT>::getSectionContents(const Elf_Shdr *Sec) const {
377
2.13k
  return getSectionContentsAsArray<uint8_t>(Sec);
378
2.13k
}
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
376
1.09k
ELFFile<ELFT>::getSectionContents(const Elf_Shdr *Sec) const {
377
1.09k
  return getSectionContentsAsArray<uint8_t>(Sec);
378
1.09k
}
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
376
336k
ELFFile<ELFT>::getSectionContents(const Elf_Shdr *Sec) const {
377
336k
  return getSectionContentsAsArray<uint8_t>(Sec);
378
336k
}
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
376
528
ELFFile<ELFT>::getSectionContents(const Elf_Shdr *Sec) const {
377
528
  return getSectionContentsAsArray<uint8_t>(Sec);
378
528
}
379
380
template <class ELFT>
381
5.26k
StringRef ELFFile<ELFT>::getRelocationTypeName(uint32_t Type) const {
382
5.26k
  return getELFRelocationTypeName(getHeader()->e_machine, Type);
383
5.26k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationTypeName(unsigned int) const
Line
Count
Source
381
1.31k
StringRef ELFFile<ELFT>::getRelocationTypeName(uint32_t Type) const {
382
1.31k
  return getELFRelocationTypeName(getHeader()->e_machine, Type);
383
1.31k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationTypeName(unsigned int) const
Line
Count
Source
381
392
StringRef ELFFile<ELFT>::getRelocationTypeName(uint32_t Type) const {
382
392
  return getELFRelocationTypeName(getHeader()->e_machine, Type);
383
392
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationTypeName(unsigned int) const
Line
Count
Source
381
2.48k
StringRef ELFFile<ELFT>::getRelocationTypeName(uint32_t Type) const {
382
2.48k
  return getELFRelocationTypeName(getHeader()->e_machine, Type);
383
2.48k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationTypeName(unsigned int) const
Line
Count
Source
381
1.07k
StringRef ELFFile<ELFT>::getRelocationTypeName(uint32_t Type) const {
382
1.07k
  return getELFRelocationTypeName(getHeader()->e_machine, Type);
383
1.07k
}
384
385
template <class ELFT>
386
void ELFFile<ELFT>::getRelocationTypeName(uint32_t Type,
387
4.84k
                                          SmallVectorImpl<char> &Result) const {
388
4.84k
  if (!isMipsELF64()) {
389
4.63k
    StringRef Name = getRelocationTypeName(Type);
390
4.63k
    Result.append(Name.begin(), Name.end());
391
4.63k
  } else {
392
210
    // The Mips N64 ABI allows up to three operations to be specified per
393
210
    // relocation record. Unfortunately there's no easy way to test for the
394
210
    // presence of N64 ELFs as they have no special flag that identifies them
395
210
    // as being N64. We can safely assume at the moment that all Mips
396
210
    // ELFCLASS64 ELFs are N64. New Mips64 ABIs should provide enough
397
210
    // information to disambiguate between old vs new ABIs.
398
210
    uint8_t Type1 = (Type >> 0) & 0xFF;
399
210
    uint8_t Type2 = (Type >> 8) & 0xFF;
400
210
    uint8_t Type3 = (Type >> 16) & 0xFF;
401
210
402
210
    // Concat all three relocation type names.
403
210
    StringRef Name = getRelocationTypeName(Type1);
404
210
    Result.append(Name.begin(), Name.end());
405
210
406
210
    Name = getRelocationTypeName(Type2);
407
210
    Result.append(1, '/');
408
210
    Result.append(Name.begin(), Name.end());
409
210
410
210
    Name = getRelocationTypeName(Type3);
411
210
    Result.append(1, '/');
412
210
    Result.append(Name.begin(), Name.end());
413
210
  }
414
4.84k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocationTypeName(unsigned int, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
387
1.31k
                                          SmallVectorImpl<char> &Result) const {
388
1.31k
  if (!isMipsELF64()) {
389
1.31k
    StringRef Name = getRelocationTypeName(Type);
390
1.31k
    Result.append(Name.begin(), Name.end());
391
1.31k
  } else {
392
0
    // The Mips N64 ABI allows up to three operations to be specified per
393
0
    // relocation record. Unfortunately there's no easy way to test for the
394
0
    // presence of N64 ELFs as they have no special flag that identifies them
395
0
    // as being N64. We can safely assume at the moment that all Mips
396
0
    // ELFCLASS64 ELFs are N64. New Mips64 ABIs should provide enough
397
0
    // information to disambiguate between old vs new ABIs.
398
0
    uint8_t Type1 = (Type >> 0) & 0xFF;
399
0
    uint8_t Type2 = (Type >> 8) & 0xFF;
400
0
    uint8_t Type3 = (Type >> 16) & 0xFF;
401
0
402
0
    // Concat all three relocation type names.
403
0
    StringRef Name = getRelocationTypeName(Type1);
404
0
    Result.append(Name.begin(), Name.end());
405
0
406
0
    Name = getRelocationTypeName(Type2);
407
0
    Result.append(1, '/');
408
0
    Result.append(Name.begin(), Name.end());
409
0
410
0
    Name = getRelocationTypeName(Type3);
411
0
    Result.append(1, '/');
412
0
    Result.append(Name.begin(), Name.end());
413
0
  }
414
1.31k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocationTypeName(unsigned int, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
387
392
                                          SmallVectorImpl<char> &Result) const {
388
392
  if (!isMipsELF64()) {
389
392
    StringRef Name = getRelocationTypeName(Type);
390
392
    Result.append(Name.begin(), Name.end());
391
392
  } else {
392
0
    // The Mips N64 ABI allows up to three operations to be specified per
393
0
    // relocation record. Unfortunately there's no easy way to test for the
394
0
    // presence of N64 ELFs as they have no special flag that identifies them
395
0
    // as being N64. We can safely assume at the moment that all Mips
396
0
    // ELFCLASS64 ELFs are N64. New Mips64 ABIs should provide enough
397
0
    // information to disambiguate between old vs new ABIs.
398
0
    uint8_t Type1 = (Type >> 0) & 0xFF;
399
0
    uint8_t Type2 = (Type >> 8) & 0xFF;
400
0
    uint8_t Type3 = (Type >> 16) & 0xFF;
401
0
402
0
    // Concat all three relocation type names.
403
0
    StringRef Name = getRelocationTypeName(Type1);
404
0
    Result.append(Name.begin(), Name.end());
405
0
406
0
    Name = getRelocationTypeName(Type2);
407
0
    Result.append(1, '/');
408
0
    Result.append(Name.begin(), Name.end());
409
0
410
0
    Name = getRelocationTypeName(Type3);
411
0
    Result.append(1, '/');
412
0
    Result.append(Name.begin(), Name.end());
413
0
  }
414
392
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocationTypeName(unsigned int, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
387
2.29k
                                          SmallVectorImpl<char> &Result) const {
388
2.29k
  if (!isMipsELF64()) {
389
2.20k
    StringRef Name = getRelocationTypeName(Type);
390
2.20k
    Result.append(Name.begin(), Name.end());
391
2.20k
  } else {
392
92
    // The Mips N64 ABI allows up to three operations to be specified per
393
92
    // relocation record. Unfortunately there's no easy way to test for the
394
92
    // presence of N64 ELFs as they have no special flag that identifies them
395
92
    // as being N64. We can safely assume at the moment that all Mips
396
92
    // ELFCLASS64 ELFs are N64. New Mips64 ABIs should provide enough
397
92
    // information to disambiguate between old vs new ABIs.
398
92
    uint8_t Type1 = (Type >> 0) & 0xFF;
399
92
    uint8_t Type2 = (Type >> 8) & 0xFF;
400
92
    uint8_t Type3 = (Type >> 16) & 0xFF;
401
92
402
92
    // Concat all three relocation type names.
403
92
    StringRef Name = getRelocationTypeName(Type1);
404
92
    Result.append(Name.begin(), Name.end());
405
92
406
92
    Name = getRelocationTypeName(Type2);
407
92
    Result.append(1, '/');
408
92
    Result.append(Name.begin(), Name.end());
409
92
410
92
    Name = getRelocationTypeName(Type3);
411
92
    Result.append(1, '/');
412
92
    Result.append(Name.begin(), Name.end());
413
92
  }
414
2.29k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocationTypeName(unsigned int, llvm::SmallVectorImpl<char>&) const
Line
Count
Source
387
841
                                          SmallVectorImpl<char> &Result) const {
388
841
  if (!isMipsELF64()) {
389
723
    StringRef Name = getRelocationTypeName(Type);
390
723
    Result.append(Name.begin(), Name.end());
391
723
  } else {
392
118
    // The Mips N64 ABI allows up to three operations to be specified per
393
118
    // relocation record. Unfortunately there's no easy way to test for the
394
118
    // presence of N64 ELFs as they have no special flag that identifies them
395
118
    // as being N64. We can safely assume at the moment that all Mips
396
118
    // ELFCLASS64 ELFs are N64. New Mips64 ABIs should provide enough
397
118
    // information to disambiguate between old vs new ABIs.
398
118
    uint8_t Type1 = (Type >> 0) & 0xFF;
399
118
    uint8_t Type2 = (Type >> 8) & 0xFF;
400
118
    uint8_t Type3 = (Type >> 16) & 0xFF;
401
118
402
118
    // Concat all three relocation type names.
403
118
    StringRef Name = getRelocationTypeName(Type1);
404
118
    Result.append(Name.begin(), Name.end());
405
118
406
118
    Name = getRelocationTypeName(Type2);
407
118
    Result.append(1, '/');
408
118
    Result.append(Name.begin(), Name.end());
409
118
410
118
    Name = getRelocationTypeName(Type3);
411
118
    Result.append(1, '/');
412
118
    Result.append(Name.begin(), Name.end());
413
118
  }
414
841
}
415
416
template <class ELFT>
417
14
uint32_t ELFFile<ELFT>::getRelativeRelocationType() const {
418
14
  return getELFRelativeRelocationType(getHeader()->e_machine);
419
14
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelativeRelocationType() const
Line
Count
Source
417
4
uint32_t ELFFile<ELFT>::getRelativeRelocationType() const {
418
4
  return getELFRelativeRelocationType(getHeader()->e_machine);
419
4
}
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelativeRelocationType() const
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelativeRelocationType() const
Line
Count
Source
417
10
uint32_t ELFFile<ELFT>::getRelativeRelocationType() const {
418
10
  return getELFRelativeRelocationType(getHeader()->e_machine);
419
10
}
Unexecuted instantiation: llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelativeRelocationType() const
420
421
template <class ELFT>
422
Expected<const typename ELFT::Sym *>
423
ELFFile<ELFT>::getRelocationSymbol(const Elf_Rel *Rel,
424
3.95k
                                   const Elf_Shdr *SymTab) const {
425
3.95k
  uint32_t Index = Rel->getSymbol(isMips64EL());
426
3.95k
  if (Index == 0)
427
619
    return nullptr;
428
3.33k
  return getEntry<Elf_Sym>(SymTab, Index);
429
3.33k
}
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
424
1.04k
                                   const Elf_Shdr *SymTab) const {
425
1.04k
  uint32_t Index = Rel->getSymbol(isMips64EL());
426
1.04k
  if (Index == 0)
427
190
    return nullptr;
428
858
  return getEntry<Elf_Sym>(SymTab, Index);
429
858
}
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
424
311
                                   const Elf_Shdr *SymTab) const {
425
311
  uint32_t Index = Rel->getSymbol(isMips64EL());
426
311
  if (Index == 0)
427
85
    return nullptr;
428
226
  return getEntry<Elf_Sym>(SymTab, Index);
429
226
}
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
424
1.81k
                                   const Elf_Shdr *SymTab) const {
425
1.81k
  uint32_t Index = Rel->getSymbol(isMips64EL());
426
1.81k
  if (Index == 0)
427
248
    return nullptr;
428
1.56k
  return getEntry<Elf_Sym>(SymTab, Index);
429
1.56k
}
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
424
788
                                   const Elf_Shdr *SymTab) const {
425
788
  uint32_t Index = Rel->getSymbol(isMips64EL());
426
788
  if (Index == 0)
427
96
    return nullptr;
428
692
  return getEntry<Elf_Sym>(SymTab, Index);
429
692
}
430
431
template <class ELFT>
432
Expected<StringRef>
433
976k
ELFFile<ELFT>::getSectionStringTable(Elf_Shdr_Range Sections) const {
434
976k
  uint32_t Index = getHeader()->e_shstrndx;
435
976k
  if (Index == ELF::SHN_XINDEX)
436
522k
    Index = Sections[0].sh_link;
437
976k
438
976k
  if (!Index) // no section string table.
439
12
    return "";
440
976k
  if (Index >= Sections.size())
441
0
    return createError("invalid section index");
442
976k
  return getStringTable(&Sections[Index]);
443
976k
}
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
433
10.6k
ELFFile<ELFT>::getSectionStringTable(Elf_Shdr_Range Sections) const {
434
10.6k
  uint32_t Index = getHeader()->e_shstrndx;
435
10.6k
  if (Index == ELF::SHN_XINDEX)
436
0
    Index = Sections[0].sh_link;
437
10.6k
438
10.6k
  if (!Index) // no section string table.
439
4
    return "";
440
10.6k
  if (Index >= Sections.size())
441
0
    return createError("invalid section index");
442
10.6k
  return getStringTable(&Sections[Index]);
443
10.6k
}
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
433
3.48k
ELFFile<ELFT>::getSectionStringTable(Elf_Shdr_Range Sections) const {
434
3.48k
  uint32_t Index = getHeader()->e_shstrndx;
435
3.48k
  if (Index == ELF::SHN_XINDEX)
436
0
    Index = Sections[0].sh_link;
437
3.48k
438
3.48k
  if (!Index) // no section string table.
439
0
    return "";
440
3.48k
  if (Index >= Sections.size())
441
0
    return createError("invalid section index");
442
3.48k
  return getStringTable(&Sections[Index]);
443
3.48k
}
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
433
959k
ELFFile<ELFT>::getSectionStringTable(Elf_Shdr_Range Sections) const {
434
959k
  uint32_t Index = getHeader()->e_shstrndx;
435
959k
  if (Index == ELF::SHN_XINDEX)
436
522k
    Index = Sections[0].sh_link;
437
959k
438
959k
  if (!Index) // no section string table.
439
8
    return "";
440
959k
  if (Index >= Sections.size())
441
0
    return createError("invalid section index");
442
959k
  return getStringTable(&Sections[Index]);
443
959k
}
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
433
2.94k
ELFFile<ELFT>::getSectionStringTable(Elf_Shdr_Range Sections) const {
434
2.94k
  uint32_t Index = getHeader()->e_shstrndx;
435
2.94k
  if (Index == ELF::SHN_XINDEX)
436
0
    Index = Sections[0].sh_link;
437
2.94k
438
2.94k
  if (!Index) // no section string table.
439
0
    return "";
440
2.94k
  if (Index >= Sections.size())
441
0
    return createError("invalid section index");
442
2.94k
  return getStringTable(&Sections[Index]);
443
2.94k
}
444
445
793k
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
445
9.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
445
4.81k
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
445
765k
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
445
13.0k
template <class ELFT> ELFFile<ELFT>::ELFFile(StringRef Object) : Buf(Object) {}
446
447
template <class ELFT>
448
793k
Expected<ELFFile<ELFT>> ELFFile<ELFT>::create(StringRef Object) {
449
793k
  if (sizeof(Elf_Ehdr) > Object.size())
450
1
    return createError("Invalid buffer");
451
793k
  return ELFFile(Object);
452
793k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::create(llvm::StringRef)
Line
Count
Source
448
9.56k
Expected<ELFFile<ELFT>> ELFFile<ELFT>::create(StringRef Object) {
449
9.56k
  if (sizeof(Elf_Ehdr) > Object.size())
450
1
    return createError("Invalid buffer");
451
9.56k
  return ELFFile(Object);
452
9.56k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::create(llvm::StringRef)
Line
Count
Source
448
4.81k
Expected<ELFFile<ELFT>> ELFFile<ELFT>::create(StringRef Object) {
449
4.81k
  if (sizeof(Elf_Ehdr) > Object.size())
450
0
    return createError("Invalid buffer");
451
4.81k
  return ELFFile(Object);
452
4.81k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::create(llvm::StringRef)
Line
Count
Source
448
765k
Expected<ELFFile<ELFT>> ELFFile<ELFT>::create(StringRef Object) {
449
765k
  if (sizeof(Elf_Ehdr) > Object.size())
450
0
    return createError("Invalid buffer");
451
765k
  return ELFFile(Object);
452
765k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::create(llvm::StringRef)
Line
Count
Source
448
13.0k
Expected<ELFFile<ELFT>> ELFFile<ELFT>::create(StringRef Object) {
449
13.0k
  if (sizeof(Elf_Ehdr) > Object.size())
450
0
    return createError("Invalid buffer");
451
13.0k
  return ELFFile(Object);
452
13.0k
}
453
454
template <class ELFT>
455
1.54M
Expected<typename ELFT::ShdrRange> ELFFile<ELFT>::sections() const {
456
1.54M
  const uintX_t SectionTableOffset = getHeader()->e_shoff;
457
1.54M
  if (SectionTableOffset == 0)
458
35
    return ArrayRef<Elf_Shdr>();
459
1.54M
460
1.54M
  if (getHeader()->e_shentsize != sizeof(Elf_Shdr))
461
1
    return createError(
462
1
        "invalid section header entry size (e_shentsize) in ELF header");
463
1.54M
464
1.54M
  const uint64_t FileSize = Buf.size();
465
1.54M
466
1.54M
  if (SectionTableOffset + sizeof(Elf_Shdr) > FileSize)
467
1
    return createError("section header table goes past the end of the file");
468
1.54M
469
1.54M
  // Invalid address alignment of section headers
470
1.54M
  if (SectionTableOffset & (alignof(Elf_Shdr) - 1))
471
0
    return createError("invalid alignment of section headers");
472
1.54M
473
1.54M
  const Elf_Shdr *First =
474
1.54M
      reinterpret_cast<const Elf_Shdr *>(base() + SectionTableOffset);
475
1.54M
476
1.54M
  uintX_t NumSections = getHeader()->e_shnum;
477
1.54M
  if (NumSections == 0)
478
849k
    NumSections = First->sh_size;
479
1.54M
480
1.54M
  if (NumSections > UINT64_MAX / sizeof(Elf_Shdr))
481
1
    return createError("section table goes past the end of file");
482
1.54M
483
1.54M
  const uint64_t SectionTableSize = NumSections * sizeof(Elf_Shdr);
484
1.54M
485
1.54M
  // Section table goes past end of file!
486
1.54M
  if (SectionTableOffset + SectionTableSize > FileSize)
487
0
    return createError("section table goes past the end of file");
488
1.54M
489
1.54M
  return makeArrayRef(First, NumSections);
490
1.54M
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::sections() const
Line
Count
Source
455
151k
Expected<typename ELFT::ShdrRange> ELFFile<ELFT>::sections() const {
456
151k
  const uintX_t SectionTableOffset = getHeader()->e_shoff;
457
151k
  if (SectionTableOffset == 0)
458
0
    return ArrayRef<Elf_Shdr>();
459
151k
460
151k
  if (getHeader()->e_shentsize != sizeof(Elf_Shdr))
461
0
    return createError(
462
0
        "invalid section header entry size (e_shentsize) in ELF header");
463
151k
464
151k
  const uint64_t FileSize = Buf.size();
465
151k
466
151k
  if (SectionTableOffset + sizeof(Elf_Shdr) > FileSize)
467
0
    return createError("section header table goes past the end of the file");
468
151k
469
151k
  // Invalid address alignment of section headers
470
151k
  if (SectionTableOffset & (alignof(Elf_Shdr) - 1))
471
0
    return createError("invalid alignment of section headers");
472
151k
473
151k
  const Elf_Shdr *First =
474
151k
      reinterpret_cast<const Elf_Shdr *>(base() + SectionTableOffset);
475
151k
476
151k
  uintX_t NumSections = getHeader()->e_shnum;
477
151k
  if (NumSections == 0)
478
0
    NumSections = First->sh_size;
479
151k
480
151k
  if (NumSections > UINT64_MAX / sizeof(Elf_Shdr))
481
0
    return createError("section table goes past the end of file");
482
151k
483
151k
  const uint64_t SectionTableSize = NumSections * sizeof(Elf_Shdr);
484
151k
485
151k
  // Section table goes past end of file!
486
151k
  if (SectionTableOffset + SectionTableSize > FileSize)
487
0
    return createError("section table goes past the end of file");
488
151k
489
151k
  return makeArrayRef(First, NumSections);
490
151k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::sections() const
Line
Count
Source
455
21.9k
Expected<typename ELFT::ShdrRange> ELFFile<ELFT>::sections() const {
456
21.9k
  const uintX_t SectionTableOffset = getHeader()->e_shoff;
457
21.9k
  if (SectionTableOffset == 0)
458
0
    return ArrayRef<Elf_Shdr>();
459
21.9k
460
21.9k
  if (getHeader()->e_shentsize != sizeof(Elf_Shdr))
461
0
    return createError(
462
0
        "invalid section header entry size (e_shentsize) in ELF header");
463
21.9k
464
21.9k
  const uint64_t FileSize = Buf.size();
465
21.9k
466
21.9k
  if (SectionTableOffset + sizeof(Elf_Shdr) > FileSize)
467
0
    return createError("section header table goes past the end of the file");
468
21.9k
469
21.9k
  // Invalid address alignment of section headers
470
21.9k
  if (SectionTableOffset & (alignof(Elf_Shdr) - 1))
471
0
    return createError("invalid alignment of section headers");
472
21.9k
473
21.9k
  const Elf_Shdr *First =
474
21.9k
      reinterpret_cast<const Elf_Shdr *>(base() + SectionTableOffset);
475
21.9k
476
21.9k
  uintX_t NumSections = getHeader()->e_shnum;
477
21.9k
  if (NumSections == 0)
478
0
    NumSections = First->sh_size;
479
21.9k
480
21.9k
  if (NumSections > UINT64_MAX / sizeof(Elf_Shdr))
481
0
    return createError("section table goes past the end of file");
482
21.9k
483
21.9k
  const uint64_t SectionTableSize = NumSections * sizeof(Elf_Shdr);
484
21.9k
485
21.9k
  // Section table goes past end of file!
486
21.9k
  if (SectionTableOffset + SectionTableSize > FileSize)
487
0
    return createError("section table goes past the end of file");
488
21.9k
489
21.9k
  return makeArrayRef(First, NumSections);
490
21.9k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::sections() const
Line
Count
Source
455
1.35M
Expected<typename ELFT::ShdrRange> ELFFile<ELFT>::sections() const {
456
1.35M
  const uintX_t SectionTableOffset = getHeader()->e_shoff;
457
1.35M
  if (SectionTableOffset == 0)
458
35
    return ArrayRef<Elf_Shdr>();
459
1.35M
460
1.35M
  if (getHeader()->e_shentsize != sizeof(Elf_Shdr))
461
1
    return createError(
462
1
        "invalid section header entry size (e_shentsize) in ELF header");
463
1.35M
464
1.35M
  const uint64_t FileSize = Buf.size();
465
1.35M
466
1.35M
  if (SectionTableOffset + sizeof(Elf_Shdr) > FileSize)
467
1
    return createError("section header table goes past the end of the file");
468
1.35M
469
1.35M
  // Invalid address alignment of section headers
470
1.35M
  if (SectionTableOffset & (alignof(Elf_Shdr) - 1))
471
0
    return createError("invalid alignment of section headers");
472
1.35M
473
1.35M
  const Elf_Shdr *First =
474
1.35M
      reinterpret_cast<const Elf_Shdr *>(base() + SectionTableOffset);
475
1.35M
476
1.35M
  uintX_t NumSections = getHeader()->e_shnum;
477
1.35M
  if (NumSections == 0)
478
849k
    NumSections = First->sh_size;
479
1.35M
480
1.35M
  if (NumSections > UINT64_MAX / sizeof(Elf_Shdr))
481
1
    return createError("section table goes past the end of file");
482
1.35M
483
1.35M
  const uint64_t SectionTableSize = NumSections * sizeof(Elf_Shdr);
484
1.35M
485
1.35M
  // Section table goes past end of file!
486
1.35M
  if (SectionTableOffset + SectionTableSize > FileSize)
487
0
    return createError("section table goes past the end of file");
488
1.35M
489
1.35M
  return makeArrayRef(First, NumSections);
490
1.35M
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::sections() const
Line
Count
Source
455
18.0k
Expected<typename ELFT::ShdrRange> ELFFile<ELFT>::sections() const {
456
18.0k
  const uintX_t SectionTableOffset = getHeader()->e_shoff;
457
18.0k
  if (SectionTableOffset == 0)
458
0
    return ArrayRef<Elf_Shdr>();
459
18.0k
460
18.0k
  if (getHeader()->e_shentsize != sizeof(Elf_Shdr))
461
0
    return createError(
462
0
        "invalid section header entry size (e_shentsize) in ELF header");
463
18.0k
464
18.0k
  const uint64_t FileSize = Buf.size();
465
18.0k
466
18.0k
  if (SectionTableOffset + sizeof(Elf_Shdr) > FileSize)
467
0
    return createError("section header table goes past the end of the file");
468
18.0k
469
18.0k
  // Invalid address alignment of section headers
470
18.0k
  if (SectionTableOffset & (alignof(Elf_Shdr) - 1))
471
0
    return createError("invalid alignment of section headers");
472
18.0k
473
18.0k
  const Elf_Shdr *First =
474
18.0k
      reinterpret_cast<const Elf_Shdr *>(base() + SectionTableOffset);
475
18.0k
476
18.0k
  uintX_t NumSections = getHeader()->e_shnum;
477
18.0k
  if (NumSections == 0)
478
0
    NumSections = First->sh_size;
479
18.0k
480
18.0k
  if (NumSections > UINT64_MAX / sizeof(Elf_Shdr))
481
0
    return createError("section table goes past the end of file");
482
18.0k
483
18.0k
  const uint64_t SectionTableSize = NumSections * sizeof(Elf_Shdr);
484
18.0k
485
18.0k
  // Section table goes past end of file!
486
18.0k
  if (SectionTableOffset + SectionTableSize > FileSize)
487
0
    return createError("section table goes past the end of file");
488
18.0k
489
18.0k
  return makeArrayRef(First, NumSections);
490
18.0k
}
491
492
template <class ELFT>
493
template <typename T>
494
Expected<const T *> ELFFile<ELFT>::getEntry(uint32_t Section,
495
212k
                                            uint32_t Entry) const {
496
212k
  auto SecOrErr = getSection(Section);
497
212k
  if (!SecOrErr)
498
0
    return SecOrErr.takeError();
499
212k
  return getEntry<T>(*SecOrErr, Entry);
500
212k
}
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
495
56.5k
                                            uint32_t Entry) const {
496
56.5k
  auto SecOrErr = getSection(Section);
497
56.5k
  if (!SecOrErr)
498
0
    return SecOrErr.takeError();
499
56.5k
  return getEntry<T>(*SecOrErr, Entry);
500
56.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
495
1.96k
                                            uint32_t Entry) const {
496
1.96k
  auto SecOrErr = getSection(Section);
497
1.96k
  if (!SecOrErr)
498
0
    return SecOrErr.takeError();
499
1.96k
  return getEntry<T>(*SecOrErr, Entry);
500
1.96k
}
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
495
737
                                            uint32_t Entry) const {
496
737
  auto SecOrErr = getSection(Section);
497
737
  if (!SecOrErr)
498
0
    return SecOrErr.takeError();
499
737
  return getEntry<T>(*SecOrErr, Entry);
500
737
}
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
495
5.14k
                                            uint32_t Entry) const {
496
5.14k
  auto SecOrErr = getSection(Section);
497
5.14k
  if (!SecOrErr)
498
0
    return SecOrErr.takeError();
499
5.14k
  return getEntry<T>(*SecOrErr, Entry);
500
5.14k
}
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
495
806
                                            uint32_t Entry) const {
496
806
  auto SecOrErr = getSection(Section);
497
806
  if (!SecOrErr)
498
0
    return SecOrErr.takeError();
499
806
  return getEntry<T>(*SecOrErr, Entry);
500
806
}
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
495
614
                                            uint32_t Entry) const {
496
614
  auto SecOrErr = getSection(Section);
497
614
  if (!SecOrErr)
498
0
    return SecOrErr.takeError();
499
614
  return getEntry<T>(*SecOrErr, Entry);
500
614
}
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
495
120k
                                            uint32_t Entry) const {
496
120k
  auto SecOrErr = getSection(Section);
497
120k
  if (!SecOrErr)
498
0
    return SecOrErr.takeError();
499
120k
  return getEntry<T>(*SecOrErr, Entry);
500
120k
}
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
495
167
                                            uint32_t Entry) const {
496
167
  auto SecOrErr = getSection(Section);
497
167
  if (!SecOrErr)
498
0
    return SecOrErr.takeError();
499
167
  return getEntry<T>(*SecOrErr, Entry);
500
167
}
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
495
20.4k
                                            uint32_t Entry) const {
496
20.4k
  auto SecOrErr = getSection(Section);
497
20.4k
  if (!SecOrErr)
498
0
    return SecOrErr.takeError();
499
20.4k
  return getEntry<T>(*SecOrErr, Entry);
500
20.4k
}
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
495
3.77k
                                            uint32_t Entry) const {
496
3.77k
  auto SecOrErr = getSection(Section);
497
3.77k
  if (!SecOrErr)
498
0
    return SecOrErr.takeError();
499
3.77k
  return getEntry<T>(*SecOrErr, Entry);
500
3.77k
}
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
495
54
                                            uint32_t Entry) const {
496
54
  auto SecOrErr = getSection(Section);
497
54
  if (!SecOrErr)
498
0
    return SecOrErr.takeError();
499
54
  return getEntry<T>(*SecOrErr, Entry);
500
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
495
1.14k
                                            uint32_t Entry) const {
496
1.14k
  auto SecOrErr = getSection(Section);
497
1.14k
  if (!SecOrErr)
498
0
    return SecOrErr.takeError();
499
1.14k
  return getEntry<T>(*SecOrErr, Entry);
500
1.14k
}
501
502
template <class ELFT>
503
template <typename T>
504
Expected<const T *> ELFFile<ELFT>::getEntry(const Elf_Shdr *Section,
505
215k
                                            uint32_t Entry) const {
506
215k
  if (sizeof(T) != Section->sh_entsize)
507
0
    return createError("invalid sh_entsize");
508
215k
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
509
215k
  if (Pos + sizeof(T) > Buf.size())
510
1
    return createError("invalid section offset");
511
215k
  return reinterpret_cast<const T *>(base() + Pos);
512
215k
}
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
505
57.3k
                                            uint32_t Entry) const {
506
57.3k
  if (sizeof(T) != Section->sh_entsize)
507
0
    return createError("invalid sh_entsize");
508
57.3k
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
509
57.3k
  if (Pos + sizeof(T) > Buf.size())
510
0
    return createError("invalid section offset");
511
57.3k
  return reinterpret_cast<const T *>(base() + Pos);
512
57.3k
}
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
505
5.36k
                                            uint32_t Entry) const {
506
5.36k
  if (sizeof(T) != Section->sh_entsize)
507
0
    return createError("invalid sh_entsize");
508
5.36k
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
509
5.36k
  if (Pos + sizeof(T) > Buf.size())
510
0
    return createError("invalid section offset");
511
5.36k
  return reinterpret_cast<const T *>(base() + Pos);
512
5.36k
}
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
505
122k
                                            uint32_t Entry) const {
506
122k
  if (sizeof(T) != Section->sh_entsize)
507
0
    return createError("invalid sh_entsize");
508
122k
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
509
122k
  if (Pos + sizeof(T) > Buf.size())
510
1
    return createError("invalid section offset");
511
122k
  return reinterpret_cast<const T *>(base() + Pos);
512
122k
}
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
505
4.46k
                                            uint32_t Entry) const {
506
4.46k
  if (sizeof(T) != Section->sh_entsize)
507
0
    return createError("invalid sh_entsize");
508
4.46k
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
509
4.46k
  if (Pos + sizeof(T) > Buf.size())
510
0
    return createError("invalid section offset");
511
4.46k
  return reinterpret_cast<const T *>(base() + Pos);
512
4.46k
}
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
505
1.96k
                                            uint32_t Entry) const {
506
1.96k
  if (sizeof(T) != Section->sh_entsize)
507
0
    return createError("invalid sh_entsize");
508
1.96k
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
509
1.96k
  if (Pos + sizeof(T) > Buf.size())
510
0
    return createError("invalid section offset");
511
1.96k
  return reinterpret_cast<const T *>(base() + Pos);
512
1.96k
}
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
505
737
                                            uint32_t Entry) const {
506
737
  if (sizeof(T) != Section->sh_entsize)
507
0
    return createError("invalid sh_entsize");
508
737
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
509
737
  if (Pos + sizeof(T) > Buf.size())
510
0
    return createError("invalid section offset");
511
737
  return reinterpret_cast<const T *>(base() + Pos);
512
737
}
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
505
806
                                            uint32_t Entry) const {
506
806
  if (sizeof(T) != Section->sh_entsize)
507
0
    return createError("invalid sh_entsize");
508
806
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
509
806
  if (Pos + sizeof(T) > Buf.size())
510
0
    return createError("invalid section offset");
511
806
  return reinterpret_cast<const T *>(base() + Pos);
512
806
}
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
505
614
                                            uint32_t Entry) const {
506
614
  if (sizeof(T) != Section->sh_entsize)
507
0
    return createError("invalid sh_entsize");
508
614
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
509
614
  if (Pos + sizeof(T) > Buf.size())
510
0
    return createError("invalid section offset");
511
614
  return reinterpret_cast<const T *>(base() + Pos);
512
614
}
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
505
167
                                            uint32_t Entry) const {
506
167
  if (sizeof(T) != Section->sh_entsize)
507
0
    return createError("invalid sh_entsize");
508
167
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
509
167
  if (Pos + sizeof(T) > Buf.size())
510
0
    return createError("invalid section offset");
511
167
  return reinterpret_cast<const T *>(base() + Pos);
512
167
}
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
505
20.4k
                                            uint32_t Entry) const {
506
20.4k
  if (sizeof(T) != Section->sh_entsize)
507
0
    return createError("invalid sh_entsize");
508
20.4k
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
509
20.4k
  if (Pos + sizeof(T) > Buf.size())
510
0
    return createError("invalid section offset");
511
20.4k
  return reinterpret_cast<const T *>(base() + Pos);
512
20.4k
}
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
505
54
                                            uint32_t Entry) const {
506
54
  if (sizeof(T) != Section->sh_entsize)
507
0
    return createError("invalid sh_entsize");
508
54
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
509
54
  if (Pos + sizeof(T) > Buf.size())
510
0
    return createError("invalid section offset");
511
54
  return reinterpret_cast<const T *>(base() + Pos);
512
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
505
1.14k
                                            uint32_t Entry) const {
506
1.14k
  if (sizeof(T) != Section->sh_entsize)
507
0
    return createError("invalid sh_entsize");
508
1.14k
  size_t Pos = Section->sh_offset + Entry * sizeof(T);
509
1.14k
  if (Pos + sizeof(T) > Buf.size())
510
0
    return createError("invalid section offset");
511
1.14k
  return reinterpret_cast<const T *>(base() + Pos);
512
1.14k
}
513
514
template <class ELFT>
515
Expected<const typename ELFT::Shdr *>
516
461k
ELFFile<ELFT>::getSection(uint32_t Index) const {
517
461k
  auto TableOrErr = sections();
518
461k
  if (!TableOrErr)
519
0
    return TableOrErr.takeError();
520
461k
  return object::getSection<ELFT>(*TableOrErr, Index);
521
461k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSection(unsigned int) const
Line
Count
Source
516
119k
ELFFile<ELFT>::getSection(uint32_t Index) const {
517
119k
  auto TableOrErr = sections();
518
119k
  if (!TableOrErr)
519
0
    return TableOrErr.takeError();
520
119k
  return object::getSection<ELFT>(*TableOrErr, Index);
521
119k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSection(unsigned int) const
Line
Count
Source
516
12.8k
ELFFile<ELFT>::getSection(uint32_t Index) const {
517
12.8k
  auto TableOrErr = sections();
518
12.8k
  if (!TableOrErr)
519
0
    return TableOrErr.takeError();
520
12.8k
  return object::getSection<ELFT>(*TableOrErr, Index);
521
12.8k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSection(unsigned int) const
Line
Count
Source
516
319k
ELFFile<ELFT>::getSection(uint32_t Index) const {
517
319k
  auto TableOrErr = sections();
518
319k
  if (!TableOrErr)
519
0
    return TableOrErr.takeError();
520
319k
  return object::getSection<ELFT>(*TableOrErr, Index);
521
319k
}
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSection(unsigned int) const
Line
Count
Source
516
9.87k
ELFFile<ELFT>::getSection(uint32_t Index) const {
517
9.87k
  auto TableOrErr = sections();
518
9.87k
  if (!TableOrErr)
519
0
    return TableOrErr.takeError();
520
9.87k
  return object::getSection<ELFT>(*TableOrErr, Index);
521
9.87k
}
522
523
template <class ELFT>
524
Expected<const typename ELFT::Shdr *>
525
0
ELFFile<ELFT>::getSection(const StringRef SectionName) const {
526
0
  auto TableOrErr = sections();
527
0
  if (!TableOrErr)
528
0
    return TableOrErr.takeError();
529
0
  for (auto &Sec : *TableOrErr) {
530
0
    auto SecNameOrErr = getSectionName(&Sec);
531
0
    if (!SecNameOrErr)
532
0
      return SecNameOrErr.takeError();
533
0
    if (*SecNameOrErr == SectionName)
534
0
      return &Sec;
535
0
  }
536
0
  return createError("invalid section name");
537
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
538
539
template <class ELFT>
540
Expected<StringRef>
541
1.01M
ELFFile<ELFT>::getStringTable(const Elf_Shdr *Section) const {
542
1.01M
  if (Section->sh_type != ELF::SHT_STRTAB)
543
1
    return createError("invalid sh_type for string table, expected SHT_STRTAB");
544
1.01M
  auto V = getSectionContentsAsArray<char>(Section);
545
1.01M
  if (!V)
546
2
    return V.takeError();
547
1.01M
  ArrayRef<char> Data = *V;
548
1.01M
  if (Data.empty())
549
1
    return createError("empty string table");
550
1.01M
  if (Data.back() != '\0')
551
1
    return createError("string table non-null terminated");
552
1.01M
  return StringRef(Data.begin(), Data.size());
553
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
541
26.9k
ELFFile<ELFT>::getStringTable(const Elf_Shdr *Section) const {
542
26.9k
  if (Section->sh_type != ELF::SHT_STRTAB)
543
0
    return createError("invalid sh_type for string table, expected SHT_STRTAB");
544
26.9k
  auto V = getSectionContentsAsArray<char>(Section);
545
26.9k
  if (!V)
546
1
    return V.takeError();
547
26.9k
  ArrayRef<char> Data = *V;
548
26.9k
  if (Data.empty())
549
0
    return createError("empty string table");
550
26.9k
  if (Data.back() != '\0')
551
0
    return createError("string table non-null terminated");
552
26.9k
  return StringRef(Data.begin(), Data.size());
553
26.9k
}
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
541
4.73k
ELFFile<ELFT>::getStringTable(const Elf_Shdr *Section) const {
542
4.73k
  if (Section->sh_type != ELF::SHT_STRTAB)
543
0
    return createError("invalid sh_type for string table, expected SHT_STRTAB");
544
4.73k
  auto V = getSectionContentsAsArray<char>(Section);
545
4.73k
  if (!V)
546
0
    return V.takeError();
547
4.73k
  ArrayRef<char> Data = *V;
548
4.73k
  if (Data.empty())
549
0
    return createError("empty string table");
550
4.73k
  if (Data.back() != '\0')
551
0
    return createError("string table non-null terminated");
552
4.73k
  return StringRef(Data.begin(), Data.size());
553
4.73k
}
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
541
983k
ELFFile<ELFT>::getStringTable(const Elf_Shdr *Section) const {
542
983k
  if (Section->sh_type != ELF::SHT_STRTAB)
543
1
    return createError("invalid sh_type for string table, expected SHT_STRTAB");
544
983k
  auto V = getSectionContentsAsArray<char>(Section);
545
983k
  if (!V)
546
1
    return V.takeError();
547
983k
  ArrayRef<char> Data = *V;
548
983k
  if (Data.empty())
549
1
    return createError("empty string table");
550
983k
  if (Data.back() != '\0')
551
1
    return createError("string table non-null terminated");
552
983k
  return StringRef(Data.begin(), Data.size());
553
983k
}
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
541
4.27k
ELFFile<ELFT>::getStringTable(const Elf_Shdr *Section) const {
542
4.27k
  if (Section->sh_type != ELF::SHT_STRTAB)
543
0
    return createError("invalid sh_type for string table, expected SHT_STRTAB");
544
4.27k
  auto V = getSectionContentsAsArray<char>(Section);
545
4.27k
  if (!V)
546
0
    return V.takeError();
547
4.27k
  ArrayRef<char> Data = *V;
548
4.27k
  if (Data.empty())
549
0
    return createError("empty string table");
550
4.27k
  if (Data.back() != '\0')
551
0
    return createError("string table non-null terminated");
552
4.27k
  return StringRef(Data.begin(), Data.size());
553
4.27k
}
554
555
template <class ELFT>
556
Expected<ArrayRef<typename ELFT::Word>>
557
33
ELFFile<ELFT>::getSHNDXTable(const Elf_Shdr &Section) const {
558
33
  auto SectionsOrErr = sections();
559
33
  if (!SectionsOrErr)
560
0
    return SectionsOrErr.takeError();
561
33
  return getSHNDXTable(Section, *SectionsOrErr);
562
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
557
33
ELFFile<ELFT>::getSHNDXTable(const Elf_Shdr &Section) const {
558
33
  auto SectionsOrErr = sections();
559
33
  if (!SectionsOrErr)
560
0
    return SectionsOrErr.takeError();
561
33
  return getSHNDXTable(Section, *SectionsOrErr);
562
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
563
564
template <class ELFT>
565
Expected<ArrayRef<typename ELFT::Word>>
566
ELFFile<ELFT>::getSHNDXTable(const Elf_Shdr &Section,
567
38
                             Elf_Shdr_Range Sections) const {
568
38
  assert(Section.sh_type == ELF::SHT_SYMTAB_SHNDX);
569
38
  auto VOrErr = getSectionContentsAsArray<Elf_Word>(&Section);
570
38
  if (!VOrErr)
571
0
    return VOrErr.takeError();
572
38
  ArrayRef<Elf_Word> V = *VOrErr;
573
38
  auto SymTableOrErr = object::getSection<ELFT>(Sections, Section.sh_link);
574
38
  if (!SymTableOrErr)
575
0
    return SymTableOrErr.takeError();
576
38
  const Elf_Shdr &SymTable = **SymTableOrErr;
577
38
  if (SymTable.sh_type != ELF::SHT_SYMTAB &&
578
38
      
SymTable.sh_type != ELF::SHT_DYNSYM0
)
579
0
    return createError("invalid sh_type");
580
38
  if (V.size() != (SymTable.sh_size / sizeof(Elf_Sym)))
581
1
    return createError("invalid section contents size");
582
37
  return V;
583
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
567
38
                             Elf_Shdr_Range Sections) const {
568
38
  assert(Section.sh_type == ELF::SHT_SYMTAB_SHNDX);
569
38
  auto VOrErr = getSectionContentsAsArray<Elf_Word>(&Section);
570
38
  if (!VOrErr)
571
0
    return VOrErr.takeError();
572
38
  ArrayRef<Elf_Word> V = *VOrErr;
573
38
  auto SymTableOrErr = object::getSection<ELFT>(Sections, Section.sh_link);
574
38
  if (!SymTableOrErr)
575
0
    return SymTableOrErr.takeError();
576
38
  const Elf_Shdr &SymTable = **SymTableOrErr;
577
38
  if (SymTable.sh_type != ELF::SHT_SYMTAB &&
578
38
      
SymTable.sh_type != ELF::SHT_DYNSYM0
)
579
0
    return createError("invalid sh_type");
580
38
  if (V.size() != (SymTable.sh_size / sizeof(Elf_Sym)))
581
1
    return createError("invalid section contents size");
582
37
  return V;
583
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
584
585
template <class ELFT>
586
Expected<StringRef>
587
4.42k
ELFFile<ELFT>::getStringTableForSymtab(const Elf_Shdr &Sec) const {
588
4.42k
  auto SectionsOrErr = sections();
589
4.42k
  if (!SectionsOrErr)
590
0
    return SectionsOrErr.takeError();
591
4.42k
  return getStringTableForSymtab(Sec, *SectionsOrErr);
592
4.42k
}
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
587
942
ELFFile<ELFT>::getStringTableForSymtab(const Elf_Shdr &Sec) const {
588
942
  auto SectionsOrErr = sections();
589
942
  if (!SectionsOrErr)
590
0
    return SectionsOrErr.takeError();
591
942
  return getStringTableForSymtab(Sec, *SectionsOrErr);
592
942
}
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
587
263
ELFFile<ELFT>::getStringTableForSymtab(const Elf_Shdr &Sec) const {
588
263
  auto SectionsOrErr = sections();
589
263
  if (!SectionsOrErr)
590
0
    return SectionsOrErr.takeError();
591
263
  return getStringTableForSymtab(Sec, *SectionsOrErr);
592
263
}
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
587
2.64k
ELFFile<ELFT>::getStringTableForSymtab(const Elf_Shdr &Sec) const {
588
2.64k
  auto SectionsOrErr = sections();
589
2.64k
  if (!SectionsOrErr)
590
0
    return SectionsOrErr.takeError();
591
2.64k
  return getStringTableForSymtab(Sec, *SectionsOrErr);
592
2.64k
}
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
587
579
ELFFile<ELFT>::getStringTableForSymtab(const Elf_Shdr &Sec) const {
588
579
  auto SectionsOrErr = sections();
589
579
  if (!SectionsOrErr)
590
0
    return SectionsOrErr.takeError();
591
579
  return getStringTableForSymtab(Sec, *SectionsOrErr);
592
579
}
593
594
template <class ELFT>
595
Expected<StringRef>
596
ELFFile<ELFT>::getStringTableForSymtab(const Elf_Shdr &Sec,
597
7.94k
                                       Elf_Shdr_Range Sections) const {
598
7.94k
599
7.94k
  if (Sec.sh_type != ELF::SHT_SYMTAB && 
Sec.sh_type != ELF::SHT_DYNSYM1.42k
)
600
0
    return createError(
601
0
        "invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM");
602
7.94k
  auto SectionOrErr = object::getSection<ELFT>(Sections, Sec.sh_link);
603
7.94k
  if (!SectionOrErr)
604
1
    return SectionOrErr.takeError();
605
7.94k
  return getStringTable(*SectionOrErr);
606
7.94k
}
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
597
1.38k
                                       Elf_Shdr_Range Sections) const {
598
1.38k
599
1.38k
  if (Sec.sh_type != ELF::SHT_SYMTAB && 
Sec.sh_type != ELF::SHT_DYNSYM240
)
600
0
    return createError(
601
0
        "invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM");
602
1.38k
  auto SectionOrErr = object::getSection<ELFT>(Sections, Sec.sh_link);
603
1.38k
  if (!SectionOrErr)
604
0
    return SectionOrErr.takeError();
605
1.38k
  return getStringTable(*SectionOrErr);
606
1.38k
}
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
597
466
                                       Elf_Shdr_Range Sections) const {
598
466
599
466
  if (Sec.sh_type != ELF::SHT_SYMTAB && 
Sec.sh_type != ELF::SHT_DYNSYM102
)
600
0
    return createError(
601
0
        "invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM");
602
466
  auto SectionOrErr = object::getSection<ELFT>(Sections, Sec.sh_link);
603
466
  if (!SectionOrErr)
604
0
    return SectionOrErr.takeError();
605
466
  return getStringTable(*SectionOrErr);
606
466
}
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
597
5.35k
                                       Elf_Shdr_Range Sections) const {
598
5.35k
599
5.35k
  if (Sec.sh_type != ELF::SHT_SYMTAB && 
Sec.sh_type != ELF::SHT_DYNSYM1.00k
)
600
0
    return createError(
601
0
        "invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM");
602
5.35k
  auto SectionOrErr = object::getSection<ELFT>(Sections, Sec.sh_link);
603
5.35k
  if (!SectionOrErr)
604
1
    return SectionOrErr.takeError();
605
5.35k
  return getStringTable(*SectionOrErr);
606
5.35k
}
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
597
740
                                       Elf_Shdr_Range Sections) const {
598
740
599
740
  if (Sec.sh_type != ELF::SHT_SYMTAB && 
Sec.sh_type != ELF::SHT_DYNSYM78
)
600
0
    return createError(
601
0
        "invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM");
602
740
  auto SectionOrErr = object::getSection<ELFT>(Sections, Sec.sh_link);
603
740
  if (!SectionOrErr)
604
0
    return SectionOrErr.takeError();
605
740
  return getStringTable(*SectionOrErr);
606
740
}
607
608
template <class ELFT>
609
Expected<StringRef>
610
973k
ELFFile<ELFT>::getSectionName(const Elf_Shdr *Section) const {
611
973k
  auto SectionsOrErr = sections();
612
973k
  if (!SectionsOrErr)
613
0
    return SectionsOrErr.takeError();
614
973k
  auto Table = getSectionStringTable(*SectionsOrErr);
615
973k
  if (!Table)
616
5
    return Table.takeError();
617
973k
  return getSectionName(Section, *Table);
618
973k
}
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
610
10.2k
ELFFile<ELFT>::getSectionName(const Elf_Shdr *Section) const {
611
10.2k
  auto SectionsOrErr = sections();
612
10.2k
  if (!SectionsOrErr)
613
0
    return SectionsOrErr.takeError();
614
10.2k
  auto Table = getSectionStringTable(*SectionsOrErr);
615
10.2k
  if (!Table)
616
1
    return Table.takeError();
617
10.2k
  return getSectionName(Section, *Table);
618
10.2k
}
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
610
3.30k
ELFFile<ELFT>::getSectionName(const Elf_Shdr *Section) const {
611
3.30k
  auto SectionsOrErr = sections();
612
3.30k
  if (!SectionsOrErr)
613
0
    return SectionsOrErr.takeError();
614
3.30k
  auto Table = getSectionStringTable(*SectionsOrErr);
615
3.30k
  if (!Table)
616
0
    return Table.takeError();
617
3.30k
  return getSectionName(Section, *Table);
618
3.30k
}
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
610
956k
ELFFile<ELFT>::getSectionName(const Elf_Shdr *Section) const {
611
956k
  auto SectionsOrErr = sections();
612
956k
  if (!SectionsOrErr)
613
0
    return SectionsOrErr.takeError();
614
956k
  auto Table = getSectionStringTable(*SectionsOrErr);
615
956k
  if (!Table)
616
4
    return Table.takeError();
617
956k
  return getSectionName(Section, *Table);
618
956k
}
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
610
2.79k
ELFFile<ELFT>::getSectionName(const Elf_Shdr *Section) const {
611
2.79k
  auto SectionsOrErr = sections();
612
2.79k
  if (!SectionsOrErr)
613
0
    return SectionsOrErr.takeError();
614
2.79k
  auto Table = getSectionStringTable(*SectionsOrErr);
615
2.79k
  if (!Table)
616
0
    return Table.takeError();
617
2.79k
  return getSectionName(Section, *Table);
618
2.79k
}
619
620
template <class ELFT>
621
Expected<StringRef> ELFFile<ELFT>::getSectionName(const Elf_Shdr *Section,
622
1.31M
                                                  StringRef DotShstrtab) const {
623
1.31M
  uint32_t Offset = Section->sh_name;
624
1.31M
  if (Offset == 0)
625
4.33k
    return StringRef();
626
1.30M
  if (Offset >= DotShstrtab.size())
627
30
    return createError("invalid string offset");
628
1.30M
  return StringRef(DotShstrtab.data() + Offset);
629
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
622
11.8k
                                                  StringRef DotShstrtab) const {
623
11.8k
  uint32_t Offset = Section->sh_name;
624
11.8k
  if (Offset == 0)
625
819
    return StringRef();
626
11.0k
  if (Offset >= DotShstrtab.size())
627
28
    return createError("invalid string offset");
628
11.0k
  return StringRef(DotShstrtab.data() + Offset);
629
11.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
622
4.32k
                                                  StringRef DotShstrtab) const {
623
4.32k
  uint32_t Offset = Section->sh_name;
624
4.32k
  if (Offset == 0)
625
234
    return StringRef();
626
4.09k
  if (Offset >= DotShstrtab.size())
627
0
    return createError("invalid string offset");
628
4.09k
  return StringRef(DotShstrtab.data() + Offset);
629
4.09k
}
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
622
1.29M
                                                  StringRef DotShstrtab) const {
623
1.29M
  uint32_t Offset = Section->sh_name;
624
1.29M
  if (Offset == 0)
625
3.10k
    return StringRef();
626
1.28M
  if (Offset >= DotShstrtab.size())
627
2
    return createError("invalid string offset");
628
1.28M
  return StringRef(DotShstrtab.data() + Offset);
629
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
622
3.32k
                                                  StringRef DotShstrtab) const {
623
3.32k
  uint32_t Offset = Section->sh_name;
624
3.32k
  if (Offset == 0)
625
178
    return StringRef();
626
3.14k
  if (Offset >= DotShstrtab.size())
627
0
    return createError("invalid string offset");
628
3.14k
  return StringRef(DotShstrtab.data() + Offset);
629
3.14k
}
630
631
/// This function returns the hash value for a symbol in the .dynsym section
632
/// Name of the API remains consistent as specified in the libelf
633
/// REF : http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#hash
634
inline unsigned hashSysV(StringRef SymbolName) {
635
  unsigned h = 0, g;
636
  for (char C : SymbolName) {
637
    h = (h << 4) + C;
638
    g = h & 0xf0000000L;
639
    if (g != 0)
640
      h ^= g >> 24;
641
    h &= ~g;
642
  }
643
  return h;
644
}
645
646
} // end namespace object
647
} // end namespace llvm
648
649
#endif // LLVM_OBJECT_ELF_H