1 //===- DWARF.h -----------------------------------------------*- C++ -*-===//
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
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"
22 struct LLDDWARFSection final : public llvm::DWARFSection {
23 InputSectionBase *sec = nullptr;
26 template <class ELFT> class LLDDwarfObj final : public llvm::DWARFObject {
28 explicit LLDDwarfObj(ObjFile<ELFT> *obj);
30 void forEachInfoSections(
31 llvm::function_ref<void(const llvm::DWARFSection &)> f) const override {
35 const llvm::DWARFSection &getLoclistsSection() const override {
36 return loclistsSection;
39 const llvm::DWARFSection &getRangesSection() const override {
43 const llvm::DWARFSection &getRnglistsSection() const override {
44 return rnglistsSection;
47 const llvm::DWARFSection &getStrOffsetsSection() const override {
48 return strOffsetsSection;
51 const llvm::DWARFSection &getLineSection() const override {
55 const llvm::DWARFSection &getAddrSection() const override {
59 const LLDDWARFSection &getGnuPubnamesSection() const override {
60 return gnuPubnamesSection;
63 const LLDDWARFSection &getGnuPubtypesSection() const override {
64 return gnuPubtypesSection;
67 StringRef getFileName() const override { return ""; }
68 StringRef getAbbrevSection() const override { return abbrevSection; }
69 StringRef getStrSection() const override { return strSection; }
70 StringRef getLineStrSection() const override { return lineStrSection; }
72 bool isLittleEndian() const override {
73 return ELFT::TargetEndianness == llvm::support::little;
76 llvm::Optional<llvm::RelocAddrEntry> find(const llvm::DWARFSection &sec,
77 uint64_t pos) const override;
80 template <class RelTy>
81 llvm::Optional<llvm::RelocAddrEntry> findAux(const InputSectionBase &sec,
83 ArrayRef<RelTy> rels) const;
85 LLDDWARFSection gnuPubnamesSection;
86 LLDDWARFSection gnuPubtypesSection;
87 LLDDWARFSection infoSection;
88 LLDDWARFSection loclistsSection;
89 LLDDWARFSection rangesSection;
90 LLDDWARFSection rnglistsSection;
91 LLDDWARFSection strOffsetsSection;
92 LLDDWARFSection lineSection;
93 LLDDWARFSection addrSection;
94 StringRef abbrevSection;
96 StringRef lineStrSection;