Changeset View
Changeset View
Standalone View
Standalone View
cmake/modules/asan-wrapper
- This file was added.
Property | Old Value | New Value |
---|---|---|
File Mode | null | 100755 |
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. | ||||
35 | if [ "$(uname)" != "Linux" ] | ||||
36 | then | ||||
37 | exec $@ | ||||
38 | fi | ||||
39 | | ||||
40 | | ||||
41 | # Get the used libasan of the application ($1). If a libasan was found, it will | ||||
42 | # be prepended to LD_PRELOAD. | ||||
43 | libasan=$(ldd $1 | grep libasan | sed "s/^[[:space:]]//" | cut -d' ' -f1) | ||||
44 | if [ -n "$libasan" ] | ||||
45 | then | ||||
46 | if [ -n "$LD_PRELOAD" ] | ||||
47 | then | ||||
48 | export LD_PRELOAD="$libasan:$LD_PRELOAD" | ||||
49 | else | ||||
50 | export LD_PRELOAD="$libasan" | ||||
51 | fi | ||||
52 | fi | ||||
53 | | ||||
54 | # Execute the application. | ||||
55 | exec $@ |