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 InputSection *getInfoSection() const {
36 return cast<InputSection>(infoSection.sec);
39 const llvm::DWARFSection &getLoclistsSection() const override {
40 return loclistsSection;
43 const llvm::DWARFSection &getRangesSection() const override {
47 const llvm::DWARFSection &getRnglistsSection() const override {
48 return rnglistsSection;
51 const llvm::DWARFSection &getStrOffsetsSection() const override {
52 return strOffsetsSection;
55 const llvm::DWARFSection &getLineSection() const override {
59 const llvm::DWARFSection &getAddrSection() const override {
63 const LLDDWARFSection &getGnuPubnamesSection() const override {
64 return gnuPubnamesSection;
67 const LLDDWARFSection &getGnuPubtypesSection() const override {
68 return gnuPubtypesSection;
71 StringRef getFileName() const override { return ""; }
72 StringRef getAbbrevSection() const override { return abbrevSection; }
73 StringRef getStrSection() const override { return strSection; }
74 StringRef getLineStrSection() const override { return lineStrSection; }
76 bool isLittleEndian() const override {
77 return ELFT::TargetEndianness == llvm::support::little;
80 llvm::Optional<llvm::RelocAddrEntry> find(const llvm::DWARFSection &sec,
81 uint64_t pos) const override;
84 template <class RelTy>
85 llvm::Optional<llvm::RelocAddrEntry> findAux(const InputSectionBase &sec,
87 ArrayRef<RelTy> rels) const;
89 LLDDWARFSection gnuPubnamesSection;
90 LLDDWARFSection gnuPubtypesSection;
91 LLDDWARFSection infoSection;
92 LLDDWARFSection loclistsSection;
93 LLDDWARFSection rangesSection;
94 LLDDWARFSection rnglistsSection;
95 LLDDWARFSection strOffsetsSection;
96 LLDDWARFSection lineSection;
97 LLDDWARFSection addrSection;
98 StringRef abbrevSection;
100 StringRef lineStrSection;