[lld] [lld-macho] Fix crash with DWARF section-relative relocations (PR #168075)
Jez Ng via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 21 08:53:00 PST 2025
================
@@ -411,10 +411,14 @@ void ObjFile::parseSections(ArrayRef<SectionHeader> sectionHeaders) {
auto *isec = make<ConcatInputSection>(section, data, align);
if (isDebugSection(isec->getFlags()) &&
isec->getSegName() == segment_names::dwarf) {
- // Instead of emitting DWARF sections, we emit STABS symbols to the
- // object files that contain them. We filter them out early to avoid
- // parsing their relocations unnecessarily.
+ // Keep debug sections in debugSections for diagnostic purposes
debugSections.push_back(isec);
+ // Add DWARF sections to subsections so their relocations are processed,
+ // but mark them dead so they aren't emitted (MachO uses STABS, not DWARF).
+ // This fixes crashes with section-relative relocations (e.g., DW_FORM_strp)
+ // while maintaining MachO's traditional STABS-only debug output.
----------------
int3 wrote:
"fixes crashes" here will not make sense to future readers who did not know how the code looked like before. let's explain it directly here; my understanding is that we cannot simply drop the sections here because it would result in a "dangling reference" issue if other sections contain relocations that point to this one
https://github.com/llvm/llvm-project/pull/168075
More information about the llvm-commits
mailing list