forked from OSchip/llvm-project
Do not inherit LoadedObjectInfo.
GdbIndexBuilder class inherited LoadedObjectInfo, but that's not necessary. llvm-svn: 296687
This commit is contained in:
parent
475b1ddfe2
commit
e02cc60c72
|
@ -67,18 +67,31 @@ using namespace llvm;
|
|||
using namespace llvm::object;
|
||||
using namespace lld::elf;
|
||||
|
||||
class lld::elf::ObjInfoTy : public llvm::LoadedObjectInfo {
|
||||
uint64_t getSectionLoadAddress(const object::SectionRef &Sec) const override {
|
||||
auto &S = static_cast<const ELFSectionRef &>(Sec);
|
||||
if (S.getFlags() & ELF::SHF_ALLOC)
|
||||
return S.getOffset();
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::unique_ptr<llvm::LoadedObjectInfo> clone() const override { return {}; }
|
||||
};
|
||||
|
||||
template <class ELFT>
|
||||
GdbIndexBuilder<ELFT>::GdbIndexBuilder(InputSection *DebugInfoSec)
|
||||
: DebugInfoSec(DebugInfoSec) {
|
||||
: DebugInfoSec(DebugInfoSec), ObjInfo(new ObjInfoTy) {
|
||||
if (Expected<std::unique_ptr<object::ObjectFile>> Obj =
|
||||
object::ObjectFile::createObjectFile(
|
||||
DebugInfoSec->template getFile<ELFT>()->MB))
|
||||
Dwarf.reset(new DWARFContextInMemory(*Obj.get(), this));
|
||||
Dwarf.reset(new DWARFContextInMemory(*Obj.get(), ObjInfo.get()));
|
||||
else
|
||||
error(toString(DebugInfoSec->template getFile<ELFT>()) +
|
||||
": error creating DWARF context");
|
||||
}
|
||||
|
||||
template <class ELFT> GdbIndexBuilder<ELFT>::~GdbIndexBuilder() {}
|
||||
|
||||
template <class ELFT>
|
||||
std::vector<std::pair<typename ELFT::uint, typename ELFT::uint>>
|
||||
GdbIndexBuilder<ELFT>::readCUList() {
|
||||
|
@ -166,22 +179,6 @@ GdbIndexBuilder<ELFT>::readAddressArea(size_t CurrentCU) {
|
|||
return Ret;
|
||||
}
|
||||
|
||||
// We return file offset as load address for allocatable sections. That is
|
||||
// currently used for collecting address ranges in readAddressArea(). We are
|
||||
// able then to find section index that range belongs to.
|
||||
template <class ELFT>
|
||||
uint64_t GdbIndexBuilder<ELFT>::getSectionLoadAddress(
|
||||
const object::SectionRef &Sec) const {
|
||||
if (static_cast<const ELFSectionRef &>(Sec).getFlags() & ELF::SHF_ALLOC)
|
||||
return static_cast<const ELFSectionRef &>(Sec).getOffset();
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
std::unique_ptr<LoadedObjectInfo> GdbIndexBuilder<ELFT>::clone() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
namespace lld {
|
||||
namespace elf {
|
||||
template class GdbIndexBuilder<ELF32LE>;
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace lld {
|
|||
namespace elf {
|
||||
|
||||
class InputSection;
|
||||
class ObjInfoTy;
|
||||
|
||||
// Struct represents single entry of address area of gdb index.
|
||||
template <class ELFT> struct AddressEntry {
|
||||
|
@ -29,15 +30,16 @@ template <class ELFT> struct AddressEntry {
|
|||
|
||||
// GdbIndexBuilder is a helper class used for extracting data required
|
||||
// for building .gdb_index section from objects.
|
||||
template <class ELFT> class GdbIndexBuilder : public llvm::LoadedObjectInfo {
|
||||
template <class ELFT> class GdbIndexBuilder {
|
||||
typedef typename ELFT::uint uintX_t;
|
||||
|
||||
InputSection *DebugInfoSec;
|
||||
|
||||
std::unique_ptr<llvm::DWARFContext> Dwarf;
|
||||
std::unique_ptr<ObjInfoTy> ObjInfo;
|
||||
|
||||
public:
|
||||
GdbIndexBuilder(InputSection *DebugInfoSec);
|
||||
~GdbIndexBuilder();
|
||||
|
||||
// Extracts the compilation units. Each first element of pair is a offset of a
|
||||
// CU in the .debug_info section and second is the length of that CU.
|
||||
|
@ -50,13 +52,6 @@ public:
|
|||
// Method extracts public names and types. It returns list of name and
|
||||
// gnu_pub* kind pairs.
|
||||
std::vector<std::pair<StringRef, uint8_t>> readPubNamesAndTypes();
|
||||
|
||||
private:
|
||||
// Method returns section file offset as a load addres for DWARF parser. That
|
||||
// allows to find the target section index for address ranges.
|
||||
uint64_t
|
||||
getSectionLoadAddress(const llvm::object::SectionRef &Sec) const override;
|
||||
std::unique_ptr<llvm::LoadedObjectInfo> clone() const override;
|
||||
};
|
||||
|
||||
// Element of GdbHashTab hash table.
|
||||
|
|
Loading…
Reference in New Issue