[memprof] Remove an unused using directive (#117004)
[llvm-project.git] / lld / test / ELF / arm-blx.s
blob84ecf736906d02d6530594e86673ee0cd89af444
1 // REQUIRES: arm
2 // RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
3 // RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %S/Inputs/far-arm-thumb-abs.s -o %tfar
4 // RUN: echo "SECTIONS { \
5 // RUN: . = 0xb4; \
6 // RUN: .callee1 : { *(.callee_low) } \
7 // RUN: .callee2 : { *(.callee_arm_low) } \
8 // RUN: .caller : { *(.text) } \
9 // RUN: .callee3 : { *(.callee_high) } \
10 // RUN: .callee4 : { *(.callee_arm_high) } } " > %t.script
11 // RUN: ld.lld --script %t.script %t %tfar -o %t2
12 // RUN: llvm-objdump -d --triple=armv7a-none-linux-gnueabi %t2 | FileCheck %s
14 /// Test BLX instruction is chosen for ARM BL/BLX instruction and Thumb callee
15 /// Using two callees to ensure at least one has 2-byte alignment.
16 .syntax unified
17 .thumb
18 .section .callee_low, "ax",%progbits
19 .align 2
20 .type callee_low,%function
21 callee_low:
22 bx lr
23 .type callee_low2, %function
24 callee_low2:
25 bx lr
27 .section .callee_arm_low, "ax",%progbits
28 .arm
29 .balign 0x100
30 .type callee_arm_low,%function
31 .align 2
32 callee_arm_low:
33 bx lr
35 .section .text, "ax",%progbits
36 .arm
37 .globl _start
38 .balign 0x10000
39 .type _start,%function
40 _start:
41 bl callee_low
42 blx callee_low
43 bl callee_low2
44 blx callee_low2
45 bl callee_high
46 blx callee_high
47 bl callee_high2
48 blx callee_high2
49 bl blx_far
50 blx blx_far2
51 /// blx to ARM instruction should be written as a BL
52 bl callee_arm_low
53 blx callee_arm_low
54 bl callee_arm_high
55 blx callee_arm_high
56 bx lr
58 .section .callee_high, "ax",%progbits
59 .balign 0x100
60 .thumb
61 .type callee_high,%function
62 callee_high:
63 bx lr
64 .type callee_high2,%function
65 callee_high2:
66 bx lr
68 .section .callee_arm_high, "ax",%progbits
69 .arm
70 .balign 0x100
71 .type callee_arm_high,%function
72 callee_arm_high:
73 bx lr
75 // CHECK: Disassembly of section .callee1:
76 // CHECK-EMPTY:
77 // CHECK-NEXT: <callee_low>:
78 // CHECK-NEXT: b4: 4770 bx lr
79 // CHECK: <callee_low2>:
80 // CHECK-NEXT: b6: 4770 bx lr
82 // CHECK: Disassembly of section .callee2:
83 // CHECK-EMPTY:
84 // CHECK-NEXT: <callee_arm_low>:
85 // CHECK-NEXT: 100: e12fff1e bx lr
87 // CHECK: Disassembly of section .caller:
88 // CHECK-EMPTY:
89 // CHECK-NEXT: <_start>:
90 // CHECK-NEXT: 10000: faffc02b blx 0xb4 <callee_low>
91 // CHECK-NEXT: 10004: faffc02a blx 0xb4 <callee_low>
92 // CHECK-NEXT: 10008: fbffc029 blx 0xb6 <callee_low2>
93 // CHECK-NEXT: 1000c: fbffc028 blx 0xb6 <callee_low2>
94 // CHECK-NEXT: 10010: fa00003a blx 0x10100 <callee_high>
95 // CHECK-NEXT: 10014: fa000039 blx 0x10100 <callee_high>
96 // CHECK-NEXT: 10018: fb000038 blx 0x10102 <callee_high2>
97 // CHECK-NEXT: 1001c: fb000037 blx 0x10102 <callee_high2>
98 /// 0x2010024 = blx_far
99 // CHECK-NEXT: 10020: fa7fffff blx 0x2010024
100 /// 0x2010028 = blx_far2
101 // CHECK-NEXT: 10024: fa7fffff blx 0x2010028
102 // CHECK-NEXT: 10028: ebffc034 bl 0x100 <callee_arm_low>
103 // CHECK-NEXT: 1002c: ebffc033 bl 0x100 <callee_arm_low>
104 // CHECK-NEXT: 10030: eb000072 bl 0x10200 <callee_arm_high>
105 // CHECK-NEXT: 10034: eb000071 bl 0x10200 <callee_arm_high>
106 // CHECK-NEXT: 10038: e12fff1e bx lr
108 // CHECK: Disassembly of section .callee3:
109 // CHECK-EMPTY:
110 // CHECK: <callee_high>:
111 // CHECK-NEXT: 10100: 4770 bx lr
112 // CHECK: <callee_high2>:
113 // CHECK-NEXT: 10102: 4770 bx lr
115 // CHECK: Disassembly of section .callee4:
116 // CHECK-EMPTY:
117 // CHECK-NEXT: <callee_arm_high>:
118 // CHECK-NEXT: 10200: e12fff1e bx lr