xref: /llvm-project/lld/test/MachO/compact-unwind-foldings.s (revision 65226d3f1f533914a5fcc2d94bb1ff95b0d55d5d)
1# REQUIRES: x86
2# Tests to verify that
3#    - the folded CUEs covered up to the last entries, even if they were removed/folded.
4#    - only entries that *should* be in eh_frame are actually included. (**)
5# (**) This is where LD64 does differently.
6
7# RUN: rm -rf %t; split-file %s %t
8# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/fold-tail.s -o %t/fold-tail.o
9# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/cues-range-gap.s -o %t/cues-range-gap.o
10
11# RUN: %lld -o %t/fold-tail.out %t/fold-tail.o
12# RUN: llvm-objdump --macho --syms --unwind-info %t/fold-tail.out | FileCheck %s
13
14# RUN: %lld -o %t/cues-range-gap.out %t/cues-range-gap.o
15
16# CHECK-LABEL: SYMBOL TABLE:
17# CHECK:       [[#%x,A_ADDR:]]  l     F __TEXT,__text _a
18# CHECK:       [[#%x,B_ADDR:]]  l     F __TEXT,__text _b
19# CHECK:       [[#%x,C_ADDR:]]  l     F __TEXT,__text _c
20# CHECK:       [[#%x,D_ADDR:]]  l     F __TEXT,__text _d
21# CHECK:       [[#%x,MAIN_ADDR:]]  g     F __TEXT,__text _main
22
23## Check that [1] offset starts at c's address + 3 (its length).
24# CHECK-LABEL: Contents of __unwind_info section:
25# CHECK:  Top level indices: (count = 2)
26# CHECK-NEXT : [0]: function offset=[[#%#.7x,MAIN_ADDR]]
27# CHECK-NEXT : [1]: function offset=[[#%#.7x,C_ADDR + 3]]
28
29#--- fold-tail.s
30        .text
31        .globl  _main
32        .p2align        4, 0x90
33_main:
34        .cfi_startproc
35        callq   _a
36        retq
37        .cfi_endproc
38
39        .p2align        4, 0x90
40_a:
41        .cfi_startproc
42        callq   _b
43        retq
44        .cfi_endproc
45
46        .p2align        4, 0x90
47_b:
48        .cfi_startproc
49        callq   _c
50        retq
51        .cfi_endproc
52
53        .p2align        4, 0x90
54_c:
55        .cfi_startproc
56        retq
57        .cfi_endproc
58
59// _d should NOT have an entry in .eh_frame
60// So it shouldn't be covered by the unwind table.
61_d:
62        xorl %eax, %eax
63        ret
64
65.subsections_via_symbols
66
67#--- cues-range-gap.s
68        .text
69        .globl  _main
70        .p2align        4, 0x90
71_main:
72        .cfi_startproc
73        callq   _a
74        retq
75        .cfi_endproc
76
77        .p2align        4, 0x90
78_a:
79        .cfi_startproc
80        callq   _b
81        retq
82        .cfi_endproc
83
84// _d is intentionally placed in between the symbols with eh_frame entries.
85// but _d should NOT have an entry in .eh_frame
86// So it shouldn't be covered by the unwind table.
87_d:
88        xorl %eax, %eax
89        ret
90
91        .p2align        4, 0x90
92_b:
93        .cfi_startproc
94        callq   _c
95        retq
96        .cfi_endproc
97
98        .p2align        4, 0x90
99_c:
100        .cfi_startproc
101        retq
102        .cfi_endproc
103
104.subsections_via_symbols
105