Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/ELF/DWARF.cpp
Line
Count
Source
1
//===- DWARF.cpp ----------------------------------------------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// The -gdb-index option instructs the linker to emit a .gdb_index section.
10
// The section contains information to make gdb startup faster.
11
// The format of the section is described at
12
// https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html.
13
//
14
//===----------------------------------------------------------------------===//
15
16
#include "DWARF.h"
17
#include "Symbols.h"
18
#include "Target.h"
19
#include "lld/Common/Memory.h"
20
#include "llvm/DebugInfo/DWARF/DWARFDebugPubTable.h"
21
#include "llvm/Object/ELFObjectFile.h"
22
23
using namespace llvm;
24
using namespace llvm::object;
25
using namespace lld;
26
using namespace lld::elf;
27
28
253
template <class ELFT> LLDDwarfObj<ELFT>::LLDDwarfObj(ObjFile<ELFT> *obj) {
29
1.65k
  for (InputSectionBase *sec : obj->getSections()) {
30
1.65k
    if (!sec)
31
1.06k
      continue;
32
593
33
593
    if (LLDDWARFSection *m =
34
109
            StringSwitch<LLDDWARFSection *>(sec->name)
35
109
                .Case(".debug_addr", &addrSection)
36
109
                .Case(".debug_gnu_pubnames", &gnuPubNamesSection)
37
109
                .Case(".debug_gnu_pubtypes", &gnuPubTypesSection)
38
109
                .Case(".debug_info", &infoSection)
39
109
                .Case(".debug_ranges", &rangeSection)
40
109
                .Case(".debug_rnglists", &rngListsSection)
41
109
                .Case(".debug_line", &lineSection)
42
109
                .Default(nullptr)) {
43
109
      m->Data = toStringRef(sec->data());
44
109
      m->sec = sec;
45
109
      continue;
46
109
    }
47
484
48
484
    if (sec->name == ".debug_abbrev")
49
51
      abbrevSection = toStringRef(sec->data());
50
433
    else if (sec->name == ".debug_str")
51
12
      strSection = toStringRef(sec->data());
52
421
    else if (sec->name == ".debug_line_str")
53
2
      lineStringSection = toStringRef(sec->data());
54
484
  }
55
253
}
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, false> >::LLDDwarfObj(lld::elf::ObjFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >*)
Line
Count
Source
28
21
template <class ELFT> LLDDwarfObj<ELFT>::LLDDwarfObj(ObjFile<ELFT> *obj) {
29
122
  for (InputSectionBase *sec : obj->getSections()) {
30
122
    if (!sec)
31
89
      continue;
32
33
33
33
    if (LLDDWARFSection *m =
34
6
            StringSwitch<LLDDWARFSection *>(sec->name)
35
6
                .Case(".debug_addr", &addrSection)
36
6
                .Case(".debug_gnu_pubnames", &gnuPubNamesSection)
37
6
                .Case(".debug_gnu_pubtypes", &gnuPubTypesSection)
38
6
                .Case(".debug_info", &infoSection)
39
6
                .Case(".debug_ranges", &rangeSection)
40
6
                .Case(".debug_rnglists", &rngListsSection)
41
6
                .Case(".debug_line", &lineSection)
42
6
                .Default(nullptr)) {
43
6
      m->Data = toStringRef(sec->data());
44
6
      m->sec = sec;
45
6
      continue;
46
6
    }
47
27
48
27
    if (sec->name == ".debug_abbrev")
49
2
      abbrevSection = toStringRef(sec->data());
50
25
    else if (sec->name == ".debug_str")
51
0
      strSection = toStringRef(sec->data());
52
25
    else if (sec->name == ".debug_line_str")
53
0
      lineStringSection = toStringRef(sec->data());
54
27
  }
55
21
}
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, false> >::LLDDwarfObj(lld::elf::ObjFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >*)
Line
Count
Source
28
2
template <class ELFT> LLDDwarfObj<ELFT>::LLDDwarfObj(ObjFile<ELFT> *obj) {
29
18
  for (InputSectionBase *sec : obj->getSections()) {
30
18
    if (!sec)
31
8
      continue;
32
10
33
10
    if (LLDDWARFSection *m =
34
0
            StringSwitch<LLDDWARFSection *>(sec->name)
35
0
                .Case(".debug_addr", &addrSection)
36
0
                .Case(".debug_gnu_pubnames", &gnuPubNamesSection)
37
0
                .Case(".debug_gnu_pubtypes", &gnuPubTypesSection)
38
0
                .Case(".debug_info", &infoSection)
39
0
                .Case(".debug_ranges", &rangeSection)
40
0
                .Case(".debug_rnglists", &rngListsSection)
41
0
                .Case(".debug_line", &lineSection)
42
0
                .Default(nullptr)) {
43
0
      m->Data = toStringRef(sec->data());
44
0
      m->sec = sec;
45
0
      continue;
46
0
    }
47
10
48
10
    if (sec->name == ".debug_abbrev")
49
0
      abbrevSection = toStringRef(sec->data());
50
10
    else if (sec->name == ".debug_str")
51
0
      strSection = toStringRef(sec->data());
52
10
    else if (sec->name == ".debug_line_str")
53
0
      lineStringSection = toStringRef(sec->data());
54
10
  }
55
2
}
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, true> >::LLDDwarfObj(lld::elf::ObjFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >*)
Line
Count
Source
28
221
template <class ELFT> LLDDwarfObj<ELFT>::LLDDwarfObj(ObjFile<ELFT> *obj) {
29
1.46k
  for (InputSectionBase *sec : obj->getSections()) {
30
1.46k
    if (!sec)
31
929
      continue;
32
535
33
535
    if (LLDDWARFSection *m =
34
103
            StringSwitch<LLDDWARFSection *>(sec->name)
35
103
                .Case(".debug_addr", &addrSection)
36
103
                .Case(".debug_gnu_pubnames", &gnuPubNamesSection)
37
103
                .Case(".debug_gnu_pubtypes", &gnuPubTypesSection)
38
103
                .Case(".debug_info", &infoSection)
39
103
                .Case(".debug_ranges", &rangeSection)
40
103
                .Case(".debug_rnglists", &rngListsSection)
41
103
                .Case(".debug_line", &lineSection)
42
103
                .Default(nullptr)) {
43
103
      m->Data = toStringRef(sec->data());
44
103
      m->sec = sec;
45
103
      continue;
46
103
    }
47
432
48
432
    if (sec->name == ".debug_abbrev")
49
49
      abbrevSection = toStringRef(sec->data());
50
383
    else if (sec->name == ".debug_str")
51
12
      strSection = toStringRef(sec->data());
52
371
    else if (sec->name == ".debug_line_str")
53
2
      lineStringSection = toStringRef(sec->data());
54
432
  }
55
221
}
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, true> >::LLDDwarfObj(lld::elf::ObjFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >*)
Line
Count
Source
28
9
template <class ELFT> LLDDwarfObj<ELFT>::LLDDwarfObj(ObjFile<ELFT> *obj) {
29
51
  for (InputSectionBase *sec : obj->getSections()) {
30
51
    if (!sec)
31
36
      continue;
32
15
33
15
    if (LLDDWARFSection *m =
34
0
            StringSwitch<LLDDWARFSection *>(sec->name)
35
0
                .Case(".debug_addr", &addrSection)
36
0
                .Case(".debug_gnu_pubnames", &gnuPubNamesSection)
37
0
                .Case(".debug_gnu_pubtypes", &gnuPubTypesSection)
38
0
                .Case(".debug_info", &infoSection)
39
0
                .Case(".debug_ranges", &rangeSection)
40
0
                .Case(".debug_rnglists", &rngListsSection)
41
0
                .Case(".debug_line", &lineSection)
42
0
                .Default(nullptr)) {
43
0
      m->Data = toStringRef(sec->data());
44
0
      m->sec = sec;
45
0
      continue;
46
0
    }
47
15
48
15
    if (sec->name == ".debug_abbrev")
49
0
      abbrevSection = toStringRef(sec->data());
50
15
    else if (sec->name == ".debug_str")
51
0
      strSection = toStringRef(sec->data());
52
15
    else if (sec->name == ".debug_line_str")
53
0
      lineStringSection = toStringRef(sec->data());
54
15
  }
55
9
}
56
57
namespace {
58
template <class RelTy> struct LLDRelocationResolver {
59
  // In the ELF ABIs, S sepresents the value of the symbol in the relocation
60
  // entry. For Rela, the addend is stored as part of the relocation entry.
61
  static uint64_t resolve(object::RelocationRef ref, uint64_t s,
62
145
                          uint64_t /* A */) {
63
145
    return s + ref.getRawDataRefImpl().p;
64
145
  }
Unexecuted instantiation: DWARF.cpp:(anonymous namespace)::LLDRelocationResolver<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, true> >::resolve(llvm::object::RelocationRef, unsigned long long, unsigned long long)
Unexecuted instantiation: DWARF.cpp:(anonymous namespace)::LLDRelocationResolver<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, true> >::resolve(llvm::object::RelocationRef, unsigned long long, unsigned long long)
DWARF.cpp:(anonymous namespace)::LLDRelocationResolver<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, true> >::resolve(llvm::object::RelocationRef, unsigned long long, unsigned long long)
Line
Count
Source
62
145
                          uint64_t /* A */) {
63
145
    return s + ref.getRawDataRefImpl().p;
64
145
  }
Unexecuted instantiation: DWARF.cpp:(anonymous namespace)::LLDRelocationResolver<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, true> >::resolve(llvm::object::RelocationRef, unsigned long long, unsigned long long)
65
};
66
67
template <class ELFT> struct LLDRelocationResolver<Elf_Rel_Impl<ELFT, false>> {
68
  // For Rel, the addend A is supplied by the caller.
69
  static uint64_t resolve(object::RelocationRef /*Ref*/, uint64_t s,
70
9
                          uint64_t a) {
71
9
    return s + a;
72
9
  }
DWARF.cpp:(anonymous namespace)::LLDRelocationResolver<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, false> >::resolve(llvm::object::RelocationRef, unsigned long long, unsigned long long)
Line
Count
Source
70
9
                          uint64_t a) {
71
9
    return s + a;
72
9
  }
Unexecuted instantiation: DWARF.cpp:(anonymous namespace)::LLDRelocationResolver<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, false> >::resolve(llvm::object::RelocationRef, unsigned long long, unsigned long long)
Unexecuted instantiation: DWARF.cpp:(anonymous namespace)::LLDRelocationResolver<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, false> >::resolve(llvm::object::RelocationRef, unsigned long long, unsigned long long)
Unexecuted instantiation: DWARF.cpp:(anonymous namespace)::LLDRelocationResolver<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, false> >::resolve(llvm::object::RelocationRef, unsigned long long, unsigned long long)
73
};
74
} // namespace
75
76
// Find if there is a relocation at Pos in Sec.  The code is a bit
77
// more complicated than usual because we need to pass a section index
78
// to llvm since it has no idea about InputSection.
79
template <class ELFT>
80
template <class RelTy>
81
Optional<RelocAddrEntry>
82
LLDDwarfObj<ELFT>::findAux(const InputSectionBase &sec, uint64_t pos,
83
375
                           ArrayRef<RelTy> rels) const {
84
375
  auto it =
85
641
      partition_point(rels, [=](const RelTy &a) { return a.r_offset < pos; });
Unexecuted instantiation: llvm::Optional<llvm::RelocAddrEntry> lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, false> >::findAux<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, true> >(lld::elf::InputSectionBase const&, unsigned long long, llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, true> >) const::'lambda'(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, true> const&)::operator()(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, true> const&) const
llvm::Optional<llvm::RelocAddrEntry> lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, false> >::findAux<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, false> >(lld::elf::InputSectionBase const&, unsigned long long, llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, false> >) const::'lambda'(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, false> const&)::operator()(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, false> const&) const
Line
Count
Source
85
30
      partition_point(rels, [=](const RelTy &a) { return a.r_offset < pos; });
Unexecuted instantiation: llvm::Optional<llvm::RelocAddrEntry> lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, false> >::findAux<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, true> >(lld::elf::InputSectionBase const&, unsigned long long, llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, true> >) const::'lambda'(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, true> const&)::operator()(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, true> const&) const
Unexecuted instantiation: llvm::Optional<llvm::RelocAddrEntry> lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, false> >::findAux<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, false> >(lld::elf::InputSectionBase const&, unsigned long long, llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, false> >) const::'lambda'(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, false> const&)::operator()(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, false> const&) const
llvm::Optional<llvm::RelocAddrEntry> lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, true> >::findAux<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, true> >(lld::elf::InputSectionBase const&, unsigned long long, llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, true> >) const::'lambda'(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, true> const&)::operator()(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, true> const&) const
Line
Count
Source
85
611
      partition_point(rels, [=](const RelTy &a) { return a.r_offset < pos; });
Unexecuted instantiation: llvm::Optional<llvm::RelocAddrEntry> lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, true> >::findAux<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, false> >(lld::elf::InputSectionBase const&, unsigned long long, llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, false> >) const::'lambda'(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, false> const&)::operator()(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, false> const&) const
Unexecuted instantiation: llvm::Optional<llvm::RelocAddrEntry> lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, true> >::findAux<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, true> >(lld::elf::InputSectionBase const&, unsigned long long, llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, true> >) const::'lambda'(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, true> const&)::operator()(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, true> const&) const
Unexecuted instantiation: llvm::Optional<llvm::RelocAddrEntry> lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, true> >::findAux<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, false> >(lld::elf::InputSectionBase const&, unsigned long long, llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, false> >) const::'lambda'(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, false> const&)::operator()(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, false> const&) const
86
375
  if (it == rels.end() || 
it->r_offset != pos283
)
87
221
    return None;
88
154
  const RelTy &rel = *it;
89
154
90
154
  const ObjFile<ELFT> *file = sec.getFile<ELFT>();
91
154
  uint32_t symIndex = rel.getSymbol(config->isMips64EL);
92
154
  const typename ELFT::Sym &sym = file->template getELFSyms<ELFT>()[symIndex];
93
154
  uint32_t secIndex = file->getSectionIndex(sym);
94
154
95
154
  // An undefined symbol may be a symbol defined in a discarded section. We
96
154
  // shall still resolve it. This is important for --gdb-index: the end address
97
154
  // offset of an entry in .debug_ranges is relocated. If it is not resolved,
98
154
  // its zero value will terminate the decoding of .debug_ranges prematurely.
99
154
  Symbol &s = file->getRelocTargetSym(rel);
100
154
  uint64_t val = 0;
101
154
  if (auto *dr = dyn_cast<Defined>(&s)) {
102
147
    val = dr->value;
103
147
104
147
    // FIXME: We should be consistent about always adding the file
105
147
    // offset or not.
106
147
    if (dr->section->flags & ELF::SHF_ALLOC)
107
49
      val += cast<InputSection>(dr->section)->getOffsetInFile();
108
147
  }
109
154
110
154
  DataRefImpl d;
111
154
  d.p = getAddend<ELFT>(rel);
112
154
  return RelocAddrEntry{secIndex, RelocationRef(d, nullptr),
113
154
                        val,      Optional<object::RelocationRef>(),
114
154
                        0,        LLDRelocationResolver<RelTy>::resolve};
115
154
}
Unexecuted instantiation: llvm::Optional<llvm::RelocAddrEntry> lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, false> >::findAux<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, true> >(lld::elf::InputSectionBase const&, unsigned long long, llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, true> >) const
llvm::Optional<llvm::RelocAddrEntry> lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, false> >::findAux<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, false> >(lld::elf::InputSectionBase const&, unsigned long long, llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, false> >) const
Line
Count
Source
83
18
                           ArrayRef<RelTy> rels) const {
84
18
  auto it =
85
18
      partition_point(rels, [=](const RelTy &a) { return a.r_offset < pos; });
86
18
  if (it == rels.end() || it->r_offset != pos)
87
9
    return None;
88
9
  const RelTy &rel = *it;
89
9
90
9
  const ObjFile<ELFT> *file = sec.getFile<ELFT>();
91
9
  uint32_t symIndex = rel.getSymbol(config->isMips64EL);
92
9
  const typename ELFT::Sym &sym = file->template getELFSyms<ELFT>()[symIndex];
93
9
  uint32_t secIndex = file->getSectionIndex(sym);
94
9
95
9
  // An undefined symbol may be a symbol defined in a discarded section. We
96
9
  // shall still resolve it. This is important for --gdb-index: the end address
97
9
  // offset of an entry in .debug_ranges is relocated. If it is not resolved,
98
9
  // its zero value will terminate the decoding of .debug_ranges prematurely.
99
9
  Symbol &s = file->getRelocTargetSym(rel);
100
9
  uint64_t val = 0;
101
9
  if (auto *dr = dyn_cast<Defined>(&s)) {
102
9
    val = dr->value;
103
9
104
9
    // FIXME: We should be consistent about always adding the file
105
9
    // offset or not.
106
9
    if (dr->section->flags & ELF::SHF_ALLOC)
107
2
      val += cast<InputSection>(dr->section)->getOffsetInFile();
108
9
  }
109
9
110
9
  DataRefImpl d;
111
9
  d.p = getAddend<ELFT>(rel);
112
9
  return RelocAddrEntry{secIndex, RelocationRef(d, nullptr),
113
9
                        val,      Optional<object::RelocationRef>(),
114
9
                        0,        LLDRelocationResolver<RelTy>::resolve};
115
9
}
Unexecuted instantiation: llvm::Optional<llvm::RelocAddrEntry> lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, false> >::findAux<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, true> >(lld::elf::InputSectionBase const&, unsigned long long, llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, true> >) const
Unexecuted instantiation: llvm::Optional<llvm::RelocAddrEntry> lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, false> >::findAux<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, false> >(lld::elf::InputSectionBase const&, unsigned long long, llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, false> >) const
llvm::Optional<llvm::RelocAddrEntry> lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, true> >::findAux<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, true> >(lld::elf::InputSectionBase const&, unsigned long long, llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, true> >) const
Line
Count
Source
83
305
                           ArrayRef<RelTy> rels) const {
84
305
  auto it =
85
305
      partition_point(rels, [=](const RelTy &a) { return a.r_offset < pos; });
86
305
  if (it == rels.end() || 
it->r_offset != pos265
)
87
161
    return None;
88
144
  const RelTy &rel = *it;
89
144
90
144
  const ObjFile<ELFT> *file = sec.getFile<ELFT>();
91
144
  uint32_t symIndex = rel.getSymbol(config->isMips64EL);
92
144
  const typename ELFT::Sym &sym = file->template getELFSyms<ELFT>()[symIndex];
93
144
  uint32_t secIndex = file->getSectionIndex(sym);
94
144
95
144
  // An undefined symbol may be a symbol defined in a discarded section. We
96
144
  // shall still resolve it. This is important for --gdb-index: the end address
97
144
  // offset of an entry in .debug_ranges is relocated. If it is not resolved,
98
144
  // its zero value will terminate the decoding of .debug_ranges prematurely.
99
144
  Symbol &s = file->getRelocTargetSym(rel);
100
144
  uint64_t val = 0;
101
144
  if (auto *dr = dyn_cast<Defined>(&s)) {
102
138
    val = dr->value;
103
138
104
138
    // FIXME: We should be consistent about always adding the file
105
138
    // offset or not.
106
138
    if (dr->section->flags & ELF::SHF_ALLOC)
107
47
      val += cast<InputSection>(dr->section)->getOffsetInFile();
108
138
  }
109
144
110
144
  DataRefImpl d;
111
144
  d.p = getAddend<ELFT>(rel);
112
144
  return RelocAddrEntry{secIndex, RelocationRef(d, nullptr),
113
144
                        val,      Optional<object::RelocationRef>(),
114
144
                        0,        LLDRelocationResolver<RelTy>::resolve};
115
144
}
llvm::Optional<llvm::RelocAddrEntry> lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, true> >::findAux<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, false> >(lld::elf::InputSectionBase const&, unsigned long long, llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, false> >) const
Line
Count
Source
83
52
                           ArrayRef<RelTy> rels) const {
84
52
  auto it =
85
52
      partition_point(rels, [=](const RelTy &a) { return a.r_offset < pos; });
86
52
  if (it == rels.end() || 
it->r_offset != pos0
)
87
51
    return None;
88
1
  const RelTy &rel = *it;
89
1
90
1
  const ObjFile<ELFT> *file = sec.getFile<ELFT>();
91
1
  uint32_t symIndex = rel.getSymbol(config->isMips64EL);
92
1
  const typename ELFT::Sym &sym = file->template getELFSyms<ELFT>()[symIndex];
93
1
  uint32_t secIndex = file->getSectionIndex(sym);
94
1
95
1
  // An undefined symbol may be a symbol defined in a discarded section. We
96
1
  // shall still resolve it. This is important for --gdb-index: the end address
97
1
  // offset of an entry in .debug_ranges is relocated. If it is not resolved,
98
1
  // its zero value will terminate the decoding of .debug_ranges prematurely.
99
1
  Symbol &s = file->getRelocTargetSym(rel);
100
1
  uint64_t val = 0;
101
1
  if (auto *dr = dyn_cast<Defined>(&s)) {
102
0
    val = dr->value;
103
0
104
0
    // FIXME: We should be consistent about always adding the file
105
0
    // offset or not.
106
0
    if (dr->section->flags & ELF::SHF_ALLOC)
107
0
      val += cast<InputSection>(dr->section)->getOffsetInFile();
108
0
  }
109
1
110
1
  DataRefImpl d;
111
1
  d.p = getAddend<ELFT>(rel);
112
1
  return RelocAddrEntry{secIndex, RelocationRef(d, nullptr),
113
1
                        val,      Optional<object::RelocationRef>(),
114
1
                        0,        LLDRelocationResolver<RelTy>::resolve};
115
1
}
Unexecuted instantiation: llvm::Optional<llvm::RelocAddrEntry> lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, true> >::findAux<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, true> >(lld::elf::InputSectionBase const&, unsigned long long, llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, true> >) const
Unexecuted instantiation: llvm::Optional<llvm::RelocAddrEntry> lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, true> >::findAux<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, false> >(lld::elf::InputSectionBase const&, unsigned long long, llvm::ArrayRef<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, false> >) const
116
117
template <class ELFT>
118
Optional<RelocAddrEntry> LLDDwarfObj<ELFT>::find(const llvm::DWARFSection &s,
119
376
                                                 uint64_t pos) const {
120
376
  auto &sec = static_cast<const LLDDWARFSection &>(s);
121
376
  if (sec.sec->areRelocsRela)
122
306
    return findAux(*sec.sec, pos, sec.sec->template relas<ELFT>());
123
70
  return findAux(*sec.sec, pos, sec.sec->template rels<ELFT>());
124
70
}
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, false> >::find(llvm::DWARFSection const&, unsigned long long) const
Line
Count
Source
119
18
                                                 uint64_t pos) const {
120
18
  auto &sec = static_cast<const LLDDWARFSection &>(s);
121
18
  if (sec.sec->areRelocsRela)
122
0
    return findAux(*sec.sec, pos, sec.sec->template relas<ELFT>());
123
18
  return findAux(*sec.sec, pos, sec.sec->template rels<ELFT>());
124
18
}
Unexecuted instantiation: lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, false> >::find(llvm::DWARFSection const&, unsigned long long) const
lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)1, true> >::find(llvm::DWARFSection const&, unsigned long long) const
Line
Count
Source
119
358
                                                 uint64_t pos) const {
120
358
  auto &sec = static_cast<const LLDDWARFSection &>(s);
121
358
  if (sec.sec->areRelocsRela)
122
306
    return findAux(*sec.sec, pos, sec.sec->template relas<ELFT>());
123
52
  return findAux(*sec.sec, pos, sec.sec->template rels<ELFT>());
124
52
}
Unexecuted instantiation: lld::elf::LLDDwarfObj<llvm::object::ELFType<(llvm::support::endianness)0, true> >::find(llvm::DWARFSection const&, unsigned long long) const
125
126
template class elf::LLDDwarfObj<ELF32LE>;
127
template class elf::LLDDwarfObj<ELF32BE>;
128
template class elf::LLDDwarfObj<ELF64LE>;
129
template class elf::LLDDwarfObj<ELF64BE>;