728d07396732d0fb786bb47759acbdaf27efb3f1
[oota-llvm.git] / test / ExecutionEngine / RuntimeDyld / X86 / MachO_x86-64_PIC_relocations.s
1 # RUN: llvm-mc -triple=x86_64-apple-macosx10.9 -relocation-model=pic -filetype=obj -o %T/foo.o %s
2 # RUN: sed "s,<filename>,%/T/foo.o,g" %s > %T/foo.s
3 # RUN: llvm-rtdyld -triple=x86_64-apple-macosx10.9 -verify -check=%T/foo.s %/T/foo.o
4
5         .section        __TEXT,__text,regular,pure_instructions
6         .globl  foo
7         .align  4, 0x90
8 foo:
9         retq
10
11         .globl  main
12         .align  4, 0x90
13 main:
14 # Test PC-rel branch.
15 # rtdyld-check: decode_operand(insn1, 0) = foo - next_pc(insn1)
16 insn1:
17         callq   foo
18
19 # Test PC-rel signed.
20 # rtdyld-check: decode_operand(insn2, 4) = x - next_pc(insn2)
21 insn2:
22         movl    x(%rip), %eax
23
24 # Test PC-rel GOT relocation.
25 # Verify both the contents of the GOT entry for y, and that the movq instruction
26 # references the correct GOT entry address:
27 # rtdyld-check: *{8}(stub_addr(<filename>, __text, y)) = y
28 # rtdyld-check: decode_operand(insn3, 4) = stub_addr(<filename>, __text, y) - next_pc(insn3)
29 insn3:
30         movq    y@GOTPCREL(%rip), %rax
31
32         movl    $0, %eax
33         retq
34
35         .comm   y,4,2
36
37         .section        __DATA,__data
38         .globl  x
39         .align  2
40 x:
41         .long   5
42
43 .subsections_via_symbols