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"
21 struct LLDDWARFSection final
: public llvm::DWARFSection
{
22 InputSectionBase
*sec
= nullptr;
25 template <class ELFT
> class LLDDwarfObj final
: public llvm::DWARFObject
{
27 explicit LLDDwarfObj(ObjFile
<ELFT
> *obj
);
29 void forEachInfoSections(
30 llvm::function_ref
<void(const llvm::DWARFSection
&)> f
) const override
{
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
{
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
{
58 const llvm::DWARFSection
&getAddrSection() const override
{
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
;
83 template <class RelTy
>
84 std::optional
<llvm::RelocAddrEntry
> findAux(const InputSectionBase
&sec
,
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
;
99 StringRef lineStrSection
;
102 } // namespace lld::elf