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/ADT/STLFunctionalExtras.h"
15 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
16 #include "llvm/Object/ELF.h"
23 struct LLDDWARFSection final
: public llvm::DWARFSection
{
24 InputSectionBase
*sec
= nullptr;
27 template <class ELFT
> class LLDDwarfObj final
: public llvm::DWARFObject
{
29 explicit LLDDwarfObj(ObjFile
<ELFT
> *obj
);
31 void forEachInfoSections(
32 llvm::function_ref
<void(const llvm::DWARFSection
&)> f
) const override
{
36 InputSection
*getInfoSection() const {
37 return cast
<InputSection
>(infoSection
.sec
);
40 const llvm::DWARFSection
&getAddrSection() const override
{
43 const llvm::DWARFSection
&getLineSection() const override
{
46 const llvm::DWARFSection
&getLoclistsSection() const override
{
47 return loclistsSection
;
49 const llvm::DWARFSection
&getRangesSection() const override
{
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
{
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
;
82 template <class RelTy
>
83 std::optional
<llvm::RelocAddrEntry
> findAux(const InputSectionBase
&sec
,
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
;
102 } // namespace lld::elf