[ELF] Follow-up to r298345 "[ELF] - Detemplate GdbIndexSection."

Fix for linux build bot:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/8144/steps/build/logs/stdio

llvm-svn: 298348
This commit is contained in:
George Rimar 2017-03-21 08:44:25 +00:00
parent 75bdc7690e
commit 3f7c3df6a4
2 changed files with 17 additions and 16 deletions

View File

@ -271,34 +271,35 @@ void elf::ObjectFile<ELFT>::initializeSections(
ArrayRef<Elf_Shdr> ObjSections = check(this->getObj().sections());
const ELFFile<ELFT> &Obj = this->getObj();
uint64_t Size = ObjSections.size();
Sections.resize(Size);
this->Sections.resize(Size);
unsigned I = -1;
StringRef SectionStringTable = check(Obj.getSectionStringTable(ObjSections));
for (const Elf_Shdr &Sec : ObjSections) {
++I;
if (Sections[I] == &InputSection::Discarded)
if (this->Sections[I] == &InputSection::Discarded)
continue;
// SHF_EXCLUDE'ed sections are discarded by the linker. However,
// if -r is given, we'll let the final link discard such sections.
// This is compatible with GNU.
if ((Sec.sh_flags & SHF_EXCLUDE) && !Config->Relocatable) {
Sections[I] = &InputSection::Discarded;
this->Sections[I] = &InputSection::Discarded;
continue;
}
switch (Sec.sh_type) {
case SHT_GROUP:
Sections[I] = &InputSection::Discarded;
if (ComdatGroups.insert(CachedHashStringRef(
getShtGroupSignature(ObjSections, Sec)))
this->Sections[I] = &InputSection::Discarded;
if (ComdatGroups
.insert(
CachedHashStringRef(getShtGroupSignature(ObjSections, Sec)))
.second)
continue;
for (uint32_t SecIndex : getShtGroupEntries(Sec)) {
if (SecIndex >= Size)
fatal(toString(this) + ": invalid section index in group: " +
Twine(SecIndex));
Sections[SecIndex] = &InputSection::Discarded;
fatal(toString(this) +
": invalid section index in group: " + Twine(SecIndex));
this->Sections[SecIndex] = &InputSection::Discarded;
}
break;
case SHT_SYMTAB:
@ -311,7 +312,7 @@ void elf::ObjectFile<ELFT>::initializeSections(
case SHT_NULL:
break;
default:
Sections[I] = createInputSection(Sec, SectionStringTable);
this->Sections[I] = createInputSection(Sec, SectionStringTable);
}
// .ARM.exidx sections have a reverse dependency on the InputSection they
@ -320,7 +321,8 @@ void elf::ObjectFile<ELFT>::initializeSections(
if (Sec.sh_link >= Sections.size())
fatal(toString(this) + ": invalid sh_link index: " +
Twine(Sec.sh_link));
Sections[Sec.sh_link]->DependentSections.push_back(Sections[I]);
this->Sections[Sec.sh_link]->DependentSections.push_back(
this->Sections[I]);
}
}
}
@ -328,9 +330,9 @@ void elf::ObjectFile<ELFT>::initializeSections(
template <class ELFT>
InputSectionBase *elf::ObjectFile<ELFT>::getRelocTarget(const Elf_Shdr &Sec) {
uint32_t Idx = Sec.sh_info;
if (Idx >= Sections.size())
if (Idx >= this->Sections.size())
fatal(toString(this) + ": invalid relocated section index: " + Twine(Idx));
InputSectionBase *Target = Sections[Idx];
InputSectionBase *Target = this->Sections[Idx];
// Strictly speaking, a relocation section must be included in the
// group of the section it relocates. However, LLVM 3.3 and earlier
@ -470,9 +472,9 @@ template <class ELFT> void elf::ObjectFile<ELFT>::initializeSymbols() {
template <class ELFT>
InputSectionBase *elf::ObjectFile<ELFT>::getSection(const Elf_Sym &Sym) const {
uint32_t Index = this->getSectionIndex(Sym);
if (Index >= Sections.size())
if (Index >= this->Sections.size())
fatal(toString(this) + ": invalid section index: " + Twine(Index));
InputSectionBase *S = Sections[Index];
InputSectionBase *S = this->Sections[Index];
// We found that GNU assembler 2.17.50 [FreeBSD] 2007-07-03 could
// generate broken objects. STT_SECTION/STT_NOTYPE symbols can be

View File

@ -158,7 +158,6 @@ public:
explicit ObjectFile(MemoryBufferRef M);
void parse(llvm::DenseSet<llvm::CachedHashStringRef> &ComdatGroups);
ArrayRef<InputSectionBase *> getSections() const { return Sections; }
InputSectionBase *getSection(const Elf_Sym &Sym) const;
SymbolBody &getSymbolBody(uint32_t SymbolIndex) const {