2018-06-27 06:20:04 +08:00
|
|
|
// REQUIRES: aarch64
|
2019-11-24 03:14:45 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t.o
|
2017-11-29 19:15:12 +08:00
|
|
|
// RUN: echo "SECTIONS { \
|
|
|
|
// RUN: .text_low 0x2000: { *(.text_low) } \
|
|
|
|
// RUN: .text_high 0x8002000 : { *(.text_high) } \
|
|
|
|
// RUN: } " > %t.script
|
2019-11-24 03:14:45 +08:00
|
|
|
// RUN: ld.lld --script %t.script %t.o -o %t
|
|
|
|
// RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t | FileCheck %s
|
2020-04-05 01:24:48 +08:00
|
|
|
// RUN: llvm-nm --no-sort %t | FileCheck --check-prefix=NM %s
|
2017-11-29 19:15:12 +08:00
|
|
|
|
|
|
|
// Check that we have the out of branch range calculation right. The immediate
|
|
|
|
// field is signed so we have a slightly higher negative displacement.
|
|
|
|
.section .text_low, "ax", %progbits
|
|
|
|
.globl _start
|
|
|
|
.type _start, %function
|
|
|
|
_start:
|
|
|
|
// Need thunk to high_target@plt
|
|
|
|
bl high_target
|
2019-11-23 16:57:54 +08:00
|
|
|
// Need thunk to .text_high+4
|
|
|
|
bl .text_high+4
|
2017-11-29 19:15:12 +08:00
|
|
|
ret
|
|
|
|
|
|
|
|
.section .text_high, "ax", %progbits
|
|
|
|
.globl high_target
|
|
|
|
.type high_target, %function
|
|
|
|
high_target:
|
|
|
|
// No Thunk needed as we are within signed immediate range
|
|
|
|
bl _start
|
|
|
|
ret
|
|
|
|
|
|
|
|
// CHECK: Disassembly of section .text_low:
|
2019-05-01 18:40:48 +08:00
|
|
|
// CHECK-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// CHECK-NEXT: <_start>:
|
2020-01-16 09:44:14 +08:00
|
|
|
// CHECK-NEXT: 2000: bl #0xc <__AArch64AbsLongThunk_high_target>
|
|
|
|
// CHECK-NEXT: 2004: bl #0x18 <__AArch64AbsLongThunk_>
|
2019-11-24 03:14:45 +08:00
|
|
|
// CHECK-NEXT: ret
|
2020-03-06 06:18:38 +08:00
|
|
|
// CHECK: <__AArch64AbsLongThunk_high_target>:
|
2020-01-16 09:44:14 +08:00
|
|
|
// CHECK-NEXT: 200c: ldr x16, #0x8
|
2019-11-24 03:14:45 +08:00
|
|
|
// CHECK-NEXT: br x16
|
2020-03-06 06:18:38 +08:00
|
|
|
// CHECK: <$d>:
|
2020-01-16 09:44:14 +08:00
|
|
|
// CHECK-NEXT: 2014: 00 20 00 08 .word 0x08002000
|
|
|
|
// CHECK-NEXT: 2018: 00 00 00 00 .word 0x00000000
|
2020-03-06 06:18:38 +08:00
|
|
|
// CHECK: <__AArch64AbsLongThunk_>:
|
2020-01-16 09:44:14 +08:00
|
|
|
// CHECK-NEXT: 201c: ldr x16, #0x8
|
|
|
|
// CHECK-NEXT: 2020: br x16
|
2020-03-06 06:18:38 +08:00
|
|
|
// CHECK: <$d>:
|
2020-01-16 09:44:14 +08:00
|
|
|
// CHECK-NEXT: 2024: 04 20 00 08 .word 0x08002004
|
|
|
|
// CHECK-NEXT: 2028: 00 00 00 00 .word 0x00000000
|
2017-11-29 19:15:12 +08:00
|
|
|
// CHECK: Disassembly of section .text_high:
|
2019-05-01 18:40:48 +08:00
|
|
|
// CHECK-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// CHECK-NEXT: <high_target>:
|
2019-11-24 03:14:45 +08:00
|
|
|
// CHECK-NEXT: 8002000: bl #-0x8000000 <_start>
|
|
|
|
// CHECK-NEXT: ret
|
2020-04-05 01:24:48 +08:00
|
|
|
|
|
|
|
/// Local symbols copied from %t.o
|
|
|
|
// NM: t $x.0
|
|
|
|
// NM-NEXT: t $x.1
|
|
|
|
/// Local thunk symbols.
|
|
|
|
// NM-NEXT: t __AArch64AbsLongThunk_high_target
|
|
|
|
// NM-NEXT: t $x
|
|
|
|
// NM-NEXT: t $d
|
|
|
|
// NM-NEXT: t __AArch64AbsLongThunk_{{$}}
|
|
|
|
// NM-NEXT: t $x
|
|
|
|
// NM-NEXT: t $d
|
|
|
|
/// Global symbols.
|
|
|
|
// NM-NEXT: T _start
|
|
|
|
// NM-NEXT: T high_target
|