Index: ELF/Writer.cpp =================================================================== --- ELF/Writer.cpp +++ ELF/Writer.cpp @@ -193,9 +193,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. @@ -1303,6 +1300,9 @@ In::VerSym, In::VerNeed, 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.