It is the GNU hash table section which should contain its own data and be responsible for imposing its requirements for the order of dynamic symbols.
Details
Diff Detail
Event Timeline
ELF/OutputSections.cpp | ||
---|---|---|
349 | Is NumHashed always the same as HashedSymbols.size()? If so, remove the variable and use HashedSymbols.size() instead. | |
413–419 | You can use std::partition to separate non-hashed symbols from hashed symbols first, and then sort the latter half. | |
ELF/OutputSections.h | ||
313–314 | You don't need this constructor. Instead of HashedSymbolData(X, Y) you can always do HashedSymbolData{X, Y} |
ELF/OutputSections.cpp | ||
---|---|---|
349 | This class requires the other class to call sortSymbols() method. Plus, it requires that addSymbol() is called the exact number of times, and these calls come from the third place. This assert ensures that everything is in sync. |
ELF/OutputSections.h | ||
---|---|---|
298–302 | This looks really weird. You are not using the argument. |
ELF/OutputSections.cpp | ||
---|---|---|
349 | The variable is required in the finalize() method. The HashedSymbols is filled in the sortSymbols() method, which is called from finalize() method of the dynamic symbol table. All finalize() methods should not depend on each other and their call order, I think. |
ELF/OutputSections.cpp | ||
---|---|---|
349 | Can you count the number of symbols that need to be in .gnu.hash here, instead of calling addSymbol for each symbol? That can be as easy as ArrayRef<Symbol> A = Out<ELFT>::DynSymTab->getSymbols(); NumHashed = std::count(A.begin(), A.end(), includeInGnuHashTable); | |
405–406 | I think this function should be called "addSymbols" rather than "sortSymbols". This indeed sorts symbols passed to this function, but that's probably secondaly. | |
ELF/OutputSections.h | ||
299 | Add a blank line here. |
- NumHashed is no longer stored in the class.
- sortSymbols() -> addSymbols().
- assert()s are removed.
Add a blank line here.