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