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