Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 114 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
#
# Makefile for striptease project
# Copyright (C) 2011,2012 Kyle J. McKay. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the author(s) shall not
# be used in advertising or otherwise to promote the sale, use or other
# dealings in this Software without prior written authorization from the
# author(s).

# Makefile for striptease project
# Copyright (C) 2011,2012 Kyle J. McKay. All rights reserved.
#
Expand All @@ -23,7 +49,92 @@
# dealings in this Software without prior written authorization from the
# author(s).

include version.mak
# The cctools version suffix these sources are based on
# The tarball can be found at:
# http://opensource.apple.com/tarballs/cctools/cctools-$(CCTOOLSVER).tar.gz

CCTOOLSVER = 855

ifneq (0,$$([(uname -r | cut -f1 -d.) -gt 9]; echo $$?)) # For old makefile.

DEBUG ?= Release
DD=build/$(DEBUG)/

CC ?= cc
CFLAGS += -O3 -fPIC -g0 -Wno-private-extern
COPTS += $(CFLAGS) -Iinclude -include preinc.h -DCCTOOLSVER=$(CCTOOLSVER)
LDOPTS += -Wl,-dead_strip,-dead_strip_dylibs,-no_eh_labels
LDOPTS += -Wl,-no_uuid,-no_version_load_command,-search_paths_first

ifeq ($(DEBUG),Debug)
COPTS+=-O0 -g
LDOPTS=+-g
else
LDOPTS+= -Wl,-S,-x,-w
endif

$(shell mkdir -p $(DD)/libstuff)

all : $(DD)tease tools

.PHONY : tools tease strip install_name_tool nm

tools : strip install_name_tool nm tease

tease : $(DD)tease
strip : $(DD)strip
install_name_tool : $(DD)install_name_tool
nm : $(DD)nm

LIBSTUFF_SRC := $(wildcard libstuff/*.c)

TEASE_SRC = tease.c $(LIBSTUFF_SRC)
STRIP_SRC = strip.c $(LIBSTUFF_SRC)
INSTALL_NAME_TOOL_SRC = install_name_tool.c $(LIBSTUFF_SRC)
NM_SRC = nm.c $(LIBSTUFF_SRC)

TEASE_OBJS = $(addprefix $(DD),$(TEASE_SRC:.c=.o)) $(DD)version_tease.o
STRIP_OBJS = $(addprefix $(DD),$(STRIP_SRC:.c=.o)) $(DD)version_strip.o

INSTALL_NAME_TOOL_OBJS = $(addprefix $(DD),$(INSTALL_NAME_TOOL_SRC:.c=.o)) \
$(DD)version_install_name_tool.o

NM_OBJS = $(addprefix $(DD),$(NM_SRC:.c=.o)) $(DD)nm.o

$(DD)%.o : %.c
$(CC) -c $(COPTS) -o $@ $<

$(DD)version_tease.o : version.c
$(CC) -c $(COPTS) -DPROGRAMNAME=tease -o $@ $<

$(DD)version_strip.o : version.c
$(CC) -c $(COPTS) -DPROGRAMNAME=strip -o $@ $<

$(DD)version_install_name_tool.o : version.c
$(CC) -c $(COPTS) -DPROGRAMNAME=install_name_tool -o $@ $<

$(DD)version_nm.o : version.c
$(CC) -c $(COPTS) -DPROGRAMNAME=nm -o $@ $<

$(DD)tease : $(TEASE_OBJS)
$(CC) -o $@ $(LDOPTS) $^

$(DD)strip : $(STRIP_OBJS)
$(CC) -o $@ $(LDOPTS) $^

$(DD)install_name_tool : $(INSTALL_NAME_TOOL_OBJS)
$(CC) -o $@ $(LDOPTS) $^

$(DD)nm : $(NM_OBJS)
$(CC) -o $@ $(LDOPTS) $^

clean :
rm -rf build


#######################################
else ## ** Begin "Old" Makefile ** ##
#######################################

.PHONY : all clean

Expand Down Expand Up @@ -194,3 +305,5 @@ endif

clean :
rm -rf build

endif # "Old" makefile.
6 changes: 3 additions & 3 deletions include/mach-o/dyld.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#ifndef _MACH_O_DYLD_H_
#define _MACH_O_DYLD_H_

#if __cplusplus
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

Expand Down Expand Up @@ -239,7 +239,7 @@ extern long NSVersionOfLinkTimeLibrary(
const char *libraryName);
extern int _NSGetExecutablePath( /* SPI first appeared in Mac OS X 10.2 */
char *buf,
unsigned long *bufsize);
uint32_t *bufsize);

/*
* The low level _dyld_... API.
Expand Down Expand Up @@ -320,7 +320,7 @@ __private_extern__ int _dyld_func_lookup(
const char *dyld_func_name,
unsigned long *address);

#if __cplusplus
#ifdef __cplusplus
}
#endif /* __cplusplus */

Expand Down
45 changes: 37 additions & 8 deletions include/mach-o/loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ struct load_command {
#define LC_DATA_IN_CODE 0x29 /* table of non-instructions in __text */
#define LC_SOURCE_VERSION 0x2A /* source version used to build binary */
#define LC_DYLIB_CODE_SIGN_DRS 0x2B /* Code signing DRs copied from linked dylibs */
#define LC_ENCRYPTION_INFO_64 0x2C /* 64-bit encrypted segment information */
#define LC_LINKER_OPTION 0x2D /* linker options in MH_OBJECT files */
#define LC_LINKER_OPTIMIZATION_HINT 0x2E /* optimization hints in MH_OBJECT files */


/*
Expand Down Expand Up @@ -1155,7 +1158,8 @@ struct rpath_command {
struct linkedit_data_command {
uint32_t cmd; /* LC_CODE_SIGNATURE, LC_SEGMENT_SPLIT_INFO,
LC_FUNCTION_STARTS, LC_DATA_IN_CODE,
or LC_DYLIB_CODE_SIGN_DRS */
LC_DYLIB_CODE_SIGN_DRS or
LC_LINKER_OPTIMIZATION_HINT. */
uint32_t cmdsize; /* sizeof(struct linkedit_data_command) */
uint32_t dataoff; /* file offset of data in __LINKEDIT segment */
uint32_t datasize; /* file size of data in __LINKEDIT segment */
Expand All @@ -1174,6 +1178,21 @@ struct encryption_info_command {
0 means not-encrypted yet */
};

/*
* The encryption_info_command_64 contains the file offset and size of an
* of an encrypted segment (for use in x86_64 targets).
*/
struct encryption_info_command_64 {
uint32_t cmd; /* LC_ENCRYPTION_INFO_64 */
uint32_t cmdsize; /* sizeof(struct encryption_info_command_64) */
uint32_t cryptoff; /* file offset of encrypted range */
uint32_t cryptsize; /* file size of encrypted range */
uint32_t cryptid; /* which enryption system,
0 means not-encrypted yet */
uint32_t pad; /* padding to make this struct's size a multiple
of 8 bytes */
};

/*
* The version_min_command contains the min OS version on which this
* binary was built to run.
Expand Down Expand Up @@ -1359,6 +1378,17 @@ struct dyld_info_command {
#define EXPORT_SYMBOL_FLAGS_REEXPORT 0x08
#define EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER 0x10

/*
* The linker_option_command contains linker options embedded in object files.
*/
struct linker_option_command {
uint32_t cmd; /* LC_LINKER_OPTION only used in MH_OBJECT filetypes */
uint32_t cmdsize;
uint32_t count; /* number of strings */
/* concatenation of zero terminated UTF8 strings.
Zero filled at end to align */
};

/*
* The symseg_command contains the offset and size of the GNU style
* symbol table information as described in the header file <symseg.h>.
Expand Down Expand Up @@ -1428,19 +1458,18 @@ struct source_version_command {
/*
* The LC_DATA_IN_CODE load commands uses a linkedit_data_command
* to point to an array of data_in_code_entry entries. Each entry
* describes a range of data in a code section. This load command
* is only used in final linked images.
* describes a range of data in a code section.
*/
struct data_in_code_entry {
uint32_t offset; /* from mach_header to start of data range*/
uint16_t length; /* number of bytes in data range */
uint16_t kind; /* a DICE_KIND_* value */
};
#define DICE_KIND_DATA 0x0001 /* L$start$data$... label */
#define DICE_KIND_JUMP_TABLE8 0x0002 /* L$start$jt8$... label */
#define DICE_KIND_JUMP_TABLE16 0x0003 /* L$start$jt16$... label */
#define DICE_KIND_JUMP_TABLE32 0x0004 /* L$start$jt32$... label */
#define DICE_KIND_ABS_JUMP_TABLE32 0x0005 /* L$start$jta32$... label */
#define DICE_KIND_DATA 0x0001
#define DICE_KIND_JUMP_TABLE8 0x0002
#define DICE_KIND_JUMP_TABLE16 0x0003
#define DICE_KIND_JUMP_TABLE32 0x0004
#define DICE_KIND_ABS_JUMP_TABLE32 0x0005



Expand Down
4 changes: 2 additions & 2 deletions include/mach-o/nlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,14 +297,14 @@ struct nlist_64 {
#define N_SYMBOL_RESOLVER 0x0100

#ifndef __STRICT_BSD__
#if __cplusplus
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*
* The function nlist(3) from the C library.
*/
extern int nlist (const char *filename, struct nlist *list);
#if __cplusplus
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __STRICT_BSD__ */
Expand Down
Loading