diff --git a/bolt/lib/Passes/LongJmp.cpp b/bolt/lib/Passes/LongJmp.cpp --- a/bolt/lib/Passes/LongJmp.cpp +++ b/bolt/lib/Passes/LongJmp.cpp @@ -18,6 +18,7 @@ namespace opts { extern cl::OptionCategory BoltOptCategory; +extern llvm::cl::opt AlignText; extern cl::opt AlignFunctions; extern cl::opt UseOldText; extern cl::opt HotFunctionsAtEnd; @@ -342,7 +343,7 @@ tentativeLayoutRelocColdPart(BC, SortedFunctions, DotAddress); ColdLayoutDone = true; if (opts::HotFunctionsAtEnd) - DotAddress = alignTo(DotAddress, BC.PageAlign); + DotAddress = alignTo(DotAddress, opts::AlignText); } DotAddress = alignTo(DotAddress, BinaryFunction::MinAlign); @@ -390,11 +391,11 @@ // Initial padding if (opts::UseOldText && EstimatedTextSize <= BC.OldTextSectionSize) { DotAddress = BC.OldTextSectionAddress; - uint64_t Pad = offsetToAlignment(DotAddress, llvm::Align(BC.PageAlign)); + uint64_t Pad = offsetToAlignment(DotAddress, llvm::Align(opts::AlignText)); if (Pad + EstimatedTextSize <= BC.OldTextSectionSize) DotAddress += Pad; } else { - DotAddress = alignTo(BC.LayoutStartAddress, BC.PageAlign); + DotAddress = alignTo(BC.LayoutStartAddress, opts::AlignText); } tentativeLayoutRelocMode(BC, SortedFunctions, DotAddress); diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp --- a/bolt/lib/Rewrite/RewriteInstance.cpp +++ b/bolt/lib/Rewrite/RewriteInstance.cpp @@ -1743,6 +1743,9 @@ if (!opts::AlignText.getNumOccurrences()) opts::AlignText = BC->PageAlign; + if (opts::AlignText < opts::AlignFunctions) + opts::AlignText = (unsigned)opts::AlignFunctions; + if (BC->isX86() && opts::Lite.getNumOccurrences() == 0 && !opts::StrictMode && !opts::UseOldText) opts::Lite = true;