2018-06-27 06:20:04 +08:00
|
|
|
// REQUIRES: arm
|
2016-06-16 17:53:46 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %S/Inputs/far-arm-thumb-abs.s -o %tfar
|
|
|
|
// RUN: echo "SECTIONS { \
|
2016-09-20 23:08:24 +08:00
|
|
|
// RUN: . = 0xb4; \
|
2016-06-16 17:53:46 +08:00
|
|
|
// RUN: .callee1 : { *(.callee_low) } \
|
|
|
|
// RUN: .callee2 : { *(.callee_arm_low) } \
|
|
|
|
// RUN: .caller : { *(.text) } \
|
|
|
|
// RUN: .callee3 : { *(.callee_high) } \
|
|
|
|
// RUN: .callee4 : { *(.callee_arm_high) } } " > %t.script
|
2019-07-22 19:37:03 +08:00
|
|
|
// RUN: ld.lld --script %t.script %t %tfar -o %t2
|
2020-03-16 08:47:44 +08:00
|
|
|
// RUN: llvm-objdump -d --triple=armv7a-none-linux-gnueabi %t2 | FileCheck %s
|
2016-06-16 17:53:46 +08:00
|
|
|
|
|
|
|
// Test BLX instruction is chosen for ARM BL/BLX instruction and Thumb callee
|
|
|
|
// Using two callees to ensure at least one has 2-byte alignment.
|
|
|
|
.syntax unified
|
|
|
|
.thumb
|
|
|
|
.section .callee_low, "ax",%progbits
|
|
|
|
.align 2
|
|
|
|
.type callee_low,%function
|
|
|
|
callee_low:
|
|
|
|
bx lr
|
|
|
|
.type callee_low2, %function
|
|
|
|
callee_low2:
|
|
|
|
bx lr
|
|
|
|
|
|
|
|
.section .callee_arm_low, "ax",%progbits
|
|
|
|
.arm
|
|
|
|
.balign 0x100
|
|
|
|
.type callee_arm_low,%function
|
|
|
|
.align 2
|
|
|
|
callee_arm_low:
|
|
|
|
bx lr
|
|
|
|
|
|
|
|
.section .text, "ax",%progbits
|
|
|
|
.arm
|
|
|
|
.globl _start
|
|
|
|
.balign 0x10000
|
|
|
|
.type _start,%function
|
|
|
|
_start:
|
|
|
|
bl callee_low
|
|
|
|
blx callee_low
|
|
|
|
bl callee_low2
|
|
|
|
blx callee_low2
|
|
|
|
bl callee_high
|
|
|
|
blx callee_high
|
|
|
|
bl callee_high2
|
|
|
|
blx callee_high2
|
|
|
|
bl blx_far
|
|
|
|
blx blx_far2
|
|
|
|
// blx to ARM instruction should be written as a BL
|
|
|
|
bl callee_arm_low
|
|
|
|
blx callee_arm_low
|
|
|
|
bl callee_arm_high
|
|
|
|
blx callee_arm_high
|
|
|
|
bx lr
|
|
|
|
|
|
|
|
.section .callee_high, "ax",%progbits
|
|
|
|
.balign 0x100
|
|
|
|
.thumb
|
|
|
|
.type callee_high,%function
|
|
|
|
callee_high:
|
|
|
|
bx lr
|
|
|
|
.type callee_high2,%function
|
|
|
|
callee_high2:
|
|
|
|
bx lr
|
|
|
|
|
|
|
|
.section .callee_arm_high, "ax",%progbits
|
|
|
|
.arm
|
|
|
|
.balign 0x100
|
|
|
|
.type callee_arm_high,%function
|
|
|
|
callee_arm_high:
|
|
|
|
bx lr
|
|
|
|
|
2019-08-21 23:30:55 +08:00
|
|
|
// CHECK: Disassembly of section .callee1:
|
|
|
|
// CHECK-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// CHECK-NEXT: <callee_low>:
|
2019-08-21 23:30:55 +08:00
|
|
|
// CHECK-NEXT: b4: 70 47 bx lr
|
2020-03-06 06:18:38 +08:00
|
|
|
// CHECK: <callee_low2>:
|
2019-08-21 23:30:55 +08:00
|
|
|
// CHECK-NEXT: b6: 70 47 bx lr
|
2016-06-16 17:53:46 +08:00
|
|
|
|
2019-08-21 23:30:55 +08:00
|
|
|
// CHECK: Disassembly of section .callee2:
|
|
|
|
// CHECK-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// CHECK-NEXT: <callee_arm_low>:
|
2019-08-21 23:30:55 +08:00
|
|
|
// CHECK-NEXT: 100: 1e ff 2f e1 bx lr
|
2016-06-16 17:53:46 +08:00
|
|
|
|
2019-08-21 23:30:55 +08:00
|
|
|
// CHECK: Disassembly of section .caller:
|
|
|
|
// CHECK-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// CHECK-NEXT: <_start>:
|
2019-08-21 23:30:55 +08:00
|
|
|
// CHECK-NEXT: 10000: 2b c0 ff fa blx #-65364 <callee_low>
|
|
|
|
// CHECK-NEXT: 10004: 2a c0 ff fa blx #-65368 <callee_low>
|
|
|
|
// CHECK-NEXT: 10008: 29 c0 ff fb blx #-65370 <callee_low2>
|
|
|
|
// CHECK-NEXT: 1000c: 28 c0 ff fb blx #-65374 <callee_low2>
|
|
|
|
// CHECK-NEXT: 10010: 3a 00 00 fa blx #232 <callee_high>
|
|
|
|
// CHECK-NEXT: 10014: 39 00 00 fa blx #228 <callee_high>
|
|
|
|
// CHECK-NEXT: 10018: 38 00 00 fb blx #226 <callee_high2>
|
|
|
|
// CHECK-NEXT: 1001c: 37 00 00 fb blx #222 <callee_high2>
|
2016-06-16 17:53:46 +08:00
|
|
|
// 10020 + 1FFFFFC + 8 = 0x2010024 = blx_far
|
2019-08-21 23:30:55 +08:00
|
|
|
// CHECK-NEXT: 10020: ff ff 7f fa blx #33554428
|
2016-06-16 17:53:46 +08:00
|
|
|
// 10024 + 1FFFFFC + 8 = 0x2010028 = blx_far2
|
2019-08-21 23:30:55 +08:00
|
|
|
// CHECK-NEXT: 10024: ff ff 7f fa blx #33554428
|
|
|
|
// CHECK-NEXT: 10028: 34 c0 ff eb bl #-65328 <callee_arm_low>
|
|
|
|
// CHECK-NEXT: 1002c: 33 c0 ff eb bl #-65332 <callee_arm_low>
|
|
|
|
// CHECK-NEXT: 10030: 72 00 00 eb bl #456 <callee_arm_high>
|
|
|
|
// CHECK-NEXT: 10034: 71 00 00 eb bl #452 <callee_arm_high>
|
|
|
|
// CHECK-NEXT: 10038: 1e ff 2f e1 bx lr
|
2016-06-16 17:53:46 +08:00
|
|
|
|
2019-08-21 23:30:55 +08:00
|
|
|
// CHECK: Disassembly of section .callee3:
|
|
|
|
// CHECK-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// CHECK: <callee_high>:
|
2019-08-21 23:30:55 +08:00
|
|
|
// CHECK-NEXT: 10100: 70 47 bx lr
|
2020-03-06 06:18:38 +08:00
|
|
|
// CHECK: <callee_high2>:
|
2019-08-21 23:30:55 +08:00
|
|
|
// CHECK-NEXT: 10102: 70 47 bx lr
|
2016-06-16 17:53:46 +08:00
|
|
|
|
2019-08-21 23:30:55 +08:00
|
|
|
// CHECK: Disassembly of section .callee4:
|
|
|
|
// CHECK-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// CHECK-NEXT: <callee_arm_high>:
|
2019-08-21 23:30:55 +08:00
|
|
|
// CHECK-NEXT: 10200: 1e ff 2f e1 bx lr
|