Skip to content

Commit e1408de

Browse files
author
Alex B
committed
Fix typo + add better comments to code.
1 parent 43949e0 commit e1408de

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

lld/MachO/ConcatOutputSection.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ uint64_t TextOutputSection::estimateStubsInRangeVA(size_t callIdx) const {
185185
isecEnd = alignToPowerOf2(isecEnd, isec->align) + isec->getSize();
186186
}
187187

188-
// Tally up any thunks that have already been placed that have address higher
189-
// than the equivalent callIdx. We first find the index of the first thunk
190-
// that is beyond the current inputs[callIdx].
188+
// Tally up any thunks that have already been placed that have VA higher than
189+
// inputs[callIdx]. First, find the index of the first thunk that is beyond
190+
// the current inputs[callIdx].
191191
auto itPostcallIdxThunks = std::partition_point(
192192
thunks.begin(), thunks.end(),
193193
[isecVA](const ConcatInputSection *t) { return t->getVA() <= isecVA; });
@@ -206,18 +206,20 @@ uint64_t TextOutputSection::estimateStubsInRangeVA(size_t callIdx) const {
206206
// Add the size of all the inputs, including the unprocessed ones.
207207
maxTextSize += isecEnd;
208208

209+
// Add the size of the thunks that have already been created that are ahead of
210+
// inputs[callIdx]. These are already created thunks that will be interleaved
211+
// with inputs[callIdx...end].
212+
maxTextSize += existingForwardThunks * target->thunkSize;
213+
209214
// Add the size of the thunks that may be created in the future. Since
210215
// 'maxPotentialThunks' overcounts, this is an estimate of the upper limit.
211216
maxTextSize += maxPotentialThunks * target->thunkSize;
212217

213-
// Add the size of the thunks that have already been created that are ahead
214-
maxTextSize += existingForwardThunks * target->thunkSize;
215-
216218
// Estimated maximum VA of last stub.
217219
uint64_t maxVAOfLastStub = maxTextSize + in.stubs->getSize();
218220

219221
// Calculaate the first address that is gueranteed to not need a thunk to
220-
// reach any stub.git
222+
// reach any stub.
221223
uint64_t stubsInRangeVA = maxVAOfLastStub - forwardBranchRange;
222224

223225
log("thunks = " + std::to_string(thunkMap.size()) +

0 commit comments

Comments
 (0)