1// REQUIRES: arm
2// RUN: llvm-mc -filetype=obj --arm-add-build-attributes -triple=armv7a-none-linux-gnueabi %s -o %t
3// RUN: ld.lld %t -o %t2
4// RUN: llvm-objdump -d --triple=armv7a-none-linux-gnueabi --no-show-raw-insn %t2 | FileCheck %s
5// RUN: llvm-objdump -s --triple=armv7a-none-linux-gnueabi %t2 | FileCheck --check-prefix=CHECK-EXIDX %s
6// RUN: llvm-readobj --program-headers --sections %t2 | FileCheck -check-prefix=CHECK-PT %s
7
8// Test that inline unwinding table entries and references to .ARM.extab
9// entries survive the re-ordering of the .ARM.exidx section
10
11 .syntax unified
12 // Will produce an ARM.exidx entry with inline unwinding instructions
13 .section .text.func1, "ax",%progbits
14 .global func1
15func1:
16 .fnstart
17 bx lr
18 .save {r7, lr}
19 .setfp r7, sp, #0
20 .fnend
21
22 // Unwinding instructions for .text2 too large for an inline entry ARM.exidx
23 // entry. A separate .ARM.extab section is created to hold the unwind entries
24 // The .ARM.exidx table entry has a reference to the .ARM.extab section.
25 .section .text.func2, "ax",%progbits
26 .global func2
27func2:
28 .fnstart
29 bx lr
30 .personality __gxx_personality_v0
31 .handlerdata
32 .long 0
33 .section .text.func2
34 .fnend
35
36 // Dummy implementation of personality routines to satisfy reference from
37 // exception tables
38 .section .text.__gcc_personality_v0, "ax", %progbits
39 .global __gxx_personality_v0
40__gxx_personality_v0:
41 bx lr
42
43 .section .text.__aeabi_unwind_cpp_pr0, "ax", %progbits
44 .global __aeabi_unwind_cpp_pr0
45__aeabi_unwind_cpp_pr0:
46 bx lr
47
48 .text
49 .global _start
50_start:
51 bl func1
52 bl func2
53 bx lr
54
55// CHECK: Disassembly of section .text:
56// CHECK-EMPTY:
57// CHECK-NEXT: <_start>:
58// CHECK-NEXT:    20108:       bl      #4 <func1>
59// CHECK-NEXT:                 bl      #4 <func2>
60// CHECK-NEXT:                 bx      lr
61// CHECK:      <func1>:
62// CHECK-NEXT:    20114:       bx      lr
63// CHECK:      <func2>:
64// CHECK-NEXT:    20118:       bx      lr
65// CHECK:      <__gxx_personality_v0>:
66// CHECK-NEXT:    2011c:       bx      lr
67// CHECK:      <__aeabi_unwind_cpp_pr0>:
68// CHECK-NEXT:    20120:       bx      lr
69
70/// 100d4 + 0x10034 = 0x20108 = main (linker generated cantunwind)
71/// 100dc + 0x10038 = 0x20114 = func1 (inline unwinding data)
72// CHECK-EXIDX:      100d4 34000100 01000000 38000100 08849780
73/// 100e4 + 0x10034 = 0x20118 = func2 (100e8 + 14 = 100fc = .ARM.extab entry)
74/// 100ec + 0x10030 = 0x2011c = __gxx_personality_v0 (linker generated cantunwind)
75// CHECK-EXIDX-NEXT: 100e4 34000100 14000000 30000100 01000000
76/// 100f4 + 0x10030 = 1101c = sentinel
77// CHECK-EXIDX-NEXT: 100f4 30000100 01000000
78
79// CHECK-PT:          Name: .ARM.exidx
80// CHECK-PT-NEXT:     Type: SHT_ARM_EXIDX (0x70000001)
81// CHECK-PT-NEXT:     Flags [
82// CHECK-PT-NEXT:       SHF_ALLOC
83// CHECK-PT-NEXT:       SHF_LINK_ORDER
84// CHECK-PT-NEXT:     ]
85// CHECK-PT-NEXT:     Address: 0x100D4
86// CHECK-PT-NEXT:     Offset: 0xD4
87// CHECK-PT-NEXT:     Size: 40
88
89// CHECK-PT:          Type: PT_ARM_EXIDX (0x70000001)
90// CHECK-PT-NEXT:     Offset: 0xD4
91// CHECK-PT-NEXT:     VirtualAddress: 0x100D4
92// CHECK-PT-NEXT:     PhysicalAddress: 0x100D4
93// CHECK-PT-NEXT:     FileSize: 40
94// CHECK-PT-NEXT:     MemSize: 40
95// CHECK-PT-NEXT:     Flags [ (0x4)
96// CHECK-PT-NEXT:       PF_R (0x4)
97// CHECK-PT-NEXT:     ]
98// CHECK-PT-NEXT:     Alignment: 4
99// CHECK-PT-NEXT:   }
100