summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2014-06-27 20:20:57 +0000
committerLang Hames <lhames@gmail.com>2014-06-27 20:20:57 +0000
commitc3747f276a212e73119980479409281df57a8269 (patch)
tree0ef07885b61475d454088c60c249aee194e70b03 /test
parent63195d7e5a1d8715566c5a33902885e28a8977c2 (diff)
downloadllvm-c3747f276a212e73119980479409281df57a8269.tar.gz
llvm-c3747f276a212e73119980479409281df57a8269.tar.bz2
llvm-c3747f276a212e73119980479409281df57a8269.tar.xz
[RuntimeDyld] Add a framework for testing relocation logic in RuntimeDyld.
This patch adds a "-verify" mode to the llvm-rtdyld utility. In verify mode, llvm-rtdyld will test supplied expressions against the linked program images that it creates in memory. This scheme can be used to verify the correctness of the relocation logic applied by RuntimeDyld. The expressions to test will be read out of files passed via the -check option (there may be more than one of these). Expressions to check are extracted from lines of the form: # rtdyld-check: <expression> This system is designed to fit the llvm-lit regression test workflow. It is format and target agnostic, and supports verification of images linked for remote targets. The expression language is defined in llvm/include/llvm/RuntimeDyldChecker.h . Examples can be found in test/ExecutionEngine/RuntimeDyld. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211956 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/ExecutionEngine/RuntimeDyld/MachO_x86-64_PIC_relocations.s32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/ExecutionEngine/RuntimeDyld/MachO_x86-64_PIC_relocations.s b/test/ExecutionEngine/RuntimeDyld/MachO_x86-64_PIC_relocations.s
new file mode 100644
index 0000000000..6c27b62dbf
--- /dev/null
+++ b/test/ExecutionEngine/RuntimeDyld/MachO_x86-64_PIC_relocations.s
@@ -0,0 +1,32 @@
+# RUN: llvm-mc -triple=x86_64-apple-macosx10.9 -relocation-model=pic -filetype=obj -o %s.o %s
+# RUN: llvm-rtdyld -triple=x86_64-apple-macosx10.9 -verify -check=%s %s.o
+# RUN: rm %s.o
+
+ .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
+ movl $0, %eax
+ retq
+
+ .section __DATA,__data
+ .globl x
+ .align 2
+x:
+ .long 5
+
+.subsections_via_symbols