]> git.proxmox.com Git - rustc.git/blame - src/libcompiler_builtins/compiler-rt/test/asan/TestCases/Darwin/unset-insert-libraries-on-exec.cc
New upstream version 1.24.1+dfsg1
[rustc.git] / src / libcompiler_builtins / compiler-rt / test / asan / TestCases / Darwin / unset-insert-libraries-on-exec.cc
CommitLineData
1a4d82fc
JJ
1// Make sure ASan removes the runtime library from DYLD_INSERT_LIBRARIES before
2// executing other programs.
3
4// RUN: %clangxx_asan %s -o %t
5// RUN: %clangxx %p/../Helpers/echo-env.cc -o %T/echo-env
92a42be0 6// RUN: %clangxx -DSHARED_LIB %s \
1a4d82fc
JJ
7// RUN: -dynamiclib -o %t-darwin-dummy-shared-lib-so.dylib
8
9// Make sure DYLD_INSERT_LIBRARIES doesn't contain the runtime library before
10// execl().
11
12// RUN: %run %t %T/echo-env >/dev/null 2>&1
92a42be0 13// RUN: env DYLD_INSERT_LIBRARIES=%t-darwin-dummy-shared-lib-so.dylib \
1a4d82fc 14// RUN: %run %t %T/echo-env 2>&1 | FileCheck %s || exit 1
92a42be0
SL
15
16#if !defined(SHARED_LIB)
1a4d82fc
JJ
17#include <unistd.h>
18int main(int argc, char *argv[]) {
19 execl(argv[1], argv[1], "DYLD_INSERT_LIBRARIES", NULL);
20 // CHECK: {{DYLD_INSERT_LIBRARIES = .*darwin-dummy-shared-lib-so.dylib.*}}
21 return 0;
22}
92a42be0
SL
23#else // SHARED_LIB
24void foo() {}
25#endif // SHARED_LIB