From 6d3af51ef4751f5b8270c1aa348f0d7ed11e2fe2 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 3 Jun 2012 21:27:16 -0700 Subject: [PATCH] Support building non-fat injection trampolines. --- trampoline.sh | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/trampoline.sh b/trampoline.sh index 824a448..7c3cfaf 100755 --- a/trampoline.sh +++ b/trampoline.sh @@ -22,15 +22,27 @@ detailed=$("${lipo}" -detailed_info "${object}") { +regex=$'\nNon-fat file: .* is architecture: (.*)' +if [[ ${detailed} =~ ${regex} ]]; then + archs=(${BASH_REMATCH[1]}) + unset detailed +else + archs=($(echo "${detailed}" | "${sed}" -e '/^architecture / { s/^architecture //; p; }; d;')) +fi + echo '#include "Trampoline.hpp"' -for arch in $(echo "${detailed}" | "${sed}" -e '/^architecture / { s/^architecture //; p; }; d;'); do - offset=$(echo "${detailed}" | "${sed}" -e ' - /^architecture / { x; s/.*/0/; x; }; - /^architecture '${arch}'$/ { x; s/.*/1/; x; }; - x; /^1$/ { x; /^ *offset / { s/^ *offset //; p; }; x; }; x; - d; - ') +for arch in "${archs[@]}"; do + if [[ "${detailed+@}" ]]; then + offset=$(echo "${detailed}" | "${sed}" -e ' + /^architecture / { x; s/.*/0/; x; }; + /^architecture '${arch}'$/ { x; s/.*/1/; x; }; + x; /^1$/ { x; /^ *offset / { s/^ *offset //; p; }; x; }; x; + d; + ') + else + offset=0 + fi file=($("${otool}" -arch "${arch}" -l "${object}" | "${sed}" -e ' x; /^1$/ { x; -- 2.45.2