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