[lld] r249842 - ELF2: Call OutputSection::finalize() from createSections.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 9 09:03:53 PDT 2015
Author: ruiu
Date: Fri Oct 9 11:03:53 2015
New Revision: 249842
URL: http://llvm.org/viewvc/llvm-project?rev=249842&view=rev
Log:
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.
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=249842&r1=249841&r2=249842&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Oct 9 11:03:53 2015
@@ -485,6 +485,12 @@ template <class ELFT> void Writer<ELFT>:
// 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>:
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();
More information about the llvm-commits
mailing list