mirror of
https://github.com/intel/llvm.git
synced 2026-01-22 07:01:03 +08:00
[ELF] Change GnuPub{Names,Types}Section from StringRef to LLDDWARFSection
Summary: The debug_info_offset value may be relocated. This is lld side change of D54375. Reviewers: ruiu, dblaikie, grimar, espindola Subscribers: emaste, arichardson, JDevlieghere, llvm-commits Differential Revision: https://reviews.llvm.org/D54376 llvm-svn: 346616
This commit is contained in:
@@ -31,11 +31,14 @@ template <class ELFT> LLDDwarfObj<ELFT>::LLDDwarfObj(ObjFile<ELFT> *Obj) {
|
||||
if (!Sec)
|
||||
continue;
|
||||
|
||||
if (LLDDWARFSection *M = StringSwitch<LLDDWARFSection *>(Sec->Name)
|
||||
.Case(".debug_info", &InfoSection)
|
||||
.Case(".debug_ranges", &RangeSection)
|
||||
.Case(".debug_line", &LineSection)
|
||||
.Default(nullptr)) {
|
||||
if (LLDDWARFSection *M =
|
||||
StringSwitch<LLDDWARFSection *>(Sec->Name)
|
||||
.Case(".debug_gnu_pubnames", &GnuPubNamesSection)
|
||||
.Case(".debug_gnu_pubtypes", &GnuPubTypesSection)
|
||||
.Case(".debug_info", &InfoSection)
|
||||
.Case(".debug_ranges", &RangeSection)
|
||||
.Case(".debug_line", &LineSection)
|
||||
.Default(nullptr)) {
|
||||
M->Data = toStringRef(Sec->data());
|
||||
M->Sec = Sec;
|
||||
continue;
|
||||
@@ -43,10 +46,6 @@ template <class ELFT> LLDDwarfObj<ELFT>::LLDDwarfObj(ObjFile<ELFT> *Obj) {
|
||||
|
||||
if (Sec->Name == ".debug_abbrev")
|
||||
AbbrevSection = toStringRef(Sec->data());
|
||||
else if (Sec->Name == ".debug_gnu_pubnames")
|
||||
GnuPubNamesSection = toStringRef(Sec->data());
|
||||
else if (Sec->Name == ".debug_gnu_pubtypes")
|
||||
GnuPubTypesSection = toStringRef(Sec->data());
|
||||
else if (Sec->Name == ".debug_str")
|
||||
StrSection = toStringRef(Sec->data());
|
||||
else if (Sec->Name == ".debug_line_str")
|
||||
|
||||
@@ -41,19 +41,19 @@ public:
|
||||
return LineSection;
|
||||
}
|
||||
|
||||
const llvm::DWARFSection &getGnuPubNamesSection() const override {
|
||||
return GnuPubNamesSection;
|
||||
}
|
||||
|
||||
const llvm::DWARFSection &getGnuPubTypesSection() const override {
|
||||
return GnuPubTypesSection;
|
||||
}
|
||||
|
||||
StringRef getFileName() const override { return ""; }
|
||||
StringRef getAbbrevSection() const override { return AbbrevSection; }
|
||||
StringRef getStringSection() const override { return StrSection; }
|
||||
StringRef getLineStringSection() const override { return LineStringSection; }
|
||||
|
||||
StringRef getGnuPubNamesSection() const override {
|
||||
return GnuPubNamesSection;
|
||||
}
|
||||
|
||||
StringRef getGnuPubTypesSection() const override {
|
||||
return GnuPubTypesSection;
|
||||
}
|
||||
|
||||
bool isLittleEndian() const override {
|
||||
return ELFT::TargetEndianness == llvm::support::little;
|
||||
}
|
||||
@@ -67,13 +67,13 @@ private:
|
||||
uint64_t Pos,
|
||||
ArrayRef<RelTy> Rels) const;
|
||||
|
||||
LLDDWARFSection GnuPubNamesSection;
|
||||
LLDDWARFSection GnuPubTypesSection;
|
||||
LLDDWARFSection InfoSection;
|
||||
LLDDWARFSection RangeSection;
|
||||
LLDDWARFSection LineSection;
|
||||
|
||||
StringRef AbbrevSection;
|
||||
StringRef GnuPubNamesSection;
|
||||
StringRef GnuPubTypesSection;
|
||||
StringRef StrSection;
|
||||
StringRef LineStringSection;
|
||||
};
|
||||
|
||||
@@ -2412,14 +2412,16 @@ readAddressAreas(DWARFContext &Dwarf, InputSection *Sec) {
|
||||
return Ret;
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
static std::vector<GdbIndexSection::NameTypeEntry>
|
||||
readPubNamesAndTypes(DWARFContext &Dwarf, uint32_t Idx) {
|
||||
StringRef Sec1 = Dwarf.getDWARFObj().getGnuPubNamesSection();
|
||||
StringRef Sec2 = Dwarf.getDWARFObj().getGnuPubTypesSection();
|
||||
auto &Obj = static_cast<const LLDDwarfObj<ELFT> &>(Dwarf.getDWARFObj());
|
||||
const DWARFSection &PubNames = Obj.getGnuPubNamesSection();
|
||||
const DWARFSection &PubTypes = Obj.getGnuPubTypesSection();
|
||||
|
||||
std::vector<GdbIndexSection::NameTypeEntry> Ret;
|
||||
for (StringRef Sec : {Sec1, Sec2}) {
|
||||
DWARFDebugPubTable Table(Sec, Config->IsLE, true);
|
||||
for (const DWARFSection *Pub : {&PubNames, &PubTypes}) {
|
||||
DWARFDebugPubTable Table(Obj, *Pub, Config->IsLE, true);
|
||||
for (const DWARFDebugPubTable::Set &Set : Table.getData())
|
||||
for (const DWARFDebugPubTable::Entry &Ent : Set.Entries)
|
||||
Ret.push_back({{Ent.Name, computeGdbHash(Ent.Name)},
|
||||
@@ -2517,7 +2519,7 @@ template <class ELFT> GdbIndexSection *GdbIndexSection::create() {
|
||||
Chunks[I].Sec = Sections[I];
|
||||
Chunks[I].CompilationUnits = readCuList(Dwarf);
|
||||
Chunks[I].AddressAreas = readAddressAreas(Dwarf, Sections[I]);
|
||||
NameTypes[I] = readPubNamesAndTypes(Dwarf, I);
|
||||
NameTypes[I] = readPubNamesAndTypes<ELFT>(Dwarf, I);
|
||||
});
|
||||
|
||||
auto *Ret = make<GdbIndexSection>();
|
||||
|
||||
Reference in New Issue
Block a user