Roll WebRTC 8613:8622, Libjingle 8611:8616
[chromium-blink-merge.git] / build / mac / verify_no_objc.sh
blobe18a5eafb0054259a79caa53132cbbd5c801fc1f
1 #!/bin/bash
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 # This script makes sure that no __OBJC,__image_info section appears in the
8 # executable file built by the Xcode target that runs the script. If such a
9 # section appears, the script prints an error message and exits nonzero.
11 # Why is this important?
13 # On 10.5, there's a bug in CFBundlePreflightExecutable that causes it to
14 # crash when operating in an executable that has not loaded at its default
15 # address (that is, when it's a position-independent executable with the
16 # MH_PIE bit set in its mach_header) and the executable has an
17 # __OBJC,__image_info section. See http://crbug.com/88697.
19 # Chrome's main executables don't use any Objective-C at all, and don't need
20 # to carry this section around. Not linking them as Objective-C when they
21 # don't need it anyway saves about 4kB in the linked executable, although most
22 # of that 4kB is just filled with zeroes.
24 # This script makes sure that nobody goofs and accidentally introduces these
25 # sections into the main executables.
27 set -eu
29 executable="${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}"
31 if xcrun otool -arch i386 -o "${executable}" | grep -q '^Contents.*section$'; \
32 then
33 echo "${0}: ${executable} has an __OBJC,__image_info section" 2>&1
34 exit 1
37 if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
38 echo "${0}: otool failed" 2>&1
39 exit 1
42 exit 0