[clang-tidy][modernize-use-starts-ends-with] Fix operator rewriting false negative...
[llvm-project.git] / lld / test / ELF / arm-exidx-order.s
blob38adae24ba541bb3484ff463646159a09fb2961e
1 // REQUIRES: arm
2 // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
3 // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %S/Inputs/arm-exidx-cantunwind.s -o %tcantunwind
4 // RUN: ld.lld --no-merge-exidx-entries %t %tcantunwind -o %t2
5 // RUN: llvm-objdump -d --triple=armv7a-none-linux-gnueabi --no-show-raw-insn %t2 | FileCheck %s
6 // RUN: llvm-objdump -s --triple=armv7a-none-linux-gnueabi %t2 | FileCheck --check-prefix=CHECK-EXIDX %s
7 // RUN: llvm-readobj --program-headers --sections %t2 | FileCheck -check-prefix=CHECK-PT %s
8 // Use Linker script to place .ARM.exidx in between .text and orphan sections
9 // RUN: echo "SECTIONS { \
10 // RUN: .text 0x11000 : { *(.text*) } \
11 // RUN: .ARM.exidx : { *(.ARM.exidx) } } " > %t.script
12 // RUN: ld.lld --no-merge-exidx-entries --script %t.script %tcantunwind %t -o %t3
13 // RUN: llvm-objdump -d --triple=armv7a-none-linux-gnueabi %t3 | FileCheck --check-prefix=CHECK-SCRIPT %s
14 // RUN: llvm-objdump -s --triple=armv7a-none-linux-gnueabi %t3 | FileCheck --check-prefix=CHECK-SCRIPT-EXIDX %s
16 /// Each assembler created .ARM.exidx section has the SHF_LINK_ORDER flag set
17 /// with the sh_link containing the section index of the executable section
18 /// containing the function it describes. The linker must combine the .ARM.exidx
19 /// InputSections in the same order that it has combined the executable section,
20 /// such that the combined .ARM.exidx OutputSection can be used as a binary
21 /// search table.
23 .syntax unified
24 .section .text, "ax",%progbits
25 .globl _start
26 _start:
27 .fnstart
28 bx lr
29 .cantunwind
30 .fnend
32 .section .text.f1, "ax", %progbits
33 .globl f1
34 f1:
35 .fnstart
36 bx lr
37 .cantunwind
38 .fnend
40 .section .text.f2, "ax", %progbits
41 .globl f2
42 f2:
43 .fnstart
44 bx lr
45 .cantunwind
46 .fnend
47 .globl f3
48 f3:
49 .fnstart
50 bx lr
51 .cantunwind
52 .fnend
54 /// Check default no linker script order.
56 // CHECK: Disassembly of section .text:
57 // CHECK-EMPTY:
58 // CHECK: <_start>:
59 // CHECK-NEXT: 20124: bx lr
60 // CHECK: <f1>:
61 // CHECK-NEXT: 20128: bx lr
62 // CHECK: <f2>:
63 // CHECK-NEXT: 2012c: bx lr
64 // CHECK: <f3>:
65 // CHECK-NEXT: 20130: bx lr
66 // CHECK: <func4>:
67 // CHECK-NEXT: 20134: bx lr
68 // CHECK: <func5>:
69 // CHECK-NEXT: 20138: bx lr
70 // CHECK: Disassembly of section .func1:
71 // CHECK-EMPTY:
72 // CHECK-NEXT: <func1>:
73 // CHECK-NEXT: 2013c: bx lr
74 // CHECK: Disassembly of section .func2:
75 // CHECK-EMPTY:
76 // CHECK-NEXT: <func2>:
77 // CHECK-NEXT: 20140: bx lr
78 // CHECK: Disassembly of section .func3:
79 // CHECK-EMPTY:
80 // CHECK-NEXT: <func3>:
81 // CHECK-NEXT: 20144: bx lr
83 /// Each .ARM.exidx section has two 4 byte fields
84 /// Field 1 is the 31-bit offset to the function. The top bit is used to
85 /// indicate whether Field 2 is a pointer or an inline table entry.
86 /// Field 2 is either a pointer to a .ARM.extab section or an inline table
87 /// In this example all Field 2 entries are inline can't unwind (0x1)
88 /// We expect to see the entries in the same order as the functions
90 // CHECK-EXIDX: Contents of section .ARM.exidx:
91 /// 100d4 + 1050 = 11124 = _start
92 /// 100dc + 104c = 11128 = f1
93 // CHECK-EXIDX-NEXT: 100d4 50000100 01000000 4c000100 01000000
94 /// 100e4 + 1048 = 1112c = f2
95 /// 100ec + 1044 = 11130 = f3
96 // CHECK-EXIDX-NEXT: 100e4 48000100 01000000 44000100 01000000
97 /// 100f4 + 1040 = 11134 = func4
98 /// 100fc + 103c = 11138 = func5
99 // CHECK-EXIDX-NEXT: 100f4 40000100 01000000 3c000100 01000000
100 /// 10104 + 1038 = 1113c = func1
101 /// 1010c + 1034 = 11140 = func2
102 // CHECK-EXIDX-NEXT: 10104 38000100 01000000 34000100 01000000
103 /// 10114 + 1030 = 11144 = func3
104 // CHECK-EXIDX-NEXT: 10114 30000100 01000000
106 /// Check that PT_ARM_EXIDX program header has been generated that describes
107 /// the .ARM.exidx output section
108 // CHECK-PT: Name: .ARM.exidx
109 // CHECK-PT-NEXT: Type: SHT_ARM_EXIDX (0x70000001)
110 // CHECK-PT-NEXT: Flags [
111 // CHECK-PT-NEXT: SHF_ALLOC
112 // CHECK-PT-NEXT: SHF_LINK_ORDER
113 // CHECK-PT-NEXT: ]
114 // CHECK-PT-NEXT: Address: 0x100D4
115 // CHECK-PT-NEXT: Offset: 0xD4
116 // CHECK-PT-NEXT: Size: 80
118 // CHECK-PT: Type: PT_ARM_EXIDX (0x70000001)
119 // CHECK-PT-NEXT: Offset: 0xD4
120 // CHECK-PT-NEXT: VirtualAddress: 0x100D4
121 // CHECK-PT-NEXT: PhysicalAddress: 0x100D4
122 // CHECK-PT-NEXT: FileSize: 80
123 // CHECK-PT-NEXT: MemSize: 80
124 // CHECK-PT-NEXT: Flags [ (0x4)
125 // CHECK-PT-NEXT: PF_R (0x4)
126 // CHECK-PT-NEXT: ]
127 // CHECK-PT-NEXT: Alignment: 4
128 // CHECK-PT-NEXT: }
131 /// Check linker script order. The .ARM.exidx section will be inserted after
132 /// the .text section but before the orphan sections
134 // CHECK-SCRIPT: Disassembly of section .text:
135 // CHECK-SCRIPT-EMPTY:
136 // CHECK-SCRIPT-NEXT: <func4>:
137 // CHECK-SCRIPT-NEXT: 11000: e12fff1e bx lr
138 // CHECK-SCRIPT: <func5>:
139 // CHECK-SCRIPT-NEXT: 11004: e12fff1e bx lr
140 // CHECK-SCRIPT: <_start>:
141 // CHECK-SCRIPT-NEXT: 11008: e12fff1e bx lr
142 // CHECK-SCRIPT: <f1>:
143 // CHECK-SCRIPT-NEXT: 1100c: e12fff1e bx lr
144 // CHECK-SCRIPT: <f2>:
145 // CHECK-SCRIPT-NEXT: 11010: e12fff1e bx lr
146 // CHECK-SCRIPT: <f3>:
147 // CHECK-SCRIPT-NEXT: 11014: e12fff1e bx lr
148 // CHECK-SCRIPT-EMPTY:
149 // CHECK-SCRIPT-NEXT: Disassembly of section .func1:
150 // CHECK-SCRIPT-EMPTY:
151 // CHECK-SCRIPT-NEXT: <func1>:
152 // CHECK-SCRIPT-NEXT: 11018: e12fff1e bx lr
153 // CHECK-SCRIPT-EMPTY:
154 // CHECK-SCRIPT-NEXT: Disassembly of section .func2:
155 // CHECK-SCRIPT-EMPTY:
156 // CHECK-SCRIPT-NEXT: <func2>:
157 // CHECK-SCRIPT-NEXT: 1101c: e12fff1e bx lr
158 // CHECK-SCRIPT-EMPTY:
159 // CHECK-SCRIPT-NEXT: Disassembly of section .func3:
160 // CHECK-SCRIPT-EMPTY:
161 // CHECK-SCRIPT-NEXT: <func3>:
162 // CHECK-SCRIPT-NEXT: 11020: e12fff1e bx lr
164 /// Check that the .ARM.exidx section is sorted in order as the functions
165 /// The offset in field 1, is 32-bit so in the binary the most significant bit
166 /// 11024 - 24 = 11000 func4
167 /// 1102c - 28 = 11004 func5
168 // CHECK-SCRIPT-EXIDX: 11024 dcffff7f 01000000 d8ffff7f 01000000
169 /// 11034 - 2c = 11008 _start
170 /// 1103c - 30 = 1100c f1
171 // CHECK-SCRIPT-EXIDX-NEXT: 11034 d4ffff7f 01000000 d0ffff7f 01000000
172 /// 11044 - 34 = 11010 f2
173 /// 1104c - 38 = 11014 f3
174 // CHECK-SCRIPT-EXIDX-NEXT: 11044 ccffff7f 01000000 c8ffff7f 01000000
175 /// 11054 - 3c = 11018 func1
176 /// 1105c - 40 = 1101c func2
177 // CHECK-SCRIPT-EXIDX-NEXT: 11054 c4ffff7f 01000000 c0ffff7f 01000000
178 /// 11064 - 44 = 11020 func3
179 /// 11068 - 48 = 11024 func3 + sizeof(func3)
180 // CHECK-SCRIPT-EXIDX-NEXT: 11064 bcffff7f 01000000 b8ffff7f 01000000