[lld] [lld][macho] Error out gracefully when offset is outside literal section (PR #164660)

Jez Ng via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 24 17:27:45 PDT 2025


int3 wrote:

`CStringInputSection::getOffset()` does this check via `getStringPiece()`. The test I added in this PR exercises this code path too.

I am reluctant to add the check for ConcatInputSections::getOffset since 1) it is likely a hot code path and 2) it is not technically an error to ask for an offset that's outside the subsection. As mentioned in the top post, ld64 seems to handle it fine even for literal sections. It's only because we look up the section contents as part of `WordLiteralInputSection::getOffset` that it becomes an issue.

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


More information about the llvm-commits mailing list