[ELF] Move fixSectionAlignments() before first call to assignAddresses()
The fixSectionAlignments() function may alter the alignment of some
OutputSections, this is likely to alter the addresses calculated earlier
in assignAddresses(). By moving the call to fixSectionAlignments() we
make sure that assignAddresses() is consistent with the early calculation
used for RangeThunks and the final call just before writing the image.
Differential Revision: https://reviews.llvm.org/D36739
llvm-svn: 312636
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 4394932..a196c51 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -192,9 +192,6 @@
if (ErrorCount)
return;
- if (!Script->Opt.HasSections && !Config->Relocatable)
- fixSectionAlignments();
-
// If -compressed-debug-sections is specified, we need to compress
// .debug_* sections. Do it right now because it changes the size of
// output sections.
@@ -1385,6 +1382,9 @@
InX::Dynamic},
[](SyntheticSection *SS) { SS->finalizeContents(); });
+ if (!Script->Opt.HasSections && !Config->Relocatable)
+ fixSectionAlignments();
+
// Some architectures use small displacements for jump instructions.
// It is linker's responsibility to create thunks containing long
// jump instructions if jump targets are too far. Create thunks.