This is an archive of the discontinued LLVM Phabricator instance.

[ELF2] Use correct symbol table indexes for hash and relocation sections
AbandonedPublic

Authored by ikudrin on Sep 17 2015, 9:26 AM.

Details

Summary

Hash and relocation sections memorized indexes of symbol table entries during the createSections phase. However, the symbol table section reordered its entries at writing phase. As a result, references in hash and relocation sections might be broken.

This patch forces dependent sections to receive information about actual indexes of symbol table entries from the symbol table section itself when this information is ready.

Diff Detail

Event Timeline

ikudrin updated this revision to Diff 35007.Sep 17 2015, 9:26 AM
ikudrin retitled this revision from to [ELF2] Use correct symbol table indexes for hash and relocation sections.
ikudrin updated this object.
ikudrin added reviewers: rafael, davide, ruiu.
ikudrin added a project: lld.
ikudrin added a subscriber: llvm-commits.

This patch also fixes failures of following test, at least on Windows:

  • elf2/dynamic-reloc.s
  • elf2/shared.s
rafael edited edge metadata.Sep 17 2015, 11:34 AM
rafael added a subscriber: rafael.

Thanks a lot for the patch and bringing the issue to my attention.

There are a few design options to explore in this area:

  • We could pass a custom hash to the DenseMap to get the same

iteration order everywhere.

  • We could use MapVector.
  • We could use a DenseMap<StringRef, SymbolNumber> along with a

std::vector<Symbol*>. Once resolution is done we then clear the map
and sort the vector.

Given that it is not clear which one is better and given that it will
probably not be too difficult to experiment with them, it is probably
better to keep it simple until we can benchmark the code.

I have then switched to using a MapVector in r247911.

Thanks,
Rafael

ikudrin abandoned this revision.Sep 17 2015, 9:53 PM