summaryrefslogtreecommitdiffstats
path: root/cmake/modules/asan-wrapper
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/modules/asan-wrapper')
-rwxr-xr-xcmake/modules/asan-wrapper55
1 files changed, 55 insertions, 0 deletions
diff --git a/cmake/modules/asan-wrapper b/cmake/modules/asan-wrapper
new file mode 100755
index 00000000..5d541033
--- /dev/null
+++ b/cmake/modules/asan-wrapper
@@ -0,0 +1,55 @@
1#!/bin/sh
2
3# The MIT License (MIT)
4#
5# Copyright (c)
6# 2013 Matthew Arsenault
7# 2015-2016 RWTH Aachen University, Federal Republic of Germany
8#
9# Permission is hereby granted, free of charge, to any person obtaining a copy
10# of this software and associated documentation files (the "Software"), to deal
11# in the Software without restriction, including without limitation the rights
12# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13# copies of the Software, and to permit persons to whom the Software is
14# furnished to do so, subject to the following conditions:
15#
16# The above copyright notice and this permission notice shall be included in all
17# copies or substantial portions of the Software.
18#
19# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25# SOFTWARE.
26
27# This script is a wrapper for AddressSanitizer. In some special cases you need
28# to preload AddressSanitizer to avoid error messages - e.g. if you're
29# preloading another library to your application. At the moment this script will
30# only do something, if we're running on a Linux platform. OSX might not be
31# affected.
32
33
34# Exit immediately, if platform is not Linux.
35if [ "$(uname)" != "Linux" ]
36then
37 exec $@
38fi
39
40
41# Get the used libasan of the application ($1). If a libasan was found, it will
42# be prepended to LD_PRELOAD.
43libasan=$(ldd $1 | grep libasan | sed "s/^[[:space:]]//" | cut -d' ' -f1)
44if [ -n "$libasan" ]
45then
46 if [ -n "$LD_PRELOAD" ]
47 then
48 export LD_PRELOAD="$libasan:$LD_PRELOAD"
49 else
50 export LD_PRELOAD="$libasan"
51 fi
52fi
53
54# Execute the application.
55exec $@