1// REQUIRES: aarch64
2// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
3// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %S/Inputs/abs255.s -o %t255.o
4// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %S/Inputs/abs256.s -o %t256.o
5// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %S/Inputs/abs257.s -o %t257.o
6
7.globl _start
8_start:
9.data
10  .hword foo - . + 0x212057
11  .hword foo - . + 0x1fa05a
12
13// Note: If this test fails, it probably happens because of
14//       the change of the address of the .data section.
15//       You may found the correct address in the aarch64_abs16.s test,
16//       if it is already fixed. Then, update addends accordingly.
17// RUN: ld.lld -z max-page-size=4096 %t.o %t256.o -o %t2
18// RUN: llvm-objdump -s --section=.data %t2 | FileCheck %s
19
20// CHECK: Contents of section .data:
21// 202158: S = 0x100, A = 0x212157, P = 0x202158
22//         S + A - P = 0xffff
23// 212a5a: S = 0x100, A = 0x1fa05a, P = 0x20215a
24//         S + A - P = 0x8000
25// CHECK-NEXT: 202158 ffff0080
26
27// RUN: not ld.lld -z max-page-size=4096 %t.o %t255.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=OVERFLOW1
28// OVERFLOW1: relocation R_AARCH64_PREL16 out of range: -32769 is not in [-32768, 65535]; references foo
29
30// RUN: not ld.lld -z max-page-size=4096 %t.o %t257.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=OVERFLOW2
31// OVERFLOW2: relocation R_AARCH64_PREL16 out of range: 65536 is not in [-32768, 65535]; references foo
32