Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/llvm-project/lld/ELF/DWARF.h
34878 views
1
//===- DWARF.h -----------------------------------------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===-------------------------------------------------------------------===//
8
9
#ifndef LLD_ELF_DWARF_H
10
#define LLD_ELF_DWARF_H
11
12
#include "InputFiles.h"
13
#include "llvm/ADT/STLExtras.h"
14
#include "llvm/ADT/STLFunctionalExtras.h"
15
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
16
#include "llvm/Object/ELF.h"
17
#include <optional>
18
19
namespace lld::elf {
20
21
class InputSection;
22
23
struct LLDDWARFSection final : public llvm::DWARFSection {
24
InputSectionBase *sec = nullptr;
25
};
26
27
template <class ELFT> class LLDDwarfObj final : public llvm::DWARFObject {
28
public:
29
explicit LLDDwarfObj(ObjFile<ELFT> *obj);
30
31
void forEachInfoSections(
32
llvm::function_ref<void(const llvm::DWARFSection &)> f) const override {
33
f(infoSection);
34
}
35
36
InputSection *getInfoSection() const {
37
return cast<InputSection>(infoSection.sec);
38
}
39
40
const llvm::DWARFSection &getAddrSection() const override {
41
return addrSection;
42
}
43
const llvm::DWARFSection &getLineSection() const override {
44
return lineSection;
45
}
46
const llvm::DWARFSection &getLoclistsSection() const override {
47
return loclistsSection;
48
}
49
const llvm::DWARFSection &getRangesSection() const override {
50
return rangesSection;
51
}
52
const llvm::DWARFSection &getRnglistsSection() const override {
53
return rnglistsSection;
54
}
55
const llvm::DWARFSection &getStrOffsetsSection() const override {
56
return strOffsetsSection;
57
}
58
59
const LLDDWARFSection &getGnuPubnamesSection() const override {
60
return gnuPubnamesSection;
61
}
62
const LLDDWARFSection &getGnuPubtypesSection() const override {
63
return gnuPubtypesSection;
64
}
65
const LLDDWARFSection &getNamesSection() const override {
66
return namesSection;
67
}
68
69
StringRef getFileName() const override { return ""; }
70
StringRef getAbbrevSection() const override { return abbrevSection; }
71
StringRef getStrSection() const override { return strSection; }
72
StringRef getLineStrSection() const override { return lineStrSection; }
73
74
bool isLittleEndian() const override {
75
return ELFT::Endianness == llvm::endianness::little;
76
}
77
78
std::optional<llvm::RelocAddrEntry> find(const llvm::DWARFSection &sec,
79
uint64_t pos) const override;
80
81
private:
82
template <class RelTy>
83
std::optional<llvm::RelocAddrEntry> findAux(const InputSectionBase &sec,
84
uint64_t pos,
85
ArrayRef<RelTy> rels) const;
86
87
LLDDWARFSection addrSection;
88
LLDDWARFSection gnuPubnamesSection;
89
LLDDWARFSection gnuPubtypesSection;
90
LLDDWARFSection infoSection;
91
LLDDWARFSection lineSection;
92
LLDDWARFSection loclistsSection;
93
LLDDWARFSection namesSection;
94
LLDDWARFSection rangesSection;
95
LLDDWARFSection rnglistsSection;
96
LLDDWARFSection strOffsetsSection;
97
StringRef abbrevSection;
98
StringRef lineStrSection;
99
StringRef strSection;
100
};
101
102
} // namespace lld::elf
103
104
#endif
105
106