| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 | 2 |
| 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # Usage: make_more_helpers.sh <version> <app_name> | 7 # Usage: make_more_helpers.sh <containing_directory> <app_name> |
| 8 # | 8 # |
| 9 # This script creates additional helper .app bundles for Chromium, based on | 9 # This script creates additional helper .app bundles for Chromium, based on |
| 10 # the existing helper .app bundle, changing their Mach-O header's flags to | 10 # the existing helper .app bundle, changing their Mach-O header's flags to |
| 11 # enable and disable various features. Based on Chromium Helper.app, it will | 11 # enable and disable various features. Based on Chromium Helper.app, it will |
| 12 # create Chromium Helper EH.app, which has the MH_NO_HEAP_EXECUTION bit | 12 # create Chromium Helper EH.app, which has the MH_NO_HEAP_EXECUTION bit |
| 13 # cleared to support Chromium child processes that require an executable heap, | 13 # cleared to support Chromium child processes that require an executable heap, |
| 14 # and Chromium Helper NP.app, which has the MH_PIE bit cleared to support | 14 # and Chromium Helper NP.app, which has the MH_PIE bit cleared to support |
| 15 # Chromium child processes that cannot tolerate ASLR. | 15 # Chromium child processes that cannot tolerate ASLR. |
| 16 # | 16 # |
| 17 # This script expects to be called from the chrome_exe target as a postbuild, | 17 # This script expects to be called from the chrome_exe target as a postbuild, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 43 fi | 43 fi |
| 44 | 44 |
| 45 local feature_helper="${helper_stem} ${feature}.app" | 45 local feature_helper="${helper_stem} ${feature}.app" |
| 46 | 46 |
| 47 rsync -acC --delete --include '*.so' "${original_helper}/" "${feature_helper}" | 47 rsync -acC --delete --include '*.so' "${original_helper}/" "${feature_helper}" |
| 48 | 48 |
| 49 local helper_feature="${helper_name} ${feature}" | 49 local helper_feature="${helper_name} ${feature}" |
| 50 local helper_feature_exe="${feature_helper}/Contents/MacOS/${helper_feature}" | 50 local helper_feature_exe="${feature_helper}/Contents/MacOS/${helper_feature}" |
| 51 mv "${feature_helper}/Contents/MacOS/${helper_name}" "${helper_feature_exe}" | 51 mv "${feature_helper}/Contents/MacOS/${helper_name}" "${helper_feature_exe}" |
| 52 | 52 |
| 53 local change_flags="\ | 53 local change_flags="$(dirname "${0}")/change_mach_o_flags.py" |
| 54 $(dirname "${0}")/../../../../build/mac/change_mach_o_flags.py" | |
| 55 "${change_flags}" ${flags} "${helper_feature_exe}" | 54 "${change_flags}" ${flags} "${helper_feature_exe}" |
| 56 | 55 |
| 57 local feature_info="${feature_helper}/Contents/Info" | 56 local feature_info="${feature_helper}/Contents/Info" |
| 58 local feature_info_plist="${feature_info}.plist" | 57 local feature_info_plist="${feature_info}.plist" |
| 59 | 58 |
| 60 defaults write "${feature_info}" "CFBundleDisplayName" "${helper_feature}" | 59 defaults write "${feature_info}" "CFBundleDisplayName" "${helper_feature}" |
| 61 defaults write "${feature_info}" "CFBundleExecutable" "${helper_feature}" | 60 defaults write "${feature_info}" "CFBundleExecutable" "${helper_feature}" |
| 62 | 61 |
| 63 cfbundleid="$(defaults read "${feature_info}" "CFBundleIdentifier")" | 62 cfbundleid="$(defaults read "${feature_info}" "CFBundleIdentifier")" |
| 64 feature_cfbundleid="${cfbundleid}.${feature}" | 63 feature_cfbundleid="${cfbundleid}.${feature}" |
| 65 defaults write "${feature_info}" "CFBundleIdentifier" "${feature_cfbundleid}" | 64 defaults write "${feature_info}" "CFBundleIdentifier" "${feature_cfbundleid}" |
| 66 | 65 |
| 67 cfbundlename="$(defaults read "${feature_info}" "CFBundleName")" | 66 cfbundlename="$(defaults read "${feature_info}" "CFBundleName")" |
| 68 feature_cfbundlename="${cfbundlename} ${feature}" | 67 feature_cfbundlename="${cfbundlename} ${feature}" |
| 69 defaults write "${feature_info}" "CFBundleName" "${feature_cfbundlename}" | 68 defaults write "${feature_info}" "CFBundleName" "${feature_cfbundlename}" |
| 70 | 69 |
| 71 # As usual, defaults might have put the plist into whatever format excites | 70 # As usual, defaults might have put the plist into whatever format excites |
| 72 # it, but Info.plists get converted back to the expected XML format. | 71 # it, but Info.plists get converted back to the expected XML format. |
| 73 plutil -convert xml1 "${feature_info_plist}" | 72 plutil -convert xml1 "${feature_info_plist}" |
| 74 | 73 |
| 75 # `defaults` also changes the file permissions, so make the file | 74 # `defaults` also changes the file permissions, so make the file |
| 76 # world-readable again. | 75 # world-readable again. |
| 77 chmod a+r "${feature_info_plist}" | 76 chmod a+r "${feature_info_plist}" |
| 78 } | 77 } |
| 79 | 78 |
| 80 if [[ ${#} -ne 2 ]]; then | 79 if [[ ${#} -ne 2 ]]; then |
| 81 echo "usage: ${0} <version> <app_name>" >& 2 | 80 echo "usage: ${0} <containing_directory> <app_name>" >& 2 |
| 82 exit 1 | 81 exit 1 |
| 83 fi | 82 fi |
| 84 | 83 |
| 85 VERSION="${1}" | 84 CONTAINING_DIRECTORY="${1}" |
| 86 APP_NAME="${2}" | 85 APP_NAME="${2}" |
| 87 | 86 |
| 88 CONTENTS_DIR="${BUILT_PRODUCTS_DIR}/${CONTENTS_FOLDER_PATH}" | 87 make_helper "${CONTAINING_DIRECTORY}" "${APP_NAME}" "EH" "--executable-heap" |
| 89 VERSIONED_DIR="${CONTENTS_DIR}/Versions" | 88 make_helper "${CONTAINING_DIRECTORY}" "${APP_NAME}" "NP" "--no-pie" |
| 90 CURRENT_VERSIONED_DIR="${VERSIONED_DIR}/${VERSION}" | |
| 91 | |
| 92 make_helper "${CURRENT_VERSIONED_DIR}" "${APP_NAME}" "EH" "--executable-heap" | |
| 93 make_helper "${CURRENT_VERSIONED_DIR}" "${APP_NAME}" "NP" "--no-pie" | |
| OLD | NEW |