2016-05-18 08:27:17 +08:00
|
|
|
# RUN: llvm-mc -triple=x86_64-apple-macosx10.9 -filetype=obj -o %T/test_x86-64.o %s
|
2015-07-04 09:35:26 +08:00
|
|
|
# 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
|
2014-07-23 12:05:58 +08:00
|
|
|
|
2014-06-28 04:20:57 +08:00
|
|
|
.section __TEXT,__text,regular,pure_instructions
|
|
|
|
.globl foo
|
|
|
|
.align 4, 0x90
|
|
|
|
foo:
|
|
|
|
retq
|
|
|
|
|
|
|
|
.globl main
|
|
|
|
.align 4, 0x90
|
|
|
|
main:
|
|
|
|
# Test PC-rel branch.
|
|
|
|
# rtdyld-check: decode_operand(insn1, 0) = foo - next_pc(insn1)
|
|
|
|
insn1:
|
|
|
|
callq foo
|
|
|
|
|
|
|
|
# Test PC-rel signed.
|
|
|
|
# rtdyld-check: decode_operand(insn2, 4) = x - next_pc(insn2)
|
|
|
|
insn2:
|
|
|
|
movl x(%rip), %eax
|
[MCJIT] Refactor and add stub inspection to the RuntimeDyldChecker framework.
This patch introduces a 'stub_addr' builtin that can be used to find the address
of the stub for a given (<file>, <section>, <symbol>) tuple. This address can be
used both to verify the contents of stubs (by loading from the returned address)
and to verify references to stubs (by comparing against the returned address).
Example (1) - Verifying stub contents:
Load 8 bytes (assuming a 64-bit target) from the stub for 'x' in the __text
section of f.o, and compare that value against the addres of 'x'.
# rtdyld-check: *{8}(stub_addr(f.o, __text, x) = x
Example (2) - Verifying references to stubs:
Decode the immediate of the instruction at label 'l', and verify that it's
equal to the offset from the next instruction's PC to the stub for 'y' in the
__text section of f.o (i.e. it's the correct PC-rel difference).
# rtdyld-check: decode_operand(l, 4) = stub_addr(f.o, __text, y) - next_pc(l)
l:
movq y@GOTPCREL(%rip), %rax
Since stub inspection requires cooperation with RuntimeDyldImpl this patch
pimpl-ifies RuntimeDyldChecker. Its implementation is moved in to a new class,
RuntimeDyldCheckerImpl, that has access to the definition of RuntimeDyldImpl.
llvm-svn: 213698
2014-07-23 06:47:39 +08:00
|
|
|
|
|
|
|
# Test PC-rel GOT relocation.
|
|
|
|
# Verify both the contents of the GOT entry for y, and that the movq instruction
|
|
|
|
# references the correct GOT entry address:
|
2014-08-20 05:26:36 +08:00
|
|
|
# rtdyld-check: *{8}(stub_addr(test_x86-64.o, __text, y)) = y
|
|
|
|
# rtdyld-check: decode_operand(insn3, 4) = stub_addr(test_x86-64.o, __text, y) - next_pc(insn3)
|
[MCJIT] Refactor and add stub inspection to the RuntimeDyldChecker framework.
This patch introduces a 'stub_addr' builtin that can be used to find the address
of the stub for a given (<file>, <section>, <symbol>) tuple. This address can be
used both to verify the contents of stubs (by loading from the returned address)
and to verify references to stubs (by comparing against the returned address).
Example (1) - Verifying stub contents:
Load 8 bytes (assuming a 64-bit target) from the stub for 'x' in the __text
section of f.o, and compare that value against the addres of 'x'.
# rtdyld-check: *{8}(stub_addr(f.o, __text, x) = x
Example (2) - Verifying references to stubs:
Decode the immediate of the instruction at label 'l', and verify that it's
equal to the offset from the next instruction's PC to the stub for 'y' in the
__text section of f.o (i.e. it's the correct PC-rel difference).
# rtdyld-check: decode_operand(l, 4) = stub_addr(f.o, __text, y) - next_pc(l)
l:
movq y@GOTPCREL(%rip), %rax
Since stub inspection requires cooperation with RuntimeDyldImpl this patch
pimpl-ifies RuntimeDyldChecker. Its implementation is moved in to a new class,
RuntimeDyldCheckerImpl, that has access to the definition of RuntimeDyldImpl.
llvm-svn: 213698
2014-07-23 06:47:39 +08:00
|
|
|
insn3:
|
|
|
|
movq y@GOTPCREL(%rip), %rax
|
|
|
|
|
|
|
|
movl $0, %eax
|
2014-06-28 04:20:57 +08:00
|
|
|
retq
|
|
|
|
|
2015-04-15 11:39:22 +08:00
|
|
|
# Test processing of the __eh_frame section.
|
|
|
|
# rtdyld-check: *{8}(section_addr(test_x86-64.o, __eh_frame) + 0x20) = eh_frame_test - (section_addr(test_x86-64.o, __eh_frame) + 0x20)
|
|
|
|
eh_frame_test:
|
|
|
|
.cfi_startproc
|
|
|
|
retq
|
|
|
|
.cfi_endproc
|
|
|
|
|
[MCJIT] Refactor and add stub inspection to the RuntimeDyldChecker framework.
This patch introduces a 'stub_addr' builtin that can be used to find the address
of the stub for a given (<file>, <section>, <symbol>) tuple. This address can be
used both to verify the contents of stubs (by loading from the returned address)
and to verify references to stubs (by comparing against the returned address).
Example (1) - Verifying stub contents:
Load 8 bytes (assuming a 64-bit target) from the stub for 'x' in the __text
section of f.o, and compare that value against the addres of 'x'.
# rtdyld-check: *{8}(stub_addr(f.o, __text, x) = x
Example (2) - Verifying references to stubs:
Decode the immediate of the instruction at label 'l', and verify that it's
equal to the offset from the next instruction's PC to the stub for 'y' in the
__text section of f.o (i.e. it's the correct PC-rel difference).
# rtdyld-check: decode_operand(l, 4) = stub_addr(f.o, __text, y) - next_pc(l)
l:
movq y@GOTPCREL(%rip), %rax
Since stub inspection requires cooperation with RuntimeDyldImpl this patch
pimpl-ifies RuntimeDyldChecker. Its implementation is moved in to a new class,
RuntimeDyldCheckerImpl, that has access to the definition of RuntimeDyldImpl.
llvm-svn: 213698
2014-07-23 06:47:39 +08:00
|
|
|
.comm y,4,2
|
|
|
|
|
2014-06-28 04:20:57 +08:00
|
|
|
.section __DATA,__data
|
|
|
|
.globl x
|
|
|
|
.align 2
|
|
|
|
x:
|
|
|
|
.long 5
|
|
|
|
|
2015-07-04 09:35:26 +08:00
|
|
|
# Test dummy-extern relocation.
|
|
|
|
# rtdyld-check: *{8}z1 = ds1
|
|
|
|
z1:
|
|
|
|
.quad ds1
|
|
|
|
|
|
|
|
# Test external-symbol relocation bypass: symbols with addr 0xffffffffffffffff
|
|
|
|
# don't have their relocations applied.
|
|
|
|
# rtdyld-check: *{8}z2 = 0
|
|
|
|
z2:
|
|
|
|
.quad ds2
|
|
|
|
|
2015-10-18 09:41:37 +08:00
|
|
|
# Test absolute symbols.
|
|
|
|
# rtdyld-check: abssym = 0xdeadbeef
|
|
|
|
.globl abssym
|
|
|
|
abssym = 0xdeadbeef
|
|
|
|
|
2016-05-20 07:26:05 +08:00
|
|
|
# Test subtractor relocations between named symbols.
|
|
|
|
# rtdyld-check: *{8}z3a = z4 - z5 + 4
|
|
|
|
z3a:
|
2015-09-11 05:05:58 +08:00
|
|
|
.quad z4 - z5 + 4
|
2015-09-09 11:14:29 +08:00
|
|
|
|
2016-05-20 07:26:05 +08:00
|
|
|
# Test subtractor relocations between anonymous symbols.
|
|
|
|
# rtdyld-check: *{8}z3b = (section_addr(test_x86-64.o, _tmp3) + 4) - (section_addr(test_x86-64.o, _tmp4)) + 8
|
|
|
|
z3b:
|
|
|
|
.quad Lanondiff_1 - Lanondiff_2 + 8
|
|
|
|
|
|
|
|
# Test subtractor relocations between named and anonymous symbols.
|
|
|
|
# rtdyld-check: *{8}z3c = z4 - (section_addr(test_x86-64.o, _tmp4)) + 12
|
|
|
|
z3c:
|
|
|
|
.quad z4 - Lanondiff_2 + 12
|
|
|
|
|
|
|
|
# Test subtractor relocations between anonymous and named symbols.
|
|
|
|
# rtdyld-check: *{8}z3d = (section_addr(test_x86-64.o, _tmp3) + 4) - z4 + 16
|
|
|
|
z3d:
|
|
|
|
.quad Lanondiff_1 - z4 + 16
|
|
|
|
|
2015-09-09 11:14:29 +08:00
|
|
|
.section __DATA,_tmp1
|
|
|
|
z4:
|
|
|
|
.byte 1
|
|
|
|
|
|
|
|
.section __DATA,_tmp2
|
|
|
|
z5:
|
|
|
|
.byte 1
|
|
|
|
|
2016-05-20 07:26:05 +08:00
|
|
|
.section __DATA,_tmp3
|
|
|
|
.long 1 # padding to make sure we handle non-zero offsets.
|
|
|
|
Lanondiff_1:
|
|
|
|
.byte 1
|
|
|
|
|
|
|
|
.section __DATA,_tmp4
|
|
|
|
Lanondiff_2:
|
|
|
|
.byte 1
|
|
|
|
|
2014-06-28 04:20:57 +08:00
|
|
|
.subsections_via_symbols
|