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