1 # RUN: llvm-mc -triple=x86_64-apple-macosx10.9 -filetype=obj -o %T/test_x86-64.o %s 2 # 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 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 # Test processing of the __eh_frame section. 35 # rtdyld-check: *{8}(section_addr(test_x86-64.o, __eh_frame) + 0x20) = eh_frame_test - (section_addr(test_x86-64.o, __eh_frame) + 0x20) 36 eh_frame_test: 37 .cfi_startproc 38 retq 39 .cfi_endproc 40 41 .comm y,4,2 42 43 .section __DATA,__data 44 .globl x 45 .align 2 46 x: 47 .long 5 48 49 # Test dummy-extern relocation. 50 # rtdyld-check: *{8}z1 = ds1 51 z1: 52 .quad ds1 53 54 # Test external-symbol relocation bypass: symbols with addr 0xffffffffffffffff 55 # don't have their relocations applied. 56 # rtdyld-check: *{8}z2 = 0 57 z2: 58 .quad ds2 59 60 # Test absolute symbols. 61 # rtdyld-check: abssym = 0xdeadbeef 62 .globl abssym 63 abssym = 0xdeadbeef 64 65 # Test subtractor relocations between named symbols. 66 # rtdyld-check: *{8}z3a = z4 - z5 + 4 67 z3a: 68 .quad z4 - z5 + 4 69 70 # Test subtractor relocations between anonymous symbols. 71 # rtdyld-check: *{8}z3b = (section_addr(test_x86-64.o, _tmp3) + 4) - (section_addr(test_x86-64.o, _tmp4)) + 8 72 z3b: 73 .quad Lanondiff_1 - Lanondiff_2 + 8 74 75 # Test subtractor relocations between named and anonymous symbols. 76 # rtdyld-check: *{8}z3c = z4 - (section_addr(test_x86-64.o, _tmp4)) + 12 77 z3c: 78 .quad z4 - Lanondiff_2 + 12 79 80 # Test subtractor relocations between anonymous and named symbols. 81 # rtdyld-check: *{8}z3d = (section_addr(test_x86-64.o, _tmp3) + 4) - z4 + 16 82 z3d: 83 .quad Lanondiff_1 - z4 + 16 84 85 .section __DATA,_tmp1 86 z4: 87 .byte 1 88 89 .section __DATA,_tmp2 90 z5: 91 .byte 1 92 93 .section __DATA,_tmp3 94 .long 1 # padding to make sure we handle non-zero offsets. 95 Lanondiff_1: 96 .byte 1 97 98 .section __DATA,_tmp4 99 Lanondiff_2: 100 .byte 1 101 102 .subsections_via_symbols 103