411954 I know how to strip a binary's symbol table of all non-global symbols except for text symbols. I also know how to strip LC_CODE_SIGNATURE load commands once they've been added. Introducing striptease. r=smorgan r=ardissone

This commit is contained in:
mark%moxienet.com 2008-01-22 20:15:57 +00:00
Родитель da3bceff60
Коммит 65194957b3
6 изменённых файлов: 9938 добавлений и 0 удалений

Просмотреть файл

@ -47,6 +47,7 @@ include $(DEPTH)/config/autoconf.mk
DIRS = \
flashblock \
idl \
striptease \
$(NULL)
APP_NAME = Camino

Просмотреть файл

@ -0,0 +1,97 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is just a lowly Makefile.
#
# The Initial Developer of the Original Code is Google Inc.
# Portions created by the Initial Developer are Copyright (C) 2008
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Mark Mentovai <mark@moxienet.com> (Original Author)
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
LIBSTUFF_CSRCS = \
libstuff/allocate.c \
libstuff/arch.c \
libstuff/arch_usage.c \
libstuff/breakout.c \
libstuff/bytesex.c \
libstuff/checkout.c \
libstuff/crc32.c \
libstuff/errors.c \
libstuff/fatal_arch.c \
libstuff/fatals.c \
libstuff/get_arch_from_host.c \
libstuff/ofile.c \
libstuff/ofile_error.c \
libstuff/print.c \
libstuff/reloc.c \
libstuff/round.c \
libstuff/set_arch_flag_name.c \
libstuff/swap_headers.c \
libstuff/symbol_list.c \
libstuff/unix_standard_mode.c \
libstuff/writeout.c \
$(NULL)
# It's possible to build strip (the unmodified original version) or tease
# (the enahnced version) by changing the value of this variable.
STRIP_OR_TEASE = tease
# Build tease (or strip) as a host program because we only care about running
# it on the build host. It doesn't need to be built for the target
# architecture.
HOST_PROGRAM = $(STRIP_OR_TEASE)
HOST_CFLAGS += -I$(srcdir)/include
HOST_CSRCS = \
$(STRIP_OR_TEASE).c \
$(LIBSTUFF_CSRCS) \
$(NULL)
# config/rules.mk has a simpler transformation to derive HOST_OBJS from
# HOST_CSRCS. It simply prepends host_ to each name. That winds up
# referencing the host_libstuff directory, which does not exist. This
# transformation splits each proposed object into its dirname and basename,
# prepending host_ only to the basename.
HOST_OBJS = $(foreach obj, \
$(HOST_CSRCS:.c=.$(OBJ_SUFFIX)), \
$(dir $(obj))$(addprefix host_,$(notdir $(obj))))
# Be sure there's a place to put libstuff objects in an objdir build.
ifneq ($(ABS_topsrcdir),$(MOZ_BUILD_ROOT))
libs::
mkdir -p libstuff
endif
include $(topsrcdir)/config/rules.mk

36
camino/striptease/README Normal file
Просмотреть файл

@ -0,0 +1,36 @@
striptease (or "tease" for short) is an enhanced version of strip. It's
capable of stripping a binary's symbol table of non-text local symbols.
This mode, enabled with the -t switch, is similar to "strip -s", except
-s strips all local symbols including text symbols. tease -t allows for
useful CrashReporter stacks to be generated on the deployment host. This
is important in light of the hidden-visibility default (-fvisibility=hidden)
that results in many symbols not being marked as global and therefore being
stripped by an ordinary strip -s.
tease also includes a -no_code_signature option, which strips any
LC_CODE_SIGNATURE load commands from the target file, in much the same way
as the ordinary strip's -no_uuid option.
Finally, tease includes an -a option, which instructs it to regenerate the
symbol table without stripping anything. tease -a is intended to be used
in conjunction with -no_code_signature (or -no_uuid), to pass over the file
and only strip the relevant Mach-O load commands without removing anything
from the symbol table.
striptease is based on strip.c and other supporting files in Apple's
cctools package. This version of striptease is based on cctools-667.3,
corresponding to Xcode Tools 3.0 and Mac OS X 10.5.0. It builds properly
under Xcode Tools 2.x on Mac OS X 10.4, as well. The cctools package is
available from:
http://www.opensource.apple.com/darwinsource/tarballs/apsl/cctools-667.3.tar.gz
cctools, and therefore strip, are available under the APSL license:
http://www.opensource.apple.com/apsl/
All files from cctools necessary to build strip are included, unmodified.
This includes strip.c. Changes to strip.c are made in tease.c. Many other
files from the cctools package not relevant to strip (or tease) are omitted
from this distribution. This README and an accompanying Makefile.in for
build system integration are also included.

Просмотреть файл

@ -0,0 +1,172 @@
/*
* Copyright (c) 2004, Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* Copyright (c) 1991 NeXT Computer, Inc. All rights reserved.
*
* File: architecture/m88k/fp_regs.h
* Author: Mike DeMoney, NeXT Computer, Inc.
*
* This include file defines Motorola 88K architecturally defined
* floating point control and status registers.
*
* HISTORY
* 23-Jan-91 Mike DeMoney (mike@next.com)
* Created.
*/
#ifndef _ARCH_M88K_FP_REGS_H_
#define _ARCH_M88K_FP_REGS_H_
#import <architecture/m88k/reg_help.h>
/*
* m88k_xrf_t -- data types that MAY be in extended register file
* Actual data types supported is implementation dependent
*/
typedef union {
float f; // 32 bit IEEE single
double d; // 64 bit IEEE double
/*
* NOTE: currently compiler implements long double type
* simply as double. In the future, it may implement
* this as 80 bit IEEE double extended or 128 bit IEEE quad
* as appropriate for the 88K implementation.
*/
long double e; // 80 or 128 bit IEEE format
/* Insure compiler aligns struct appropriately */
#ifdef __GNUC__
unsigned x[4] __attribute__(( aligned(16) ));
#else
unsigned x[4];
#endif
} m88k_xrf_t;
/*
* FPSR -- Floating Point Status Register
*/
typedef struct {
unsigned :BITS_WIDTH(31,17);
unsigned xmod:BIT_WIDTH(16); // extended registers modified
unsigned :BITS_WIDTH(15,5);
unsigned afinv:BIT_WIDTH(4); // accumulated invalid flag
unsigned afdvz:BIT_WIDTH(3); // accumulated div by zero flag
unsigned afunf:BIT_WIDTH(2); // accumulated underflow flag
unsigned afovf:BIT_WIDTH(1); // accumulated overflow flag
unsigned afinx:BIT_WIDTH(0); // accumulated inexact flag
} m88k_fpsr_t;
/*
* FPCR -- Floating Point Control Register
* 88K architecturally specified form.
* Does not expose implementation-dependent functions
*/
typedef enum {
M88K_RM_NEAREST = 0, // round toward nearest
M88K_RM_ZERO = 1, // round toward zero
M88K_RM_NEGINF = 2, // round toward negative infinity
M88K_RM_POSINF =3 // round toward positive infinity
} m88k_fpcr_rm_t;
typedef struct {
unsigned :BITS_WIDTH(31,16);
m88k_fpcr_rm_t rm:BITS_WIDTH(15,14); // rounding mode
unsigned :BITS_WIDTH(13,5);
unsigned efinv:BIT_WIDTH(4); // invalid exception enable
unsigned efdvz:BIT_WIDTH(3); // div by zero exception enable
unsigned efunf:BIT_WIDTH(2); // underflow exception enable
unsigned efovf:BIT_WIDTH(1); // overflow exception enable
unsigned efinx:BIT_WIDTH(0); // inexact exception enable
} m88k_fpcr_t;
/*
* FPCR -- Floating Point Control Register
* 88110 implementation -- includes "TCFP" features.
*/
typedef struct {
unsigned :BITS_WIDTH(31,22);
unsigned tcfp:BIT_WIDTH(21); // def results for INF/NaN
unsigned :BITS_WIDTH(20,19);
unsigned tcfpunf:BIT_WIDTH(18); // underflow -> zero
unsigned tcfpovf:BIT_WIDTH(17); // overflow -> inf
unsigned :BIT_WIDTH(16);
m88k_fpcr_rm_t rm:BITS_WIDTH(15,14); // rounding mode
unsigned :BITS_WIDTH(13,5);
unsigned efinv:BIT_WIDTH(4); // invalid exception enable
unsigned efdvz:BIT_WIDTH(3); // div by zero exception enable
unsigned efunf:BIT_WIDTH(2); // underflow exception enable
unsigned efovf:BIT_WIDTH(1); // overflow exception enable
unsigned efinx:BIT_WIDTH(0); // inexact exception enable
} m88110_fpcr_t;
#ifdef m88k
#ifndef __STRICT_ANSI__
/*
* read and write fpsr and fpcr registers
*
* FIXME: When the compiler is fixed, convert to style of inlines shown
* in m88110_sfu0.h which do not use either CONTENTS() macro or
* *(foo_t *)& casts (and therefore, don't force the compiler to generate
* a memory reference.
*/
static __inline__ m88k_fpsr_t m88k_get_fpsr()
{
unsigned cr_tmp;
__asm__ volatile ("fldcr %0,fcr62 ; get_fpsr()" : "=r" (cr_tmp));
return *(m88k_fpsr_t *)&cr_tmp;
}
static __inline__ void m88k_set_fpsr(m88k_fpsr_t fpsr_val)
{
/*
* Must force xmod to 1, since OS uses this to determine
* if XRF must be context switched. Not setting to 1
* will NOT corrupt other threads registers, but will
* result in loss of this threads register values.
*/
fpsr_val.xmod = 1;
__asm__ volatile ("fstcr %0,fcr62 ; set_fpsr()"
: : "r" (CONTENTS(fpsr_val)));
}
static __inline__ m88k_fpcr_t m88k_get_fpcr()
{
unsigned cr_tmp;
__asm__ volatile ("fldcr %0,fcr63 ; get_fpcr()" : "=r" (cr_tmp));
return *(m88k_fpcr_t *)&cr_tmp;
}
static __inline__ void m88k_set_fpcr(m88k_fpcr_t fpcr_val)
{
__asm__ volatile ("fstcr %0,fcr63 ; set_fpcr()"
: : "r" (CONTENTS(fpcr_val)));
}
#endif /* __STRICT_ANSI__ */
#endif /* m88k */
#endif /* _ARCH_M88K_FP_REGS_H_ */

4816
camino/striptease/strip.c Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

4816
camino/striptease/tease.c Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу