Add strings to .dynstr early.
authorRui Ueyama <ruiu@google.com>
Wed, 2 Nov 2016 02:18:01 +0000 (02:18 +0000)
committerRui Ueyama <ruiu@google.com>
Wed, 2 Nov 2016 02:18:01 +0000 (02:18 +0000)
commita959393a1595917e2260fa3928f48a0db3b1f4fa
tree0d0e7bd3b2a70ea30760f8c3bf09a29f513a5cc5
parentb4f6ebf80695ee4aeefe4184728a1b3379b54baa
Add strings to .dynstr early.

Previously, we added strings from DynamicSection::finalize().
It was a bit tricky because finalize() is supposed to fix the final
size of the section, but adding new strings would change the size of
.dynstr section. So there was a dependency between finalize functions
of .dynamic and .dynstr.

However, I noticed that we can elimiante the dependency by simply
add strings early; we don't have to do that in finalize() but can do
from DynamicSection's ctor.

This patch defines a new function, DynamicSection::addEntries, to
add .dynamic entries that doesn't depend on other sections.

llvm-svn: 285784
lld/ELF/OutputSections.cpp
lld/ELF/OutputSections.h
lld/ELF/Writer.cpp
lld/test/ELF/dynamic-reloc.s
lld/test/ELF/shared-be.s
lld/test/ELF/shared.s
lld/test/ELF/verneed.s