Bump version to 19.1.0-rc3
[llvm-project.git] / llvm / test / ExecutionEngine / RuntimeDyld / X86 / MachO_x86-64_PIC_relocations.s
blob92052957a37da752ce302b280d52c793941e0069
1 # RUN: rm -rf %t && mkdir -p %t
2 # RUN: llvm-mc -triple=x86_64-apple-macosx10.9 -filetype=obj -o %t/test_x86-64.o %s
3 # RUN: llvm-rtdyld -triple=x86_64-apple-macosx10.9 -dummy-extern ds1=0xfffffffffffffffe -dummy-extern ds2=0xffffffffffffffff -verify -check=%s %t/test_x86-64.o
5 .section __TEXT,__text,regular,pure_instructions
6 .globl foo
7 .align 4, 0x90
8 foo:
9 retq
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
19 # Test PC-rel signed.
20 # rtdyld-check: decode_operand(insn2, 4) = x - next_pc(insn2)
21 insn2:
22 movl x(%rip), %eax
24 # Test PC-rel GOT relocation.
25 # Verify the alignment of the GOT entry, the contents of the GOT entry for y,
26 # and that the movq instruction references the correct GOT entry address:
27 # rtdyld-check: stub_addr(test_x86-64.o/__text, y)[2:0] = 0
28 # rtdyld-check: *{8}(stub_addr(test_x86-64.o/__text, y)) = y
29 # rtdyld-check: decode_operand(insn3, 4) = stub_addr(test_x86-64.o/__text, y) - next_pc(insn3)
30 insn3:
31 movq y@GOTPCREL(%rip), %rax
33 movl $0, %eax
34 retq
36 # Test processing of the __eh_frame section.
37 # rtdyld-check: *{8}(section_addr(test_x86-64.o, __eh_frame) + 0x20) = eh_frame_test - (section_addr(test_x86-64.o, __eh_frame) + 0x20)
38 eh_frame_test:
39 .cfi_startproc
40 retq
41 .cfi_endproc
43 .comm y,4,2
45 .section __DATA,__data
46 .globl x
47 .align 2
49 .long 5
51 # Test dummy-extern relocation.
52 # rtdyld-check: *{8}z1 = ds1
53 z1:
54 .quad ds1
56 # Test external-symbol relocation bypass: symbols with addr 0xffffffffffffffff
57 # don't have their relocations applied.
58 # rtdyld-check: *{8}z2 = 0
59 z2:
60 .quad ds2
62 # Test absolute symbols.
63 # rtdyld-check: abssym = 0xdeadbeef
64 .globl abssym
65 abssym = 0xdeadbeef
67 # Test subtractor relocations between named symbols.
68 # rtdyld-check: *{8}z3a = z4 - z5 + 4
69 z3a:
70 .quad z4 - z5 + 4
72 # Test subtractor relocations between anonymous symbols.
73 # rtdyld-check: *{8}z3b = (section_addr(test_x86-64.o, _tmp3) + 4) - (section_addr(test_x86-64.o, _tmp4)) + 8
74 z3b:
75 .quad Lanondiff_1 - Lanondiff_2 + 8
77 # Test subtractor relocations between named and anonymous symbols.
78 # rtdyld-check: *{8}z3c = z4 - (section_addr(test_x86-64.o, _tmp4)) + 12
79 z3c:
80 .quad z4 - Lanondiff_2 + 12
82 # Test subtractor relocations between anonymous and named symbols.
83 # rtdyld-check: *{8}z3d = (section_addr(test_x86-64.o, _tmp3) + 4) - z4 + 16
84 z3d:
85 .quad Lanondiff_1 - z4 + 16
87 .section __DATA,_tmp1
88 z4:
89 .byte 1
91 .section __DATA,_tmp2
92 z5:
93 .byte 1
95 .section __DATA,_tmp3
96 .long 1 # padding to make sure we handle non-zero offsets.
97 Lanondiff_1:
98 .byte 1
100 .section __DATA,_tmp4
101 Lanondiff_2:
102 .byte 1
104 .subsections_via_symbols