1// REQUIRES: arm
2// RUN: llvm-mc -g --triple=armv7a-linux-gnueabihf -arm-add-build-attributes -filetype=obj -o %t.o %s
3// RUN: ld.lld %t.o -o %t 2>&1 | FileCheck %s --check-prefix=WARN
4// RUN: llvm-objdump --no-show-raw-insn -d %t | FileCheck %s
5
6.syntax unified
7.section .arm_target, "ax", %progbits
8.balign 0x1000
9.arm
10arm_func_with_notype:
11.type arm_func_with_explicit_notype, %notype
12arm_func_with_explicit_notype:
13 bx lr
14
15.section .thumb_target, "ax", %progbits
16.balign 4
17.thumb
18thumb_func_with_notype:
19.type thumb_func_with_explicit_notype, %notype
20thumb_func_with_explicit_notype:
21 bx lr
22
23/// All the symbols that are targets of the branch relocations do not have
24/// type STT_FUNC. LLD should not insert interworking thunks as non STT_FUNC
25/// symbols have no state information, the ABI assumes the user has manually
26/// done the interworking. For the BL and BLX instructions LLD should
27/// preserve the original instruction instead of writing out the correct one
28/// for the assumed state at the target.
29/// LLD will warn for the BL and BLX cases where the behavior has changed
30/// from LLD 10.0
31.section .arm_caller, "ax", %progbits
32.balign 4
33.arm
34.global _start
35_start:
36 b .arm_target
37 b arm_func_with_notype
38 b arm_func_with_explicit_notype
39 b .thumb_target
40 b thumb_func_with_notype
41 b thumb_func_with_explicit_notype
42 bl .arm_target
43 bl arm_func_with_notype
44 bl arm_func_with_explicit_notype
45 bl .thumb_target
46 bl thumb_func_with_notype
47 bl thumb_func_with_explicit_notype
48// WARN: {{.*}}.s:[[# @LINE+1]]:(.arm_caller+0x30): branch and link relocation: R_ARM_CALL to STT_SECTION symbol .arm_target ; interworking not performed
49 blx .arm_target
50// WARN: {{.*}}.s:[[# @LINE+1]]:(.arm_caller+0x34): branch and link relocation: R_ARM_CALL to non STT_FUNC symbol: arm_func_with_notype interworking not performed; consider using directive '.type arm_func_with_notype, %function' to give symbol type STT_FUNC if interworking between ARM and Thumb is required
51 blx arm_func_with_notype
52// WARN: {{.*}}.s:[[# @LINE+1]]:(.arm_caller+0x38): branch and link relocation: R_ARM_CALL to non STT_FUNC symbol: arm_func_with_explicit_notype interworking not performed; consider using directive '.type arm_func_with_explicit_notype, %function' to give symbol type STT_FUNC if interworking between ARM and Thumb is required
53 blx arm_func_with_explicit_notype
54// WARN: {{.*}}.s:[[# @LINE+1]]:(.arm_caller+0x3C): branch and link relocation: R_ARM_CALL to STT_SECTION symbol .thumb_target ; interworking not performed
55 blx .thumb_target
56// WARN: {{.*}}.s:[[# @LINE+1]]:(.arm_caller+0x40): branch and link relocation: R_ARM_CALL to non STT_FUNC symbol: thumb_func_with_notype interworking not performed; consider using directive '.type thumb_func_with_notype, %function' to give symbol type STT_FUNC if interworking between ARM and Thumb is required
57 blx thumb_func_with_notype
58// WARN: {{.*}}.s:[[# @LINE+1]]:(.arm_caller+0x44): branch and link relocation: R_ARM_CALL to non STT_FUNC symbol: thumb_func_with_explicit_notype interworking not performed; consider using directive '.type thumb_func_with_explicit_notype, %function' to give symbol type STT_FUNC if interworking between ARM and Thumb is required
59 blx thumb_func_with_explicit_notype
60
61 .section .thumb_caller, "ax", %progbits
62 .thumb
63 .balign 4
64 .global thumb_caller
65thumb_caller:
66 b.w .arm_target
67 b.w arm_func_with_notype
68 b.w arm_func_with_explicit_notype
69 b.w .thumb_target
70 b.w thumb_func_with_notype
71 b.w thumb_func_with_explicit_notype
72 beq.w .arm_target
73 beq.w arm_func_with_notype
74 beq.w arm_func_with_explicit_notype
75 beq.w .thumb_target
76 beq.w thumb_func_with_notype
77 beq.w thumb_func_with_explicit_notype
78// WARN: {{.*}}.s:[[# @LINE+1]]:(.thumb_caller+0x30): branch and link relocation: R_ARM_THM_CALL to STT_SECTION symbol .arm_target ; interworking not performed
79 bl .arm_target
80// WARN: {{.*}}.s:[[# @LINE+1]]:(.thumb_caller+0x34): branch and link relocation: R_ARM_THM_CALL to non STT_FUNC symbol: arm_func_with_notype interworking not performed; consider using directive '.type arm_func_with_notype, %function' to give symbol type STT_FUNC if interworking between ARM and Thumb is required
81 bl arm_func_with_notype
82 // WARN: {{.*}}.s:[[# @LINE+1]]:(.thumb_caller+0x38): branch and link relocation: R_ARM_THM_CALL to non STT_FUNC symbol: arm_func_with_explicit_notype interworking not performed; consider using directive '.type arm_func_with_explicit_notype, %function' to give symbol type STT_FUNC if interworking between ARM and Thumb is required
83 bl arm_func_with_explicit_notype
84// WARN: {{.*}}.s:[[# @LINE+1]]:(.thumb_caller+0x3C): branch and link relocation: R_ARM_THM_CALL to STT_SECTION symbol .thumb_target ; interworking not performed
85 bl .thumb_target
86// WARN: {{.*}}.s:[[# @LINE+1]]:(.thumb_caller+0x40): branch and link relocation: R_ARM_THM_CALL to non STT_FUNC symbol: thumb_func_with_notype interworking not performed; consider using directive '.type thumb_func_with_notype, %function' to give symbol type STT_FUNC if interworking between ARM and Thumb is required
87 bl thumb_func_with_notype
88// {{.*}}.s:[[# @LINE+1]]:(.thumb_caller+0x44): branch and link relocation: R_ARM_THM_CALL to non STT_FUNC symbol: thumb_func_with_explicit_notype interworking not performed; consider using directive '.type thumb_func_with_explicit_notype, %function' to give symbol type STT_FUNC if interworking between ARM and Thumb is required
89 bl thumb_func_with_explicit_notype
90 blx .arm_target
91 blx arm_func_with_notype
92 blx arm_func_with_explicit_notype
93 blx .thumb_target
94 blx thumb_func_with_notype
95 blx thumb_func_with_explicit_notype
96
97// CHECK: 00021008 <_start>:
98// CHECK-NEXT: 21008: b       #-16
99// CHECK-NEXT: 2100c: b       #-20
100// CHECK-NEXT: 21010: b       #-24
101// CHECK-NEXT: 21014: b       #-24
102// CHECK-NEXT: 21018: b       #-28
103// CHECK-NEXT: 2101c: b       #-32
104// CHECK-NEXT: 21020: bl      #-40
105// CHECK-NEXT: 21024: bl      #-44
106// CHECK-NEXT: 21028: bl      #-48
107// CHECK-NEXT: 2102c: bl      #-48
108// CHECK-NEXT: 21030: bl      #-52
109// CHECK-NEXT: 21034: bl      #-56
110// CHECK-NEXT: 21038: blx     #-64
111// CHECK-NEXT: 2103c: blx     #-68
112// CHECK-NEXT: 21040: blx     #-72
113// CHECK-NEXT: 21044: blx     #-72
114// CHECK-NEXT: 21048: blx     #-76
115// CHECK-NEXT: 2104c: blx     #-80
116
117// CHECK: 00021050 <thumb_caller>:
118// CHECK-NEXT: 21050: b.w     #-84
119// CHECK-NEXT: 21054: b.w     #-88
120// CHECK-NEXT: 21058: b.w     #-92
121// CHECK-NEXT: 2105c: b.w     #-92
122// CHECK-NEXT: 21060: b.w     #-96
123// CHECK-NEXT: 21064: b.w     #-100
124// CHECK-NEXT: 21068: beq.w   #-108
125// CHECK-NEXT: 2106c: beq.w   #-112
126// CHECK-NEXT: 21070: beq.w   #-116
127// CHECK-NEXT: 21074: beq.w   #-116
128// CHECK-NEXT: 21078: beq.w   #-120
129// CHECK-NEXT: 2107c: beq.w   #-124
130// CHECK-NEXT: 21080: bl      #-132
131// CHECK-NEXT: 21084: bl      #-136
132// CHECK-NEXT: 21088: bl      #-140
133// CHECK-NEXT: 2108c: bl      #-140
134// CHECK-NEXT: 21090: bl      #-144
135// CHECK-NEXT: 21094: bl      #-148
136// CHECK-NEXT: 21098: blx     #-156
137// CHECK-NEXT: 2109c: blx     #-160
138// CHECK-NEXT: 210a0: blx     #-164
139// CHECK-NEXT: 210a4: blx     #-164
140// CHECK-NEXT: 210a8: blx     #-168
141// CHECK-NEXT: 210ac: blx     #-172
142