[lld] [llvm] [lld-macho] Fix thunks for non-__text TEXT sections (PR #99052)
Daniel Bertalan via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 22 10:32:45 PDT 2024
================
@@ -127,10 +127,20 @@ bool TextOutputSection::needsThunks() const {
uint64_t isecAddr = addr;
for (ConcatInputSection *isec : inputs)
isecAddr = alignToPowerOf2(isecAddr, isec->align) + isec->getSize();
- if (isecAddr - addr + in.stubs->getSize() <=
- std::min(target->backwardBranchRange, target->forwardBranchRange))
+ // Other sections besides __text might be small enough to pass this
+ // test but nevertheless need thunks for calling into oher sections.
+ // An imperfect heuristic to use in this case is that if a section
+ // we've already processed in this segment needs thunks, so do the
+ // rest.
+ bool needsThunks = parent && parent->needsThunks;
+ if (!needsThunks &&
+ isecAddr - addr + in.stubs->getSize() <=
+ std::min(target->backwardBranchRange, target->forwardBranchRange))
return false;
// Yes, this program is large enough to need thunks.
+ if (parent) {
+ parent->needsThunks = true;
+ }
----------------
BertalanD wrote:
LG, but I'm wondering, when is `parent` null here?
https://github.com/llvm/llvm-project/pull/99052
More information about the llvm-commits
mailing list