[llvm-branch-commits] [lld] [lld][macho] Fix thunks with multiple text sections (PR #197049)

Vy Nguyen via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon May 11 19:03:43 PDT 2026


================
@@ -191,17 +194,55 @@ void TextOutputSection::createThunk(const ConcatInputSection &isec,
   thunks.push_back(thunkInfo.isec);
 }
 
+std::optional<uint64_t>
+TextOutputSection::estimateStubsEndVA(unsigned numPotentialThunks) const {
+  if (!parent)
+    return std::nullopt;
+
+  auto sections =
+      ArrayRef(parent->getSections())
+          .drop_until([&](const OutputSection *osec) { return osec == this; });
+
+  // Walk backwards to find the last stubs section
+  while (!sections.empty()) {
+    auto *osec = sections.back();
+    if (osec->isNeeded() && (osec == in.stubs || osec == in.objcStubs))
----------------
oontvoo wrote:

does `stubHelper` need checking here too?

https://github.com/llvm/llvm-project/pull/197049


More information about the llvm-branch-commits mailing list