[PATCH] D14196: [ELF2] Ensure the DynSymTab to be finalized before the others
Igor Kudrin via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 30 01:03:01 PDT 2015
ikudrin created this revision.
ikudrin added reviewers: rafael, ruiu.
ikudrin added a subscriber: llvm-commits.
ikudrin added a project: lld.
It is required to fill up the GNU hash table section before its finalize() method is called.
http://reviews.llvm.org/D14196
Files:
ELF/OutputSections.cpp
ELF/Writer.cpp
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -585,6 +585,11 @@
// DynStrTab but .dynstr may appear before .dynamic.
Out<ELFT>::Dynamic->finalize();
+ // The dynamic symbols section should be finalized before the others
+ // because it can fill up the GNU hash section.
+ if (isOutputDynamic())
+ Out<ELFT>::DynSymTab->finalize();
+
// Fill other section headers.
for (OutputSectionBase<ELFT> *Sec : OutputSections)
Sec->finalize();
Index: ELF/OutputSections.cpp
===================================================================
--- ELF/OutputSections.cpp
+++ ELF/OutputSections.cpp
@@ -340,8 +340,7 @@
}
template <class ELFT> void GnuHashTableSection<ELFT>::finalize() {
- ArrayRef<SymbolBody *> A = Out<ELFT>::DynSymTab->getSymbols();
- unsigned NumHashed = std::count_if(A.begin(), A.end(), includeInGnuHashTable);
+ unsigned NumHashed = HashedSymbols.size();
NBuckets = calcNBuckets(NumHashed);
MaskWords = calcMaskWords(NumHashed);
// Second hash shift estimation: just predefined values.
@@ -900,6 +899,9 @@
}
template <class ELFT> void SymbolTableSection<ELFT>::finalize() {
+ if (this->Header.sh_size)
+ return; // Already finalized.
+
this->Header.sh_size = getNumSymbols() * sizeof(Elf_Sym);
this->Header.sh_link = StrTabSec.SectionIndex;
this->Header.sh_info = NumLocals + 1;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14196.38787.patch
Type: text/x-patch
Size: 1432 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151030/512d155a/attachment.bin>
More information about the llvm-commits
mailing list