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 -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. 66 # rtdyld-check: *{8}z3 = z4 - z5 + 4 67 z3: 68 .quad z4 - z5 + 4 69 70 .section __DATA,_tmp1 71 z4: 72 .byte 1 73 74 .section __DATA,_tmp2 75 z5: 76 .byte 1 77 78 .subsections_via_symbols 79