diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp --- a/lld/MachO/InputFiles.cpp +++ b/lld/MachO/InputFiles.cpp @@ -1096,7 +1096,12 @@ // llvm-mc omits CU entries for functions that need DWARF encoding, but // `ld -r` doesn't. We can ignore them because we will re-synthesize these // CU entries from the DWARF info during the output phase. - if ((encoding & target->modeDwarfEncoding) == target->modeDwarfEncoding) + static_assert(static_cast(UNWIND_X86_64_MODE_MASK) == + static_cast(UNWIND_X86_MODE_MASK) && + static_cast < uint32_t(UNWIND_ARM64_MODE_MASK) == + static_cast(UNWIND_X86_64_MODE_MASK)); + if ((encoding & static_cast(UNWIND_X86_64_MODE_MASK)) == + target->modeDwarfEncoding) continue; ConcatInputSection *referentIsec; diff --git a/lld/MachO/UnwindInfoSection.cpp b/lld/MachO/UnwindInfoSection.cpp --- a/lld/MachO/UnwindInfoSection.cpp +++ b/lld/MachO/UnwindInfoSection.cpp @@ -397,6 +397,10 @@ static_cast(UNWIND_X86_MODE_MASK)); static_assert(static_cast(UNWIND_X86_64_MODE_STACK_IND) == static_cast(UNWIND_X86_MODE_STACK_IND)); + // Can't fold DWARF sections. + if ((encoding & static_cast(UNWIND_X86_64_MODE_MASK)) == + target->modeDwarfEncoding) + return false; if ((target->cpuType == CPU_TYPE_X86_64 || target->cpuType == CPU_TYPE_X86) && (encoding & UNWIND_X86_64_MODE_MASK) == UNWIND_X86_64_MODE_STACK_IND) { // FIXME: Consider passing in the two function addresses and getting