2018-09-15 07:51:05 +08:00
|
|
|
//===- DWARF.h -----------------------------------------------*- C++ -*-===//
|
2016-10-20 17:19:48 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +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
|
2016-10-20 17:19:48 +08:00
|
|
|
//
|
|
|
|
//===-------------------------------------------------------------------===//
|
|
|
|
|
2018-09-15 07:51:05 +08:00
|
|
|
#ifndef LLD_ELF_DWARF_H
|
|
|
|
#define LLD_ELF_DWARF_H
|
2016-10-20 17:19:48 +08:00
|
|
|
|
|
|
|
#include "InputFiles.h"
|
2018-11-08 05:39:09 +08:00
|
|
|
#include "llvm/ADT/STLExtras.h"
|
2016-12-15 17:08:13 +08:00
|
|
|
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
|
2017-07-18 19:55:35 +08:00
|
|
|
#include "llvm/Object/ELF.h"
|
2016-10-20 17:19:48 +08:00
|
|
|
|
|
|
|
namespace lld {
|
|
|
|
namespace elf {
|
|
|
|
|
2017-02-24 00:49:07 +08:00
|
|
|
class InputSection;
|
2016-10-20 17:19:48 +08:00
|
|
|
|
2017-07-20 06:27:35 +08:00
|
|
|
struct LLDDWARFSection final : public llvm::DWARFSection {
|
|
|
|
InputSectionBase *Sec = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class ELFT> class LLDDwarfObj final : public llvm::DWARFObject {
|
|
|
|
public:
|
2017-07-27 06:13:32 +08:00
|
|
|
explicit LLDDwarfObj(ObjFile<ELFT> *Obj);
|
2018-09-15 07:51:17 +08:00
|
|
|
|
2018-11-08 05:39:09 +08:00
|
|
|
void forEachInfoSections(
|
|
|
|
llvm::function_ref<void(const llvm::DWARFSection &)> F) const override {
|
|
|
|
F(InfoSection);
|
2017-07-20 06:27:35 +08:00
|
|
|
}
|
2018-09-15 07:51:17 +08:00
|
|
|
|
2017-07-20 06:27:35 +08:00
|
|
|
const llvm::DWARFSection &getRangeSection() const override {
|
|
|
|
return RangeSection;
|
|
|
|
}
|
2018-09-15 07:51:17 +08:00
|
|
|
|
2018-12-03 18:48:57 +08:00
|
|
|
const llvm::DWARFSection &getRnglistsSection() const override {
|
|
|
|
return RngListsSection;
|
|
|
|
}
|
|
|
|
|
2017-07-20 06:27:35 +08:00
|
|
|
const llvm::DWARFSection &getLineSection() const override {
|
|
|
|
return LineSection;
|
|
|
|
}
|
2018-09-15 07:51:17 +08:00
|
|
|
|
2018-12-03 18:48:57 +08:00
|
|
|
const llvm::DWARFSection &getAddrSection() const override {
|
|
|
|
return AddrSection;
|
|
|
|
}
|
|
|
|
|
2018-11-12 02:57:35 +08:00
|
|
|
const llvm::DWARFSection &getGnuPubNamesSection() const override {
|
2017-07-20 06:27:35 +08:00
|
|
|
return GnuPubNamesSection;
|
|
|
|
}
|
2018-09-15 07:51:17 +08:00
|
|
|
|
2018-11-12 02:57:35 +08:00
|
|
|
const llvm::DWARFSection &getGnuPubTypesSection() const override {
|
2017-07-20 06:27:35 +08:00
|
|
|
return GnuPubTypesSection;
|
|
|
|
}
|
2018-09-15 07:51:17 +08:00
|
|
|
|
2018-11-12 02:57:35 +08:00
|
|
|
StringRef getFileName() const override { return ""; }
|
|
|
|
StringRef getAbbrevSection() const override { return AbbrevSection; }
|
|
|
|
StringRef getStringSection() const override { return StrSection; }
|
|
|
|
StringRef getLineStringSection() const override { return LineStringSection; }
|
|
|
|
|
2017-07-20 06:27:35 +08:00
|
|
|
bool isLittleEndian() const override {
|
|
|
|
return ELFT::TargetEndianness == llvm::support::little;
|
|
|
|
}
|
2018-09-15 07:51:17 +08:00
|
|
|
|
2017-07-20 06:27:35 +08:00
|
|
|
llvm::Optional<llvm::RelocAddrEntry> find(const llvm::DWARFSection &Sec,
|
|
|
|
uint64_t Pos) const override;
|
2018-09-15 07:51:17 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
template <class RelTy>
|
|
|
|
llvm::Optional<llvm::RelocAddrEntry> findAux(const InputSectionBase &Sec,
|
|
|
|
uint64_t Pos,
|
|
|
|
ArrayRef<RelTy> Rels) const;
|
|
|
|
|
2018-11-12 02:57:35 +08:00
|
|
|
LLDDWARFSection GnuPubNamesSection;
|
|
|
|
LLDDWARFSection GnuPubTypesSection;
|
2018-09-15 07:51:17 +08:00
|
|
|
LLDDWARFSection InfoSection;
|
|
|
|
LLDDWARFSection RangeSection;
|
2018-12-03 18:48:57 +08:00
|
|
|
LLDDWARFSection RngListsSection;
|
2018-09-15 07:51:17 +08:00
|
|
|
LLDDWARFSection LineSection;
|
2018-12-03 18:48:57 +08:00
|
|
|
LLDDWARFSection AddrSection;
|
2018-09-15 07:51:17 +08:00
|
|
|
StringRef AbbrevSection;
|
|
|
|
StringRef StrSection;
|
2018-10-03 16:59:46 +08:00
|
|
|
StringRef LineStringSection;
|
2017-07-20 06:27:35 +08:00
|
|
|
};
|
|
|
|
|
2016-10-20 17:19:48 +08:00
|
|
|
} // namespace elf
|
|
|
|
} // namespace lld
|
|
|
|
|
|
|
|
#endif
|