diff options
Diffstat (limited to 'lld/ELF/SyntheticSections.cpp')
-rw-r--r-- | lld/ELF/SyntheticSections.cpp | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index f93c09b95d75..6af10237fb83 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -650,14 +650,13 @@ GotSection::GotSection() } void GotSection::addEntry(Symbol &sym) { - sym.gotIndex = numEntries; - ++numEntries; + assert(sym.auxIdx == symAux.size() - 1); + symAux.back().gotIdx = numEntries++; } bool GotSection::addDynTlsEntry(Symbol &sym) { - if (sym.globalDynIndex != -1U) - return false; - sym.globalDynIndex = numEntries; + assert(sym.auxIdx == symAux.size() - 1); + symAux.back().tlsGdIdx = numEntries; // Global Dynamic TLS entries take two GOT slots. numEntries += 2; return true; @@ -674,11 +673,11 @@ bool GotSection::addTlsIndex() { } uint64_t GotSection::getGlobalDynAddr(const Symbol &b) const { - return this->getVA() + b.globalDynIndex * config->wordsize; + return this->getVA() + b.getTlsGdIdx() * config->wordsize; } uint64_t GotSection::getGlobalDynOffset(const Symbol &b) const { - return b.globalDynIndex * config->wordsize; + return b.getTlsGdIdx() * config->wordsize; } void GotSection::finalizeContents() { @@ -972,12 +971,18 @@ void MipsGotSection::build() { } } - // Update Symbol::gotIndex field to use this + // Update SymbolAux::gotIdx field to use this // value later in the `sortMipsSymbols` function. - for (auto &p : primGot->global) - p.first->gotIndex = p.second; - for (auto &p : primGot->relocs) - p.first->gotIndex = p.second; + for (auto &p : primGot->global) { + if (p.first->auxIdx == uint32_t(-1)) + p.first->allocateAux(); + symAux.back().gotIdx = p.second; + } + for (auto &p : primGot->relocs) { + if (p.first->auxIdx == uint32_t(-1)) + p.first->allocateAux(); + symAux.back().gotIdx = p.second; + } // Create dynamic relocations. for (FileGot &got : gots) { @@ -1145,7 +1150,8 @@ GotPltSection::GotPltSection() } void GotPltSection::addEntry(Symbol &sym) { - assert(sym.pltIndex == entries.size()); + assert(sym.auxIdx == symAux.size() - 1 && + symAux.back().pltIdx == entries.size()); entries.push_back(&sym); } @@ -1190,7 +1196,7 @@ IgotPltSection::IgotPltSection() target->gotEntrySize, getIgotPltName()) {} void IgotPltSection::addEntry(Symbol &sym) { - assert(sym.pltIndex == entries.size()); + assert(symAux.back().pltIdx == entries.size()); entries.push_back(&sym); } @@ -2069,7 +2075,7 @@ static bool sortMipsSymbols(const SymbolTableEntry &l, // Sort entries related to non-local preemptible symbols by GOT indexes. // All other entries go to the beginning of a dynsym in arbitrary order. if (l.sym->isInGot() && r.sym->isInGot()) - return l.sym->gotIndex < r.sym->gotIndex; + return l.sym->getGotIdx() < r.sym->getGotIdx(); if (!l.sym->isInGot() && !r.sym->isInGot()) return false; return !l.sym->isInGot(); @@ -2546,7 +2552,8 @@ void PltSection::writeTo(uint8_t *buf) { } void PltSection::addEntry(Symbol &sym) { - sym.pltIndex = entries.size(); + assert(sym.auxIdx == symAux.size() - 1); + symAux.back().pltIdx = entries.size(); entries.push_back(&sym); } @@ -2592,7 +2599,8 @@ size_t IpltSection::getSize() const { } void IpltSection::addEntry(Symbol &sym) { - sym.pltIndex = entries.size(); + assert(sym.auxIdx == symAux.size() - 1); + symAux.back().pltIdx = entries.size(); entries.push_back(&sym); } |