reloc-directive.s
1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
## Target specific relocation support is tested in MC/$target/*reloc-directive*.s
# RUN: llvm-mc -triple=x86_64 %s | FileCheck %s --check-prefix=ASM
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t
# RUN: llvm-readobj -r %t | FileCheck %s
# ASM: .Ltmp0:
# ASM-NEXT: .reloc (.Ltmp0+3)-2, R_X86_64_NONE, foo
# ASM-NEXT: .Ltmp1:
# ASM-NEXT: .reloc .Ltmp1-1, R_X86_64_NONE, foo
# ASM-NEXT: .Ltmp2:
# ASM-NEXT: .reloc 2+.Ltmp2, R_X86_64_NONE, foo
# ASM-NEXT: .reloc (1+foo)+3, R_X86_64_NONE, data+1
# CHECK: 0x2 R_X86_64_NONE foo 0x0
# CHECK-NEXT: 0x0 R_X86_64_NONE foo 0x0
# CHECK-NEXT: 0x3 R_X86_64_NONE foo 0x0
# CHECK-NEXT: 0x4 R_X86_64_NONE data 0x1
.text
.globl foo
foo:
ret
.reloc .+3-2, R_X86_64_NONE, foo
.reloc .-1, R_X86_64_NONE, foo
.reloc 2+., R_X86_64_NONE, foo
.reloc 1+foo+3, R_X86_64_NONE, data+1
.data
.globl data
data:
.long 0
# RUN: not llvm-mc -filetype=obj -triple=x86_64 --defsym=ERR=1 %s 2>&1 | FileCheck %s --check-prefix=ERR
.ifdef ERR
.text
.globl a, b
a: ret
b: ret
x: ret
y: ret
# ERR: {{.*}}.s:[[#@LINE+1]]:10: error: expected comma
.reloc 0 R_X86_64_NONE, a
# ERR: {{.*}}.s:[[#@LINE+1]]:8: error: .reloc offset is negative
.reloc -1, R_X86_64_NONE, a
# ERR: {{.*}}.s:[[#@LINE+1]]:8: error: .reloc offset is not relocatable
.reloc 2*., R_X86_64_NONE, a
# ERR: {{.*}}.s:[[#@LINE+1]]:8: error: .reloc offset is not relocatable
.reloc a+a, R_X86_64_NONE, a
## GNU as accepts a-a but rejects b-a.
# ERR: {{.*}}.s:[[#@LINE+1]]:8: error: .reloc offset is not representable
.reloc a-a, R_X86_64_NONE, a
## TODO GNU as accepts x-x and y-x.
# ERR: {{.*}}.s:[[#@LINE+1]]:8: error: .reloc offset is not representable
.reloc x-x, R_X86_64_NONE, a
# ERR: {{.*}}.s:[[#@LINE+1]]:8: error: directional label undefined
.reloc 1f, R_X86_64_NONE, a
.endif