1# REQUIRES: aarch64
2# RUN: split-file %s %t
3
4# RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-linux %t/test.s -o %t.o
5# RUN: ld.lld -shared --script %t/script %t.o -o %t.so
6# RUN: ld.lld -pie --script %t/script %t.o -o %t.exe
7# RUN: llvm-readobj -r %t.so | FileCheck --check-prefix=RELOCS-SHARED %s
8# RUN: llvm-readobj -r %t.exe | FileCheck --check-prefix=RELOCS-PIE %s
9# RUN: llvm-objdump --no-show-raw-insn -d %t.so | FileCheck --check-prefix=DISAS %s
10
11## Check if the R_AARCH64_LD64_GOTPAGE_LO15 generates the GOT entries.
12# RELOCS-SHARED:      Relocations [
13# RELOCS-SHARED-NEXT:   Section (5) .rela.dyn {
14# RELOCS-SHARED-NEXT:     0x{{[0-9A-F]+}} R_AARCH64_GLOB_DAT global1 0x{{[0-9A-F]+}}
15# RELOCS-SHARED-NEXT:     0x{{[0-9A-F]+}} R_AARCH64_GLOB_DAT global2 0x{{[0-9A-F]+}}
16# RELOCS-SHARED-NEXT:   }
17# RELOCS-SHARED-NEXT: ]
18
19# RELOCS-PIE:      Relocations [
20# RELOCS-PIE-NEXT:   Section (5) .rela.dyn {
21# RELOCS-PIE-NEXT:     0x{{[0-9A-F]+}} R_AARCH64_RELATIVE - 0x{{[0-9A-F]+}}
22# RELOCS-PIE-NEXT:     0x{{[0-9A-F]+}} R_AARCH64_RELATIVE - 0x{{[0-9A-F]+}}
23# RELOCS-PIE-NEXT:   }
24# RELOCS-PIE-NEXT: ]
25
26# DISAS:      adrp    x0, 0xf000
27# DISAS-NEXT: ldr     x0, [x0, #4088]
28# DISAS-NEXT: ldr     x1, [x0, #4096]
29
30#--- script
31SECTIONS {
32  .got (0x10000 - 8) : { *.got }
33}
34
35#--- test.s
36.globl	_start
37.type	_start,@function
38_start:
39	adrp    x0, _GLOBAL_OFFSET_TABLE_
40	ldr     x0, [x0, #:gotpage_lo15:global1]
41	ldr     x1, [x0, #:gotpage_lo15:global2]
42
43.type   global1,@object
44.comm   global1,8,8
45.type   global2,@object
46.comm   global2,8,8
47