2015-09-27 16:45:38 +08:00
|
|
|
# RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-freebsd %s -o %t
|
2016-09-12 18:02:41 +08:00
|
|
|
# RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-freebsd %p/Inputs/uabs_label.s -o %t2.o
|
|
|
|
# RUN: ld.lld %t %t2.o -o %t2
|
2015-09-27 16:45:38 +08:00
|
|
|
# RUN: llvm-objdump -d %t2 | FileCheck %s
|
2015-09-28 20:22:25 +08:00
|
|
|
# REQUIRES: aarch64
|
2015-09-27 16:45:38 +08:00
|
|
|
|
2015-10-01 03:44:30 +08:00
|
|
|
.section .R_AARCH64_ADR_PREL_LO21,"ax",@progbits
|
2015-09-27 16:45:38 +08:00
|
|
|
.globl _start
|
|
|
|
_start:
|
|
|
|
adr x1,msg
|
|
|
|
msg: .asciz "Hello, world\n"
|
|
|
|
msgend:
|
|
|
|
|
2015-10-01 03:44:30 +08:00
|
|
|
# CHECK: Disassembly of section .R_AARCH64_ADR_PREL_LO21:
|
2015-09-27 16:45:38 +08:00
|
|
|
# CHECK: _start:
|
2015-10-01 03:44:30 +08:00
|
|
|
# CHECK: 0: 21 00 00 10 adr x1, #4
|
|
|
|
# CHECK: msg:
|
|
|
|
# CHECK: 4:
|
|
|
|
# #4 is the adr immediate value.
|
2015-10-03 06:00:42 +08:00
|
|
|
|
|
|
|
.section .R_AARCH64_ADR_PREL_PG_H121,"ax",@progbits
|
|
|
|
adrp x1,mystr
|
|
|
|
mystr:
|
|
|
|
.asciz "blah"
|
|
|
|
.size mystr, 4
|
|
|
|
|
2016-10-04 16:58:55 +08:00
|
|
|
# S = 0x20012, A = 0x4, P = 0x20012
|
2015-10-03 06:00:42 +08:00
|
|
|
# PAGE(S + A) = 0x11000
|
|
|
|
# PAGE(P) = 0x11000
|
|
|
|
#
|
|
|
|
# CHECK: Disassembly of section .R_AARCH64_ADR_PREL_PG_H121:
|
|
|
|
# CHECK-NEXT: $x.2:
|
2016-10-04 16:58:55 +08:00
|
|
|
# CHECK-NEXT: 20012: 01 00 00 90 adrp x1, #0
|
2015-10-04 03:56:07 +08:00
|
|
|
|
|
|
|
.section .R_AARCH64_ADD_ABS_LO12_NC,"ax",@progbits
|
|
|
|
add x0, x0, :lo12:.L.str
|
|
|
|
.L.str:
|
|
|
|
.asciz "blah"
|
|
|
|
.size mystr, 4
|
|
|
|
|
2016-10-04 16:58:55 +08:00
|
|
|
# S = 0x2001b, A = 0x4
|
2015-10-04 03:56:07 +08:00
|
|
|
# R = (S + A) & 0xFFF = 0x1f
|
|
|
|
# R << 10 = 0x7c00
|
|
|
|
#
|
|
|
|
# CHECK: Disassembly of section .R_AARCH64_ADD_ABS_LO12_NC:
|
|
|
|
# CHECK-NEXT: $x.4:
|
2016-10-04 16:58:55 +08:00
|
|
|
# CHECK-NEXT: 2001b: 00 7c 00 91 add x0, x0, #31
|
2015-11-08 12:45:26 +08:00
|
|
|
|
|
|
|
.section .R_AARCH64_LDST64_ABS_LO12_NC,"ax",@progbits
|
|
|
|
ldr x28, [x27, :lo12:foo]
|
|
|
|
foo:
|
|
|
|
.asciz "foo"
|
|
|
|
.size mystr, 3
|
|
|
|
|
2016-10-04 16:58:55 +08:00
|
|
|
# S = 0x20024, A = 0x4
|
2015-11-08 12:45:26 +08:00
|
|
|
# R = ((S + A) & 0xFFF) << 7 = 0x00001400
|
|
|
|
# 0x00001400 | 0xf940177c = 0xf940177c
|
|
|
|
# CHECK: Disassembly of section .R_AARCH64_LDST64_ABS_LO12_NC:
|
|
|
|
# CHECK-NEXT: $x.6:
|
2016-10-04 16:58:55 +08:00
|
|
|
# CHECK-NEXT: 20024: 7c 17 40 f9 ldr x28, [x27, #40]
|
2015-11-13 11:26:59 +08:00
|
|
|
|
|
|
|
.section .SUB,"ax",@progbits
|
|
|
|
nop
|
|
|
|
sub:
|
|
|
|
nop
|
|
|
|
|
|
|
|
# CHECK: Disassembly of section .SUB:
|
|
|
|
# CHECK-NEXT: $x.8:
|
2016-10-04 16:58:55 +08:00
|
|
|
# CHECK-NEXT: 2002c: 1f 20 03 d5 nop
|
2015-11-13 11:26:59 +08:00
|
|
|
# CHECK: sub:
|
2016-10-04 16:58:55 +08:00
|
|
|
# CHECK-NEXT: 20030: 1f 20 03 d5 nop
|
2015-11-13 11:26:59 +08:00
|
|
|
|
|
|
|
.section .R_AARCH64_CALL26,"ax",@progbits
|
|
|
|
call26:
|
|
|
|
bl sub
|
|
|
|
|
2016-10-04 16:58:55 +08:00
|
|
|
# S = 0x2002c, A = 0x4, P = 0x20034
|
2015-11-13 11:26:59 +08:00
|
|
|
# R = S + A - P = -0x4 = 0xfffffffc
|
|
|
|
# (R & 0x0ffffffc) >> 2 = 0x03ffffff
|
|
|
|
# 0x94000000 | 0x03ffffff = 0x97ffffff
|
|
|
|
# CHECK: Disassembly of section .R_AARCH64_CALL26:
|
|
|
|
# CHECK-NEXT: call26:
|
2016-10-04 16:58:55 +08:00
|
|
|
# CHECK-NEXT: 20034: ff ff ff 97 bl #-4
|
2015-11-13 11:26:59 +08:00
|
|
|
|
|
|
|
.section .R_AARCH64_JUMP26,"ax",@progbits
|
|
|
|
jump26:
|
|
|
|
b sub
|
|
|
|
|
2016-10-04 16:58:55 +08:00
|
|
|
# S = 0x2002c, A = 0x4, P = 0x20038
|
2015-11-13 11:26:59 +08:00
|
|
|
# R = S + A - P = -0x8 = 0xfffffff8
|
|
|
|
# (R & 0x0ffffffc) >> 2 = 0x03fffffe
|
|
|
|
# 0x14000000 | 0x03fffffe = 0x17fffffe
|
|
|
|
# CHECK: Disassembly of section .R_AARCH64_JUMP26:
|
|
|
|
# CHECK-NEXT: jump26:
|
2016-10-04 16:58:55 +08:00
|
|
|
# CHECK-NEXT: 20038: fe ff ff 17 b #-8
|
2015-11-21 05:35:38 +08:00
|
|
|
|
|
|
|
.section .R_AARCH64_LDST32_ABS_LO12_NC,"ax",@progbits
|
|
|
|
ldst32:
|
|
|
|
ldr s4, [x5, :lo12:foo32]
|
|
|
|
foo32:
|
|
|
|
.asciz "foo"
|
|
|
|
.size mystr, 3
|
|
|
|
|
2016-10-04 16:58:55 +08:00
|
|
|
# S = 0x2003c, A = 0x4
|
2015-11-21 05:35:38 +08:00
|
|
|
# R = ((S + A) & 0xFFC) << 8 = 0x00004000
|
|
|
|
# 0x00004000 | 0xbd4000a4 = 0xbd4040a4
|
|
|
|
# CHECK: Disassembly of section .R_AARCH64_LDST32_ABS_LO12_NC:
|
|
|
|
# CHECK-NEXT: ldst32:
|
2016-10-04 16:58:55 +08:00
|
|
|
# CHECK-NEXT: 2003c: a4 40 40 bd ldr s4, [x5, #64]
|
2015-11-21 05:35:38 +08:00
|
|
|
|
|
|
|
.section .R_AARCH64_LDST8_ABS_LO12_NC,"ax",@progbits
|
|
|
|
ldst8:
|
|
|
|
ldrsb x11, [x13, :lo12:foo8]
|
|
|
|
foo8:
|
|
|
|
.asciz "foo"
|
|
|
|
.size mystr, 3
|
|
|
|
|
2016-10-04 16:58:55 +08:00
|
|
|
# S = 0x20044, A = 0x4
|
2015-11-21 05:35:38 +08:00
|
|
|
# R = ((S + A) & 0xFFF) << 10 = 0x00012000
|
|
|
|
# 0x00012000 | 0x398001ab = 0x398121ab
|
|
|
|
# CHECK: Disassembly of section .R_AARCH64_LDST8_ABS_LO12_NC:
|
|
|
|
# CHECK-NEXT: ldst8:
|
2016-10-04 16:58:55 +08:00
|
|
|
# CHECK-NEXT: 20044: ab 21 81 39 ldrsb x11, [x13, #72]
|
2016-01-14 09:30:21 +08:00
|
|
|
|
|
|
|
.section .R_AARCH64_LDST128_ABS_LO12_NC,"ax",@progbits
|
|
|
|
ldst128:
|
|
|
|
ldr q20, [x19, #:lo12:foo128]
|
|
|
|
foo128:
|
|
|
|
.asciz "foo"
|
|
|
|
.size mystr, 3
|
|
|
|
|
2016-10-04 16:58:55 +08:00
|
|
|
# S = 0x2004c, A = 0x4
|
2016-01-14 09:30:21 +08:00
|
|
|
# R = ((S + A) & 0xFF8) << 6 = 0x00001400
|
|
|
|
# 0x00001400 | 0x3dc00274 = 0x3dc01674
|
|
|
|
# CHECK: Disassembly of section .R_AARCH64_LDST128_ABS_LO12_NC:
|
|
|
|
# CHECK: ldst128:
|
2016-10-04 16:58:55 +08:00
|
|
|
# CHECK: 2004c: 74 16 c0 3d ldr q20, [x19, #80]
|
2016-01-14 09:30:21 +08:00
|
|
|
#foo128:
|
2016-10-04 16:58:55 +08:00
|
|
|
# 20050: 66 6f 6f 00 .word
|
2016-01-15 09:49:51 +08:00
|
|
|
|
|
|
|
.section .R_AARCH64_LDST16_ABS_LO12_NC,"ax",@progbits
|
|
|
|
ldst16:
|
|
|
|
ldr h17, [x19, :lo12:foo16]
|
|
|
|
foo16:
|
|
|
|
.asciz "foo"
|
|
|
|
.size mystr, 3
|
|
|
|
|
2016-10-04 16:58:55 +08:00
|
|
|
# S = 0x20054, A = 0x4
|
2016-01-15 09:49:51 +08:00
|
|
|
# R = ((S + A) & 0x0FFC) << 9 = 0xb000
|
|
|
|
# 0xb000 | 0x7d400271 = 0x7d40b271
|
|
|
|
# CHECK: Disassembly of section .R_AARCH64_LDST16_ABS_LO12_NC:
|
|
|
|
# CHECK-NEXT: ldst16:
|
2016-10-04 16:58:55 +08:00
|
|
|
# CHECK-NEXT: 20054: 71 b2 40 7d ldr h17, [x19, #88]
|
2016-09-12 18:02:41 +08:00
|
|
|
|
|
|
|
.section .R_AARCH64_MOVW_UABS,"ax",@progbits
|
|
|
|
movz1:
|
|
|
|
movk x12, #:abs_g0_nc:uabs_label
|
|
|
|
movk x13, #:abs_g1_nc:uabs_label
|
|
|
|
movk x14, #:abs_g2_nc:uabs_label
|
|
|
|
movz x15, #:abs_g3:uabs_label
|
|
|
|
movk x16, #:abs_g3:uabs_label
|
|
|
|
|
|
|
|
## 4222124650659840 == (0xF << 48)
|
|
|
|
# CHECK: Disassembly of section .R_AARCH64_MOVW_UABS:
|
|
|
|
# CHECK-NEXT: movz1:
|
|
|
|
# CHECK-NEXT: 8c 01 80 f2 movk x12, #12
|
|
|
|
# CHECK-NEXT: ad 01 a0 f2 movk x13, #13, lsl #16
|
|
|
|
# CHECK-NEXT: ce 01 c0 f2 movk x14, #14, lsl #32
|
|
|
|
# CHECK-NEXT: ef 01 e0 d2 mov x15, #4222124650659840
|
|
|
|
# CHECK-NEXT: f0 01 e0 f2 movk x16, #15, lsl #48
|