1// REQUIRES: aarch64
2// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-freebsd %s -o %t.o
3// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-freebsd %p/Inputs/relocation-copy.s -o %t2.o
4// RUN: ld.lld -shared %t2.o -soname fixed-length-string.so -o %t2.so
5// RUN: ld.lld %t.o %t2.so -o %t
6// RUN: llvm-readobj -S -r --symbols %t | FileCheck %s
7// RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=CODE %s
8// RUN: llvm-objdump -s --section=.rodata %t | FileCheck --check-prefix=RODATA %s
9
10.text
11.globl _start
12_start:
13    adr x1, x
14    adrp x2, y
15    add x2, x2, :lo12:y
16.rodata
17    .word z
18
19// CHECK:     Name: .bss
20// CHECK-NEXT:     Type: SHT_NOBITS
21// CHECK-NEXT:     Flags [
22// CHECK-NEXT:       SHF_ALLOC
23// CHECK-NEXT:       SHF_WRITE
24// CHECK-NEXT:     ]
25// CHECK-NEXT:     Address: 0x2303F0
26// CHECK-NEXT:     Offset:
27// CHECK-NEXT:     Size: 24
28// CHECK-NEXT:     Link:
29// CHECK-NEXT:     Info:
30// CHECK-NEXT:     AddressAlignment: 16
31
32// CHECK: Relocations [
33// CHECK-NEXT:   Section ({{.*}}) .rela.dyn {
34// CHECK-NEXT:     0x2303F0 R_AARCH64_COPY x 0x0
35// CHECK-NEXT:     0x230400 R_AARCH64_COPY y 0x0
36// CHECK-NEXT:     0x230404 R_AARCH64_COPY z 0x0
37// CHECK-NEXT:   }
38// CHECK-NEXT: ]
39
40// CHECK: Symbols [
41// CHECK:     Name: x
42// CHECK-NEXT:     Value: 0x2303F0
43// CHECK-NEXT:     Size: 4
44// CHECK-NEXT:     Binding: Global
45// CHECK-NEXT:     Type: Object
46// CHECK-NEXT:     Other:
47// CHECK-NEXT:     Section: .bss
48// CHECK:     Name: y
49// CHECK-NEXT:     Value: 0x230400
50// CHECK-NEXT:     Size: 4
51// CHECK-NEXT:     Binding: Global
52// CHECK-NEXT:     Type: Object
53// CHECK-NEXT:     Other:
54// CHECK-NEXT:     Section: .bss
55// CHECK:     Name: z
56// CHECK-NEXT:     Value: 0x230404
57// CHECK-NEXT:     Size: 4
58// CHECK-NEXT:     Binding: Global
59// CHECK-NEXT:     Type: Object
60// CHECK-NEXT:     Other:
61// CHECK-NEXT:     Section: .bss
62// CHECK: ]
63
64// CODE: Disassembly of section .text:
65// CODE-EMPTY:
66// CODE-NEXT: <_start>:
67// S + A - P = 0x2303f0 + 0 - 0x21031c = 131284
68// CODE-NEXT:  21031c: adr  x1, #131284
69// Page(S + A) - Page(P) = Page(0x230400) - Page(0x210320) = 131072
70// CODE-NEXT:  210320: adrp x2, #131072
71// (S + A) & 0xFFF = (0x230400 + 0) & 0xFFF = 1024
72// CODE-NEXT:  210324: add  x2, x2, #1024
73
74// RODATA: Contents of section .rodata:
75// S(z) = 0x230404
76// RODATA-NEXT:  200318 04042300
77