2 # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %s -o %t.o
3 # RUN: %lld -dylib -arch arm64 -lSystem -o %t %t.o
4 # RUN: llvm-objdump --syms %t > %t.objdump
5 # RUN: llvm-objdump --no-print-imm-hex --macho -d --section=__const %t >> %t.objdump
6 # RUN: FileCheck %s < %t.objdump
8 # CHECK-LABEL: SYMBOL TABLE:
9 # CHECK-DAG: [[#%x,PTR_1:]] l O __DATA_CONST,__const _ptr_1
10 # CHECK-DAG: [[#%x,PTR_2:]] l O __DATA_CONST,__const _ptr_2
11 # CHECK-DAG: [[#%x,BAR:]] g F __TEXT,__text _bar
12 # CHECK-DAG: [[#%x,BAZ:]] g O __DATA,__data _baz
15 ## BRANCH26 relocations are 4-byte aligned, so 123 is truncated to 120
16 # CHECK-NEXT: bl 0x[[#BAR+120]]
17 ## PAGE21 relocations are aligned to 4096 bytes
18 # CHECK-NEXT: adrp x2, [[#]] ; 0x[[#BAZ+4096-128]]
19 # CHECK-NEXT: ldr x2, [x2, #128]
20 # CHECK-NEXT: adrp x3, 8 ; 0x8000
21 # CHECK-NEXT: ldr q0, [x3, #144]
24 # CHECK-LABEL: Contents of (__DATA_CONST,__const) section
25 # CHECK: [[#PTR_1]] {{0*}}[[#BAZ]] 00000000 00000000 00000000
26 # CHECK: [[#PTR_2]] {{0*}}[[#BAZ+123]] 00000000 00000000 00000000
29 .globl _foo, _bar, _baz, _quux
32 ## Generates ARM64_RELOC_BRANCH26 and ARM64_RELOC_ADDEND
34 ## Generates ARM64_RELOC_PAGE21 and ADDEND
35 adrp x2
, _baz@PAGE
+ 4097
36 ## Generates ARM64_RELOC_PAGEOFF12
37 ldr x2
, [x2
, _baz@PAGEOFF
]
39 ## Generates ARM64_RELOC_PAGE21
41 ## Generates ARM64_RELOC_PAGEOFF12 with internal slide 4
42 ldr q0
, [x3
, _quux@PAGEOFF
]
59 .section __DATA_CONST,__const
60 ## These generate ARM64_RELOC_UNSIGNED symbol relocations. llvm-mc seems to
61 ## generate UNSIGNED section relocations only for compact unwind sections, so
62 ## those relocations are being tested in compact-unwind.s.
70 .subsections_via_symbols