File: arm-exidx-gc.s

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (126 lines) | stat: -rw-r--r-- 3,787 bytes parent folder | download | duplicates (21)
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
// REQUIRES: arm
// RUN: llvm-mc -filetype=obj --arm-add-build-attributes -triple=armv7a-none-linux-gnueabi %s -o %t
// RUN: ld.lld %t --no-merge-exidx-entries -o %t2 --gc-sections
// RUN: llvm-objdump -d --triple=armv7a-none-linux-gnueabi --no-show-raw-insn %t2 | FileCheck %s
// RUN: llvm-objdump -s --triple=armv7a-none-linux-gnueabi %t2 | FileCheck --check-prefix=CHECK-EXIDX %s

/// Test the behavior of .ARM.exidx sections under garbage collection
/// A .ARM.exidx section is live if it has a relocation to a live executable
/// section.
/// A .ARM.exidx section may have a relocation to a .ARM.extab section, if the
/// .ARM.exidx is live then the .ARM.extab section is live

 .syntax unified
 .section .text.func1, "ax",%progbits
 .global func1
func1:
 .fnstart
 bx lr
 .save {r7, lr}
 .setfp r7, sp, #0
 .fnend

 .section .text.unusedfunc1, "ax",%progbits
 .global unusedfunc1
unusedfunc1:
 .fnstart
 bx lr
 .cantunwind
 .fnend

 /// Unwinding instructions for .text2 too large for an inline entry ARM.exidx
 /// entry. A separate .ARM.extab section is created to hold the unwind entries
 /// The .ARM.exidx table entry has a reference to the .ARM.extab section.
 .section .text.func2, "ax",%progbits
 .global func2
func2:
 .fnstart
 bx lr
 .personality __gxx_personality_v0
 .handlerdata
 .section .text.func2
 .fnend

 /// An unused function with a reference to a .ARM.extab section. Both should
 /// be removed by gc.
 .section .text.unusedfunc2, "ax",%progbits
 .global unusedfunc2
unusedfunc2:
 .fnstart
 bx lr
 .personality __gxx_personality_v1
 .handlerdata
 .section .text.unusedfunc2
 .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:
 .fnstart
 bx lr
 .cantunwind
 .fnend

 .section .text.__gcc_personality_v1, "ax", %progbits
 .global __gxx_personality_v1
__gxx_personality_v1:
 .fnstart
 bx lr
 .cantunwind
 .fnend

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

// Entry point for GC
 .text
 .global _start
_start:
 bl func1
 bl func2
 bx lr

/// GC should have only removed unusedfunc1 and unusedfunc2 the personality
/// routines are kept alive by references from live .ARM.exidx and .ARM.extab
/// sections
// CHECK: Disassembly of section .text:
// CHECK-EMPTY:
// CHECK-NEXT: <_start>:
// CHECK-NEXT:   2010c:       bl      0x20118 <func1>
// CHECK-NEXT:   20110:       bl      0x2011c <func2>
// CHECK-NEXT:   20114:       bx      lr
// CHECK: <func1>:
// CHECK-NEXT:   20118:       bx      lr
// CHECK: <func2>:
// CHECK-NEXT:   2011c:       bx      lr
// CHECK: <__gxx_personality_v0>:
// CHECK-NEXT:   20120:       bx      lr
// CHECK: <__aeabi_unwind_cpp_pr0>:
// CHECK-NEXT:   20124:       bx      lr

/// GC should have removed table entries for unusedfunc1, unusedfunc2
/// and __gxx_personality_v1
// CHECK-NOT: unusedfunc1
// CHECK-NOT: unusedfunc2
// CHECK-NOT: __gxx_personality_v1

/// CHECK-EXIDX: Contents of section .ARM.exidx:
/// 100d4 + 1038 = 1110c = _start
/// 100dc + 103c = 11118 = func1
// CHECK-EXIDX-NEXT: 100d4 38000100 01000000 3c000100 08849780
/// 100e4 + 1038 = 1111c = func2 (100e8 + 1c = 10104 = .ARM.extab)
/// 100ec + 1034 = 11120 = __gxx_personality_v0
// CHECK-EXIDX-NEXT: 100e4 38000100 1c000000 34000100 01000000
/// 100f4 + 1030 = 11018 = __aeabi_unwind_cpp_pr0
/// 100fc + 102c = 1101c = __aeabi_unwind_cpp_pr0 + sizeof(__aeabi_unwind_cpp_pr0)
// CHECK-EXIDX-NEXT: 100f4 30000100 01000000 2c000100 01000000
// CHECK-EXIDX-NEXT: Contents of section .ARM.extab:
/// 10104 + 101c = 11120 = __gxx_personality_v0
// CHECK-EXIDX-NEXT: 10104 1c000100 b0b0b000