diff --git a/lld/MachO/UnwindInfoSection.cpp b/lld/MachO/UnwindInfoSection.cpp --- a/lld/MachO/UnwindInfoSection.cpp +++ b/lld/MachO/UnwindInfoSection.cpp @@ -168,9 +168,14 @@ assert(target->hasAttr(r.type, RelocAttrBits::UNSIGNED)); if (r.offset % sizeof(CompactUnwindEntry) == 0) { - if (auto *referentIsec = r.referent.dyn_cast()) - if (!cast(referentIsec)->shouldOmitFromOutput()) - allEntriesAreOmitted = false; + InputSection *referentIsec; + if (auto *isec = r.referent.dyn_cast()) + referentIsec = isec; + else + referentIsec = cast(r.referent.dyn_cast())->isec; + + if (!cast(referentIsec)->shouldOmitFromOutput()) + allEntriesAreOmitted = false; continue; }