Coverage Report

Created: 2018-07-19 03:59

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