]> git.saurik.com Git - apple/configd.git/blob - update-sanitizer-dylib-references
configd-963.tar.gz
[apple/configd.git] / update-sanitizer-dylib-references
1 #!/bin/sh
2
3 #
4 # fix address-sanitizer library @rpath references
5 #
6
7 xsan_setup() {
8 XSAN_DIR="/usr/local/lib/sanitizers"
9 case "${PLATFORM_NAME}" in
10 macosx )
11 ASAN_DYLIB="clang_rt.asan_osx_dynamic.dylib"
12 TSAN_DYLIB="clang_rt.tsan_osx_dynamic.dylib"
13 ;;
14 iphoneos )
15 ASAN_DYLIB="clang_rt.asan_ios_dynamic.dylib"
16 TSAN_DYLIB="clang_rt.tsan_ios_dynamic.dylib"
17 ;;
18 iphonesimulator )
19 ASAN_DYLIB="clang_rt.asan_iossim_dynamic.dylib"
20 TSAN_DYLIB="clang_rt.tsan_iossim_dynamic.dylib"
21 ;;
22 tvos )
23 ASAN_DYLIB="clang_rt.asan_tvos_dynamic.dylib"
24 TSAN_DYLIB="clang_rt.tsan_tvos_dynamic.dylib"
25 ;;
26 tvsosimulator )
27 ASAN_DYLIB="clang_rt.asan_tvossim_dynamic.dylib"
28 TSAN_DYLIB="clang_rt.tsan_tvossim_dynamic.dylib"
29 ;;
30 watchos )
31 ASAN_DYLIB="clang_rt.asan_watchos_dynamic.dylib"
32 TSAN_DYLIB="clang_rt.tsan_watchos_dynamic.dylib"
33 ;;
34 watchsimulator )
35 ASAN_DYLIB="clang_rt.asan_watchossim_dynamic.dylib"
36 TSAN_DYLIB="clang_rt.tsan_watchossim_dynamic.dylib"
37 ;;
38 * )
39 ASAN_DYLIB="clang_rt.asan_$(RC_PROJECT_COMPILATION_PLATFORM)_dynamic.dylib"
40 TSAN_DYLIB="clang_rt.tsan_$(RC_PROJECT_COMPILATION_PLATFORM)_dynamic.dylib"
41 ;;
42 esac
43 }
44
45 xsan_setup=0
46 for VARIANT in ${BUILD_VARIANTS}
47 do
48 case "${VARIANT}" in
49 "asan" )
50 #
51 # change address sanitizer @rpath reference
52 #
53 ASAN_FILE="${DSTROOT}${INSTALL_PATH}/"
54 if [ -n "${EXECUTABLE_FOLDER_PATH}" ]; then
55 ASAN_FILE+="${EXECUTABLE_FOLDER_PATH}/"
56 fi
57 ASAN_FILE+="${EXECUTABLE_PREFIX}${PRODUCT_NAME}_asan${EXECUTABLE_SUFFIX}"
58
59 if [ -x "${ASAN_FILE}" ]; then
60 if [ ${xsan_setup} -eq 0 ]; then
61 xsan_setup
62 xsan_setup=1
63 fi
64
65 install_name_tool \
66 -change \
67 "@rpath/lib${ASAN_DYLIB}" \
68 "${XSAN_DIR}/lib${ASAN_DYLIB}" \
69 "${ASAN_FILE}"
70 if [ $? -ne 0 ]; then
71 echo "install_name_tool failed"
72 printenv | sort
73 exit 1
74 fi
75 fi
76 ;;
77 "tsan" )
78 #
79 # change thread sanitizer @rpath reference
80 #
81 TSAN_FILE="${DSTROOT}${INSTALL_PATH}/"
82 if [ -n "${EXECUTABLE_FOLDER_PATH}" ]; then
83 TSAN_FILE+="${EXECUTABLE_FOLDER_PATH}/"
84 fi
85 TSAN_FILE+="${EXECUTABLE_PREFIX}${PRODUCT_NAME}_tsan${EXECUTABLE_SUFFIX}"
86
87 if [ -x "${TSAN_FILE}" ]; then
88 if [ ${xsan_setup} -eq 0 ]; then
89 xsan_setup
90 xsan_setup=1
91 fi
92
93 install_name_tool \
94 -change \
95 "@rpath/lib${TSAN_DYLIB}" \
96 "${XSAN_DIR}/lib${TSAN_DYLIB}" \
97 "${TSAN_FILE}"
98 if [ $? -ne 0 ]; then
99 echo "install_name_tool failed"
100 printenv | sort
101 exit 1
102 fi
103 fi
104 ;;
105 * )
106 ;;
107 esac
108 done