File: aarch64-thunk-script.s

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (67 lines) | stat: -rw-r--r-- 2,306 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// REQUIRES: aarch64
// RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t.o
// RUN: echo "SECTIONS { \
// RUN:       .text_low 0x2000: { *(.text_low) } \
// RUN:       .text_high 0x8002000 : { *(.text_high) } \
// RUN:       } " > %t.script
// RUN: ld.lld --script %t.script %t.o -o %t
// RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t | FileCheck %s
// RUN: llvm-nm --no-sort --special-syms %t | FileCheck --check-prefix=NM %s

// 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
 // Need thunk to .text_high+4
 bl .text_high+4
 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:
// CHECK-EMPTY:
// CHECK-NEXT: <_start>:
// CHECK-NEXT:     2000:       bl      0x200c <__AArch64AbsLongThunk_high_target>
// CHECK-NEXT:     2004:       bl      0x201c <__AArch64AbsLongThunk_>
// CHECK-NEXT:                 ret
// CHECK: <__AArch64AbsLongThunk_high_target>:
// CHECK-NEXT:     200c:       ldr     x16, 0x2014
// CHECK-NEXT:                 br      x16
// CHECK: <$d>:
// CHECK-NEXT:     2014:       00 20 00 08     .word   0x08002000
// CHECK-NEXT:     2018:       00 00 00 00     .word   0x00000000
// CHECK:      <__AArch64AbsLongThunk_>:
// CHECK-NEXT:     201c:       ldr x16, 0x2024
// CHECK-NEXT:     2020:       br x16
// CHECK:      <$d>:
// CHECK-NEXT:     2024:       04 20 00 08     .word   0x08002004
// CHECK-NEXT:     2028:       00 00 00 00     .word   0x00000000
// CHECK: Disassembly of section .text_high:
// CHECK-EMPTY:
// CHECK-NEXT: <high_target>:
// CHECK-NEXT:  8002000:       bl      0x2000 <_start>
// CHECK-NEXT:                 ret

/// 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