[NFC][opt] Improve help message (#97805)
[llvm-project.git] / lld / ELF / DWARF.h
blob64c25c706c3437aec2e50fd7b82593404614a8f6
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/ADT/STLFunctionalExtras.h"
15 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
16 #include "llvm/Object/ELF.h"
17 #include <optional>
19 namespace lld::elf {
21 class InputSection;
23 struct LLDDWARFSection final : public llvm::DWARFSection {
24 InputSectionBase *sec = nullptr;
27 template <class ELFT> class LLDDwarfObj final : public llvm::DWARFObject {
28 public:
29 explicit LLDDwarfObj(ObjFile<ELFT> *obj);
31 void forEachInfoSections(
32 llvm::function_ref<void(const llvm::DWARFSection &)> f) const override {
33 f(infoSection);
36 InputSection *getInfoSection() const {
37 return cast<InputSection>(infoSection.sec);
40 const llvm::DWARFSection &getAddrSection() const override {
41 return addrSection;
43 const llvm::DWARFSection &getLineSection() const override {
44 return lineSection;
46 const llvm::DWARFSection &getLoclistsSection() const override {
47 return loclistsSection;
49 const llvm::DWARFSection &getRangesSection() const override {
50 return rangesSection;
52 const llvm::DWARFSection &getRnglistsSection() const override {
53 return rnglistsSection;
55 const llvm::DWARFSection &getStrOffsetsSection() const override {
56 return strOffsetsSection;
59 const LLDDWARFSection &getGnuPubnamesSection() const override {
60 return gnuPubnamesSection;
62 const LLDDWARFSection &getGnuPubtypesSection() const override {
63 return gnuPubtypesSection;
65 const LLDDWARFSection &getNamesSection() const override {
66 return namesSection;
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; }
74 bool isLittleEndian() const override {
75 return ELFT::Endianness == llvm::endianness::little;
78 std::optional<llvm::RelocAddrEntry> find(const llvm::DWARFSection &sec,
79 uint64_t pos) const override;
81 private:
82 template <class RelTy>
83 std::optional<llvm::RelocAddrEntry> findAux(const InputSectionBase &sec,
84 uint64_t pos,
85 ArrayRef<RelTy> rels) const;
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;
102 } // namespace lld::elf
104 #endif