Skip to content

Commit

Permalink
[lld-macho] Stop crash when emitting personalities with -dead_strip
Browse files Browse the repository at this point in the history
The <internal> symbol was tripping an assertion in getVA() because it
was not marked as used. Per the comment above that symbols creation,
dead stripping has already occurred so marking this symbol as used is
accurate.

Fixes #55565

Differential revision: https://reviews.llvm.org/D126072
  • Loading branch information
abrachet committed May 20, 2022
1 parent d390035 commit 190b0f4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions lld/MachO/UnwindInfoSection.cpp
Expand Up @@ -309,6 +309,7 @@ void UnwindInfoSectionImpl::prepareRelocations(ConcatInputSection *isec) {
/*includeInSymtab=*/true,
/*isThumb=*/false, /*isReferencedDynamically=*/false,
/*noDeadStrip=*/false);
s->used = true;
in.got->addEntry(s);
}
r.referent = s;
Expand Down
22 changes: 13 additions & 9 deletions lld/test/MachO/weak-definition-gc.s
Expand Up @@ -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
Expand Down

0 comments on commit 190b0f4

Please sign in to comment.