diff --git a/lld/MachO/UnwindInfoSection.cpp b/lld/MachO/UnwindInfoSection.cpp --- a/lld/MachO/UnwindInfoSection.cpp +++ b/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; diff --git a/lld/test/MachO/weak-definition-gc.s b/lld/test/MachO/weak-definition-gc.s --- a/lld/test/MachO/weak-definition-gc.s +++ b/lld/test/MachO/weak-definition-gc.s @@ -66,15 +66,19 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/weak-aligned-1.s -o %t/weak-aligned-1.o # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/weak-aligned-2.s -o %t/weak-aligned-2.o # RUN: %lld -o %t/out -lSystem %t/weak-aligned-1.o %t/weak-aligned-2.o -# RUN: llvm-objdump --syms --section=__const --full-contents %t/out | FileCheck --check-prefix=ALIGN %s -# ALIGN: SYMBOL TABLE: -# ALIGN-DAG: [[#%x, ADDR:]] l O __DATA_CONST,__const _weak1 -# ALIGN-DAG: {{0*}}[[#ADDR+ 0x4]] l O __DATA_CONST,__const _weak3 -# ALIGN-DAG: {{0*}}[[#ADDR+ 0x8]] l O __DATA_CONST,__const _weak2 -# ALIGN-DAG: {{0*}}[[#ADDR+0x10]] g O __DATA_CONST,__const _aligned -# ALIGN: Contents of section __DATA_CONST,__const: -# ALIGN-NEXT: {{0*}}[[#ADDR]] 11111111 33333333 22222222 00000000 -# ALIGN-NEXT: {{0*}}[[#ADDR+0x10]] 81818181 81818181 82828282 82828282 +# RUN: llvm-objdump --syms --section=__const --full-contents %t/out | FileCheck --check-prefixes=ALIGN,ALIGN2 %s +# RUN: %lld -o %t/out -lSystem %t/weak-aligned-1.o %t/weak-aligned-2.o -dead_strip +# RUN: llvm-objdump --syms --section=__const --full-contents %t/out | FileCheck --check-prefixes=ALIGN,ALIGN3 %s +# ALIGN: SYMBOL TABLE: +# ALIGN-DAG: [[#%x, ADDR:]] l O __DATA_CONST,__const _weak1 +# ALIGN2-DAG: {{0*}}[[#ADDR+ 0x4]] l O __DATA_CONST,__const _weak3 +# ALIGN3-DAG: {{0*}}[[#ADDR+ 0x4]] l O __DATA_CONST,__const _weak2 +# ALIGN2-DAG: {{0*}}[[#ADDR+ 0x8]] l O __DATA_CONST,__const _weak2 +# ALIGN-DAG: {{0*}}[[#ADDR+0x10]] g O __DATA_CONST,__const _aligned +# ALIGN: Contents of section __DATA_CONST,__const: +# ALIGN2-NEXT: {{0*}}[[#ADDR]] 11111111 33333333 22222222 00000000 +# ALIGN3-NEXT: {{0*}}[[#ADDR]] 11111111 22222222 00000000 00000000 +# ALIGN-NEXT: {{0*}}[[#ADDR+0x10]] 81818181 81818181 82828282 82828282 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/weak-def.s -o %t/weak-def.o # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/strong-def.s -o %t/strong-def.o