]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/ELF/arm-exidx-gc.s
Vendor import of lld trunk r338150:
[FreeBSD/FreeBSD.git] / test / ELF / arm-exidx-gc.s
1 // REQUIRES: arm
2 // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
3 // RUN: ld.lld %t --no-merge-exidx-entries -o %t2 --gc-sections 2>&1
4 // RUN: llvm-objdump -d -triple=armv7a-none-linux-gnueabi %t2 | FileCheck %s
5 // RUN: llvm-objdump -s -triple=armv7a-none-linux-gnueabi %t2 | FileCheck -check-prefix=CHECK-EXIDX %s
6
7 // Test the behavior of .ARM.exidx sections under garbage collection
8 // A .ARM.exidx section is live if it has a relocation to a live executable
9 // section.
10 // A .ARM.exidx section may have a relocation to a .ARM.extab section, if the
11 // .ARM.exidx is live then the .ARM.extab section is live
12
13  .syntax unified
14  .section .text.func1, "ax",%progbits
15  .global func1
16 func1:
17  .fnstart
18  bx lr
19  .save {r7, lr}
20  .setfp r7, sp, #0
21  .fnend
22
23  .section .text.unusedfunc1, "ax",%progbits
24  .global unusedfunc1
25 unusedfunc1:
26  .fnstart
27  bx lr
28  .cantunwind
29  .fnend
30
31  // Unwinding instructions for .text2 too large for an inline entry ARM.exidx
32  // entry. A separate .ARM.extab section is created to hold the unwind entries
33  // The .ARM.exidx table entry has a reference to the .ARM.extab section.
34  .section .text.func2, "ax",%progbits
35  .global func2
36 func2:
37  .fnstart
38  bx lr
39  .personality __gxx_personality_v0
40  .handlerdata
41  .section .text.func2
42  .fnend
43
44  // An unused function with a reference to a .ARM.extab section. Both should
45  // be removed by gc.
46  .section .text.unusedfunc2, "ax",%progbits
47  .global unusedfunc2
48 unusedfunc2:
49  .fnstart
50  bx lr
51  .personality __gxx_personality_v1
52  .handlerdata
53  .section .text.unusedfunc2
54  .fnend
55
56  // Dummy implementation of personality routines to satisfy reference from
57  // exception tables
58  .section .text.__gcc_personality_v0, "ax", %progbits
59  .global __gxx_personality_v0
60 __gxx_personality_v0:
61  .fnstart
62  bx lr
63  .cantunwind
64  .fnend
65
66  .section .text.__gcc_personality_v1, "ax", %progbits
67  .global __gxx_personality_v1
68 __gxx_personality_v1:
69  .fnstart
70  bx lr
71  .cantunwind
72  .fnend
73
74  .section .text.__aeabi_unwind_cpp_pr0, "ax", %progbits
75  .global __aeabi_unwind_cpp_pr0
76 __aeabi_unwind_cpp_pr0:
77  .fnstart
78  bx lr
79  .cantunwind
80  .fnend
81
82 // Entry point for GC
83  .text
84  .global _start
85 _start:
86  bl func1
87  bl func2
88  bx lr
89
90 // GC should have only removed unusedfunc1 and unusedfunc2 the personality
91 // routines are kept alive by references from live .ARM.exidx and .ARM.extab
92 // sections
93 // CHECK: Disassembly of section .text:
94 // CHECK-NEXT: _start:
95 // CHECK-NEXT:   11000:       01 00 00 eb     bl      #4 <func1>
96 // CHECK-NEXT:   11004:       01 00 00 eb     bl      #4 <func2>
97 // CHECK-NEXT:   11008:       1e ff 2f e1     bx      lr
98 // CHECK: func1:
99 // CHECK-NEXT:   1100c:       1e ff 2f e1     bx      lr
100 // CHECK: func2:
101 // CHECK-NEXT:   11010:       1e ff 2f e1     bx      lr
102 // CHECK: __gxx_personality_v0:
103 // CHECK-NEXT:   11014:       1e ff 2f e1     bx      lr
104 // CHECK: __aeabi_unwind_cpp_pr0:
105 // CHECK-NEXT:   11018:       1e ff 2f e1     bx      lr
106
107 // GC should have removed table entries for unusedfunc1, unusedfunc2
108 // and __gxx_personality_v1
109 // CHECK-NOT: unusedfunc1
110 // CHECK-NOT: unusedfunc2
111 // CHECK-NOT: __gxx_personality_v1
112
113 // CHECK-EXIDX: Contents of section .ARM.exidx:
114 // 100d4 + f38 = 1100c = func1
115 // 100dc + f34 = 11010 = func2 (100e0 + 1c = 100fc = .ARM.extab)
116 // CHECK-EXIDX-NEXT: 100d4 380f0000 08849780 340f0000 1c000000
117 // 100e4 + f30 = 11014 = __gxx_personality_v0
118 // 100ec + f2c = 11018 = __aeabi_unwind_cpp_pr0
119 // CHECK-EXIDX-NEXT: 100e4 300f0000 01000000 2c0f0000 01000000
120 // 100f4 + f28 = 1101c = __aeabi_unwind_cpp_pr0 + sizeof(__aeabi_unwind_cpp_pr0)
121 // CHECK-EXIDX-NEXT: 100f4 280f0000 01000000
122 // CHECK-EXIDX-NEXT: Contents of section .ARM.extab:
123 // 100fc + f18 = 11014 = __gxx_personality_v0
124 // CHECK-EXIDX-NEXT: 100fc 180f0000 b0b0b000