Path: blob/main/contrib/llvm-project/lld/ELF/DWARF.h
34878 views
//===- DWARF.h -----------------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===-------------------------------------------------------------------===//78#ifndef LLD_ELF_DWARF_H9#define LLD_ELF_DWARF_H1011#include "InputFiles.h"12#include "llvm/ADT/STLExtras.h"13#include "llvm/ADT/STLFunctionalExtras.h"14#include "llvm/DebugInfo/DWARF/DWARFContext.h"15#include "llvm/Object/ELF.h"16#include <optional>1718namespace lld::elf {1920class InputSection;2122struct LLDDWARFSection final : public llvm::DWARFSection {23InputSectionBase *sec = nullptr;24};2526template <class ELFT> class LLDDwarfObj final : public llvm::DWARFObject {27public:28explicit LLDDwarfObj(ObjFile<ELFT> *obj);2930void forEachInfoSections(31llvm::function_ref<void(const llvm::DWARFSection &)> f) const override {32f(infoSection);33}3435InputSection *getInfoSection() const {36return cast<InputSection>(infoSection.sec);37}3839const llvm::DWARFSection &getAddrSection() const override {40return addrSection;41}42const llvm::DWARFSection &getLineSection() const override {43return lineSection;44}45const llvm::DWARFSection &getLoclistsSection() const override {46return loclistsSection;47}48const llvm::DWARFSection &getRangesSection() const override {49return rangesSection;50}51const llvm::DWARFSection &getRnglistsSection() const override {52return rnglistsSection;53}54const llvm::DWARFSection &getStrOffsetsSection() const override {55return strOffsetsSection;56}5758const LLDDWARFSection &getGnuPubnamesSection() const override {59return gnuPubnamesSection;60}61const LLDDWARFSection &getGnuPubtypesSection() const override {62return gnuPubtypesSection;63}64const LLDDWARFSection &getNamesSection() const override {65return namesSection;66}6768StringRef getFileName() const override { return ""; }69StringRef getAbbrevSection() const override { return abbrevSection; }70StringRef getStrSection() const override { return strSection; }71StringRef getLineStrSection() const override { return lineStrSection; }7273bool isLittleEndian() const override {74return ELFT::Endianness == llvm::endianness::little;75}7677std::optional<llvm::RelocAddrEntry> find(const llvm::DWARFSection &sec,78uint64_t pos) const override;7980private:81template <class RelTy>82std::optional<llvm::RelocAddrEntry> findAux(const InputSectionBase &sec,83uint64_t pos,84ArrayRef<RelTy> rels) const;8586LLDDWARFSection addrSection;87LLDDWARFSection gnuPubnamesSection;88LLDDWARFSection gnuPubtypesSection;89LLDDWARFSection infoSection;90LLDDWARFSection lineSection;91LLDDWARFSection loclistsSection;92LLDDWARFSection namesSection;93LLDDWARFSection rangesSection;94LLDDWARFSection rnglistsSection;95LLDDWARFSection strOffsetsSection;96StringRef abbrevSection;97StringRef lineStrSection;98StringRef strSection;99};100101} // namespace lld::elf102103#endif104105106