]>
git.saurik.com Git - cycript.git/blob - trampoline.sh
fd4be0d768038b5d3bbb9062ce3077a56c6c229a
15 detailed
=$("${lipo}" -detailed_info "${object}")
17 regex
=$
'\nNon-fat file: .* is architecture: (.*)'
18 if [[ ${detailed} =~
${regex} ]]; then
19 archs
=(${BASH_REMATCH[1]})
22 archs
=($(echo "${detailed}" | "${sed}" -e '/^architecture / { s/^architecture //; p; }; d;'))
25 echo '#include "Trampoline.hpp"'
27 for arch
in "${archs[@]}"; do
28 if [[ "${detailed+@}" ]]; then
29 offset
=$
(echo "${detailed}" | "${sed}" -e '
30 /^architecture / { x; s/.*/0/; x; };
31 /^architecture '${arch}'$/ { x; s/.*/1/; x; };
32 x; /^1$/ { x; /^ *offset / { s/^ *offset //; p; }; x; }; x;
39 file=($
("${otool}" -arch "${arch}" -l "${object}" | "${sed}" -e '
41 /^ *fileoff / { s/^.* //; p; };
42 /^ *filesize / { s/^.* //; p; };
45 /^ *cmd LC_SEGMENT/ { x; s/.*/1/; x; };
54 echo "static const char ${name}_${arch}_data_[] = {"
56 od -v -t x1
-t c
-j "$((offset + fileoff))" -N "${filesize}" "${object}" | "${sed}" -e '
70 s/\([^,][^,]\)/0x\1/g;
72 /^,$/ ! { s/^/ /g; p; }; d;
79 entry
=$("${nm}" -arch "${arch}" "${object}" | "${sed}" -e '/ _Start$/ { s/ .*//; p; }; d;')
81 echo "static size_t ${name}_${arch}_entry_ = 0x${entry:=0};"
85 "${otool}" -arch "${arch}" -vVt "${object}"
89 echo "static Trampoline ${name}_${arch}_ = {"
90 echo " ${name}_${arch}_data_,"
91 echo " sizeof(${name}_${arch}_data_),"
92 echo " ${name}_${arch}_entry_,"