[PATCH] D31379: [XRay][compiler-rt] Add a test for -fPIE
Dean Michael Berris via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 26 20:35:18 PDT 2017
dberris created this revision.
Ensure that builds using -fPIE and -mpie-copy-relocations and XRay work
just fine.
https://reviews.llvm.org/D31379
Files:
test/xray/TestCases/Linux/pie_test.cc
Index: test/xray/TestCases/Linux/pie_test.cc
===================================================================
--- /dev/null
+++ test/xray/TestCases/Linux/pie_test.cc
@@ -0,0 +1,34 @@
+// Test to ensure if we handle PIE executables properly.
+
+// RUN: %clangxx_xray -fxray-instrument -std=c++11 -fPIE %s -o %t
+// RUN: XRAY_OPTIONS="patch_premain=true verbosity=1 xray_logfile_base=pie-test-logging-" %run %t 2>&1 | FileCheck %s
+//
+// RUN: %clangxx_xray -fxray-instrument -std=c++11 -fPIE -mpie-copy-relocations %s -o %t
+// RUN: XRAY_OPTIONS="patch_premain=true verbosity=1 xray_logfile_base=pie-test-logging-" %run %t 2>&1 | FileCheck %s
+// RUN: rm pie-test-logging-*
+
+#include <cstdio>
+
+[[clang::xray_always_instrument]]
+unsigned short foo (unsigned b);
+
+[[clang::xray_always_instrument]]
+unsigned short bar (unsigned short a)
+{
+ printf("bar() is always instrumented!\n");
+ return foo(a);
+}
+
+unsigned short foo (unsigned b)
+{
+ printf("foo() is always instrumented!\n");
+ return b + b + 5;
+}
+
+int main ()
+{
+ // CHECK: XRay: Log file in 'pie-test-logging-{{.*}}'
+ bar(10);
+ // CHECK: bar() is always instrumented!
+ // CHECK-NEXT: foo() is always instrumented!
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31379.93094.patch
Type: text/x-patch
Size: 1203 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170327/47c89870/attachment.bin>
More information about the llvm-commits
mailing list