]> git.saurik.com Git - apple/configd.git/blob - update-sanitizer-dylib-references
configd-1109.101.1.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 echo ""
40 echo "*** Unexpected PLATFORM_NAME \"${PLATFORM_NAME}\", using \"$(RC_PROJECT_COMPILATION_PLATFORM)\""
41 echo ""
42 ASAN_DYLIB="clang_rt.asan_$(RC_PROJECT_COMPILATION_PLATFORM)_dynamic.dylib"
43 TSAN_DYLIB="clang_rt.tsan_$(RC_PROJECT_COMPILATION_PLATFORM)_dynamic.dylib"
44 ;;
45 esac
46 }
47
48 xsan_setup=0
49 for VARIANT in ${BUILD_VARIANTS}
50 do
51 case "${VARIANT}" in
52 "asan" )
53 #
54 # change address sanitizer @rpath reference
55 #
56 ASAN_FILE="${DSTROOT}${INSTALL_PATH}/"
57 if [ -n "${EXECUTABLE_FOLDER_PATH}" ]; then
58 ASAN_FILE+="${EXECUTABLE_FOLDER_PATH}/"
59 fi
60 ASAN_FILE+="${EXECUTABLE_PREFIX}${PRODUCT_NAME}_asan${EXECUTABLE_SUFFIX}"
61
62 if [ -x "${ASAN_FILE}" ]; then
63 if [ ${xsan_setup} -eq 0 ]; then
64 xsan_setup
65 xsan_setup=1
66 fi
67
68 install_name_tool \
69 -change \
70 "@rpath/lib${ASAN_DYLIB}" \
71 "${XSAN_DIR}/lib${ASAN_DYLIB}" \
72 "${ASAN_FILE}"
73 if [ $? -ne 0 ]; then
74 echo "install_name_tool failed"
75 printenv | sort
76 exit 1
77 fi
78 fi
79 ;;
80 "tsan" )
81 #
82 # change thread sanitizer @rpath reference
83 #
84 TSAN_FILE="${DSTROOT}${INSTALL_PATH}/"
85 if [ -n "${EXECUTABLE_FOLDER_PATH}" ]; then
86 TSAN_FILE+="${EXECUTABLE_FOLDER_PATH}/"
87 fi
88 TSAN_FILE+="${EXECUTABLE_PREFIX}${PRODUCT_NAME}_tsan${EXECUTABLE_SUFFIX}"
89
90 if [ -x "${TSAN_FILE}" ]; then
91 if [ ${xsan_setup} -eq 0 ]; then
92 xsan_setup
93 xsan_setup=1
94 fi
95
96 install_name_tool \
97 -change \
98 "@rpath/lib${TSAN_DYLIB}" \
99 "${XSAN_DIR}/lib${TSAN_DYLIB}" \
100 "${TSAN_FILE}"
101 if [ $? -ne 0 ]; then
102 echo "install_name_tool failed"
103 printenv | sort
104 exit 1
105 fi
106 fi
107 ;;
108 * )
109 ;;
110 esac
111 done