michael@0: #!/bin/bash michael@0: michael@0: # Copyright (c) 2011 The Chromium Authors. All rights reserved. michael@0: # Use of this source code is governed by a BSD-style license that can be michael@0: # found in the LICENSE file. michael@0: michael@0: # This script makes sure that no __OBJC,__image_info section appears in the michael@0: # executable file built by the Xcode target that runs the script. If such a michael@0: # section appears, the script prints an error message and exits nonzero. michael@0: # michael@0: # Why is this important? michael@0: # michael@0: # On 10.5, there's a bug in CFBundlePreflightExecutable that causes it to michael@0: # crash when operating in an executable that has not loaded at its default michael@0: # address (that is, when it's a position-independent executable with the michael@0: # MH_PIE bit set in its mach_header) and the executable has an michael@0: # __OBJC,__image_info section. See http://crbug.com/88697. michael@0: # michael@0: # Chrome's main executables don't use any Objective-C at all, and don't need michael@0: # to carry this section around. Not linking them as Objective-C when they michael@0: # don't need it anyway saves about 4kB in the linked executable, although most michael@0: # of that 4kB is just filled with zeroes. michael@0: # michael@0: # This script makes sure that nobody goofs and accidentally introduces these michael@0: # sections into the main executables. michael@0: michael@0: set -eu michael@0: michael@0: otool="${DEVELOPER_BIN_DIR:-/usr/bin}/otool" michael@0: executable="${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}" michael@0: michael@0: if "${otool}" -arch i386 -o "${executable}" | grep -q '^Contents.*section$'; \ michael@0: then michael@0: echo "${0}: ${executable} has an __OBJC,__image_info section" 2>&1 michael@0: exit 1 michael@0: fi michael@0: michael@0: if [[ ${PIPESTATUS[0]} -ne 0 ]]; then michael@0: echo "${0}: otool failed" 2>&1 michael@0: exit 1 michael@0: fi michael@0: michael@0: exit 0