summaryrefslogtreecommitdiff
path: root/test/ELF/arm-exidx-dedup.s
blob: 1648f77152e97f67b99a23976d12216dcb1ef2e5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
// RUN: ld.lld %t --no-merge-exidx-entries -o %t2
// RUN: llvm-objdump -s %t2 | FileCheck --check-prefix CHECK-DUPS %s
// RUN: ld.lld %t -o %t3
// RUN: llvm-objdump -s %t3 | FileCheck %s
// REQUIRES: arm
// Test that lld can at least remove duplicate .ARM.exidx sections. A more
// fine grained implementation will be able to remove duplicate entries within
// a .ARM.exidx section.

// With duplicate entries
// CHECK-DUPS: Contents of section .ARM.exidx:
// CHECK-DUPS-NEXT:  100d4 2c0f0000 01000000 280f0000 01000000
// CHECK-DUPS-NEXT:  100e4 240f0000 01000000 200f0000 01000000
// CHECK-DUPS-NEXT:  100f4 1c0f0000 08849780 180f0000 08849780
// CHECK-DUPS-NEXT:  10104 140f0000 08849780 100f0000 14000000
// CHECK-DUPS-NEXT:  10114 0c0f0000 18000000 080f0000 01000000
// CHECK-DUPS-NEXT: Contents of section .ARM.extab:

// After duplicate entry removal
// CHECK: Contents of section .ARM.exidx:
// CHECK-NEXT:  100d4 2c0f0000 01000000 340f0000 08849780
// CHECK-NEXT:  100e4 380f0000 14000000 340f0000 18000000
// CHECK-NEXT:  100f4 300f0000 01000000
// CHECK-NEXT: Contents of section .ARM.extab:
        .syntax unified

        // Expect 1 EXIDX_CANTUNWIND entry.
        .section .text.00, "ax", %progbits
        .globl _start
_start:
        .fnstart
        bx lr
        .cantunwind
        .fnend

        // Expect .ARM.exidx.text.01 to be identical to .ARM.exidx.text.00
        .section .text.01, "ax", %progbits
        .globl f1
f1:
        .fnstart
        bx lr
        .cantunwind
        .fnend

        // Expect 2 EXIDX_CANTUNWIND entries, these can be duplicated into
        // .ARM.exid.text.00
        .section .text.02, "ax", %progbits
        .globl f2
f2:
        .fnstart
        bx lr
        .cantunwind
        .fnend

        .globl f3
f3:
        .fnstart
        bx lr
        .cantunwind
        .fnend

        // Expect inline unwind instructions, not a duplicate of previous entry.
        .section .text.03, "ax", %progbits
        .global f4
f4:
        .fnstart
        bx lr
        .save {r7, lr}
        .setfp r7, sp, #0
        .fnend

        // Expect 2 inline unwind entries that are a duplicate of
        // .ARM.exidx.text.03
        .section .text.04, "ax", %progbits
        .global f5
f5:
        .fnstart
        bx lr
        .save {r7, lr}
        .setfp r7, sp, #0
        .fnend

        .global f6
f6:
        .fnstart
        bx lr
        .save {r7, lr}
        .setfp r7, sp, #0
        .fnend

        // Expect a section with a reference to an .ARM.extab. Not a duplicate
        // of previous inline table entry.
        .section .text.05, "ax",%progbits
        .global f7
f7:
        .fnstart
        bx lr
        .personality __gxx_personality_v0
        .handlerdata
        .long 0
        .fnend

        // Expect a reference to an identical .ARM.extab. We do not try to
        // deduplicate references to .ARM.extab sections.
        .section .text.06, "ax",%progbits
        .global f8
f8:
        .fnstart
        bx lr
        .personality __gxx_personality_v0
        .handlerdata
        .long 0
        .fnend

 // Dummy implementation of personality routines to satisfy reference from
 // exception tables
        .section .text.__gcc_personality_v0, "ax", %progbits
        .global __gxx_personality_v0
__gxx_personality_v0:
        bx lr

        .section .text.__aeabi_unwind_cpp_pr0, "ax", %progbits
        .global __aeabi_unwind_cpp_pr0
__aeabi_unwind_cpp_pr0:
        bx lr