--- /dev/null
+Only in libstuff: CVS
+diff -ubr libstuff/Makefile libstuff/Makefile
+--- libstuff/Makefile Fri Sep 6 18:27:55 2002
++++ libstuff/Makefile Mon Aug 25 21:54:30 2003
+@@ -1,7 +1,7 @@
+ RC_OS = macos
+ OFLAG = -O
+ ifeq "macos" "$(RC_OS)"
+- X_CFLAGS := $(shell if [ "$(RC_RELEASE)" != "Beaker" ] && \
++ X_CFLAGS := $(shell if [ `uname` != "Linux" ] && [ "$(RC_RELEASE)" != "Beaker" ] && \
+ [ "$(RC_RELEASE)" != "Bunsen" ] && \
+ [ "$(RC_RELEASE)" != "Gonzo" ] && \
+ [ "$(RC_RELEASE)" != "Kodiak" ]; then \
+@@ -10,14 +10,18 @@
+ endif
+
+
+-USE_DEPENDENCY_FILE := $(shell if [ "$(notdir $(CC))" != "mwccppc" ]; then \
++USE_DEPENDENCY_FILE := $(shell if [ `uname` != "Linux" ] && [ "$(notdir $(CC))" != "mwccppc" ]; then \
+ echo YES ; else echo NO ; \
+ fi; )
+
+ ifeq "mwccppc" "$(notdir $(CC))"
+ CFLAGS = $(OFLAG) -g -gccinc -I$(SRCROOT)/../include
+ else
+- CFLAGS = $(OFLAG) -g -I$(SRCROOT)/../include -Wall -Wno-precomp $(X_CFLAGS)
++ ifeq "Linux" "$(shell uname)"
++ CFLAGS = $(OFLAG) -g -I$(SRCROOT)/../include -Wall $(X_CFLAGS) -D__ppc__ -I/usr/include -I../../../macosx-include
++ else
++ CFLAGS = $(OFLAG) -g -I$(SRCROOT)/../include -Wall $(X_CFLAGS)
++ endif
+ endif
+
+ ifneq "" "$(wildcard /bin/mkdirs)"
+@@ -40,7 +44,8 @@
+ set_arch_flag_name.c seg_addr_table.c dylib_table.c \
+ breakout.c writeout.c checkout.c fatal_arch.c ofile_get_word.c \
+ vm_flush_cache.c hash_string.c dylib_roots.c guess_short_name.c \
+- SymLoc.c get_arch_from_host.c crc32.c macosx_deployment_target.c
++ SymLoc.c get_arch_from_host.c crc32.c macosx_deployment_target.c \
++ symbol_list.c fake-mach.c
+ OBJS = $(CFILES:.c=.o)
+ INSTALL_FILES = $(CFILES) Makefile notes
+
+@@ -90,7 +95,7 @@
+ OFILE_DIR=. \
+ SRCROOT=.. \
+ SYMROOT=.. \
+- COPTS="-dynamic" \
++ COPTS="" \
+ OFLAG="$(OFLAG)" \
+ CFILES="$(CFILES)" \
+ RC_CFLAGS="$(RC_CFLAGS)" \
+@@ -103,7 +108,7 @@
+ OFILE_DIR=$(OBJROOT)/dynamic_obj \
+ SRCROOT=$(SRCROOT) \
+ SYMROOT=$(SYMROOT) \
+- COPTS="-dynamic" \
++ COPTS="" \
+ OFLAG="$(OFLAG)" \
+ CFILES="$(CFILES)" \
+ RC_CFLAGS="$(RC_CFLAGS)" \
+@@ -120,7 +125,7 @@
+ OFILE_DIR=. \
+ SRCROOT=.. \
+ SYMROOT=.. \
+- COPTS="-dynamic -pg" \
++ COPTS="-pg" \
+ OFLAG="$(OFLAG)" \
+ RC_CFLAGS="$(RC_CFLAGS)" \
+ RC_ARCHS="$(RC_ARCHS)"; \
+@@ -132,7 +137,7 @@
+ OFILE_DIR=$(OBJROOT)/profile_obj \
+ SRCROOT=$(SRCROOT) \
+ SYMROOT=$(SYMROOT) \
+- COPTS="-dynamic -pg" \
++ COPTS="-pg" \
+ OFLAG="$(OFLAG)" \
+ RC_CFLAGS="$(RC_CFLAGS)" \
+ RC_ARCHS="$(RC_ARCHS)"; \
+@@ -167,7 +172,8 @@
+ fi
+
+ $(PRODUCT): $(OFILE_DIR) $(SYMROOT) $(OBJS)
+- libtool -static -o $(SYMROOT)/$(PRODUCT) $(OBJS)
++ ar r $(SYMROOT)/$(PRODUCT) $(OBJS)
++ ranlib $(SYMROOT)/$(PRODUCT)
+
+ ifeq "NO" "$(USE_DEPENDENCY_FILE)"
+ .c.o:
+diff -ubr libstuff/SymLoc.c libstuff/SymLoc.c
+--- libstuff/SymLoc.c Fri Sep 6 18:27:55 2002
++++ libstuff/SymLoc.c Mon Aug 25 13:17:40 2003
+@@ -1,15 +1,15 @@
+-#import <libc.h>
+-#import <ctype.h>
+-#import <sys/types.h>
++#include <libc.h>
++#include <ctype.h>
++#include <sys/types.h>
+ #ifdef __OPENSTEP__
+ #define _POSIX_SOURCE
+ #endif
+-#import <dirent.h>
+-#import <pwd.h>
+-#import "stuff/bool.h"
+-#import "stuff/errors.h"
+-#import "stuff/allocate.h"
+-#import "stuff/SymLoc.h"
++#include <dirent.h>
++#include <pwd.h>
++#include "stuff/bool.h"
++#include "stuff/errors.h"
++#include "stuff/allocate.h"
++#include "stuff/SymLoc.h"
+
+ const char *
+ symLocForDylib(const char *installName, const char *releaseName,
+@@ -101,6 +101,7 @@
+ system_error("symLocForDylib(): Can't opendir %s", buf);
+ return NULL;
+ }
++ c = NULL;
+
+ // read DylibProjects entries
+ *buf = '\0';
+diff -ubr libstuff/arch.c libstuff/arch.c
+--- libstuff/arch.c Tue Jan 14 23:35:27 2003
++++ libstuff/arch.c Mon Aug 25 13:17:40 2003
+@@ -60,11 +60,13 @@
+ { "ppc750", CPU_TYPE_POWERPC, CPU_SUBTYPE_POWERPC_750 },
+ { "ppc7400",CPU_TYPE_POWERPC, CPU_SUBTYPE_POWERPC_7400 },
+ { "ppc7450",CPU_TYPE_POWERPC, CPU_SUBTYPE_POWERPC_7450 },
++ { "ppc970", CPU_TYPE_POWERPC, CPU_SUBTYPE_POWERPC_970 },
+ { "i486", CPU_TYPE_I386, CPU_SUBTYPE_486 },
+ { "i486SX", CPU_TYPE_I386, CPU_SUBTYPE_486SX },
+ { "pentium",CPU_TYPE_I386, CPU_SUBTYPE_PENT }, /* same as i586 */
+ { "i586", CPU_TYPE_I386, CPU_SUBTYPE_586 },
+- { "pentpro", CPU_TYPE_I386, CPU_SUBTYPE_PENTPRO },
++ { "pentpro", CPU_TYPE_I386, CPU_SUBTYPE_PENTPRO }, /* same as i686 */
++ { "i686", CPU_TYPE_I386, CPU_SUBTYPE_PENTPRO },
+ { "pentIIm3",CPU_TYPE_I386, CPU_SUBTYPE_PENTII_M3 },
+ { "pentIIm5",CPU_TYPE_I386, CPU_SUBTYPE_PENTII_M5 },
+ { "m68030", CPU_TYPE_MC680x0, CPU_SUBTYPE_MC68030_ONLY },
+@@ -269,7 +271,8 @@
+ const struct arch_flag *flag)
+ {
+ if(flag->cputype == CPU_TYPE_POWERPC ||
+- flag->cputype == CPU_TYPE_VEO)
++ flag->cputype == CPU_TYPE_VEO ||
++ flag->cputype == CPU_TYPE_I386)
+ return(0x1000); /* 4K */
+ else
+ return(0x2000); /* 8K */
+diff -ubr libstuff/best_arch.c libstuff/best_arch.c
+--- libstuff/best_arch.c Tue Jan 14 23:35:27 2003
++++ libstuff/best_arch.c Mon Aug 25 13:17:40 2003
+@@ -44,7 +44,8 @@
+ struct fat_arch *fat_archs,
+ unsigned long nfat_archs)
+ {
+- unsigned long i, lowest_family, lowest_model, lowest_index;
++ unsigned long i;
++ long lowest_family, lowest_model, lowest_index;
+
+ /*
+ * Look for the first exact match.
+@@ -183,14 +184,21 @@
+ * An exact match as not found. So for all the PowerPC subtypes
+ * pick the subtype from the following order starting from a subtype
+ * that will work (contains altivec if needed):
+- * 7450, 7400, 750, 604e, 604, 603ev, 603e, 603, ALL
++ * 790, 7450, 7400, 750, 604e, 604, 603ev, 603e, 603, ALL
+ * Note the 601 is NOT in the list above. It is only picked via
+ * an exact match. For an unknown subtype pick only the ALL type if
+ * it exists.
+ */
+ switch(cpusubtype){
++ case CPU_SUBTYPE_POWERPC_970:
+ case CPU_SUBTYPE_POWERPC_7450:
+ case CPU_SUBTYPE_POWERPC_7400:
++ for(i = 0; i < nfat_archs; i++){
++ if(fat_archs[i].cputype != cputype)
++ continue;
++ if(fat_archs[i].cpusubtype == CPU_SUBTYPE_POWERPC_970)
++ return(fat_archs + i);
++ }
+ for(i = 0; i < nfat_archs; i++){
+ if(fat_archs[i].cputype != cputype)
+ continue;
+diff -ubr libstuff/bytesex.c libstuff/bytesex.c
+--- libstuff/bytesex.c Fri Sep 6 18:27:56 2002
++++ libstuff/bytesex.c Mon Aug 25 13:17:40 2003
+@@ -25,13 +25,13 @@
+ #include <string.h>
+ #include <mach-o/fat.h>
+ #include <mach-o/loader.h>
+-#import <mach/m68k/thread_status.h>
+-#import <mach/ppc/thread_status.h>
+-#import <mach/m88k/thread_status.h>
+-#import <mach/i860/thread_status.h>
+-#import <mach/i386/thread_status.h>
+-#import <mach/hppa/thread_status.h>
+-#import <mach/sparc/thread_status.h>
++#include <mach/m68k/thread_status.h>
++#include <mach/ppc/thread_status.h>
++#include <mach/m88k/thread_status.h>
++#include <mach/i860/thread_status.h>
++#include <mach/i386/thread_status.h>
++#include <mach/hppa/thread_status.h>
++#include <mach/sparc/thread_status.h>
+ #include <mach-o/nlist.h>
+ #include <mach-o/reloc.h>
+ #include <mach-o/ranlib.h>
+diff -ubr libstuff/checkout.c libstuff/checkout.c
+--- libstuff/checkout.c Fri Sep 6 18:27:57 2002
++++ libstuff/checkout.c Mon Aug 25 13:17:40 2003
+@@ -132,9 +132,11 @@
+ }
+ lc = (struct load_command *)((char *)lc + lc->cmdsize);
+ }
+- if(object->mh->filetype == MH_DYLIB && dl_id == NULL)
++ if((object->mh->filetype == MH_DYLIB ||
++ object->mh->filetype == MH_DYLIB_STUB) && dl_id == NULL)
+ fatal_arch(arch, member, "malformed file (no LC_ID_DYLIB load "
+- "command in MH_DYLIB file): ");
++ "command in %s file): ", object->mh->filetype == MH_DYLIB ?
++ "MH_DYLIB" : "MH_DYLIB_STUB");
+ if(object->hints_cmd != NULL){
+ if(object->dyst == NULL && object->hints_cmd->nhints != 0)
+ fatal_arch(arch, member, "malformed file (LC_TWOLEVEL_HINTS "
+@@ -161,7 +163,8 @@
+ * and a relocatable object file. Since it has a dynamic symbol
+ * table command it could have an indirect symbol table.
+ */
+- if(object->mh->filetype == MH_DYLIB){
++ if(object->mh->filetype == MH_DYLIB /* ||
++ object->mh->filetype == MH_DYLIB_STUB */ ){
+ /*
+ * This is a dynamic shared library.
+ * The order of the symbolic info is:
+@@ -172,10 +175,10 @@
+ * undefined symbols
+ * two-level namespace hints
+ * external relocation entries
++ * indirect symbol table
+ * table of contents
+ * module table
+ * reference table
+- * indirect symbol table
+ * string table
+ * strings for external symbols
+ * strings for local symbols
+diff -ubr libstuff/crc32.c libstuff/crc32.c
+--- libstuff/crc32.c Fri Sep 6 18:27:57 2002
++++ libstuff/crc32.c Mon Aug 25 13:19:21 2003
+@@ -35,6 +35,12 @@
+ */
+ #include <sys/types.h>
+
++#if ( defined(__MWERKS__) && !defined(__private_extern__) )
++#define __private_extern__ __declspec(private_extern)
++#elif ( defined(__linux__) && !defined(__private_extern__) )
++#define __private_extern__ extern
++#endif
++
+ static const u_int32_t crctab[] = {
+ 0x0,
+ 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
+diff -ubr libstuff/dylib_roots.c libstuff/dylib_roots.c
+--- libstuff/dylib_roots.c Fri Sep 6 18:27:58 2002
++++ libstuff/dylib_roots.c Mon Aug 25 13:17:40 2003
+@@ -21,7 +21,7 @@
+ enum bool check_result;
+ };
+
+-static void check_for_install_name(
++static void check_for_dylib(
+ struct ofile *ofile,
+ char *arch_name,
+ void *cookie);
+@@ -77,7 +77,7 @@
+ }
+ }
+ ofile_process(image_file_name, NULL, 0, TRUE,
+- TRUE, TRUE, FALSE, check_for_install_name, &block);
++ TRUE, TRUE, FALSE, check_for_dylib, &block);
+ if(block.check_result == TRUE)
+ return(image_file_name);
+ free(image_file_name);
+@@ -148,14 +148,14 @@
+ #endif
+ /*
+ * Now that we found a file with the same base_name in the root
+- * check to see that it is a dynamic library with the correct
+- * install name. Assume it is an if it is not then the
+- * routine check_for_install_name() will reset the check_result
+- * in the block passed to it back to FALSE.
++ * check to see that it is a dynamic library. Assume it is an
++ * if it is not then the routine check_for_dylib() will
++ * reset the check_result in the block passed to
++ * it back to FALSE.
+ */
+ block.check_result = TRUE;
+ ofile_process(ftsent->fts_path, NULL, 0, TRUE,
+- TRUE, TRUE, FALSE, check_for_install_name,&block);
++ TRUE, TRUE, FALSE, check_for_dylib,&block);
+ if(block.check_result == TRUE){
+ image_file_name = allocate(ftsent->fts_pathlen + 1);
+ strcpy(image_file_name, ftsent->fts_path);
+@@ -189,7 +189,7 @@
+
+ static
+ void
+-check_for_install_name(
++check_for_dylib(
+ struct ofile *ofile,
+ char *arch_name,
+ void *cookie)
+@@ -197,11 +197,9 @@
+ unsigned long i;
+ struct check_block *block;
+ struct load_command *lc;
+- struct dylib_command *dl;
+- char *name;
+
+ #ifdef BIG_DEBUG
+- printf("In check_for_install_name() ofile->file_name = %s",
++ printf("In check_for_dylib() ofile->file_name = %s",
+ ofile->file_name);
+ if(arch_name != NULL)
+ printf(" arch_name = %s\n", arch_name);
+@@ -218,13 +216,6 @@
+ lc = ofile->load_commands;
+ for(i = 0; i < ofile->mh->ncmds; i++){
+ if(lc->cmd == LC_ID_DYLIB){
+- dl = (struct dylib_command *)lc;
+- name = (char *)lc + dl->dylib.name.offset;
+- if(strncmp(name, "@executable_path/",
+- sizeof("@executable_path") - 1) == 0)
+- return;
+- if(strcmp(name, block->install_name) != 0)
+- block->check_result = FALSE;
+ return;
+ }
+ lc = (struct load_command *)((char *)lc + lc->cmdsize);
+Only in libstuff: fake-mach.c
+diff -ubr libstuff/get_arch_from_host.c libstuff/get_arch_from_host.c
+--- libstuff/get_arch_from_host.c Tue Jan 14 23:35:27 2003
++++ libstuff/get_arch_from_host.c Mon Aug 25 13:17:40 2003
+@@ -181,6 +181,14 @@
+ if(specific_arch_flag != NULL)
+ specific_arch_flag->name = "ppc7450";
+ return(1);
++ case CPU_SUBTYPE_POWERPC_970:
++ if(family_arch_flag != NULL){
++ family_arch_flag->name = "ppc";
++ family_arch_flag->cpusubtype = CPU_SUBTYPE_POWERPC_ALL;
++ }
++ if(specific_arch_flag != NULL)
++ specific_arch_flag->name = "ppc970";
++ return(1);
+ default:
+ if(family_arch_flag != NULL){
+ family_arch_flag->name = "ppc";
+Only in libstuff: gpul_notes
+diff -ubr libstuff/notes libstuff/notes
+--- libstuff/notes Tue Jan 14 23:35:27 2003
++++ libstuff/notes Mon Aug 25 12:12:33 2003
+@@ -5,6 +5,69 @@
+ TODO:
+ - Deal with LC_PREPAGE and unknown load commands that don't need to be swapped.
+
++Changes for the 5.12 release (the cctools-469 release):
++- Fixed a problem with the added checks of the of the dylib_module struct in
++ ofile.c made in cctools-466 for Radar bug #3208399 where it did not work if
++ the file was not in host byte sex. The fix was to copy the struct and byte
++ swap it if needed before doing the checks on the copy of the struct in
++ check_dylib_module() in ofile.c . Radar bug #3228664.
++
++Changes for the 5.12 release (the cctools-467 release):
++- Added support for the PPC_RELOC_LO14_SECTDIFF relocation type used with
++ double word load/store instructions. Radar bug #3218027.
++ - Added tests for PPC_RELOC_LO14_SECTDIFF in both reloc_has_pair() and
++ reloc_is_sectdiff() in reloc.c .
++
++Changes for the 5.12 release (the cctools-466 release):
++- Fixed the incorrect casts on the comparison of the nlist struct's n_strx field
++ where the value being compared to was casted to a long. The correct fix was
++ to cast n_strx to an unsigned long.
++- Added the missing checking of the dylib_module struct in ofile.c so that it
++ would not return an ofile struct with a bad dylib_module. Also fixed a number
++ of places the routine Mach_O_error() was called to print an error message but
++ the code failed to return a failure status. Radar bug #3208399.
++
++Changes for the 5.12 release (the cctools-464 release):
++- Made changes to build cleanly with gcc3.3
++ - Removed -Wno-precomp from the Makefile
++ - Fixed warnings for "comparison between signed and unsigned" in writeout.c,
++ symbol_list.c, ofile_get_word.c, round.c, ofile.c, and best_arch.c .
++
++Changes for the 5.12 release (the cctools-462 release):
++- Added support for MH_DYLIB_STUB libraries. Radar bug #3193744.
++ - Did NOT change writeout() in writeout.c to handle the timestamp in
++ MH_DYLIB_STUB filetypes like MH_DYLIB filetypes as the timestamp should
++ not be changed or else this would mess up building prebound.
++ - Changed the routines in ofile.c to handle MH_DYLIB_STUB filetypes like
++ MH_DYLIB filetypes.
++ - Changed check_object() in checkout.c to handle MH_DYLIB_STUB filetypes like
++ MH_DYLIB filetypes.
++
++Changes for the 5.12 release (the cctools-457 release):
++- Changed ofile_map() added ofile_map_from_memory() which is everything from
++ the original ofile_map() except mapping the file. This is needed so the
++ NSCreateObjectFileImageFromMemory() api can be implemented. Radar bug
++ #3131622.
++
++Changes for the 5.12 release (the cctools-455 release):
++- Changed the code in dylib_roots.c to remove the check that the actual path of
++ a binary equals the install name of the dynamic library. Radar bug #3147668.
++
++Changes for the 5.12 release (the cctools-450 release):
++- Changed get_segalign_from_flag() in arch.c to have 4K returned for i386 also.
++ Radar bug #3120579.
++
++Changes for the 5.12 release (the cctools-449 release):
++- Added the arch flag i686 to be the same as pentpro in arch.c. Radar bug
++ #3111977.
++
++Changes for the 5.11 release (the cctools-444 release):
++- Added the file symbol_list.c which contains the code from strip.c for the
++ symbol lists. Now also used by ld(1)'s -exported_symbols_list and
++ -unexported_symbols_list options. Radar bug #3083844.
++- Picked up fix to LocForDylib() in SymLoc.c that was crashing when the
++ DylibProjects directory was empty. Radar bug #3079374.
++
+ Changes for the 5.11 release (the cctools-440 release):
+ - Fixed the warnings about extra tokens at end of #endif directive in ofile.c
+ (Radar bug #3072042).
+diff -ubr libstuff/ofile.c libstuff/ofile.c
+--- libstuff/ofile.c Tue Jan 14 23:35:27 2003
++++ libstuff/ofile.c Mon Aug 25 23:49:59 2003
+@@ -27,6 +27,7 @@
+ #include <libc.h>
+ #include <mach/mach.h>
+ #include "stuff/openstep_mach.h"
++#include <stddef.h>
+ #include <stdarg.h>
+ #include <limits.h>
+ #include <errno.h>
+@@ -35,12 +36,12 @@
+ #include <sys/file.h>
+ #include <mach-o/fat.h>
+ #include <mach-o/loader.h>
+-#import <mach/m68k/thread_status.h>
+-#import <mach/ppc/thread_status.h>
+-#import <mach/m88k/thread_status.h>
+-#import <mach/i860/thread_status.h>
+-#import <mach/i386/thread_status.h>
+-#import <mach/sparc/thread_status.h>
++#include <mach/m68k/thread_status.h>
++#include <mach/ppc/thread_status.h>
++#include <mach/m88k/thread_status.h>
++#include <mach/i860/thread_status.h>
++#include <mach/i386/thread_status.h>
++#include <mach/sparc/thread_status.h>
+ #include <mach-o/nlist.h>
+ #include <mach-o/reloc.h>
+ #include "stuff/bool.h"
+@@ -91,6 +92,12 @@
+ unsigned long *member_name_size);
+ static enum check_type check_Mach_O(
+ struct ofile *ofile);
++static enum check_type check_dylib_module(
++ struct ofile *ofile,
++ struct symtab_command *st,
++ struct dysymtab_command *dyst,
++ char *strings,
++ unsigned long module_index);
+
+ #ifndef OFI
+ /*
+@@ -229,7 +236,8 @@
+ else if(process_non_objects == TRUE ||
+ ofile.arch_type == OFILE_Mach_O){
+ if(ofile.arch_type == OFILE_Mach_O &&
+- ofile.mh->filetype == MH_DYLIB){
++ (ofile.mh->filetype == MH_DYLIB ||
++ ofile.mh->filetype == MH_DYLIB_STUB)){
+ if(dylib_flat == TRUE){
+ processor(&ofile, arch_name, cookie);
+ }
+@@ -349,7 +357,8 @@
+ else if(process_non_objects == TRUE ||
+ ofile.arch_type == OFILE_Mach_O){
+ if(ofile.arch_type == OFILE_Mach_O &&
+- ofile.mh->filetype == MH_DYLIB){
++ (ofile.mh->filetype == MH_DYLIB ||
++ ofile.mh->filetype == MH_DYLIB_STUB)){
+ if(dylib_flat == TRUE){
+ processor(&ofile, NULL, cookie);
+ }
+@@ -445,7 +454,8 @@
+ else if(process_non_objects == TRUE ||
+ ofile.arch_type == OFILE_Mach_O){
+ if(ofile.arch_type == OFILE_Mach_O &&
+- ofile.mh->filetype == MH_DYLIB){
++ (ofile.mh->filetype == MH_DYLIB ||
++ ofile.mh->filetype == MH_DYLIB_STUB)){
+ if(dylib_flat == TRUE){
+ processor(&ofile, ofile.arch_flag.name, cookie);
+ }
+@@ -557,9 +567,9 @@
+ }
+ #ifdef OTOOL
+ if(ofile.mh->magic == SWAP_LONG(MH_MAGIC)){
+- if(SWAP_LONG(ofile.mh->cputype) ==
++ if((cpu_type_t)SWAP_LONG(ofile.mh->cputype) ==
+ arch_flags[i].cputype &&
+- (SWAP_LONG(ofile.mh->cpusubtype) ==
++ ((cpu_subtype_t)SWAP_LONG(ofile.mh->cpusubtype) ==
+ arch_flags[i].cpusubtype ||
+ family == TRUE)){
+ arch_found = TRUE;
+@@ -580,7 +590,8 @@
+ if(arch_found == FALSE)
+ return;
+ }
+- if(ofile.mh->filetype == MH_DYLIB){
++ if(ofile.mh->filetype == MH_DYLIB ||
++ ofile.mh->filetype == MH_DYLIB_STUB){
+ if(dylib_flat == TRUE){
+ processor(&ofile, NULL, cookie);
+ }
+@@ -658,19 +669,15 @@
+ {
+ int fd;
+ struct stat stat_buf;
+- unsigned long i, size, magic;
++ unsigned long size, magic;
+ kern_return_t r;
+ char *addr;
+- enum byte_sex host_byte_sex;
+- struct arch_flag host_arch_flag;
+- enum bool family;
+- const struct arch_flag *family_arch_flag;
+
+ magic = 0; /* to shut up the compiler warning message */
+ memset(ofile, '\0', sizeof(struct ofile));
+
+ /* Open the file and map it in */
+- if((fd = open(file_name, O_RDONLY)) == -1){
++ if((fd = open(file_name, O_RDWR)) == -1){
+ #ifdef OFI
+ return(NSObjectFileImageAccess);
+ #else
+@@ -700,6 +707,35 @@
+ printf("Modification time = %ld\n", (long int)stat_buf.st_mtime);
+ #endif /* OTOOL */
+
++ return(ofile_map_from_memory(addr, size, file_name, arch_flag,
++ object_name, ofile, archives_with_fat_objects));
++}
++
++/*
++ * ofile_map_from_memory() is the guts of ofile_map() but with an interface
++ * to pass the address and size of the file already mapped in.
++ */
++__private_extern__
++#ifdef OFI
++NSObjectFileImageReturnCode
++#else
++enum bool
++#endif
++ofile_map_from_memory(
++char *addr,
++unsigned long size,
++const char *file_name,
++const struct arch_flag *arch_flag, /* can be NULL */
++const char *object_name, /* can be NULL */
++struct ofile *ofile,
++enum bool archives_with_fat_objects)
++{
++ unsigned long i, magic;
++ enum byte_sex host_byte_sex;
++ struct arch_flag host_arch_flag;
++ enum bool family;
++ const struct arch_flag *family_arch_flag;
++
+ /* fill in the start of the ofile structure */
+ ofile->file_name = savestr(file_name);
+ if(ofile->file_name == NULL)
+@@ -1176,7 +1212,7 @@
+ }
+
+ #ifdef OTOOL
+- if(addr - ofile->file_addr > ofile->file_size){
++ if(addr - ofile->file_addr > (ptrdiff_t)ofile->file_size){
+ error("fat file: %s offset to architecture %s extends past end "
+ "of file", ofile->file_name, ofile->arch_flag.name);
+ return(FALSE);
+@@ -1327,7 +1363,7 @@
+ return(FALSE);
+ }
+ #ifdef OTOOL
+- if((addr + SARMAG) - ofile->file_addr > ofile->file_size){
++ if((addr + SARMAG) - ofile->file_addr > (ptrdiff_t)ofile->file_size){
+ archive_error(ofile, "offset to first member extends past the end "
+ "of the file");
+ return(FALSE);
+@@ -1832,7 +1868,7 @@
+
+ /*
+ * ofile_first_module() set up the ofile structure (the dylib_module field)
+- * for the first module of an MH_DYLIB file.
++ * for the first module of an MH_DYLIB or MH_DYLIB_STUB file.
+ */
+ __private_extern__
+ enum bool
+@@ -1856,7 +1892,8 @@
+
+ if(ofile->file_type == OFILE_FAT){
+ if(ofile->arch_type != OFILE_Mach_O &&
+- ofile->mh->filetype != MH_DYLIB){
++ (ofile->mh->filetype != MH_DYLIB &&
++ ofile->mh->filetype != MH_DYLIB_STUB)){
+ error("ofile_first_module() called on fat file: %s with a "
+ "non-MH_DYLIB architecture or no architecture selected\n",
+ ofile->file_name);
+@@ -1864,7 +1901,8 @@
+ }
+ }
+ else if(ofile->arch_type != OFILE_Mach_O &&
+- ofile->mh->filetype != MH_DYLIB){
++ (ofile->mh->filetype != MH_DYLIB &&
++ ofile->mh->filetype != MH_DYLIB_STUB)){
+ error("ofile_first_module() called and file type of %s is "
+ "non-MH_DYLIB\n", ofile->file_name);
+ return(FALSE);
+@@ -1902,20 +1940,22 @@
+ m = *ofile->dylib_module;
+ if(swapped)
+ swap_dylib_module(&m, 1, host_byte_sex);
++ if(check_dylib_module(ofile, st, dyst, strings, 0) == CHECK_BAD)
++ return(FALSE);
+ ofile->dylib_module_name = strings + m.module_name;
+ return(TRUE);
+ }
+
+ /*
+ * ofile_next_module() set up the ofile structure (the dylib_module field)
+- * for the next module of an MH_DYLIB file.
++ * for the next module of an MH_DYLIB or MH_DYLIB_STUB file.
+ */
+ __private_extern__
+ enum bool
+ ofile_next_module(
+ struct ofile *ofile)
+ {
+- unsigned long i;
++ unsigned long i, module_index;
+ struct symtab_command *st;
+ struct dysymtab_command *dyst;
+ struct load_command *lc;
+@@ -1926,7 +1966,8 @@
+
+ if(ofile->file_type == OFILE_FAT){
+ if(ofile->arch_type != OFILE_Mach_O &&
+- ofile->mh->filetype != MH_DYLIB){
++ (ofile->mh->filetype != MH_DYLIB &&
++ ofile->mh->filetype != MH_DYLIB_STUB)){
+ error("ofile_next_module() called on fat file: %s with a "
+ "non-MH_DYLIB architecture or no architecture selected\n",
+ ofile->file_name);
+@@ -1934,7 +1975,8 @@
+ }
+ }
+ else if(ofile->arch_type != OFILE_Mach_O &&
+- ofile->mh->filetype != MH_DYLIB){
++ (ofile->mh->filetype != MH_DYLIB &&
++ ofile->mh->filetype != MH_DYLIB_STUB)){
+ error("ofile_next_module() called and file type of %s is "
+ "non-MH_DYLIB\n", ofile->file_name);
+ return(FALSE);
+@@ -1959,7 +2001,8 @@
+ return(FALSE);
+ }
+
+- if((ofile->dylib_module + 1) - ofile->modtab >= ofile->nmodtab)
++ module_index = (ofile->dylib_module + 1) - ofile->modtab;
++ if(module_index >= ofile->nmodtab)
+ return(FALSE);
+
+ ofile->dylib_module++;
+@@ -1969,13 +2012,17 @@
+ m = *ofile->dylib_module;
+ if(swapped)
+ swap_dylib_module(&m, 1, host_byte_sex);
++ if(check_dylib_module(ofile, st, dyst, strings, module_index) ==
++ CHECK_BAD)
++ return(FALSE);
+ ofile->dylib_module_name = strings + m.module_name;
+ return(TRUE);
+ }
+
+ /*
+ * ofile_specific_module() set up the ofile structure (the dylib_module fields)
+- * for the specified module, module_name, of an MH_DYLIB file.
++ * for the specified module, module_name, of an MH_DYLIB or an MH_DYLIB_STUB
++ * file.
+ */
+ __private_extern__
+ enum bool
+@@ -2000,7 +2047,8 @@
+
+ if(ofile->file_type == OFILE_FAT){
+ if(ofile->arch_type != OFILE_Mach_O &&
+- ofile->mh->filetype != MH_DYLIB){
++ (ofile->mh->filetype != MH_DYLIB &&
++ ofile->mh->filetype != MH_DYLIB_STUB)){
+ error("ofile_specific_module() called on fat file: %s with a "
+ "non-MH_DYLIB architecture or no architecture selected\n",
+ ofile->file_name);
+@@ -2008,7 +2056,8 @@
+ }
+ }
+ else if(ofile->arch_type != OFILE_Mach_O &&
+- ofile->mh->filetype != MH_DYLIB){
++ (ofile->mh->filetype != MH_DYLIB &&
++ ofile->mh->filetype != MH_DYLIB_STUB)){
+ error("ofile_specific_module() called and file type of %s is "
+ "non-MH_DYLIB\n", ofile->file_name);
+ return(FALSE);
+@@ -2047,8 +2096,10 @@
+ m = *p;
+ if(swapped)
+ swap_dylib_module(&m, 1, host_byte_sex);
+- if(strcmp(module_name, strings + m.module_name) == 0){
+ ofile->dylib_module = p;
++ if(check_dylib_module(ofile, st, dyst, strings, i) == CHECK_BAD)
++ return(FALSE);
++ if(strcmp(module_name, strings + m.module_name) == 0){
+ ofile->dylib_module_name = strings + m.module_name;
+ return(TRUE);
+ }
+@@ -2520,10 +2571,12 @@
+ return(CHECK_BAD);
+ }
+ if(ofile->file_type == OFILE_FAT){
+- if(ofile->fat_archs[ofile->narch].cputype != ofile->mh->cputype)
++ if(ofile->fat_archs[ofile->narch].cputype != ofile->mh->cputype){
+ Mach_O_error(ofile, "malformed fat file (fat header "
+ "architecture: %lu's cputype does not match "
+ "object file's mach header)", ofile->narch);
++ return(CHECK_BAD);
++ }
+ }
+ /*
+ * Make a pass through the load commands checking them to the level
+@@ -3595,55 +3648,73 @@
+ }
+ }
+ if(st == NULL){
+- if(dyst != NULL)
++ if(dyst != NULL){
+ Mach_O_error(ofile, "truncated or malformed object (contains "
+ "LC_DYSYMTAB load command without a LC_SYMTAB load command)");
++ return(CHECK_BAD);
++ }
+ }
+ else{
+ if(dyst != NULL){
+ if(dyst->nlocalsym != 0 &&
+- dyst->ilocalsym > st->nsyms)
++ dyst->ilocalsym > st->nsyms){
+ Mach_O_error(ofile, "truncated or malformed object "
+ "(ilocalsym in LC_DYSYMTAB load command extends past "
+ "the end of the symbol table)");
++ return(CHECK_BAD);
++ }
+ if(dyst->nlocalsym != 0 &&
+- dyst->ilocalsym + dyst->nlocalsym > st->nsyms)
++ dyst->ilocalsym + dyst->nlocalsym > st->nsyms){
+ Mach_O_error(ofile, "truncated or malformed object "
+ "(ilocalsym plus nlocalsym in LC_DYSYMTAB load command "
+ "extends past the end of the symbol table)");
++ return(CHECK_BAD);
++ }
+
+ if(dyst->nextdefsym != 0 &&
+- dyst->iextdefsym > st->nsyms)
++ dyst->iextdefsym > st->nsyms){
+ Mach_O_error(ofile, "truncated or malformed object "
+ "(iextdefsym in LC_DYSYMTAB load command extends past "
+ "the end of the symbol table)");
++ return(CHECK_BAD);
++ }
+ if(dyst->nextdefsym != 0 &&
+- dyst->iextdefsym + dyst->nextdefsym > st->nsyms)
++ dyst->iextdefsym + dyst->nextdefsym > st->nsyms){
+ Mach_O_error(ofile, "truncated or malformed object "
+ "(iextdefsym plus nextdefsym in LC_DYSYMTAB load "
+ "command extends past the end of the symbol table)");
++ return(CHECK_BAD);
++ }
+
+ if(dyst->nundefsym != 0 &&
+- dyst->iundefsym > st->nsyms)
++ dyst->iundefsym > st->nsyms){
+ Mach_O_error(ofile, "truncated or malformed object "
+ "(iundefsym in LC_DYSYMTAB load command extends past "
+ "the end of the symbol table)");
++ return(CHECK_BAD);
++ }
+ if(dyst->nundefsym != 0 &&
+- dyst->iundefsym + dyst->nundefsym > st->nsyms)
++ dyst->iundefsym + dyst->nundefsym > st->nsyms){
+ Mach_O_error(ofile, "truncated or malformed object "
+ "(iundefsym plus nundefsym in LC_DYSYMTAB load command "
+ "extends past the end of the symbol table)");
++ return(CHECK_BAD);
++ }
+ if(rc != NULL){
+- if(rc->init_module > dyst->nmodtab)
++ if(rc->init_module > dyst->nmodtab){
+ Mach_O_error(ofile, "malformed object (init_module in "
+ "LC_ROUTINES load command extends past the end of "
+ "the module table)");
++ return(CHECK_BAD);
++ }
+ }
+ if(hints != NULL){
+- if(hints->nhints != dyst->nundefsym)
++ if(hints->nhints != dyst->nundefsym){
+ Mach_O_error(ofile, "malformed object (nhints in "
+ "LC_TWOLEVEL_HINTS load command not the same as "
+ "nundefsym in LC_DYSYMTAB load command)");
++ return(CHECK_BAD);
++ }
+ }
+ }
+ }
+@@ -3655,6 +3726,109 @@
+ }
+
+ /* looks good return ok */
++ return(CHECK_GOOD);
++#endif /* OTOOL */
++}
++
++/*
++ * check_dylib_module() checks the object file's dylib_module as referenced
++ * by the dylib_module field in the ofile for correctness.
++ */
++static
++enum check_type
++check_dylib_module(
++struct ofile *ofile,
++struct symtab_command *st,
++struct dysymtab_command *dyst,
++char *strings,
++unsigned long module_index)
++{
++#ifdef OTOOL
++ return(CHECK_GOOD);
++#else /* !defined OTOOL */
++ unsigned long i;
++ enum byte_sex host_byte_sex;
++ enum bool swapped;
++ struct dylib_module m;
++
++ m = *ofile->dylib_module;
++ host_byte_sex = get_host_byte_sex();
++ swapped = (enum bool)(host_byte_sex != ofile->object_byte_sex);
++ if(swapped)
++ swap_dylib_module(&m, 1, host_byte_sex);
++
++ if(m.module_name > st->strsize){
++ Mach_O_error(ofile, "truncated or malformed object (module_name "
++ "of module table entry %lu past the end of the string table)",
++ module_index);
++ return(CHECK_BAD);
++ }
++ for(i = m.module_name; i < st->strsize && strings[i] != '\0'; i++)
++ ;
++ if(i >= st->strsize){
++ Mach_O_error(ofile, "truncated or malformed object (module_name "
++ "of module table entry %lu extends past the end of the string "
++ "table)", module_index);
++ return(CHECK_BAD);
++ }
++
++ if(m.nextdefsym != 0){
++ if(m.iextdefsym > st->nsyms){
++ Mach_O_error(ofile, "truncated or malformed object (iextdefsym "
++ "field of module table entry %lu past the end of the "
++ "symbol table", module_index);
++ return(CHECK_BAD);
++ }
++ if(m.iextdefsym + m.nextdefsym > st->nsyms){
++ Mach_O_error(ofile, "truncated or malformed object (iextdefsym "
++ "field of module table entry %lu plus nextdefsym field "
++ "extends past the end of the symbol table", module_index);
++ return(CHECK_BAD);
++ }
++ }
++ if(m.nlocalsym != 0){
++ if(m.ilocalsym > st->nsyms){
++ Mach_O_error(ofile, "truncated or malformed object (ilocalsym "
++ "field of module table entry %lu past the end of the "
++ "symbol table", module_index);
++ return(CHECK_BAD);
++ }
++ if(m.ilocalsym + m.nlocalsym > st->nsyms){
++ Mach_O_error(ofile, "truncated or malformed object (ilocalsym "
++ "field of module table entry %lu plus nlocalsym field "
++ "extends past the end of the symbol table", module_index);
++ return(CHECK_BAD);
++ }
++ }
++ if(m.nrefsym != 0){
++ if(m.irefsym > dyst->nextrefsyms){
++ Mach_O_error(ofile, "truncated or malformed object (irefsym "
++ "field of module table entry %lu past the end of the "
++ "reference table", module_index);
++ return(CHECK_BAD);
++ }
++ if(m.irefsym + m.nrefsym > dyst->nextrefsyms){
++ Mach_O_error(ofile, "truncated or malformed object (irefsym "
++ "field of module table entry %lu plus nrefsym field "
++ "extends past the end of the reference table",module_index);
++ return(CHECK_BAD);
++ }
++ }
++ if(m.nextrel != 0){
++ if(m.iextrel > dyst->extreloff){
++ Mach_O_error(ofile, "truncated or malformed object (iextrel "
++ "field of module table entry %lu past the end of the "
++ "external relocation enrties", module_index);
++ return(CHECK_BAD);
++ }
++ if(m.iextrel + m.nextrel > dyst->extreloff){
++ Mach_O_error(ofile, "truncated or malformed object (iextrel "
++ "field of module table entry %lu plus nextrel field "
++ "extends past the end of the external relocation enrties",
++ module_index);
++ return(CHECK_BAD);
++ }
++ }
+ return(CHECK_GOOD);
+ #endif /* OTOOL */
+ }
+diff -ubr libstuff/ofile_get_word.c libstuff/ofile_get_word.c
+--- libstuff/ofile_get_word.c Fri Sep 6 18:28:00 2002
++++ libstuff/ofile_get_word.c Mon Aug 25 13:17:40 2003
+@@ -34,7 +34,7 @@
+ unsigned long *word,
+ void *get_word_data /* struct mach_object_file *ofile */ )
+ {
+- int i, j;
++ unsigned long i, j;
+ struct load_command *lc;
+ struct segment_command *sg;
+ struct section *s;
+diff -ubr libstuff/print.c libstuff/print.c
+--- libstuff/print.c Tue Apr 30 00:37:20 2002
++++ libstuff/print.c Mon Aug 25 13:17:40 2003
+@@ -21,8 +21,8 @@
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+-#import <stdio.h>
+-#import "stuff/print.h"
++#include <stdio.h>
++#include "stuff/print.h"
+
+ /*
+ * All printing of all messages for ofile functions goes through this function.
+diff -ubr libstuff/reloc.c libstuff/reloc.c
+--- libstuff/reloc.c Tue Jan 14 23:35:27 2003
++++ libstuff/reloc.c Mon Aug 25 13:17:40 2003
+@@ -106,6 +106,7 @@
+ r_type == PPC_RELOC_SECTDIFF ||
+ r_type == PPC_RELOC_HI16_SECTDIFF ||
+ r_type == PPC_RELOC_LO16_SECTDIFF ||
++ r_type == PPC_RELOC_LO14_SECTDIFF ||
+ r_type == PPC_RELOC_HA16_SECTDIFF ||
+ r_type == PPC_RELOC_JBSR)
+ return(TRUE);
+@@ -164,6 +165,7 @@
+ if(r_type == PPC_RELOC_SECTDIFF ||
+ r_type == PPC_RELOC_HI16_SECTDIFF ||
+ r_type == PPC_RELOC_LO16_SECTDIFF ||
++ r_type == PPC_RELOC_LO14_SECTDIFF ||
+ r_type == PPC_RELOC_HA16_SECTDIFF)
+ return(TRUE);
+ break;
+diff -ubr libstuff/round.c libstuff/round.c
+--- libstuff/round.c Tue Apr 30 00:37:20 2002
++++ libstuff/round.c Mon Aug 25 13:17:40 2003
+@@ -26,9 +26,9 @@
+ * round() rounds v to a multiple of r.
+ */
+ __private_extern__
+-long
++unsigned long
+ round(
+-long v,
++unsigned long v,
+ unsigned long r)
+ {
+ r--;
+diff -ubr libstuff/swap_headers.c libstuff/swap_headers.c
+--- libstuff/swap_headers.c Tue Jan 14 23:35:27 2003
++++ libstuff/swap_headers.c Mon Aug 25 13:17:40 2003
+@@ -22,13 +22,13 @@
+ * @APPLE_LICENSE_HEADER_END@
+ */
+ #include <mach-o/loader.h>
+-#import <mach/m68k/thread_status.h>
+-#import <mach/ppc/thread_status.h>
+-#import <mach/m88k/thread_status.h>
+-#import <mach/i860/thread_status.h>
+-#import <mach/i386/thread_status.h>
+-#import <mach/hppa/thread_status.h>
+-#import <mach/sparc/thread_status.h>
++#include <mach/m68k/thread_status.h>
++#include <mach/ppc/thread_status.h>
++#include <mach/m88k/thread_status.h>
++#include <mach/i860/thread_status.h>
++#include <mach/i386/thread_status.h>
++#include <mach/hppa/thread_status.h>
++#include <mach/sparc/thread_status.h>
+ #include "stuff/bool.h"
+ #include "stuff/bytesex.h"
+ #include "stuff/errors.h"
+Only in libstuff: symbol_list.c
+diff -ubr libstuff/writeout.c libstuff/writeout.c
+--- libstuff/writeout.c Fri Sep 6 18:28:00 2002
++++ libstuff/writeout.c Mon Aug 25 13:17:40 2003
+@@ -511,7 +511,7 @@
+ write_size = (file + file_size) - p;
+ else
+ write_size = WRITE_SIZE;
+- if(write(fd, p, write_size) != write_size){
++ if(write(fd, p, write_size) != (int)write_size){
+ system_error("can't write output file: %s", output);
+ goto cleanup;
+ }
+@@ -560,7 +560,7 @@
+ }
+ else{
+ no_throttle:
+- if(write(fd, file, file_size) != file_size){
++ if(write(fd, file, file_size) != (int)file_size){
+ system_error("can't write output file: %s", output);
+ goto cleanup;
+ }
+@@ -807,7 +807,7 @@
+ strings_size = object->output_strings_size;
+ }
+ for(j = 0; j < nsymbols; j++){
+- if(symbols[j].n_un.n_strx > strings_size)
++ if((unsigned long)symbols[j].n_un.n_strx > strings_size)
+ continue;
+ if(toc_symbol(symbols + j, commons_in_toc,
+ object->sections) == TRUE){
+@@ -998,7 +998,7 @@
+ char *output,
+ enum bool library_warnings)
+ {
+- long i;
++ unsigned long i;
+ enum bool multiple_defs;
+ struct member *member;
+
+@@ -1008,7 +1008,7 @@
+ * only once (marked by changing the sign of their ran_off).
+ */
+ multiple_defs = FALSE;
+- for(i = 0; i < (long)arch->toc_nranlibs - 1; i++){
++ for(i = 0; i < arch->toc_nranlibs - 1; i++){
+ if(strcmp(arch->toc_ranlibs[i].ran_un.ran_name,
+ arch->toc_ranlibs[i+1].ran_un.ran_name) == 0){
+ if(multiple_defs == FALSE){