I use the following method:
Export only the needed symbols by describing them in a .exp file, and passing "-exported_symbols_list path/to/file.exp" to the linker.
The file would contain, for example:
- Code: Select all
# -----------------------------------------------------------------------
# VST
_VSTPluginMain
# -----------------------------------------------------------------------
# AudioUnit
# These two symbols must match the following syntax:
#
# Main entry: _$(JucePlugin_AUExportPrefix)Entry
# View entry: _$(JucePlugin_AUExportPrefix)ViewEntry
#
# JucePlugin_AUExportPrefix is defined in JucePluginCharacteristics.h
_MyPluginEntry
_MyPluginViewEntry
# -----------------------------------------------------------------------
# RTAS
_CDSPDoHostCommand
_CDSPGetLoLong
_CDSPSendLoLong
_CProcessGroupGetBundleRef
_CProcessGroupRestoreResourceFile
_CProcessGroupUseResourceFile
_CloseMachOPlugIn
_Dispatcher
_NewMachOPlugIn
__PI_GetRoutineDescriptor
_main_macho
Note that you need to specify different files for i386 and x86_64 symbols, as RTAS and AudioUnit's view are exported only in i386.
Then I'm using the following perl script, found on a Apple mailing list thread (link is dead now), to strip down the rest:
- Code: Select all
# /usr/bin/perl -w
# http://lists.apple.com/archives/xcode-users/2006/mar/msg00552.html
#
# Last updated: 21MAR06, Andy O'Meara and Rob Barris
#
# This is an Xcode post-build phase script for devs who sleep better at night knowing
# that their deployment binaries are as stripped as possible. This makes life more difficult
# for a hacker/cracker to locate sensitive code to trace, study, and/or extract.
#
# This script will execute only if the Xcode "Deployment Postprocessing" setting
# is set (aka DEPLOYMENT_POSTPROCESSING).
#
# The downside to shipping a stripped binary is that your user's crash reports
# will be useless unless you have a link map to convert code offsets (from a stack trace)
# into proc names. To address this, this script moves your pre-stripped executable
# to the build dir, appending "_full" to the filename, allowing you to retain it for
# the day you need it in order to decipher a stack trace. You do this by using 'atos'
# with the original generated binary (type 'man atos' for info).
#
# Recommended Xcode build settings:
# Dead Code Stripping YES
# Only Link In Essential Symbols NO
# Deployment Postprocessing YES (this activates this script)
# Strip Linked Product NO
# Use Separate Strip NO
# Strip Style All Symbols
# Strip Debug Symbols During Copy NO
# Preserve Private External Symbols NO
# Separate PCH Symbols YES
# Symbols Hidden By Default YES (Critical!)
# Inline Functions Hidden YES
#
# Note that if you're building a dynamic library, you'll need to explicitly
# declare any symbols that you want to be exported. See the following:
# file:///Developer/ADC%20Reference%20Library/documentation/DeveloperTools/Conceptual/CppRuntimeEnv/Articles/SymbolVisibility.html
#
use strict;
die "$0: Must be run from Xcode" unless $ENV{"BUILT_PRODUCTS_DIR"};
# This script is activated via an Xcode env flag.
if ( $ENV{DEPLOYMENT_POSTPROCESSING} ne "YES" ) {
exit 0;
}
# Strip output only for Protect configuration
if ( $ENV{CONFIGURATION} ne "Protect" ) {
exit 0;
}
print "\n\n==================== Commencing external stripping phase...\n";
my $BINARY = "$ENV{BUILT_PRODUCTS_DIR}/$ENV{WRAPPER_NAME}/Contents/MacOS/$ENV{EXECUTABLE_NAME}";
my $BINARY_FULL = "$ENV{BUILT_PRODUCTS_DIR}/$ENV{EXECUTABLE_NAME}_full";
my $BINARY_i386 = "${BINARY}_i386";
my $BINARY_x86_64 = "${BINARY}_x86_64";
# Extract each arch into a "thin" binary for stripping
`lipo "$BINARY" -thin x86_64 -output "$BINARY_x86_64" `;
`lipo "$BINARY" -thin i386 -output "$BINARY_i386"`;
# Retain the orignal binary for QA and use with the util 'atos'
`mv -f "$BINARY" "$BINARY_FULL"`;
# Perform desired stripping on each thin binary.
`strip -S -x -o "${BINARY_i386}_tmp" -r "$BINARY_i386"`;
`strip -S -x -o "${BINARY_x86_64}_tmp" -r "$BINARY_x86_64" `;
# We're now done with the original thin binaries, so chuck them.
`rm -f "$BINARY_i386"`;
`rm -f "$BINARY_x86_64" `;
# Make the new universal binary from our stripped thin pieces.
`lipo -arch i386 "${BINARY_i386}_tmp" -arch x86_64 "${BINARY_x86_64}_tmp" -create -output "$BINARY"`;
# We're now done with the temp thin binaries, so chuck them.
`rm -f "${BINARY_i386}_tmp"`;
`rm -f "${BINARY_x86_64}_tmp" `;
`rm -f "${BINARY_FULL}" `;
print "\n==================== External strip phase complete\n";
#EOF
This statement is false.