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 &getRangeSection() const override {
39 const llvm::DWARFSection &getRnglistsSection() const override {
40 return rngListsSection;
43 const llvm::DWARFSection &getLineSection() const override {
47 const llvm::DWARFSection &getAddrSection() const override {
51 const llvm::DWARFSection &getGnuPubNamesSection() const override {
52 return gnuPubNamesSection;
55 const llvm::DWARFSection &getGnuPubTypesSection() const override {
56 return gnuPubTypesSection;
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; }
64 bool isLittleEndian() const override {
65 return ELFT::TargetEndianness == llvm::support::little;
68 llvm::Optional<llvm::RelocAddrEntry> find(const llvm::DWARFSection &sec,
69 uint64_t pos) const override;
72 template <class RelTy>
73 llvm::Optional<llvm::RelocAddrEntry> findAux(const InputSectionBase &sec,
75 ArrayRef<RelTy> rels) const;
77 LLDDWARFSection gnuPubNamesSection;
78 LLDDWARFSection gnuPubTypesSection;
79 LLDDWARFSection infoSection;
80 LLDDWARFSection rangeSection;
81 LLDDWARFSection rngListsSection;
82 LLDDWARFSection lineSection;
83 LLDDWARFSection addrSection;
84 StringRef abbrevSection;
86 StringRef lineStringSection;