Index: lld/MachO/UnwindInfoSection.cpp =================================================================== --- lld/MachO/UnwindInfoSection.cpp +++ lld/MachO/UnwindInfoSection.cpp @@ -309,6 +309,7 @@ /*includeInSymtab=*/true, /*isThumb=*/false, /*isReferencedDynamically=*/false, /*noDeadStrip=*/false); + s->used = true; in.got->addEntry(s); } r.referent = s; Index: lld/test/MachO/personality-dead-strip.s =================================================================== --- /dev/null +++ lld/test/MachO/personality-dead-strip.s @@ -0,0 +1,20 @@ +# RUN: rm -rf %t +# RUN: mkdir %t +# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %s -o %t/test.o +## Check that this doesn't crash. +# RUN: %lld -lSystem -o %t/test %t/test.o -dead_strip + +.text +_my_personality: + mov $1345, %rax + +_has_unwind_1: + .cfi_startproc + .cfi_personality 155, _my_personality + .cfi_def_cfa_offset 16 + ret + .cfi_endproc + +.globl _main +_main: + callq _has_unwind_1