2021-03-12 02:28:14 +08:00
|
|
|
# REQUIRES: aarch64
|
2021-02-28 01:30:17 +08:00
|
|
|
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %s -o %t.o
|
|
|
|
# RUN: %lld -dylib -arch arm64 -lSystem -o %t %t.o
|
2021-03-12 02:28:14 +08:00
|
|
|
# RUN: llvm-objdump --syms %t > %t.objdump
|
|
|
|
# RUN: llvm-objdump --macho -d --section=__const %t >> %t.objdump
|
|
|
|
# RUN: FileCheck %s < %t.objdump
|
2021-02-28 01:30:17 +08:00
|
|
|
|
|
|
|
# CHECK-LABEL: SYMBOL TABLE:
|
|
|
|
# CHECK-DAG: [[#%x,PTR_1:]] l O __DATA_CONST,__const _ptr_1
|
|
|
|
# CHECK-DAG: [[#%x,PTR_2:]] l O __DATA_CONST,__const _ptr_2
|
|
|
|
# CHECK-DAG: [[#%x,BAR:]] g F __TEXT,__text _bar
|
|
|
|
# CHECK-DAG: [[#%x,BAZ:]] g O __DATA,__data _baz
|
|
|
|
|
|
|
|
# CHECK-LABEL: _foo:
|
|
|
|
## BRANCH26 relocations are 4-byte aligned, so 123 is truncated to 120
|
2021-04-12 11:23:37 +08:00
|
|
|
# CHECK-NEXT: bl 0x[[#BAR+120]]
|
2021-02-28 01:30:17 +08:00
|
|
|
## PAGE21 relocations are aligned to 4096 bytes
|
2021-04-12 11:23:37 +08:00
|
|
|
# CHECK-NEXT: adrp x2, [[#]] ; 0x[[#BAZ+4096-128]]
|
|
|
|
# CHECK-NEXT: ldr x2, [x2, #128]
|
|
|
|
# CHECK-NEXT: adrp x3, 8 ; 0x8000
|
|
|
|
# CHECK-NEXT: ldr q0, [x3, #144]
|
2021-02-28 01:30:17 +08:00
|
|
|
# CHECK-NEXT: ret
|
|
|
|
|
|
|
|
# CHECK-LABEL: Contents of (__DATA_CONST,__const) section
|
2021-04-12 11:23:37 +08:00
|
|
|
# CHECK: [[#PTR_1]] {{0*}}[[#BAZ]] 00000000 00000000 00000000
|
|
|
|
# CHECK: [[#PTR_2]] {{0*}}[[#BAZ+123]] 00000000 00000000 00000000
|
2021-02-28 01:30:17 +08:00
|
|
|
|
|
|
|
.text
|
2021-03-06 00:17:08 +08:00
|
|
|
.globl _foo, _bar, _baz, _quux
|
2021-02-28 01:30:17 +08:00
|
|
|
.p2align 2
|
|
|
|
_foo:
|
|
|
|
## Generates ARM64_RELOC_BRANCH26 and ARM64_RELOC_ADDEND
|
|
|
|
bl _bar + 123
|
|
|
|
## Generates ARM64_RELOC_PAGE21 and ADDEND
|
|
|
|
adrp x2, _baz@PAGE + 4097
|
|
|
|
## Generates ARM64_RELOC_PAGEOFF12
|
|
|
|
ldr x2, [x2, _baz@PAGEOFF]
|
2021-03-06 00:17:08 +08:00
|
|
|
|
|
|
|
## Generates ARM64_RELOC_PAGE21
|
|
|
|
adrp x3, _quux@PAGE
|
|
|
|
## Generates ARM64_RELOC_PAGEOFF12 with internal slide 4
|
|
|
|
ldr q0, [x3, _quux@PAGEOFF]
|
2021-02-28 01:30:17 +08:00
|
|
|
ret
|
|
|
|
|
|
|
|
.p2align 2
|
|
|
|
_bar:
|
|
|
|
ret
|
|
|
|
|
|
|
|
.data
|
|
|
|
.space 128
|
|
|
|
_baz:
|
|
|
|
.space 1
|
|
|
|
|
2021-03-06 00:17:08 +08:00
|
|
|
.p2align 4
|
|
|
|
_quux:
|
|
|
|
.quad 0
|
|
|
|
.quad 80
|
|
|
|
|
2021-02-28 01:30:17 +08:00
|
|
|
.section __DATA_CONST,__const
|
|
|
|
## These generate ARM64_RELOC_UNSIGNED symbol relocations. llvm-mc seems to
|
|
|
|
## generate UNSIGNED section relocations only for compact unwind sections, so
|
|
|
|
## those relocations are being tested in compact-unwind.s.
|
|
|
|
_ptr_1:
|
|
|
|
.quad _baz
|
|
|
|
.space 8
|
|
|
|
_ptr_2:
|
2021-02-28 01:30:19 +08:00
|
|
|
.quad _baz + 123
|
2021-02-28 01:30:17 +08:00
|
|
|
.space 8
|
|
|
|
|
|
|
|
.subsections_via_symbols
|