1 ## Tests that lld-macho can handle the case where personality symbols with the same name
2 ## are both from a dylib and locally defined in an object file.
5 # RUN: rm -rf %t; split-file %s %t
6 # RUN: llvm-mc -emit-compact-unwind-non-canonical=true -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/user_2.s -o %t/user_2.o
7 # RUN: llvm-mc -emit-compact-unwind-non-canonical=true -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/user_3.s -o %t/user_3.o
9 ## Test case for linking 3+ personaltiies (all globals) without crashing because all the non-canonical are DWARFs
10 # RUN: llvm-mc -emit-compact-unwind-non-canonical=false -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/user_4.s -o %t/user_4.o
12 # RUN: yaml2obj %t/combined.yaml > %t/combined.o
14 ## Pre-condition: check that ___gxx_personality_v0 really is locally defined in combined.o before we proceed.
15 # RUN: llvm-nm %t/combined.o | grep '___gxx_personality_v0' | FileCheck %s --check-prefix=PRECHECK
16 # PRECHECK: {{.*}} t ___gxx_personality_v0
17 # PRECHECK-NOT: {{.*}} U ___gxx_personality_v0
18 # PRECHECK-NOT: {{.*}} T ___gxx_personality_v0
20 ## check that we can link with 4 personalities without crashing:
21 ## ___gxx_personality_v0 (libc++.tbd), ___gxx_personality_v0(local), _personality_1, and _personality_2
22 # RUN: %lld -lSystem -lc++ %t/user_2.o %t/combined.o -o %t/a.out
23 ## ___gxx_personality_v0 (global), ___gxx_personality_v0(libc++.tbd), _personality_1, and _personality_2
24 # RUN: %lld -lSystem -lc++ %t/user_3.o %t/user_2.o -o %t/b.out
25 ## ___gxx_personality_v0 (global), ___gxx_personality_v0(local), _personality_1, and _personality_2
26 # RUN: %lld -lSystem -dylib %t/user_3.o %t/combined.o %t/user_2.o -o %t/c.out
28 ## check that we can link with 3+ personalities without crashing because
29 ## non-canonical personalities are dwarf.
30 ## This has ___gxx_personality_v0(global), ___gxx_personality_v0(local), and _personality_{1,2,3,4}
31 ## Only the ___gxx_personality_v0(global) should have compact-unwind. The rest should have DWARFs.
32 # RUN: %lld -lSystem -lc++ %t/user_4.o %t/combined.o -o %t/d.out
35 # RUN: llvm-nm %t/a.out | FileCheck %s --check-prefix=POSTCHECK
36 # POSTCHECK: {{.*}} U ___gxx_personality_v0
37 # POSTCHECK: {{.*}} t ___gxx_personality_v0
39 # RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --bind %t/a.out | FileCheck %s --check-prefixes=A,CHECK -D#%x,OFF=0x100000000
40 # RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --bind %t/b.out | FileCheck %s --check-prefixes=BC,CHECK -D#%x,OFF=0x100000000
41 # RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --bind %t/c.out | FileCheck %s --check-prefixes=BC,C,CHECK -D#%x,OFF=0
43 # RUN: llvm-objdump --macho --indirect-symbols --unwind-info --bind %t/d.out | FileCheck %s --check-prefixes=D -D#%x,OFF=0x100000000
45 # A: Indirect symbols for (__DATA_CONST,__got)
46 # A-NEXT: address index name
47 # A: 0x[[#%x,GXX_PERSONALITY_LO:]] [[#]] ___gxx_personality_v0
48 # A: 0x[[#%x,GXX_PERSONALITY_HI:]] [[#]] ___gxx_personality_v0
49 # A: 0x[[#%x,PERSONALITY_1:]] LOCAL
50 # A: 0x[[#%x,PERSONALITY_2:]] LOCAL
52 # BC: Indirect symbols for (__DATA_CONST,__got)
53 # BC-NEXT: address index name
54 # C: 0x[[#%x,GXX_PERSONALITY_HI:]] LOCAL
55 # BC: 0x[[#%x,GXX_PERSONALITY_LO:]] LOCAL
56 # BC: 0x[[#%x,PERSONALITY_1:]] LOCAL
57 # BC: 0x[[#%x,PERSONALITY_2:]] LOCAL
59 # CHECK: Personality functions: (count = 3)
60 # CHECK-DAG: personality[{{[0-9]+}}]: 0x{{0*}}[[#GXX_PERSONALITY_LO-OFF]]
61 # CHECK-DAG: personality[{{[0-9]+}}]: 0x{{0*}}[[#PERSONALITY_1-OFF]]
62 # CHECK-DAG: personality[{{[0-9]+}}]: 0x{{0*}}[[#PERSONALITY_2-OFF]]
65 # A-NEXT: segment section address type addend dylib symbol
66 # A-NEXT: __DATA_CONST __got 0x[[#GXX_PERSONALITY_LO-0]] pointer 0 libc++abi ___gxx_personality_v0
69 # D: Indirect symbols for (__DATA_CONST,__got)
70 # D-NEXT: address index name
71 # D: 0x[[#%x,GXX_PERSONALITY_HI:]] [[#]] ___gxx_personality_v0
72 # D: 0x[[#%x,PERSONALITY_1:]] [[#]] _personality_1
73 # D: 0x[[#%x,PERSONALITY_2:]] [[#]] _personality_2
74 # D: 0x[[#%x,PERSONALITY_3:]] [[#]] _personality_3
75 # D: 0x[[#%x,PERSONALITY_4:]] [[#]] _personality_4
76 # D: 0x[[#%x,GXX_PERSONALITY_LO:]] [[#]] ___gxx_personality_v0
78 # D: Contents of __unwind_info section:
79 # D: Personality functions: (count = 1)
80 personality
[1]: 0x
{{0*}}[[#GXX_PERSONALITY_HI-OFF]]
83 # D: segment section address type addend dylib symbol
84 # D: __DATA_CONST __got 0x[[#GXX_PERSONALITY_HI-0]] pointer 0 libc++abi ___gxx_personality_v0
88 ## Check that dylib symbols are picked (which means without libc++, we'd get an undefined symbol error.
89 # RUN: not %lld -lSystem %t/user_2.o %t/combined.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERRORCHECK
90 # ERRORCHECK: {{.*}} undefined symbol: ___gxx_personality_v0
93 .globl _main, _personality_1, _personality_2, _personality_3, _personality_4
99 .cfi_personality 155, _personality_1
100 .cfi_def_cfa_offset 16
106 .cfi_personality 155, _personality_2
107 .cfi_def_cfa_offset 16
113 .cfi_personality 155, _personality_3
114 .cfi_def_cfa_offset 16
121 .cfi_personality 155, _personality_4
122 .cfi_def_cfa_offset 16
128 .cfi_personality 155, ___gxx_personality_v0
129 .cfi_def_cfa_offset 16
144 .private_extern ___gxx_personality_v0
149 .cfi_personality 155, ___gxx_personality_v0
150 .cfi_def_cfa_offset 16
155 .no_dead_strip ___gxx_personality_v0
156 ___gxx_personality_v0
:
159 .subsections_via_symbols
163 .globl _main, _personality_1, _personality_2
169 .cfi_personality 155, _personality_1
170 .cfi_def_cfa_offset 16
176 .cfi_personality 155, _personality_2
177 .cfi_def_cfa_offset 16
183 .cfi_personality 155, ___gxx_personality_v0
184 .cfi_def_cfa_offset 16
193 ## This yaml was created from the combined.o object file described in this comment:
194 ## https://reviews.llvm.org/D107533#2935217
232 - sectname
: __eh_frame
244 content
: 1400000000000000017A520001781001100C0708900100001800000000000000017A505200017810069B04000000100C070890011800000004000000F8FFFFFFFFFFFFFF0100000000000000000E1000
286 - sectname
: __compact_unwind
298 content
: '00000000000000000100000000000202000000000000000000000000000000000000000000000000010000000000020200000000000000000000000000000000'
330 - cmd
: LC_BUILD_VERSION
339 - cmd
: LC_DATA_IN_CODE
373 - ___gxx_personality_v0