2 // RUN
: rm
-rf
%t && split-file
%s
%t
4 // RUN
: llvm-mc
-filetype
=obj
-triple
=armv7a-none-linux-gnueabi
--arm-add-build-attributes
%t/a.s
-o
%t/a.o
5 // RUN
: ld.lld
%t/a.o
-T %t/exidx-non-zero-offset.
t -o
%t/non-zero
6 // RUN
: llvm-readelf
--program-headers
--unwind
--symbols
-x
.exceptions %t/non-zero | FileCheck %s
7 // RUN
: ld.lld
%t/a.o
-T %t/exidx-zero-offset.
t -o
%t/zero
8 // RUN
: llvm-readelf
--program-headers
--unwind
--symbols
-x
.exceptions %t/zero | FileCheck %s
10 /// On platforms that load ELF files directly the ARM.exidx sections
11 /// are located with the PT_ARM_EXIDX program header. This requires
12 /// all
.ARM.exidx input sections to be placed in a single
13 /// .ARM.exidx output section. Embedded systems that do not load
14 /// from an ELF file use the linker defined symbols __exidx_start
and
15 /// __exidx_stop. There is no requirement to place the
.ARM.exidx
16 /// input sections in their own output section. This test case checks
17 /// that
a .ARM.exidx synthetic section that isn't at a zero offset
18 /// within the output section gets the correct offsets. We check
19 /// this by checking that equal amounts of alignment padding
20 /// inserted before and after the section start produce the same
23 /// For the two linker scripts, one with the .ARM.exidx table
24 /// at a zero offset within its output section and one with a
25 /// non-zero offset, but both at the same file and address;
26 /// the PT_ARM_EXIDX, symbols and table contents should be the
28 // CHECK: EXIDX 0x010080 0x00000080 0x00000080 0x00028 0x00028 R 0x4
30 /// unwind entries starting from the right address are identical.
31 /// llvm-readelf does not seem to be able to detect Thumb functionNames
32 /// whereas arm-none-eabi-readelf can. Used CHECK rather than CHECK-NEXT
33 /// to cope with possible improvements llvm-readelf.
34 // CHECK: FunctionAddress: 0x0
35 // CHECK-NEXT: FunctionName: f1
36 // CHECK-NEXT: Model: Compact (Inline)
37 // CHECK-NEXT: PersonalityIndex: 0
38 // CHECK-NEXT: Opcodes [
39 // CHECK-NEXT: 0x97 ; vsp = r7
40 // CHECK-NEXT: 0x84 0x08 ; pop {r7, lr}
43 // CHECK-NEXT: Entry {
44 // CHECK-NEXT: FunctionAddress: 0x8
45 // CHECK-NEXT: FunctionName: f2
46 // CHECK-NEXT: Model: CantUnwind
48 // CHECK-NEXT: Entry {
49 // CHECK-NEXT: FunctionAddress: 0xE
50 // CHECK: ExceptionHandlingTable: .ARM.extab
51 // CHECK-NEXT: TableEntryAddress: 0xA8
52 // CHECK-NEXT: Model: Generic
53 // CHECK-NEXT: PersonalityRoutineAddress: 0x12
55 // CHECK-NEXT: Entry {
56 // CHECK-NEXT: FunctionAddress: 0x10
57 // CHECK: Model: CantUnwind
59 // CHECK-NEXT: Entry {
60 // CHECK-NEXT: FunctionAddress: 0x14
61 // CHECK-NEXT: FunctionName: __ARMv7ABSLongThunk_f3
62 // CHECK-NEXT: Model: CantUnwind
65 // CHECK: {{[0-9]+}}: 00000080 {{.*}} __exidx_start
66 // CHECK-NEXT: {{[0-9]+}}: 000000a8 {{.*}} __exidx_end
68 // CHECK: 0x00000080 80ffff7f 08849780 80ffff7f 01000000
69 // CHECK-NEXT: 0x00000090 7effff7f 14000000 78ffff7f 01000000
70 // CHECK-NEXT: 0x000000a0 74ffff7f 01000000
72 //--- exidx-non-zero-offset.t
74 .text : { *(.text .text.*) }
75 /* Addition of thunk in .text changes alignment padding */
77 /* Alignment padding within .exceptions */
79 /* Embedded C libraries find exceptions via linker defined
85 .ARM.extab : { *(.ARM.extab .ARM.extab.*) }
88 //--- exidx-zero-offset.t
90 .text : { *(.text .text.*) }
91 /* Addition of thunk in .text changes alignment padding */
92 /* alignment padding before .exceptions starts */
93 .exceptions : ALIGN(128) {
94 /* Embedded C libraries find exceptions via linker defined
100 .ARM.extab : { *(.ARM.extab .ARM.extab.*) }
106 /// Expect inline unwind instructions.
107 .section .text.01, "ax", %progbits
114 /// provoke an interworking thunk.
121 /// Expect no unwind information from assembler. The linker must
122 /// synthesise an EXIDX_CANTUNWIND entry to prevent an exception
123 /// thrown through f2 from matching against the unwind instructions
125 .section .text.02, "ax", %progbits
132 /// Expect 1 EXIDX_CANTUNWIND entry that can be merged into the linker
133 /// generated EXIDX_CANTUNWIND as if the assembler had generated it.
134 .section .text.03, "ax",%progbits
145 /// Expect a section with a reference to an .ARM.extab.
146 .section .text.04, "ax",%progbits
153 .personality __gxx_personality_v0
159 /// Dummy implementation of personality routines to satisfy reference
160 /// from exception tables, linker will generate EXIDX_CANTUNWIND.
161 .section .text.__aeabi_unwind_cpp_pr0, "ax", %progbits
162 .global __aeabi_unwind_cpp_pr0
163 .type __aeabi_unwind_cpp_pr0, %function
165 __aeabi_unwind_cpp_pr0:
168 .section .text.__gcc_personality_v0, "ax", %progbits
169 .global __gxx_personality_v0
170 .type __gcc_personality_v0, %function
172 __gxx_personality_v0: