]> git.saurik.com Git - apple/security.git/blob - symbol_strip.sh
Security-177.tar.gz
[apple/security.git] / symbol_strip.sh
1 #!/bin/sh
2
3 if [ $# -ne 1 ]
4 then
5 echo "Export file name required."
6 exit 1
7 fi
8 expfile="$1"
9 expbase=`basename $expfile`
10
11 echo ====== BUILT_PRODUCTS_DIR ${BUILT_PRODUCTS_DIR} ======
12 echo ====== INNER_PRODUCT_SUBPATH ${INNER_PRODUCT_SUBPATH} ======
13
14 # Don't rerun this unless the file has been relinked
15 if [ "${BUILT_PRODUCTS_DIR}/${expbase}.timestamp" -nt "${BUILT_PRODUCTS_DIR}/${INNER_PRODUCT_SUBPATH}" ]; then
16 echo "${BUILT_PRODUCTS_DIR}/${INNER_PRODUCT_SUBPATH} is up to date."
17 exit 0
18 fi
19 #
20 # Under pbbuild, install target builds the target binary directly in DSTROOT, not
21 # in BUILT_PRODUCTS_DIR. Normal development build results in building the
22 # binary in SYMROOT, which is the same as BUILT_PRODUCTS_DIR.
23 #
24 if [ -e ${BUILT_PRODUCTS_DIR}/${INNER_PRODUCT_SUBPATH} ]
25 then
26 binary_file=${BUILT_PRODUCTS_DIR}/${INNER_PRODUCT_SUBPATH}
27 elif [ -e ${DSTROOT}/${INSTALL_PATH}/${INNER_PRODUCT_SUBPATH} ]
28 then
29 binary_file=${DSTROOT}/${INSTALL_PATH}/${INNER_PRODUCT_SUBPATH}
30 else
31 echo ==== Can not find linked Security binary ====
32 exit 1
33 fi
34 echo "Scanning $binary_file"
35 ARCHS=`lipo -info "$binary_file" | awk -F : '{print $3}'`
36 for arch in $ARCHS
37 do
38 echo "Generating exports file ${BUILT_PRODUCTS_DIR}/${expbase}_$arch"
39 nm -gp -arch $arch "$binary_file" \
40 | egrep -v '^/| U _' \
41 | awk '{print $3}' \
42 | egrep '_(|tf|ti|C)(|Q[2-9])8Security|_(N|ZN|ZNK|ZTTN|ZTVN)8Security|_ZN9KeySchema|^_(Sec|CSSM|Authorization)' \
43 | cat - "$expfile" \
44 | sort -u > "${BUILT_PRODUCTS_DIR}/${expbase}_$arch"
45 echo nmedit -s "${BUILT_PRODUCTS_DIR}/${expbase}_$arch" -arch $arch "$binary_file"
46 nmedit -s "${BUILT_PRODUCTS_DIR}/${expbase}_$arch" -arch $arch "$binary_file"
47 done
48 touch "${BUILT_PRODUCTS_DIR}/${expbase}.timestamp"