Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / ELF / DWARF.h
blobe1688fef9c9e47c13037c963dbb9b55a5cc8aa64
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 //===-------------------------------------------------------------------===//
9 #ifndef LLD_ELF_DWARF_H
10 #define LLD_ELF_DWARF_H
12 #include "InputFiles.h"
13 #include "llvm/ADT/STLExtras.h"
14 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
15 #include "llvm/Object/ELF.h"
17 namespace lld::elf {
19 class InputSection;
21 struct LLDDWARFSection final : public llvm::DWARFSection {
22 InputSectionBase *sec = nullptr;
25 template <class ELFT> class LLDDwarfObj final : public llvm::DWARFObject {
26 public:
27 explicit LLDDwarfObj(ObjFile<ELFT> *obj);
29 void forEachInfoSections(
30 llvm::function_ref<void(const llvm::DWARFSection &)> f) const override {
31 f(infoSection);
34 InputSection *getInfoSection() const {
35 return cast<InputSection>(infoSection.sec);
38 const llvm::DWARFSection &getLoclistsSection() const override {
39 return loclistsSection;
42 const llvm::DWARFSection &getRangesSection() const override {
43 return rangesSection;
46 const llvm::DWARFSection &getRnglistsSection() const override {
47 return rnglistsSection;
50 const llvm::DWARFSection &getStrOffsetsSection() const override {
51 return strOffsetsSection;
54 const llvm::DWARFSection &getLineSection() const override {
55 return lineSection;
58 const llvm::DWARFSection &getAddrSection() const override {
59 return addrSection;
62 const LLDDWARFSection &getGnuPubnamesSection() const override {
63 return gnuPubnamesSection;
66 const LLDDWARFSection &getGnuPubtypesSection() const override {
67 return gnuPubtypesSection;
70 StringRef getFileName() const override { return ""; }
71 StringRef getAbbrevSection() const override { return abbrevSection; }
72 StringRef getStrSection() const override { return strSection; }
73 StringRef getLineStrSection() const override { return lineStrSection; }
75 bool isLittleEndian() const override {
76 return ELFT::TargetEndianness == llvm::endianness::little;
79 std::optional<llvm::RelocAddrEntry> find(const llvm::DWARFSection &sec,
80 uint64_t pos) const override;
82 private:
83 template <class RelTy>
84 std::optional<llvm::RelocAddrEntry> findAux(const InputSectionBase &sec,
85 uint64_t pos,
86 ArrayRef<RelTy> rels) const;
88 LLDDWARFSection gnuPubnamesSection;
89 LLDDWARFSection gnuPubtypesSection;
90 LLDDWARFSection infoSection;
91 LLDDWARFSection loclistsSection;
92 LLDDWARFSection rangesSection;
93 LLDDWARFSection rnglistsSection;
94 LLDDWARFSection strOffsetsSection;
95 LLDDWARFSection lineSection;
96 LLDDWARFSection addrSection;
97 StringRef abbrevSection;
98 StringRef strSection;
99 StringRef lineStrSection;
102 } // namespace lld::elf
104 #endif