aboutsummaryrefslogtreecommitdiff
path: root/test/cfi/icall/external-call.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/cfi/icall/external-call.c')
-rw-r--r--test/cfi/icall/external-call.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/cfi/icall/external-call.c b/test/cfi/icall/external-call.c
new file mode 100644
index 000000000000..43fc25207562
--- /dev/null
+++ b/test/cfi/icall/external-call.c
@@ -0,0 +1,27 @@
+// RUN: %clangxx_cfi -o %t1 %s
+// RUN: %t1 c 1 2>&1 | FileCheck --check-prefix=CFI %s
+// RUN: %t1 s 2 2>&1 | FileCheck --check-prefix=CFI %s
+
+// This test uses jump tables containing PC-relative references to external
+// symbols, which the Mach-O object writer does not currently support.
+// XFAIL: darwin
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+int main(int argc, char **argv) {
+ // CFI: 1
+ fprintf(stderr, "1\n");
+
+ double (*fn)(double);
+ if (argv[1][0] == 's')
+ fn = sin;
+ else
+ fn = cos;
+
+ fn(atof(argv[2]));
+
+ // CFI: 2
+ fprintf(stderr, "2\n");
+}