[lld] [lld-macho] Fix thunk insertion for multiple .text sections scenario (PR #175704)
Ellis Hoag via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 20 10:03:37 PST 2026
================
@@ -114,41 +115,61 @@ void ConcatOutputSection::addInput(ConcatInputSection *input) {
DenseMap<Symbol *, ThunkInfo> lld::macho::thunkMap;
-// Determine whether we need thunks, which depends on the target arch -- RISC
-// (i.e., ARM) generally does because it has limited-range branch/call
-// instructions, whereas CISC (i.e., x86) generally doesn't. RISC only needs
-// thunks for programs so large that branch source & destination addresses
-// might differ more than the range of branch instruction(s).
-bool TextOutputSection::needsThunks() const {
- if (!target->usesThunks())
- return false;
- uint64_t isecAddr = addr;
+namespace {
+
+// Returns true if `osec` can be the target of a BRANCH relocation.
+// Branch targets include code sections and stub sections for dynamic calls.
+bool isBranchTargetSection(const OutputSection *osec) {
----------------
ellishg wrote:
```suggestion
static bool isBranchTargetSection(const OutputSection *osec) {
```
https://github.com/llvm/llvm-project/pull/175704
More information about the llvm-commits
mailing list