2003/09/07 04:46:18
[org.ibex.core.git] / upstream / darwin-linker / patches / libstuff.patch
1 Only in libstuff/: CVS
2 diff -rub libstuff/Makefile libstuff/Makefile
3 --- libstuff/Makefile   Fri Sep  6 18:27:55 2002
4 +++ libstuff/Makefile   Sat Sep  6 20:12:21 2003
5 @@ -1,7 +1,7 @@
6  RC_OS = macos
7  OFLAG = -O
8  ifeq "macos" "$(RC_OS)"
9 -  X_CFLAGS := $(shell if [ "$(RC_RELEASE)" != "Beaker" ] &&    \
10 +  X_CFLAGS := $(shell if [ `uname` != "Linux" ] && [ "$(RC_RELEASE)" != "Beaker" ] &&    \
11                          [ "$(RC_RELEASE)" != "Bunsen" ] &&    \
12                          [ "$(RC_RELEASE)" != "Gonzo"  ] &&    \
13                          [ "$(RC_RELEASE)" != "Kodiak" ]; then \
14 @@ -10,14 +10,18 @@
15  endif
16  
17  
18 -USE_DEPENDENCY_FILE := $(shell if [ "$(notdir $(CC))" != "mwccppc" ]; then \
19 +USE_DEPENDENCY_FILE := $(shell if [ `uname` != "Linux" ] && [ "$(notdir $(CC))" != "mwccppc" ]; then \
20              echo YES ; else echo NO ; \
21              fi; )
22         
23  ifeq "mwccppc" "$(notdir $(CC))"
24    CFLAGS = $(OFLAG) -g -gccinc -I$(SRCROOT)/../include
25  else
26 -  CFLAGS = $(OFLAG) -g -I$(SRCROOT)/../include -Wall -Wno-precomp $(X_CFLAGS)
27 +  ifeq "Linux" "$(shell uname)"
28 +    CFLAGS = $(OFLAG) -g -I$(SRCROOT)/../include -Wall $(X_CFLAGS) -D__LITTLE_ENDIAN__ -U__BIG_ENDIAN__ -D__ppc__ -I/usr/include -I../../../macosx-include
29 +  else
30 +    CFLAGS = $(OFLAG) -g -I$(SRCROOT)/../include -Wall $(X_CFLAGS)
31 +  endif
32  endif
33  
34  ifneq "" "$(wildcard /bin/mkdirs)"
35 @@ -40,7 +44,8 @@
36           set_arch_flag_name.c seg_addr_table.c dylib_table.c \
37           breakout.c writeout.c checkout.c fatal_arch.c ofile_get_word.c \
38           vm_flush_cache.c hash_string.c dylib_roots.c guess_short_name.c \
39 -         SymLoc.c get_arch_from_host.c crc32.c macosx_deployment_target.c
40 +         SymLoc.c get_arch_from_host.c crc32.c macosx_deployment_target.c \
41 +         symbol_list.c fake-mach.c
42  OBJS = $(CFILES:.c=.o)
43  INSTALL_FILES = $(CFILES) Makefile notes
44  
45 @@ -90,7 +95,7 @@
46                 OFILE_DIR=.                                             \
47                 SRCROOT=..                                              \
48                 SYMROOT=..                                              \
49 -               COPTS="-dynamic"                                        \
50 +               COPTS=""                                        \
51                 OFLAG="$(OFLAG)"                                        \
52                 CFILES="$(CFILES)"                                      \
53                 RC_CFLAGS="$(RC_CFLAGS)"                                \
54 @@ -103,7 +108,7 @@
55                 OFILE_DIR=$(OBJROOT)/dynamic_obj                        \
56                 SRCROOT=$(SRCROOT)                                      \
57                 SYMROOT=$(SYMROOT)                                      \
58 -               COPTS="-dynamic"                                        \
59 +               COPTS=""                                        \
60                 OFLAG="$(OFLAG)"                                        \
61                 CFILES="$(CFILES)"                                      \
62                 RC_CFLAGS="$(RC_CFLAGS)"                                \
63 @@ -120,7 +125,7 @@
64                 OFILE_DIR=.                                             \
65                 SRCROOT=..                                              \
66                 SYMROOT=..                                              \
67 -               COPTS="-dynamic -pg"                                    \
68 +               COPTS="-pg"                                     \
69                 OFLAG="$(OFLAG)"                                        \
70                 RC_CFLAGS="$(RC_CFLAGS)"                                \
71                 RC_ARCHS="$(RC_ARCHS)";                                 \
72 @@ -132,7 +137,7 @@
73                 OFILE_DIR=$(OBJROOT)/profile_obj                        \
74                 SRCROOT=$(SRCROOT)                                      \
75                 SYMROOT=$(SYMROOT)                                      \
76 -               COPTS="-dynamic -pg"                                    \
77 +               COPTS="-pg"                                     \
78                 OFLAG="$(OFLAG)"                                        \
79                 RC_CFLAGS="$(RC_CFLAGS)"                                \
80                 RC_ARCHS="$(RC_ARCHS)";                                 \
81 @@ -167,7 +172,8 @@
82         fi
83  
84  $(PRODUCT):    $(OFILE_DIR) $(SYMROOT) $(OBJS)
85 -       libtool -static -o $(SYMROOT)/$(PRODUCT) $(OBJS)
86 +       ar r $(SYMROOT)/$(PRODUCT) $(OBJS)
87 +       ranlib $(SYMROOT)/$(PRODUCT)
88  
89  ifeq "NO" "$(USE_DEPENDENCY_FILE)"
90  .c.o:
91 diff -rub libstuff/SymLoc.c libstuff/SymLoc.c
92 --- libstuff/SymLoc.c   Fri Sep  6 18:27:55 2002
93 +++ libstuff/SymLoc.c   Mon Aug 25 13:17:40 2003
94 @@ -1,15 +1,15 @@
95 -#import <libc.h>
96 -#import <ctype.h>
97 -#import <sys/types.h>
98 +#include <libc.h>
99 +#include <ctype.h>
100 +#include <sys/types.h>
101  #ifdef __OPENSTEP__
102  #define _POSIX_SOURCE
103  #endif
104 -#import <dirent.h>
105 -#import <pwd.h>
106 -#import "stuff/bool.h"
107 -#import "stuff/errors.h"
108 -#import "stuff/allocate.h"
109 -#import "stuff/SymLoc.h"
110 +#include <dirent.h>
111 +#include <pwd.h>
112 +#include "stuff/bool.h"
113 +#include "stuff/errors.h"
114 +#include "stuff/allocate.h"
115 +#include "stuff/SymLoc.h"
116  
117  const char *
118  symLocForDylib(const char *installName, const char *releaseName,
119 @@ -101,6 +101,7 @@
120          system_error("symLocForDylib(): Can't opendir %s", buf);
121          return NULL;
122      }
123 +    c = NULL;
124  
125      // read DylibProjects entries
126      *buf = '\0';
127 diff -rub libstuff/arch.c libstuff/arch.c
128 --- libstuff/arch.c     Tue Jan 14 23:35:27 2003
129 +++ libstuff/arch.c     Mon Aug 25 13:17:40 2003
130 @@ -60,11 +60,13 @@
131      { "ppc750", CPU_TYPE_POWERPC, CPU_SUBTYPE_POWERPC_750 },
132      { "ppc7400",CPU_TYPE_POWERPC, CPU_SUBTYPE_POWERPC_7400 },
133      { "ppc7450",CPU_TYPE_POWERPC, CPU_SUBTYPE_POWERPC_7450 },
134 +    { "ppc970", CPU_TYPE_POWERPC, CPU_SUBTYPE_POWERPC_970 },
135      { "i486",   CPU_TYPE_I386,    CPU_SUBTYPE_486 },
136      { "i486SX", CPU_TYPE_I386,    CPU_SUBTYPE_486SX },
137      { "pentium",CPU_TYPE_I386,    CPU_SUBTYPE_PENT }, /* same as i586 */
138      { "i586",   CPU_TYPE_I386,    CPU_SUBTYPE_586 },
139 -    { "pentpro", CPU_TYPE_I386, CPU_SUBTYPE_PENTPRO },
140 +    { "pentpro", CPU_TYPE_I386, CPU_SUBTYPE_PENTPRO }, /* same as i686 */
141 +    { "i686",   CPU_TYPE_I386, CPU_SUBTYPE_PENTPRO },
142      { "pentIIm3",CPU_TYPE_I386, CPU_SUBTYPE_PENTII_M3 },
143      { "pentIIm5",CPU_TYPE_I386, CPU_SUBTYPE_PENTII_M5 },
144      { "m68030", CPU_TYPE_MC680x0, CPU_SUBTYPE_MC68030_ONLY },
145 @@ -269,7 +271,8 @@
146  const struct arch_flag *flag)
147  {
148         if(flag->cputype == CPU_TYPE_POWERPC ||
149 -          flag->cputype == CPU_TYPE_VEO)
150 +          flag->cputype == CPU_TYPE_VEO ||
151 +          flag->cputype == CPU_TYPE_I386)
152             return(0x1000); /* 4K */
153         else
154             return(0x2000); /* 8K */
155 diff -rub libstuff/best_arch.c libstuff/best_arch.c
156 --- libstuff/best_arch.c        Tue Jan 14 23:35:27 2003
157 +++ libstuff/best_arch.c        Mon Aug 25 13:17:40 2003
158 @@ -44,7 +44,8 @@
159  struct fat_arch *fat_archs,
160  unsigned long nfat_archs)
161  {
162 -    unsigned long i, lowest_family, lowest_model, lowest_index;
163 +    unsigned long i;
164 +    long lowest_family, lowest_model, lowest_index;
165  
166         /*
167          * Look for the first exact match.
168 @@ -183,14 +184,21 @@
169              * An exact match as not found.  So for all the PowerPC subtypes
170              * pick the subtype from the following order starting from a subtype
171              * that will work (contains altivec if needed):
172 -            *  7450, 7400, 750, 604e, 604, 603ev, 603e, 603, ALL
173 +            *  790, 7450, 7400, 750, 604e, 604, 603ev, 603e, 603, ALL
174              * Note the 601 is NOT in the list above.  It is only picked via
175              * an exact match.  For an unknown subtype pick only the ALL type if
176              * it exists.
177              */
178             switch(cpusubtype){
179 +           case CPU_SUBTYPE_POWERPC_970:
180             case CPU_SUBTYPE_POWERPC_7450:
181             case CPU_SUBTYPE_POWERPC_7400:
182 +               for(i = 0; i < nfat_archs; i++){
183 +                   if(fat_archs[i].cputype != cputype)
184 +                       continue;
185 +                   if(fat_archs[i].cpusubtype == CPU_SUBTYPE_POWERPC_970)
186 +                       return(fat_archs + i);
187 +               }
188                 for(i = 0; i < nfat_archs; i++){
189                     if(fat_archs[i].cputype != cputype)
190                         continue;
191 diff -rub libstuff/bytesex.c libstuff/bytesex.c
192 --- libstuff/bytesex.c  Fri Sep  6 18:27:56 2002
193 +++ libstuff/bytesex.c  Mon Aug 25 13:17:40 2003
194 @@ -25,13 +25,13 @@
195  #include <string.h>
196  #include <mach-o/fat.h>
197  #include <mach-o/loader.h>
198 -#import <mach/m68k/thread_status.h>
199 -#import <mach/ppc/thread_status.h>
200 -#import <mach/m88k/thread_status.h>
201 -#import <mach/i860/thread_status.h>
202 -#import <mach/i386/thread_status.h>
203 -#import <mach/hppa/thread_status.h>
204 -#import <mach/sparc/thread_status.h>
205 +#include <mach/m68k/thread_status.h>
206 +#include <mach/ppc/thread_status.h>
207 +#include <mach/m88k/thread_status.h>
208 +#include <mach/i860/thread_status.h>
209 +#include <mach/i386/thread_status.h>
210 +#include <mach/hppa/thread_status.h>
211 +#include <mach/sparc/thread_status.h>
212  #include <mach-o/nlist.h>
213  #include <mach-o/reloc.h>
214  #include <mach-o/ranlib.h>
215 diff -rub libstuff/checkout.c libstuff/checkout.c
216 --- libstuff/checkout.c Fri Sep  6 18:27:57 2002
217 +++ libstuff/checkout.c Mon Aug 25 13:17:40 2003
218 @@ -132,9 +132,11 @@
219             }
220             lc = (struct load_command *)((char *)lc + lc->cmdsize);
221         }
222 -       if(object->mh->filetype == MH_DYLIB && dl_id == NULL)
223 +       if((object->mh->filetype == MH_DYLIB ||
224 +           object->mh->filetype == MH_DYLIB_STUB) && dl_id == NULL)
225             fatal_arch(arch, member, "malformed file (no LC_ID_DYLIB load "
226 -               "command in MH_DYLIB file): ");
227 +               "command in %s file): ", object->mh->filetype == MH_DYLIB ?
228 +               "MH_DYLIB" : "MH_DYLIB_STUB");
229         if(object->hints_cmd != NULL){
230             if(object->dyst == NULL && object->hints_cmd->nhints != 0)
231                 fatal_arch(arch, member, "malformed file (LC_TWOLEVEL_HINTS "
232 @@ -161,7 +163,8 @@
233              * and a relocatable object file.  Since it has a dynamic symbol
234              * table command it could have an indirect symbol table.
235              */
236 -           if(object->mh->filetype == MH_DYLIB){
237 +           if(object->mh->filetype == MH_DYLIB /* ||
238 +              object->mh->filetype == MH_DYLIB_STUB */ ){
239                 /*
240                  * This is a dynamic shared library.
241                  * The order of the symbolic info is:
242 @@ -172,10 +175,10 @@
243                  *              undefined symbols
244                  *      two-level namespace hints
245                  *      external relocation entries
246 +                *      indirect symbol table
247                  *      table of contents
248                  *      module table
249                  *      reference table
250 -                *      indirect symbol table
251                  *      string table
252                  *              strings for external symbols
253                  *              strings for local symbols
254 diff -rub libstuff/crc32.c libstuff/crc32.c
255 --- libstuff/crc32.c    Fri Sep  6 18:27:57 2002
256 +++ libstuff/crc32.c    Mon Aug 25 13:19:21 2003
257 @@ -35,6 +35,12 @@
258   */
259  #include <sys/types.h>
260  
261 +#if ( defined(__MWERKS__) && !defined(__private_extern__) )
262 +#define __private_extern__ __declspec(private_extern)
263 +#elif ( defined(__linux__) && !defined(__private_extern__) )
264 +#define __private_extern__ extern
265 +#endif
266 +
267  static const u_int32_t crctab[] = {
268         0x0,
269         0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
270 diff -rub libstuff/dylib_roots.c libstuff/dylib_roots.c
271 --- libstuff/dylib_roots.c      Fri Sep  6 18:27:58 2002
272 +++ libstuff/dylib_roots.c      Mon Aug 25 13:17:40 2003
273 @@ -21,7 +21,7 @@
274      enum bool check_result;
275  };
276  
277 -static void check_for_install_name(
278 +static void check_for_dylib(
279      struct ofile *ofile,
280      char *arch_name,
281      void *cookie);
282 @@ -77,7 +77,7 @@
283                 }
284             }
285             ofile_process(image_file_name, NULL, 0, TRUE,
286 -                         TRUE, TRUE, FALSE, check_for_install_name, &block);
287 +                         TRUE, TRUE, FALSE, check_for_dylib, &block);
288             if(block.check_result == TRUE)
289                 return(image_file_name);
290             free(image_file_name);
291 @@ -148,14 +148,14 @@
292  #endif
293                 /*
294                  * Now that we found a file with the same base_name in the root
295 -                * check to see that it is a dynamic library with the correct
296 -                * install name.  Assume it is an if it is not then the
297 -                * routine check_for_install_name() will reset the check_result
298 -                * in the block passed to it back to FALSE.
299 +                * check to see that it is a dynamic library. Assume it is an
300 +                * if it is not then the routine check_for_dylib() will 
301 +                * reset the check_result in the block passed to 
302 +                * it back to FALSE.
303                  */
304                 block.check_result = TRUE;
305                 ofile_process(ftsent->fts_path, NULL, 0, TRUE,
306 -                             TRUE, TRUE, FALSE, check_for_install_name,&block);
307 +                             TRUE, TRUE, FALSE, check_for_dylib,&block);
308                 if(block.check_result == TRUE){
309                     image_file_name = allocate(ftsent->fts_pathlen + 1);
310                     strcpy(image_file_name, ftsent->fts_path);
311 @@ -189,7 +189,7 @@
312  
313  static
314  void
315 -check_for_install_name(
316 +check_for_dylib(
317  struct ofile *ofile,
318  char *arch_name,
319  void *cookie)
320 @@ -197,11 +197,9 @@
321      unsigned long i;
322      struct check_block *block;
323      struct load_command *lc;
324 -    struct dylib_command *dl;
325 -    char *name;
326  
327  #ifdef BIG_DEBUG
328 -       printf("In check_for_install_name() ofile->file_name = %s",
329 +       printf("In check_for_dylib() ofile->file_name = %s",
330                ofile->file_name);
331         if(arch_name != NULL)
332             printf(" arch_name = %s\n", arch_name);
333 @@ -218,13 +216,6 @@
334         lc = ofile->load_commands;
335         for(i = 0; i < ofile->mh->ncmds; i++){
336             if(lc->cmd == LC_ID_DYLIB){
337 -               dl = (struct dylib_command *)lc;
338 -               name = (char *)lc + dl->dylib.name.offset;
339 -               if(strncmp(name, "@executable_path/",
340 -                          sizeof("@executable_path") - 1) == 0)
341 -                   return;
342 -               if(strcmp(name, block->install_name) != 0)
343 -                   block->check_result = FALSE;
344                 return;
345             }
346             lc = (struct load_command *)((char *)lc + lc->cmdsize);
347 Only in libstuff/: dynamic_obj
348 Only in libstuff/: fake-mach.c
349 diff -rub libstuff/get_arch_from_host.c libstuff/get_arch_from_host.c
350 --- libstuff/get_arch_from_host.c       Tue Jan 14 23:35:27 2003
351 +++ libstuff/get_arch_from_host.c       Mon Aug 25 13:17:40 2003
352 @@ -181,6 +181,14 @@
353                 if(specific_arch_flag != NULL)
354                     specific_arch_flag->name = "ppc7450";
355                 return(1);
356 +           case CPU_SUBTYPE_POWERPC_970:
357 +               if(family_arch_flag != NULL){
358 +                   family_arch_flag->name = "ppc";
359 +                   family_arch_flag->cpusubtype = CPU_SUBTYPE_POWERPC_ALL;
360 +               }
361 +               if(specific_arch_flag != NULL)
362 +                   specific_arch_flag->name = "ppc970";
363 +               return(1);
364             default:
365                 if(family_arch_flag != NULL){
366                      family_arch_flag->name = "ppc";
367 Only in libstuff/: gpul_notes
368 Only in libstuff/: libstuff.a
369 Only in libstuff/: libstuff.dylib
370 Only in libstuff/: libstuff_p.a
371 diff -rub libstuff/notes libstuff/notes
372 --- libstuff/notes      Tue Jan 14 23:35:27 2003
373 +++ libstuff/notes      Mon Aug 25 12:12:33 2003
374 @@ -5,6 +5,69 @@
375  TODO:
376  - Deal with LC_PREPAGE and unknown load commands that don't need to be swapped.
377  
378 +Changes for the 5.12 release (the cctools-469 release):
379 +- Fixed a problem with the added checks of the of the dylib_module struct in
380 +  ofile.c made in cctools-466 for Radar bug #3208399 where it did not work if
381 +  the file was not in host byte sex.  The fix was to copy the struct and byte
382 +  swap it if needed before doing the checks on the copy of the struct in
383 +  check_dylib_module() in ofile.c .  Radar bug #3228664.
384 +
385 +Changes for the 5.12 release (the cctools-467 release):
386 +- Added support for the PPC_RELOC_LO14_SECTDIFF relocation type used with
387 +  double word load/store instructions. Radar bug #3218027.
388 +  - Added tests for PPC_RELOC_LO14_SECTDIFF in both reloc_has_pair() and
389 +    reloc_is_sectdiff() in reloc.c .
390 +
391 +Changes for the 5.12 release (the cctools-466 release):
392 +- Fixed the incorrect casts on the comparison of the nlist struct's n_strx field
393 +  where the value being compared to was casted to a long.  The correct fix was
394 +  to cast n_strx to an unsigned long.
395 +- Added the missing checking of the dylib_module struct in ofile.c so that it
396 +  would not return an ofile struct with a bad dylib_module.  Also fixed a number
397 +  of places the routine Mach_O_error() was called to print an error message but
398 +  the code failed to return a failure status.  Radar bug #3208399.
399 +
400 +Changes for the 5.12 release (the cctools-464 release):
401 +- Made changes to build cleanly with gcc3.3
402 +  - Removed -Wno-precomp from the Makefile
403 +  - Fixed warnings for "comparison between signed and unsigned" in writeout.c,
404 +    symbol_list.c, ofile_get_word.c, round.c, ofile.c, and best_arch.c .
405 +
406 +Changes for the 5.12 release (the cctools-462 release):
407 +- Added support for MH_DYLIB_STUB libraries.  Radar bug #3193744.
408 +  - Did NOT change writeout() in writeout.c to handle the timestamp in 
409 +    MH_DYLIB_STUB filetypes like MH_DYLIB filetypes as the timestamp should
410 +    not be changed or else this would mess up building prebound.
411 +  - Changed the routines in ofile.c to handle MH_DYLIB_STUB filetypes like
412 +    MH_DYLIB filetypes.
413 +  - Changed check_object() in checkout.c to handle MH_DYLIB_STUB filetypes like
414 +    MH_DYLIB filetypes.
415 +
416 +Changes for the 5.12 release (the cctools-457 release):
417 +- Changed ofile_map() added ofile_map_from_memory() which is everything from
418 +  the original ofile_map() except mapping the file.  This is needed so the
419 +  NSCreateObjectFileImageFromMemory() api can be implemented.  Radar bug
420 +  #3131622.
421 +
422 +Changes for the 5.12 release (the cctools-455 release):
423 +- Changed the code in dylib_roots.c to remove the check that the actual path of
424 +  a binary equals the install name of the dynamic library.  Radar bug #3147668.
425 +
426 +Changes for the 5.12 release (the cctools-450 release):
427 +- Changed get_segalign_from_flag() in arch.c to have 4K returned for i386 also.
428 +  Radar bug #3120579.
429 +
430 +Changes for the 5.12 release (the cctools-449 release):
431 +- Added the arch flag i686 to be the same as pentpro in arch.c. Radar bug
432 +  #3111977.
433 +
434 +Changes for the 5.11 release (the cctools-444 release):
435 +- Added the file symbol_list.c which contains the code from strip.c for the
436 +  symbol lists.  Now also used by ld(1)'s -exported_symbols_list and
437 +  -unexported_symbols_list options.  Radar bug #3083844.
438 +- Picked up fix to LocForDylib() in SymLoc.c that was crashing when the
439 +  DylibProjects directory was empty.  Radar bug #3079374.
440 +
441  Changes for the 5.11 release (the cctools-440 release):
442  - Fixed the warnings about extra tokens at end of #endif directive in ofile.c
443    (Radar bug #3072042).
444 diff -rub libstuff/ofile.c libstuff/ofile.c
445 --- libstuff/ofile.c    Tue Jan 14 23:35:27 2003
446 +++ libstuff/ofile.c    Tue Sep  2 20:15:34 2003
447 @@ -21,12 +21,14 @@
448   * 
449   * @APPLE_LICENSE_HEADER_END@
450   */
451 +#include "machine/endian.h"
452  #ifdef SHLIB
453  #include "shlib.h"
454  #endif
455  #include <libc.h>
456  #include <mach/mach.h>
457  #include "stuff/openstep_mach.h"
458 +#include <stddef.h>
459  #include <stdarg.h>
460  #include <limits.h>
461  #include <errno.h>
462 @@ -35,12 +37,12 @@
463  #include <sys/file.h>
464  #include <mach-o/fat.h>
465  #include <mach-o/loader.h>
466 -#import <mach/m68k/thread_status.h>
467 -#import <mach/ppc/thread_status.h>
468 -#import <mach/m88k/thread_status.h>
469 -#import <mach/i860/thread_status.h>
470 -#import <mach/i386/thread_status.h>
471 -#import <mach/sparc/thread_status.h>
472 +#include <mach/m68k/thread_status.h>
473 +#include <mach/ppc/thread_status.h>
474 +#include <mach/m88k/thread_status.h>
475 +#include <mach/i860/thread_status.h>
476 +#include <mach/i386/thread_status.h>
477 +#include <mach/sparc/thread_status.h>
478  #include <mach-o/nlist.h>
479  #include <mach-o/reloc.h>
480  #include "stuff/bool.h"
481 @@ -91,6 +93,12 @@
482      unsigned long *member_name_size);
483  static enum check_type check_Mach_O(
484      struct ofile *ofile);
485 +static enum check_type check_dylib_module(
486 +    struct ofile *ofile,
487 +    struct symtab_command *st,
488 +    struct dysymtab_command *dyst,
489 +    char *strings,
490 +    unsigned long module_index);
491  
492  #ifndef OFI
493  /*
494 @@ -229,7 +237,8 @@
495                             else if(process_non_objects == TRUE ||
496                                     ofile.arch_type == OFILE_Mach_O){
497                                 if(ofile.arch_type == OFILE_Mach_O &&
498 -                                  ofile.mh->filetype == MH_DYLIB){
499 +                                  (ofile.mh->filetype == MH_DYLIB ||
500 +                                   ofile.mh->filetype == MH_DYLIB_STUB)){
501                                     if(dylib_flat == TRUE){
502                                         processor(&ofile, arch_name, cookie);
503                                     }
504 @@ -349,7 +358,8 @@
505                         else if(process_non_objects == TRUE ||
506                                 ofile.arch_type == OFILE_Mach_O){
507                             if(ofile.arch_type == OFILE_Mach_O &&
508 -                              ofile.mh->filetype == MH_DYLIB){
509 +                              (ofile.mh->filetype == MH_DYLIB ||
510 +                               ofile.mh->filetype == MH_DYLIB_STUB)){
511                                 if(dylib_flat == TRUE){
512                                     processor(&ofile, NULL, cookie);
513                                 }
514 @@ -445,7 +455,8 @@
515                 else if(process_non_objects == TRUE ||
516                         ofile.arch_type == OFILE_Mach_O){
517                     if(ofile.arch_type == OFILE_Mach_O &&
518 -                      ofile.mh->filetype == MH_DYLIB){
519 +                      (ofile.mh->filetype == MH_DYLIB ||
520 +                       ofile.mh->filetype == MH_DYLIB_STUB)){
521                         if(dylib_flat == TRUE){
522                             processor(&ofile, ofile.arch_flag.name, cookie);
523                         }
524 @@ -557,9 +568,9 @@
525                     }
526  #ifdef OTOOL
527                     if(ofile.mh->magic == SWAP_LONG(MH_MAGIC)){
528 -                       if(SWAP_LONG(ofile.mh->cputype) ==
529 +                       if((cpu_type_t)SWAP_LONG(ofile.mh->cputype) ==
530                                 arch_flags[i].cputype &&
531 -                          (SWAP_LONG(ofile.mh->cpusubtype) ==
532 +                          ((cpu_subtype_t)SWAP_LONG(ofile.mh->cpusubtype) ==
533                                 arch_flags[i].cpusubtype ||
534                             family == TRUE)){
535                             arch_found = TRUE;
536 @@ -580,7 +591,8 @@
537                 if(arch_found == FALSE)
538                     return;
539             }
540 -           if(ofile.mh->filetype == MH_DYLIB){
541 +           if(ofile.mh->filetype == MH_DYLIB ||
542 +              ofile.mh->filetype == MH_DYLIB_STUB){
543                 if(dylib_flat == TRUE){
544                     processor(&ofile, NULL, cookie);
545                 }
546 @@ -658,19 +670,15 @@
547  {
548      int fd;
549      struct stat stat_buf;
550 -    unsigned long i, size, magic;
551 +    unsigned long size, magic;
552      kern_return_t r;
553      char *addr;
554 -    enum byte_sex host_byte_sex;
555 -    struct arch_flag host_arch_flag;
556 -    enum bool family;
557 -    const struct arch_flag *family_arch_flag;
558  
559         magic = 0; /* to shut up the compiler warning message */
560         memset(ofile, '\0', sizeof(struct ofile));
561  
562         /* Open the file and map it in */
563 -       if((fd = open(file_name, O_RDONLY)) == -1){
564 +       if((fd = open(file_name, O_RDWR)) == -1){
565  #ifdef OFI
566             return(NSObjectFileImageAccess);
567  #else
568 @@ -700,6 +708,35 @@
569             printf("Modification time = %ld\n", (long int)stat_buf.st_mtime);
570  #endif /* OTOOL */
571  
572 +       return(ofile_map_from_memory(addr, size, file_name, arch_flag,
573 +                            object_name, ofile, archives_with_fat_objects));
574 +}
575 +
576 +/*
577 + * ofile_map_from_memory() is the guts of ofile_map() but with an interface
578 + * to pass the address and size of the file already mapped in.
579 + */
580 +__private_extern__
581 +#ifdef OFI
582 +NSObjectFileImageReturnCode
583 +#else
584 +enum bool
585 +#endif
586 +ofile_map_from_memory(
587 +char *addr,
588 +unsigned long size,
589 +const char *file_name,
590 +const struct arch_flag *arch_flag,     /* can be NULL */
591 +const char *object_name,               /* can be NULL */
592 +struct ofile *ofile,
593 +enum bool archives_with_fat_objects)
594 +{
595 +    unsigned long i, magic;
596 +    enum byte_sex host_byte_sex;
597 +    struct arch_flag host_arch_flag;
598 +    enum bool family;
599 +    const struct arch_flag *family_arch_flag;
600 +
601         /* fill in the start of the ofile structure */
602         ofile->file_name = savestr(file_name);
603         if(ofile->file_name == NULL)
604 @@ -939,7 +976,7 @@
605                 }
606             }
607         }
608 -       /* see if this file is Mach-O file */
609 +
610         else if(size >= sizeof(struct mach_header) &&
611                 (magic == MH_MAGIC || magic == SWAP_LONG(MH_MAGIC))){
612             ofile->file_type = OFILE_Mach_O;
613 @@ -1176,7 +1213,7 @@
614         }
615  
616  #ifdef OTOOL
617 -       if(addr - ofile->file_addr > ofile->file_size){
618 +       if(addr - ofile->file_addr > (ptrdiff_t)ofile->file_size){
619             error("fat file: %s offset to architecture %s extends past end "
620                   "of file", ofile->file_name, ofile->arch_flag.name);
621             return(FALSE);
622 @@ -1327,7 +1364,7 @@
623             return(FALSE);
624         }
625  #ifdef OTOOL
626 -       if((addr + SARMAG) - ofile->file_addr > ofile->file_size){
627 +       if((addr + SARMAG) - ofile->file_addr > (ptrdiff_t)ofile->file_size){
628             archive_error(ofile, "offset to first member extends past the end "
629                           "of the file");
630             return(FALSE);
631 @@ -1832,7 +1869,7 @@
632  
633  /*
634   * ofile_first_module() set up the ofile structure (the dylib_module field)
635 - * for the first module of an MH_DYLIB file.
636 + * for the first module of an MH_DYLIB or MH_DYLIB_STUB file.
637   */
638  __private_extern__
639  enum bool
640 @@ -1856,7 +1893,8 @@
641  
642         if(ofile->file_type == OFILE_FAT){
643             if(ofile->arch_type != OFILE_Mach_O &&
644 -              ofile->mh->filetype != MH_DYLIB){
645 +              (ofile->mh->filetype != MH_DYLIB &&
646 +               ofile->mh->filetype != MH_DYLIB_STUB)){
647                 error("ofile_first_module() called on fat file: %s with a "
648                       "non-MH_DYLIB architecture or no architecture selected\n",
649                       ofile->file_name);
650 @@ -1864,7 +1902,8 @@
651             }
652         }
653         else if(ofile->arch_type != OFILE_Mach_O &&
654 -               ofile->mh->filetype != MH_DYLIB){
655 +               (ofile->mh->filetype != MH_DYLIB &&
656 +                ofile->mh->filetype != MH_DYLIB_STUB)){
657             error("ofile_first_module() called and file type of %s is "
658                   "non-MH_DYLIB\n", ofile->file_name);
659             return(FALSE);
660 @@ -1902,20 +1941,22 @@
661         m = *ofile->dylib_module;
662         if(swapped)
663             swap_dylib_module(&m, 1, host_byte_sex);
664 +       if(check_dylib_module(ofile, st, dyst, strings, 0) == CHECK_BAD)
665 +           return(FALSE);
666         ofile->dylib_module_name = strings + m.module_name;
667         return(TRUE);
668  }
669  
670  /*
671   * ofile_next_module() set up the ofile structure (the dylib_module field)
672 - * for the next module of an MH_DYLIB file.
673 + * for the next module of an MH_DYLIB or MH_DYLIB_STUB file.
674   */
675  __private_extern__
676  enum bool
677  ofile_next_module(
678  struct ofile *ofile)
679  {
680 -    unsigned long i;
681 +    unsigned long i, module_index;
682      struct symtab_command *st;
683      struct dysymtab_command *dyst;
684      struct load_command *lc;
685 @@ -1926,7 +1967,8 @@
686  
687         if(ofile->file_type == OFILE_FAT){
688             if(ofile->arch_type != OFILE_Mach_O &&
689 -              ofile->mh->filetype != MH_DYLIB){
690 +              (ofile->mh->filetype != MH_DYLIB &&
691 +               ofile->mh->filetype != MH_DYLIB_STUB)){
692                 error("ofile_next_module() called on fat file: %s with a "
693                       "non-MH_DYLIB architecture or no architecture selected\n",
694                       ofile->file_name);
695 @@ -1934,7 +1976,8 @@
696             }
697         }
698         else if(ofile->arch_type != OFILE_Mach_O &&
699 -               ofile->mh->filetype != MH_DYLIB){
700 +               (ofile->mh->filetype != MH_DYLIB &&
701 +                ofile->mh->filetype != MH_DYLIB_STUB)){
702             error("ofile_next_module() called and file type of %s is "
703                   "non-MH_DYLIB\n", ofile->file_name);
704             return(FALSE);
705 @@ -1959,7 +2002,8 @@
706             return(FALSE);
707         }
708  
709 -       if((ofile->dylib_module + 1) - ofile->modtab >= ofile->nmodtab)
710 +       module_index = (ofile->dylib_module + 1) - ofile->modtab;
711 +       if(module_index >= ofile->nmodtab)
712             return(FALSE);
713  
714         ofile->dylib_module++;
715 @@ -1969,13 +2013,17 @@
716         m = *ofile->dylib_module;
717         if(swapped)
718             swap_dylib_module(&m, 1, host_byte_sex);
719 +       if(check_dylib_module(ofile, st, dyst, strings, module_index) ==
720 +          CHECK_BAD)
721 +           return(FALSE);
722         ofile->dylib_module_name = strings + m.module_name;
723         return(TRUE);
724  }
725  
726  /*
727   * ofile_specific_module() set up the ofile structure (the dylib_module fields)
728 - * for the specified module, module_name, of an MH_DYLIB file.
729 + * for the specified module, module_name, of an MH_DYLIB or an MH_DYLIB_STUB
730 + * file.
731   */
732  __private_extern__
733  enum bool
734 @@ -2000,7 +2048,8 @@
735  
736         if(ofile->file_type == OFILE_FAT){
737             if(ofile->arch_type != OFILE_Mach_O &&
738 -              ofile->mh->filetype != MH_DYLIB){
739 +              (ofile->mh->filetype != MH_DYLIB &&
740 +               ofile->mh->filetype != MH_DYLIB_STUB)){
741                 error("ofile_specific_module() called on fat file: %s with a "
742                       "non-MH_DYLIB architecture or no architecture selected\n",
743                       ofile->file_name);
744 @@ -2008,7 +2057,8 @@
745             }
746         }
747         else if(ofile->arch_type != OFILE_Mach_O &&
748 -               ofile->mh->filetype != MH_DYLIB){
749 +               (ofile->mh->filetype != MH_DYLIB &&
750 +                ofile->mh->filetype != MH_DYLIB_STUB)){
751             error("ofile_specific_module() called and file type of %s is "
752                   "non-MH_DYLIB\n", ofile->file_name);
753             return(FALSE);
754 @@ -2047,8 +2097,10 @@
755             m = *p;
756             if(swapped)
757                 swap_dylib_module(&m, 1, host_byte_sex);
758 -           if(strcmp(module_name, strings + m.module_name) == 0){
759                 ofile->dylib_module = p;
760 +           if(check_dylib_module(ofile, st, dyst, strings, i) == CHECK_BAD)
761 +               return(FALSE);
762 +           if(strcmp(module_name, strings + m.module_name) == 0){
763                 ofile->dylib_module_name = strings + m.module_name;
764                 return(TRUE);
765             }
766 @@ -2520,10 +2572,12 @@
767             return(CHECK_BAD);
768         }
769         if(ofile->file_type == OFILE_FAT){
770 -           if(ofile->fat_archs[ofile->narch].cputype != ofile->mh->cputype)
771 +           if(ofile->fat_archs[ofile->narch].cputype != ofile->mh->cputype){
772                 Mach_O_error(ofile, "malformed fat file (fat header "
773                     "architecture: %lu's cputype does not match "
774                     "object file's mach header)", ofile->narch);
775 +               return(CHECK_BAD);
776 +           }
777         }
778         /*
779          * Make a pass through the load commands checking them to the level
780 @@ -3595,55 +3649,73 @@
781             }
782         }
783         if(st == NULL){
784 -           if(dyst != NULL)
785 +           if(dyst != NULL){
786                 Mach_O_error(ofile, "truncated or malformed object (contains "
787                   "LC_DYSYMTAB load command without a LC_SYMTAB load command)");
788 +               return(CHECK_BAD);
789 +           }
790         }
791         else{
792             if(dyst != NULL){
793                 if(dyst->nlocalsym != 0 &&
794 -                  dyst->ilocalsym > st->nsyms)
795 +                  dyst->ilocalsym > st->nsyms){
796                     Mach_O_error(ofile, "truncated or malformed object "
797                         "(ilocalsym in LC_DYSYMTAB load command extends past "
798                         "the end of the symbol table)");
799 +                   return(CHECK_BAD);
800 +               }
801                 if(dyst->nlocalsym != 0 &&
802 -                  dyst->ilocalsym + dyst->nlocalsym > st->nsyms)
803 +                  dyst->ilocalsym + dyst->nlocalsym > st->nsyms){
804                     Mach_O_error(ofile, "truncated or malformed object "
805                         "(ilocalsym plus nlocalsym in LC_DYSYMTAB load command "
806                         "extends past the end of the symbol table)");
807 +                   return(CHECK_BAD);
808 +               }
809  
810                 if(dyst->nextdefsym != 0 &&
811 -                  dyst->iextdefsym > st->nsyms)
812 +                  dyst->iextdefsym > st->nsyms){
813                     Mach_O_error(ofile, "truncated or malformed object "
814                         "(iextdefsym in LC_DYSYMTAB load command extends past "
815                         "the end of the symbol table)");
816 +                   return(CHECK_BAD);
817 +               }
818                 if(dyst->nextdefsym != 0 &&
819 -                  dyst->iextdefsym + dyst->nextdefsym > st->nsyms)
820 +                  dyst->iextdefsym + dyst->nextdefsym > st->nsyms){
821                     Mach_O_error(ofile, "truncated or malformed object "
822                         "(iextdefsym plus nextdefsym in LC_DYSYMTAB load "
823                         "command extends past the end of the symbol table)");
824 +                   return(CHECK_BAD);
825 +               }
826  
827                 if(dyst->nundefsym != 0 &&
828 -                  dyst->iundefsym > st->nsyms)
829 +                  dyst->iundefsym > st->nsyms){
830                     Mach_O_error(ofile, "truncated or malformed object "
831                         "(iundefsym in LC_DYSYMTAB load command extends past "
832                         "the end of the symbol table)");
833 +                   return(CHECK_BAD);
834 +               }
835                 if(dyst->nundefsym != 0 &&
836 -                  dyst->iundefsym + dyst->nundefsym > st->nsyms)
837 +                  dyst->iundefsym + dyst->nundefsym > st->nsyms){
838                     Mach_O_error(ofile, "truncated or malformed object "
839                         "(iundefsym plus nundefsym in LC_DYSYMTAB load command "
840                         "extends past the end of the symbol table)");
841 +                   return(CHECK_BAD);
842 +               }
843                 if(rc != NULL){
844 -                   if(rc->init_module > dyst->nmodtab)
845 +                   if(rc->init_module > dyst->nmodtab){
846                         Mach_O_error(ofile, "malformed object (init_module in "
847                             "LC_ROUTINES load command extends past the end of "
848                             "the module table)");
849 +                       return(CHECK_BAD);
850 +                   }
851                 }
852                 if(hints != NULL){
853 -                   if(hints->nhints != dyst->nundefsym)
854 +                   if(hints->nhints != dyst->nundefsym){
855                         Mach_O_error(ofile, "malformed object (nhints in "
856                             "LC_TWOLEVEL_HINTS load command not the same as "
857                             "nundefsym in LC_DYSYMTAB load command)");
858 +                       return(CHECK_BAD);
859 +                   }
860                 }
861             }
862         }
863 @@ -3655,6 +3727,109 @@
864         }
865  
866         /* looks good return ok */
867 +       return(CHECK_GOOD);
868 +#endif /* OTOOL */
869 +}
870 +
871 +/*
872 + * check_dylib_module() checks the object file's dylib_module as referenced
873 + * by the dylib_module field in the ofile for correctness.
874 + */
875 +static
876 +enum check_type
877 +check_dylib_module(
878 +struct ofile *ofile,
879 +struct symtab_command *st,
880 +struct dysymtab_command *dyst,
881 +char *strings,
882 +unsigned long module_index)
883 +{
884 +#ifdef OTOOL
885 +       return(CHECK_GOOD);
886 +#else /* !defined OTOOL */
887 +    unsigned long i;
888 +    enum byte_sex host_byte_sex;
889 +    enum bool swapped;
890 +    struct dylib_module m;
891 +
892 +       m = *ofile->dylib_module;
893 +       host_byte_sex = get_host_byte_sex();
894 +       swapped = (enum bool)(host_byte_sex != ofile->object_byte_sex);
895 +       if(swapped)
896 +           swap_dylib_module(&m, 1, host_byte_sex);
897 +
898 +       if(m.module_name > st->strsize){
899 +           Mach_O_error(ofile, "truncated or malformed object (module_name "
900 +               "of module table entry %lu past the end of the string table)",
901 +               module_index);
902 +           return(CHECK_BAD);
903 +       }
904 +       for(i = m.module_name; i < st->strsize && strings[i] != '\0'; i++)
905 +               ;
906 +       if(i >= st->strsize){
907 +           Mach_O_error(ofile, "truncated or malformed object (module_name "
908 +               "of module table entry %lu extends past the end of the string "
909 +               "table)", module_index);
910 +           return(CHECK_BAD);
911 +       }
912 +
913 +       if(m.nextdefsym != 0){
914 +           if(m.iextdefsym > st->nsyms){
915 +               Mach_O_error(ofile, "truncated or malformed object (iextdefsym "
916 +                   "field of module table entry %lu past the end of the "
917 +                   "symbol table", module_index);
918 +               return(CHECK_BAD);
919 +           }
920 +           if(m.iextdefsym + m.nextdefsym > st->nsyms){
921 +               Mach_O_error(ofile, "truncated or malformed object (iextdefsym "
922 +                   "field of module table entry %lu plus nextdefsym field "
923 +                   "extends past the end of the symbol table", module_index);
924 +               return(CHECK_BAD);
925 +           }
926 +       }
927 +       if(m.nlocalsym != 0){
928 +           if(m.ilocalsym > st->nsyms){
929 +               Mach_O_error(ofile, "truncated or malformed object (ilocalsym "
930 +                   "field of module table entry %lu past the end of the "
931 +                   "symbol table", module_index);
932 +               return(CHECK_BAD);
933 +           }
934 +           if(m.ilocalsym + m.nlocalsym > st->nsyms){
935 +               Mach_O_error(ofile, "truncated or malformed object (ilocalsym "
936 +                   "field of module table entry %lu plus nlocalsym field "
937 +                   "extends past the end of the symbol table", module_index);
938 +               return(CHECK_BAD);
939 +           }
940 +       }
941 +       if(m.nrefsym != 0){
942 +           if(m.irefsym > dyst->nextrefsyms){
943 +               Mach_O_error(ofile, "truncated or malformed object (irefsym "
944 +                   "field of module table entry %lu past the end of the "
945 +                   "reference table", module_index);
946 +               return(CHECK_BAD);
947 +           }
948 +           if(m.irefsym + m.nrefsym > dyst->nextrefsyms){
949 +               Mach_O_error(ofile, "truncated or malformed object (irefsym "
950 +                   "field of module table entry %lu plus nrefsym field "
951 +                   "extends past the end of the reference table",module_index);
952 +               return(CHECK_BAD);
953 +           }
954 +       }
955 +       if(m.nextrel != 0){
956 +           if(m.iextrel > dyst->extreloff){
957 +               Mach_O_error(ofile, "truncated or malformed object (iextrel "
958 +                   "field of module table entry %lu past the end of the "
959 +                   "external relocation enrties", module_index);
960 +               return(CHECK_BAD);
961 +           }
962 +           if(m.iextrel + m.nextrel > dyst->extreloff){
963 +               Mach_O_error(ofile, "truncated or malformed object (iextrel "
964 +                   "field of module table entry %lu plus nextrel field "
965 +                   "extends past the end of the external relocation enrties",
966 +                   module_index);
967 +               return(CHECK_BAD);
968 +           }
969 +       }
970         return(CHECK_GOOD);
971  #endif /* OTOOL */
972  }
973 diff -rub libstuff/ofile_get_word.c libstuff/ofile_get_word.c
974 --- libstuff/ofile_get_word.c   Fri Sep  6 18:28:00 2002
975 +++ libstuff/ofile_get_word.c   Mon Aug 25 13:17:40 2003
976 @@ -34,7 +34,7 @@
977  unsigned long *word,
978  void *get_word_data /* struct mach_object_file *ofile */ )
979  {
980 -    int i, j;
981 +    unsigned long i, j;
982      struct load_command *lc;
983      struct segment_command *sg;
984      struct section *s;
985 diff -rub libstuff/print.c libstuff/print.c
986 --- libstuff/print.c    Tue Apr 30 00:37:20 2002
987 +++ libstuff/print.c    Mon Aug 25 13:17:40 2003
988 @@ -21,8 +21,8 @@
989   * 
990   * @APPLE_LICENSE_HEADER_END@
991   */
992 -#import <stdio.h>
993 -#import "stuff/print.h"
994 +#include <stdio.h>
995 +#include "stuff/print.h"
996  
997  /*
998   * All printing of all messages for ofile functions goes through this function.
999 Only in libstuff/: profile_obj
1000 diff -rub libstuff/reloc.c libstuff/reloc.c
1001 --- libstuff/reloc.c    Tue Jan 14 23:35:27 2003
1002 +++ libstuff/reloc.c    Mon Aug 25 13:17:40 2003
1003 @@ -106,6 +106,7 @@
1004                r_type == PPC_RELOC_SECTDIFF ||
1005                r_type == PPC_RELOC_HI16_SECTDIFF ||
1006                r_type == PPC_RELOC_LO16_SECTDIFF ||
1007 +              r_type == PPC_RELOC_LO14_SECTDIFF ||
1008                r_type == PPC_RELOC_HA16_SECTDIFF ||
1009                r_type == PPC_RELOC_JBSR)
1010                 return(TRUE);
1011 @@ -164,6 +165,7 @@
1012             if(r_type == PPC_RELOC_SECTDIFF ||
1013                r_type == PPC_RELOC_HI16_SECTDIFF ||
1014                r_type == PPC_RELOC_LO16_SECTDIFF ||
1015 +              r_type == PPC_RELOC_LO14_SECTDIFF ||
1016                r_type == PPC_RELOC_HA16_SECTDIFF)
1017                 return(TRUE);
1018             break;
1019 diff -rub libstuff/round.c libstuff/round.c
1020 --- libstuff/round.c    Tue Apr 30 00:37:20 2002
1021 +++ libstuff/round.c    Mon Aug 25 13:17:40 2003
1022 @@ -26,9 +26,9 @@
1023   * round() rounds v to a multiple of r.
1024   */
1025  __private_extern__
1026 -long
1027 +unsigned long
1028  round(
1029 -long v,
1030 +unsigned long v,
1031  unsigned long r)
1032  {
1033         r--;
1034 Only in libstuff/: shlib_obj
1035 Only in libstuff/: static_obj
1036 diff -rub libstuff/swap_headers.c libstuff/swap_headers.c
1037 --- libstuff/swap_headers.c     Tue Jan 14 23:35:27 2003
1038 +++ libstuff/swap_headers.c     Mon Aug 25 13:17:40 2003
1039 @@ -22,13 +22,13 @@
1040   * @APPLE_LICENSE_HEADER_END@
1041   */
1042  #include <mach-o/loader.h>
1043 -#import <mach/m68k/thread_status.h>
1044 -#import <mach/ppc/thread_status.h>
1045 -#import <mach/m88k/thread_status.h>
1046 -#import <mach/i860/thread_status.h>
1047 -#import <mach/i386/thread_status.h>
1048 -#import <mach/hppa/thread_status.h>
1049 -#import <mach/sparc/thread_status.h>
1050 +#include <mach/m68k/thread_status.h>
1051 +#include <mach/ppc/thread_status.h>
1052 +#include <mach/m88k/thread_status.h>
1053 +#include <mach/i860/thread_status.h>
1054 +#include <mach/i386/thread_status.h>
1055 +#include <mach/hppa/thread_status.h>
1056 +#include <mach/sparc/thread_status.h>
1057  #include "stuff/bool.h"
1058  #include "stuff/bytesex.h"
1059  #include "stuff/errors.h"
1060 Only in libstuff/: symbol_list.c
1061 diff -rub libstuff/writeout.c libstuff/writeout.c
1062 --- libstuff/writeout.c Fri Sep  6 18:28:00 2002
1063 +++ libstuff/writeout.c Mon Aug 25 13:17:40 2003
1064 @@ -511,7 +511,7 @@
1065                     write_size = (file + file_size) - p;
1066                 else
1067                     write_size = WRITE_SIZE;
1068 -               if(write(fd, p, write_size) != write_size){
1069 +               if(write(fd, p, write_size) != (int)write_size){
1070                     system_error("can't write output file: %s", output);
1071                     goto cleanup;
1072                 }
1073 @@ -560,7 +560,7 @@
1074         }
1075         else{
1076  no_throttle:
1077 -           if(write(fd, file, file_size) != file_size){
1078 +           if(write(fd, file, file_size) != (int)file_size){
1079                 system_error("can't write output file: %s", output);
1080                 goto cleanup;
1081             }
1082 @@ -807,7 +807,7 @@
1083                     strings_size = object->output_strings_size;
1084                 }
1085                 for(j = 0; j < nsymbols; j++){
1086 -                   if(symbols[j].n_un.n_strx > strings_size)
1087 +                   if((unsigned long)symbols[j].n_un.n_strx > strings_size)
1088                         continue;
1089                     if(toc_symbol(symbols + j, commons_in_toc,
1090                        object->sections) == TRUE){
1091 @@ -998,7 +998,7 @@
1092  char *output,
1093  enum bool library_warnings)
1094  {
1095 -    long i;
1096 +    unsigned long i;
1097      enum bool multiple_defs;
1098      struct member *member;
1099  
1100 @@ -1008,7 +1008,7 @@
1101          * only once (marked by changing the sign of their ran_off).
1102          */
1103         multiple_defs = FALSE;
1104 -       for(i = 0; i < (long)arch->toc_nranlibs - 1; i++){
1105 +       for(i = 0; i < arch->toc_nranlibs - 1; i++){
1106             if(strcmp(arch->toc_ranlibs[i].ran_un.ran_name,
1107                       arch->toc_ranlibs[i+1].ran_un.ran_name) == 0){
1108                 if(multiple_defs == FALSE){