xref: /llvm-project/lld/test/MachO/eh-frame-dead-strip.s (revision a745e47900dde15c180d5caea7a1d292ca809eb1)
1# REQUIRES: x86, aarch64
2
3# RUN: rm -rf %t; split-file %s %t
4# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos11.0 %t/strong.s -o %t/strong_x86_64.o
5# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos11.0 %t/weak.s -o %t/weak_x86_64.o
6# RUN: %lld -dylib -dead_strip %t/strong_x86_64.o %t/weak_x86_64.o -o %t/libstrongweak_x86_64.dylib
7# RUN: llvm-dwarfdump --eh-frame %t/libstrongweak_x86_64.dylib | FileCheck --check-prefixes CHECK,X86_64 %s
8# RUN: %lld -dylib -dead_strip %t/weak_x86_64.o %t/strong_x86_64.o -o %t/libweakstrong_x86_64.dylib
9# RUN: llvm-dwarfdump --eh-frame %t/libweakstrong_x86_64.dylib | FileCheck --check-prefixes CHECK,X86_64 %s
10
11# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos11.0 %t/strong.s -o %t/strong_arm64.o
12# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos11.0 %t/weak.s -o %t/weak_arm64.o
13# RUN: %lld -arch arm64 -dylib -dead_strip %t/strong_arm64.o %t/weak_arm64.o -o %t/libstrongweak_arm64.dylib
14# RUN: llvm-dwarfdump --eh-frame %t/libstrongweak_arm64.dylib | FileCheck --check-prefixes CHECK,ARM64 %s
15# RUN: %lld -arch arm64 -dylib -dead_strip %t/weak_arm64.o %t/strong_arm64.o -o %t/libweakstrong_arm64.dylib
16# RUN: llvm-dwarfdump --eh-frame %t/libweakstrong_arm64.dylib | FileCheck --check-prefixes CHECK,ARM64 %s
17
18## Verify that unneeded FDEs (and their CIEs) are dead-stripped even if they
19## point to a live symbol (e.g. because we had multiple weak definitions).
20
21# CHECK: .eh_frame contents:
22# X86_64: 00000000 00000014 00000000 CIE
23# X86_64: 00000018 0000001c 0000001c FDE cie=00000000
24# ARM64: 00000000 00000010 00000000 CIE
25# ARM64: 00000014 00000018 00000018 FDE cie=00000000
26# CHECK-NOT: CIE
27# CHECK-NOT: FDE
28
29#--- strong.s
30.globl _fun
31_fun:
32  .cfi_startproc
33  ## cfi_escape cannot be encoded in compact unwind
34  .cfi_escape 0
35  ret
36  .cfi_endproc
37
38#--- weak.s
39.globl _fun
40.weak_definition _fun
41_fun:
42  .cfi_startproc
43  ## cfi_escape cannot be encoded in compact unwind
44  .cfi_escape 0
45  ret
46  .cfi_endproc
47