1# REQUIRES: aarch64 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 --macho -d --section=__const %t >> %t.objdump 6# RUN: FileCheck %s < %t.objdump 7 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 13 14# CHECK-LABEL: _foo: 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] 22# CHECK-NEXT: ret 23 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 27 28.text 29.globl _foo, _bar, _baz, _quux 30.p2align 2 31_foo: 32 ## Generates ARM64_RELOC_BRANCH26 and ARM64_RELOC_ADDEND 33 bl _bar + 123 34 ## Generates ARM64_RELOC_PAGE21 and ADDEND 35 adrp x2, _baz@PAGE + 4097 36 ## Generates ARM64_RELOC_PAGEOFF12 37 ldr x2, [x2, _baz@PAGEOFF] 38 39 ## Generates ARM64_RELOC_PAGE21 40 adrp x3, _quux@PAGE 41 ## Generates ARM64_RELOC_PAGEOFF12 with internal slide 4 42 ldr q0, [x3, _quux@PAGEOFF] 43 ret 44 45.p2align 2 46_bar: 47 ret 48 49.data 50.space 128 51_baz: 52.space 1 53 54.p2align 4 55_quux: 56.quad 0 57.quad 80 58 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. 63_ptr_1: 64 .quad _baz 65 .space 8 66_ptr_2: 67 .quad _baz + 123 68 .space 8 69 70.subsections_via_symbols 71