]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/lld/ELF/DWARF.h
MFC r355940:
[FreeBSD/FreeBSD.git] / contrib / llvm-project / lld / ELF / DWARF.h
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/DebugInfo/DWARF/DWARFContext.h"
15 #include "llvm/Object/ELF.h"
16
17 namespace lld {
18 namespace elf {
19
20 class InputSection;
21
22 struct LLDDWARFSection final : public llvm::DWARFSection {
23   InputSectionBase *sec = nullptr;
24 };
25
26 template <class ELFT> class LLDDwarfObj final : public llvm::DWARFObject {
27 public:
28   explicit LLDDwarfObj(ObjFile<ELFT> *obj);
29
30   void forEachInfoSections(
31       llvm::function_ref<void(const llvm::DWARFSection &)> f) const override {
32     f(infoSection);
33   }
34
35   const llvm::DWARFSection &getRangeSection() const override {
36     return rangeSection;
37   }
38
39   const llvm::DWARFSection &getRnglistsSection() const override {
40     return rngListsSection;
41   }
42
43   const llvm::DWARFSection &getLineSection() const override {
44     return lineSection;
45   }
46
47   const llvm::DWARFSection &getAddrSection() const override {
48     return addrSection;
49   }
50
51   const llvm::DWARFSection &getGnuPubNamesSection() const override {
52     return gnuPubNamesSection;
53   }
54
55   const llvm::DWARFSection &getGnuPubTypesSection() const override {
56     return gnuPubTypesSection;
57   }
58
59   StringRef getFileName() const override { return ""; }
60   StringRef getAbbrevSection() const override { return abbrevSection; }
61   StringRef getStringSection() const override { return strSection; }
62   StringRef getLineStringSection() const override { return lineStringSection; }
63
64   bool isLittleEndian() const override {
65     return ELFT::TargetEndianness == llvm::support::little;
66   }
67
68   llvm::Optional<llvm::RelocAddrEntry> find(const llvm::DWARFSection &sec,
69                                             uint64_t pos) const override;
70
71 private:
72   template <class RelTy>
73   llvm::Optional<llvm::RelocAddrEntry> findAux(const InputSectionBase &sec,
74                                                uint64_t pos,
75                                                ArrayRef<RelTy> rels) const;
76
77   LLDDWARFSection gnuPubNamesSection;
78   LLDDWARFSection gnuPubTypesSection;
79   LLDDWARFSection infoSection;
80   LLDDWARFSection rangeSection;
81   LLDDWARFSection rngListsSection;
82   LLDDWARFSection lineSection;
83   LLDDWARFSection addrSection;
84   StringRef abbrevSection;
85   StringRef strSection;
86   StringRef lineStringSection;
87 };
88
89 } // namespace elf
90 } // namespace lld
91
92 #endif