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
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
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
14 .section .text.func1, "ax",%progbits
23 .section .text.unusedfunc1, "ax",%progbits
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
39 .personality __gxx_personality_v0
44 // An unused function with a reference to a .ARM.extab section. Both should
46 .section .text.unusedfunc2, "ax",%progbits
51 .personality __gxx_personality_v1
53 .section .text.unusedfunc2
56 // Dummy implementation of personality routines to satisfy reference from
58 .section .text.__gcc_personality_v0, "ax", %progbits
59 .global __gxx_personality_v0
66 .section .text.__gcc_personality_v1, "ax", %progbits
67 .global __gxx_personality_v1
74 .section .text.__aeabi_unwind_cpp_pr0, "ax", %progbits
75 .global __aeabi_unwind_cpp_pr0
76 __aeabi_unwind_cpp_pr0:
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
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
99 // CHECK-NEXT: 1100c: 1e ff 2f e1 bx lr
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
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
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