zig/deps/lld/ELF/DWARF.h

93 lines
2.6 KiB
C
Raw Normal View History

2019-02-08 06:07:18 +08:00
//===- DWARF.h -----------------------------------------------*- C++ -*-===//
//
2019-08-04 00:43:55 +08:00
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===-------------------------------------------------------------------===//
2019-02-08 06:07:18 +08:00
#ifndef LLD_ELF_DWARF_H
#define LLD_ELF_DWARF_H
#include "InputFiles.h"
2019-02-08 06:07:18 +08:00
#include "llvm/ADT/STLExtras.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/Object/ELF.h"
namespace lld {
namespace elf {
class InputSection;
2018-01-18 06:29:21 +08:00
struct LLDDWARFSection final : public llvm::DWARFSection {
2019-08-04 00:43:55 +08:00
InputSectionBase *sec = nullptr;
};
2018-01-18 06:29:21 +08:00
template <class ELFT> class LLDDwarfObj final : public llvm::DWARFObject {
public:
2019-08-04 00:43:55 +08:00
explicit LLDDwarfObj(ObjFile<ELFT> *obj);
2019-02-08 06:07:18 +08:00
void forEachInfoSections(
2019-08-04 00:43:55 +08:00
llvm::function_ref<void(const llvm::DWARFSection &)> f) const override {
f(infoSection);
2018-01-18 06:29:21 +08:00
}
2019-02-08 06:07:18 +08:00
2018-01-18 06:29:21 +08:00
const llvm::DWARFSection &getRangeSection() const override {
2019-08-04 00:43:55 +08:00
return rangeSection;
2018-01-18 06:29:21 +08:00
}
2019-02-08 06:07:18 +08:00
const llvm::DWARFSection &getRnglistsSection() const override {
2019-08-04 00:43:55 +08:00
return rngListsSection;
2019-02-08 06:07:18 +08:00
}
2018-01-18 06:29:21 +08:00
const llvm::DWARFSection &getLineSection() const override {
2019-08-04 00:43:55 +08:00
return lineSection;
2018-01-18 06:29:21 +08:00
}
2019-02-08 06:07:18 +08:00
const llvm::DWARFSection &getAddrSection() const override {
2019-08-04 00:43:55 +08:00
return addrSection;
2019-02-08 06:07:18 +08:00
}
const llvm::DWARFSection &getGnuPubNamesSection() const override {
2019-08-04 00:43:55 +08:00
return gnuPubNamesSection;
2018-01-18 06:29:21 +08:00
}
2019-02-08 06:07:18 +08:00
const llvm::DWARFSection &getGnuPubTypesSection() const override {
2019-08-04 00:43:55 +08:00
return gnuPubTypesSection;
2018-01-18 06:29:21 +08:00
}
2019-02-08 06:07:18 +08:00
StringRef getFileName() const override { return ""; }
2019-08-04 00:43:55 +08:00
StringRef getAbbrevSection() const override { return abbrevSection; }
StringRef getStringSection() const override { return strSection; }
StringRef getLineStringSection() const override { return lineStringSection; }
2019-02-08 06:07:18 +08:00
2018-01-18 06:29:21 +08:00
bool isLittleEndian() const override {
return ELFT::TargetEndianness == llvm::support::little;
}
2019-02-08 06:07:18 +08:00
2019-08-04 00:43:55 +08:00
llvm::Optional<llvm::RelocAddrEntry> find(const llvm::DWARFSection &sec,
uint64_t pos) const override;
2019-02-08 06:07:18 +08:00
private:
template <class RelTy>
2019-08-04 00:43:55 +08:00
llvm::Optional<llvm::RelocAddrEntry> findAux(const InputSectionBase &sec,
uint64_t pos,
ArrayRef<RelTy> rels) const;
LLDDWARFSection gnuPubNamesSection;
LLDDWARFSection gnuPubTypesSection;
LLDDWARFSection infoSection;
LLDDWARFSection rangeSection;
LLDDWARFSection rngListsSection;
LLDDWARFSection lineSection;
LLDDWARFSection addrSection;
StringRef abbrevSection;
StringRef strSection;
StringRef lineStringSection;
};
} // namespace elf
} // namespace lld
#endif