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 + +[[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! +}