ELF2: Call OutputSection::finalize() from createSections.

Previously, we did this in assignAddresses(), but finalization was
not part of assigning addresses, so this is a better place.

llvm-svn: 249842
This commit is contained in:
Rui Ueyama 2015-10-09 16:03:53 +00:00
parent ffd132878a
commit af311c1d01
1 changed files with 6 additions and 3 deletions

View File

@ -485,6 +485,12 @@ template <class ELFT> void Writer<ELFT>::createSections() {
// Fill the DynStrTab early.
Out<ELFT>::Dynamic->finalize();
// Fix each section's header (e.g. sh_size, sh_link, etc.)
for (OutputSectionBase<ELFT::Is64Bits> *Sec : OutputSections) {
Out<ELFT>::StrTab->add(Sec->getName());
Sec->finalize();
}
}
template <class ELFT>
@ -524,9 +530,6 @@ template <class ELFT> void Writer<ELFT>::assignAddresses() {
FileHeaderPHDR.Header.p_align = Target->getPageSize();
for (OutputSectionBase<ELFT::Is64Bits> *Sec : OutputSections) {
Out<ELFT>::StrTab->add(Sec->getName());
Sec->finalize();
if (Sec->getSize()) {
uintX_t Flags = toPHDRFlags(Sec->getFlags());
ProgramHeader<ELFT> *Last = PHDRs.back();