[lld] 190b0f4 - [lld-macho] Stop crash when emitting personalities with -dead_strip

Alex Brachet via llvm-commits llvm-commits at lists.llvm.org
Fri May 20 14:40:55 PDT 2022


Author: Alex Brachet
Date: 2022-05-20T21:40:47Z
New Revision: 190b0f42cf559af7299c53ff010b55bc9b4f5f8c

URL: https://github.com/llvm/llvm-project/commit/190b0f42cf559af7299c53ff010b55bc9b4f5f8c
DIFF: https://github.com/llvm/llvm-project/commit/190b0f42cf559af7299c53ff010b55bc9b4f5f8c.diff

LOG: [lld-macho] Stop crash when emitting personalities with -dead_strip

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 https://github.com/llvm/llvm-project/issues/55565

Differential revision: https://reviews.llvm.org/D126072

Added: 
    

Modified: 
    lld/MachO/UnwindInfoSection.cpp
    lld/test/MachO/weak-definition-gc.s

Removed: 
    


################################################################################
diff  --git a/lld/MachO/UnwindInfoSection.cpp b/lld/MachO/UnwindInfoSection.cpp
index c0850af09388f..7aa0e8253c768 100644
--- a/lld/MachO/UnwindInfoSection.cpp
+++ b/lld/MachO/UnwindInfoSection.cpp
@@ -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;

diff  --git a/lld/test/MachO/weak-definition-gc.s b/lld/test/MachO/weak-definition-gc.s
index e1d5cb44ddb0e..15c3b88c25461 100644
--- 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


        


More information about the llvm-commits mailing list