summaryrefslogtreecommitdiff
path: root/test/msan/wrap_indirect_calls.cc
blob: b4bac1ecbd22284e8ec841532d829690018a0c71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Test indirect call wrapping in MemorySanitizer.

// RUN: %clangxx_msan -O0 %p/wrap_indirect_calls/two.cc -fPIC -shared -o %t-two-so.so
// RUN: %clangxx_msan -O0 %p/wrap_indirect_calls/wrapper.cc -fPIC -shared -o %t-wrapper-so.so

// Disable fast path.

// RUN: %clangxx_msan -O0 %p/wrap_indirect_calls/caller.cc %p/wrap_indirect_calls/one.cc %s \
// RUN:     %t-two-so.so %t-wrapper-so.so \
// RUN:     -mllvm -msan-wrap-indirect-calls=wrapper \
// RUN:     -mllvm -msan-wrap-indirect-calls-fast=0 \
// RUN:     -DSLOW=1 \
// RUN:     -Wl,--defsym=__executable_start=0 -o %t
// RUN: %t

// Enable fast path, call from executable, -O0.

// RUN: %clangxx_msan -O0 %p/wrap_indirect_calls/caller.cc %p/wrap_indirect_calls/one.cc %s \
// RUN:     %t-two-so.so %t-wrapper-so.so \
// RUN:     -mllvm -msan-wrap-indirect-calls=wrapper \
// RUN:     -mllvm -msan-wrap-indirect-calls-fast=1 \
// RUN:     -DSLOW=0 \
// RUN:     -Wl,--defsym=__executable_start=0 -o %t
// RUN: %t

// Enable fast path, call from executable, -O3.

// RUN: %clangxx_msan -O3 %p/wrap_indirect_calls/caller.cc %p/wrap_indirect_calls/one.cc %s \
// RUN:     %t-two-so.so %t-wrapper-so.so \
// RUN:     -mllvm -msan-wrap-indirect-calls=wrapper \
// RUN:     -mllvm -msan-wrap-indirect-calls-fast=1 \
// RUN:     -DSLOW=0 \
// RUN:     -Wl,--defsym=__executable_start=0 -o %t
// RUN: %t

// Enable fast path, call from DSO, -O0.

// RUN: %clangxx_msan -O0 %p/wrap_indirect_calls/caller.cc %p/wrap_indirect_calls/one.cc -shared \
// RUN:     %t-two-so.so %t-wrapper-so.so \
// RUN:     -mllvm -msan-wrap-indirect-calls=wrapper \
// RUN:     -mllvm -msan-wrap-indirect-calls-fast=1 \
// RUN:     -DSLOW=0 \
// RUN:     -Wl,--defsym=__executable_start=0 -o %t-caller-so.so
// RUN: %clangxx_msan -O0 %s %t-caller-so.so %t-two-so.so %t-wrapper-so.so -o %t
// RUN: %t

// Enable fast path, call from DSO, -O3.

// RUN: %clangxx_msan -O3 %p/wrap_indirect_calls/caller.cc %p/wrap_indirect_calls/one.cc -shared \
// RUN:     %t-two-so.so %t-wrapper-so.so \
// RUN:     -mllvm -msan-wrap-indirect-calls=wrapper \
// RUN:     -mllvm -msan-wrap-indirect-calls-fast=1 \
// RUN:     -DSLOW=0 \
// RUN:     -Wl,--defsym=__executable_start=0 -o %t-caller-so.so
// RUN: %clangxx_msan -O3 %s %t-caller-so.so %t-two-so.so %t-wrapper-so.so -o %t
// RUN: %t

// The actual test is in multiple files in wrap_indirect_calls/ directory.
void run_test();

int main() {
  run_test();
  return 0;
}