xref: /llvm-project/lld/test/MachO/arm64-reloc-pointer-to-got.s (revision b5c850f718e1bc4d1aa0588f65ae53086f978e1a)
1# REQUIRES: aarch64
2
3# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %s -o %t.o
4# RUN: %lld -lSystem -arch arm64 -o %t %t.o
5# RUN: llvm-objdump --macho -d --full-contents --section-headers %t | FileCheck %s
6
7## FIXME: Even though we have reserved a GOT slot for _foo due to
8## POINTER_TO_GOT, we should still be able to relax this GOT_LOAD reference to
9## it.
10# CHECK:      _main:
11# CHECK-NEXT: adrp x8, [[#]] ; 0x100004000
12# CHECK-NEXT: ldr  x8, [x8]
13# CHECK-NEXT: ret
14
15# CHECK: Idx   Name          Size     VMA              Type
16# CHECK: [[#]] __got         00000008 0000000100004000 DATA
17# CHECK: [[#]] __data        00000004 0000000100008000 DATA
18
19## The relocated data should contain the difference between the addresses of
20## __data and __got in little-endian form.
21# CHECK:       Contents of section __DATA,__data:
22# CHECK-NEXT:  100008000 00c0ffff
23
24.globl _main, _foo
25.p2align 2
26_main:
27  adrp x8, _foo@GOTPAGE
28  ldr  x8, [x8, _foo@GOTPAGEOFF]
29  ret
30
31.p2align 2
32_foo:
33  ret
34
35.data
36.long _foo@GOT - .
37