[lld] r296687 - Do not inherit LoadedObjectInfo.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 1 14:02:37 PST 2017
Author: ruiu
Date: Wed Mar 1 16:02:37 2017
New Revision: 296687
URL: http://llvm.org/viewvc/llvm-project?rev=296687&view=rev
Log:
Do not inherit LoadedObjectInfo.
GdbIndexBuilder class inherited LoadedObjectInfo, but that's not necessary.
Modified:
lld/trunk/ELF/GdbIndex.cpp
lld/trunk/ELF/GdbIndex.h
Modified: lld/trunk/ELF/GdbIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/GdbIndex.cpp?rev=296687&r1=296686&r2=296687&view=diff
==============================================================================
--- lld/trunk/ELF/GdbIndex.cpp (original)
+++ lld/trunk/ELF/GdbIndex.cpp Wed Mar 1 16:02:37 2017
@@ -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(s
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>;
Modified: lld/trunk/ELF/GdbIndex.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/GdbIndex.h?rev=296687&r1=296686&r2=296687&view=diff
==============================================================================
--- lld/trunk/ELF/GdbIndex.h (original)
+++ lld/trunk/ELF/GdbIndex.h Wed Mar 1 16:02:37 2017
@@ -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 AddressEntr
// 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.
More information about the llvm-commits
mailing list