1# REQUIRES: aarch64
2# RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-freebsd %p/Inputs/aarch64-condb-reloc.s -o %t1.o
3# RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-freebsd %s -o %t2.o
4# RUN: ld.lld %t1.o %t2.o -o %t
5# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
6# RUN: ld.lld -shared %t1.o %t2.o -o %t.so
7# RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck --check-prefix=DSO %s
8# RUN: llvm-readobj -S -r %t.so | FileCheck -check-prefix=DSOREL %s
9
10# 0x11024 - 36 = 0x11000
11# 0x11028 - 24 = 0x11010
12# 0x1102c - 16 = 0x1101c
13# CHECK:      Disassembly of section .text:
14# CHECK-EMPTY:
15# CHECK-NEXT: <_foo>:
16# CHECK-NEXT:    210120: nop
17# CHECK-NEXT:    210124: nop
18# CHECK-NEXT:    210128: nop
19# CHECK-NEXT:    21012c: nop
20# CHECK:      <_bar>:
21# CHECK-NEXT:    210130: nop
22# CHECK-NEXT:    210134: nop
23# CHECK-NEXT:    210138: nop
24# CHECK:      <_dah>:
25# CHECK-NEXT:    21013c: nop
26# CHECK-NEXT:    210140: nop
27# CHECK:      <_start>:
28# CHECK-NEXT:    210144: b.eq 0x210120 <_foo>
29# CHECK-NEXT:    210148: b.eq 0x210130 <_bar>
30# CHECK-NEXT:    21014c: b.eq 0x21013c <_dah>
31
32#DSOREL:      Section {
33#DSOREL:        Index:
34#DSOREL:        Name: .got.plt
35#DSOREL-NEXT:   Type: SHT_PROGBITS
36#DSOREL-NEXT:   Flags [
37#DSOREL-NEXT:     SHF_ALLOC
38#DSOREL-NEXT:     SHF_WRITE
39#DSOREL-NEXT:   ]
40#DSOREL-NEXT:   Address: 0x30470
41#DSOREL-NEXT:   Offset: 0x470
42#DSOREL-NEXT:   Size: 48
43#DSOREL-NEXT:   Link: 0
44#DSOREL-NEXT:   Info: 0
45#DSOREL-NEXT:   AddressAlignment: 8
46#DSOREL-NEXT:   EntrySize: 0
47#DSOREL-NEXT:  }
48#DSOREL:      Relocations [
49#DSOREL-NEXT:  Section ({{.*}}) .rela.plt {
50#DSOREL-NEXT:    0x30488 R_AARCH64_JUMP_SLOT _foo
51#DSOREL-NEXT:    0x30490 R_AARCH64_JUMP_SLOT _bar
52#DSOREL-NEXT:    0x30498 R_AARCH64_JUMP_SLOT _dah
53#DSOREL-NEXT:  }
54#DSOREL-NEXT:]
55
56#DSO:      Disassembly of section .text:
57#DSO-EMPTY:
58#DSO-NEXT: <_foo>:
59#DSO-NEXT:     10338: nop
60#DSO-NEXT:     1033c: nop
61#DSO-NEXT:     10340: nop
62#DSO-NEXT:     10344: nop
63#DSO:      <_bar>:
64#DSO-NEXT:     10348: nop
65#DSO-NEXT:     1034c: nop
66#DSO-NEXT:     10350: nop
67#DSO:      <_dah>:
68#DSO-NEXT:     10354: nop
69#DSO-NEXT:     10358: nop
70#DSO:      <_start>:
71#DSO-NEXT:     1035c: b.eq 0x10390 <_foo@plt>
72#DSO-NEXT:     10360: b.eq 0x103a0 <_bar@plt>
73#DSO-NEXT:     10364: b.eq 0x103b0 <_dah@plt>
74#DSO-EMPTY:
75#DSO-NEXT: Disassembly of section .plt:
76#DSO-EMPTY:
77#DSO-NEXT: <.plt>:
78#DSO-NEXT:     10370: stp x16, x30, [sp, #-16]!
79#DSO-NEXT:     10374: adrp x16, #131072
80#DSO-NEXT:     10378: ldr x17, [x16, #1152]
81#DSO-NEXT:     1037c: add x16, x16, #1152
82#DSO-NEXT:     10380: br x17
83#DSO-NEXT:     10384: nop
84#DSO-NEXT:     10388: nop
85#DSO-NEXT:     1038c: nop
86#DSO-EMPTY:
87#DSO-NEXT:   <_foo@plt>:
88#DSO-NEXT:     10390: adrp x16, #131072
89#DSO-NEXT:     10394: ldr x17, [x16, #1160]
90#DSO-NEXT:     10398: add x16, x16, #1160
91#DSO-NEXT:     1039c: br x17
92#DSO-EMPTY:
93#DSO-NEXT:   <_bar@plt>:
94#DSO-NEXT:     103a0: adrp x16, #131072
95#DSO-NEXT:     103a4: ldr x17, [x16, #1168]
96#DSO-NEXT:     103a8: add x16, x16, #1168
97#DSO-NEXT:     103ac: br x17
98#DSO-EMPTY:
99#DSO-NEXT:   <_dah@plt>:
100#DSO-NEXT:     103b0: adrp x16, #131072
101#DSO-NEXT:     103b4: ldr x17, [x16, #1176]
102#DSO-NEXT:     103b8: add x16, x16, #1176
103#DSO-NEXT:     103bc: br x17
104
105.globl _start
106_start:
107 b.eq _foo
108 b.eq _bar
109 b.eq _dah
110