2 diff -ubr misc/Makefile misc/Makefile
3 --- misc/Makefile Tue Jan 14 23:35:29 2003
4 +++ misc/Makefile Mon Aug 25 22:06:23 2003
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 - echo -Wno-long-double -no-cpp-precomp; \
15 + echo -Wno-long-double -no-cpp-precomp ; \
20 CFLAGS = $(OFLAG) -g \
21 -I$(SRCROOT) -I$(SRCROOT)/../include -I$(OFILE_DIR)
23 - CFLAGS = $(OFLAG) -g -Wall -Wno-precomp $(X_CFLAGS) \
24 + ifeq "Linux" "$(shell uname)"
25 + CFLAGS = $(OFLAG) -g -Wall $(X_CFLAGS) \
26 + -I$(SRCROOT) -I$(SRCROOT)/../include -I$(OFILE_DIR) -D__ppc__ -I/usr/include -I../../macosx-include
28 + CFLAGS = $(OFLAG) -g -Wall $(X_CFLAGS) \
29 -I$(SRCROOT) -I$(SRCROOT)/../include -I$(OFILE_DIR)
33 -USE_DEPENDENCY_FILE := $(shell if [ "$(notdir $(CC))" != "mwccppc" ]; then \
34 +USE_DEPENDENCY_FILE := $(shell if [ `uname` != "Linux" ] && [ "$(notdir $(CC))" != "mwccppc" ]; then \
35 echo YES ; else echo NO ; \
39 LOCLIBDIR = /usr/local/lib
42 -CFILES2 = main.c lipo.c size.c strings.c nm.c checksyms.c inout.c \
43 - indr.c strip.c atom.c segedit.c kern_tool.c cmpdylib.c \
44 - dylib_pcsampler.c pagestuff.c redo_prebinding.c seg_addr_table.c \
45 - check_dylib.c seg_hack.c check_hints.c install_name_tool.c
46 +CFILES2 = seg_hack.c strip.c
47 ifeq "nextstep" "$(RC_OS)"
54 -PROGS = lipo.NEW size.NEW strings.NEW nm.NEW \
55 - libtool.NEW checksyms.NEW indr.NEW strip.NEW nmedit.NEW \
56 - segedit.NEW kern_tool.NEW cmpdylib.NEW \
57 - dylib_pcsampler.NEW pagestuff.NEW redo_prebinding.NEW \
58 - seg_addr_table.NEW check_dylib.NEW seg_hack.NEW install_name_tool.NEW
59 +PROGS = seg_hack.NEW strip.NEW
61 teflon_all macos_all: $(PROGS)
64 lib_ofiles: $(OFILE_DIR) $(SYMROOT) libredo_prebinding.a
67 - vers_string -c $(VERS_STRING_FLAGS) cctools_misc > $(OFILE_DIR)/$@
68 + ./vers_string -c $(VERS_STRING_FLAGS) cctools_misc > $(OFILE_DIR)/$@
70 ifeq "NO" "$(USE_DEPENDENCY_FILE)"
73 $(OFILE_DIR)/seg_hack.o $(OFILE_DIR)/vers.o $(LIBSTUFF)
74 $(CC) $(CFLAGS) $(RC_CFLAGS) -o $(SYMROOT)/seg_hack.NEW \
75 $(OFILE_DIR)/seg_hack.private.o
76 + cp $(SYMROOT)/seg_hack.NEW $(SYMROOT)/seg_hack
78 install_name_tool.NEW: install_name_tool.o vers.o
79 $(CC) $(CFLAGS) $(RC_CFLAGS) -nostdlib -r \
81 $(SYMROOT)/redo_prebinding.NEW \
82 $(SYMROOT)/libredo_prebinding.a \
83 $(SYMROOT)/kern_tool.NEW \
84 - $(SYMROOT)/cmpdylib.NEW
85 + $(SYMROOT)/cmpdylib.NEW \
92 Only in misc: check_dylib.c
93 Only in misc: check_hints.c
94 Only in misc: checksyms.c
95 Only in misc: cmpdylib.c
96 Only in misc: dylib_pcsampler.c
100 Only in misc: install_name_tool.c
101 Only in misc: kern_tool.c
102 Only in misc: libtool.c
106 diff -ubr misc/notes misc/notes
107 --- misc/notes Tue Jan 14 23:35:29 2003
108 +++ misc/notes Mon Aug 25 12:12:34 2003
110 could have been set otherwise and does not print the next line.
111 - Maybe add fat support for segedit(1)
113 +Changes for the 5.12 release (the cctools-474 release):
114 +- Fixed a bug in redo_prebinding that was leaking memory if the
115 + allow_missing_architectures parameter was used and the fat file did not
116 + contain an architecture. The fix was in load_library() in 4 places it
117 + checks to see if the missing architecure is allowed to be missing and it now
118 + unmap's the ofile before returning. Radar bug #3144803.
120 +Changes for the 5.12 release (the cctools-472 release):
121 +- Fixed a bug in seg_addr_table(1) when run with -relayout the <<< Next split
122 + address to assign >>> isn't getting set properly. The fix in in main() to add
123 + relayout == FALSE to the if() condition for the code that loops and updates
124 + the NEXT_SPLIT_ADDRESS_TO_ASSIGN. Radar bug #3245958.
126 +Changes for the 5.12 release (the cctools-470 release):
127 +- Added the -c option to strip(1) to strip the section contents of a dynamic
128 + shared library and create a stub library. Radar bug #3235093.
129 +- Changed install_name_tool(1) to not change MH_DYLIB_STUB filetypes.
130 + Radar bug #3235093.
131 +- Added the flag -search_paths_first to cause -lx flags to search each path
132 + for .dylib then .a before searching next path to libtool(1). Radar bug
134 + - Added the enum bool variable search_paths_first to the cmd_flags struct and
135 + code to parse out the option, set variable and add it to the ldflags[] in
137 + - The new static routines search_paths_for_lname() and search_path_for_lname()
139 + - In file_name_from_l_flag() a test of the new search_paths_first variable is
140 + done and if TRUE then search_paths_for_lname() is called.
142 +Changes for the 5.12 release (the cctools-469 release):
143 +- Added support for the -weak-lx, -weak_library and -weak_framework flags to
144 + libtool(1). Radar bug #3069758.
145 +- Fixed a bug seg_addr_table(1) in next_flat_seg1addr() where the variable i
146 + was previously changed to unsigned. The second loop uses this varaiable as
147 + signed and thus this change was causing the loop to never terminate. Radar
150 +Changes for the 5.12 release (the cctools-466 release):
151 +- Fixed a bug in libtool(1) for the -static option that caused it to crash if
152 + the objects contained no symbols to put in the table of contents. Radar bug
154 +- Fixed the incorrect casts on the comparison of the nlist struct's n_strx field
155 + where the value being compared to was casted to a long. The correct fix was
156 + to cast n_strx to an unsigned long.
157 +- Changed print_mach_symbols() in nm.c to print "(dynamically looked up)" for
158 + the library ordinal DYNAMIC_LOOKUP_ORDINAL which are looked up dynamically
159 + with flat namespace semantics in two-level namespace images. Radar bug
161 +- Changed get_primary_lib() in redo_prebinding.c to check for the library
162 + ordinal DYNAMIC_LOOKUP_ORDINAL and return NULL. Radar bug #3210803.
164 +Changes for the 5.12 release (the cctools-464 release):
165 +- Made changes to build cleanly with gcc3.3
166 + - Removed -Wno-precomp from the Makefile
167 + - Fixed warnings for "comparison between signed and unsigned" in lipo.c,
168 + size.c, strings.c, nm.c, libtool.c, checksyms.c, indr.c, strip.c, segedit.c,
169 + kern_tool.c, cmpdylib.c, dylib_pcsampler.c, pagestuff.c, redo_prebinding.c,
170 + seg_addr_table.c, check_dylib.c, seg_hack.c and install_name_tool.c.
172 +Changes for the 5.12 release (the cctools-463 release):
173 +- Added support for MH_DYLIB_STUB libraries. Radar bug #3193744.
174 + - Added the testing for MH_DYLIB_STUB along with MH_DYLIB in add_member()
176 + - Added the testing for MH_DYLIB_STUB along with MH_DYLIB in
177 + translate_object() in indr.c in the error check.
178 + - Added a case for MH_DYLIB_STUB in type_buf() in file.c (note this is the
179 + old file(1) command and is no longer used).
180 + - Added the testing for MH_DYLIB_STUB along with MH_DYLIB in check_dylib()
181 + in cmpdylib.c in 2 places.
182 + - Added the testing for MH_DYLIB_STUB along with MH_DYLIB in checksyms() and
183 + in check_dynamic_binary() in checksyms.c in 3 places in all.
184 + - Added the testing for MH_DYLIB_STUB along with MH_DYLIB in check_hints.c .
186 +Changes for the 5.12 release (the cctools-461 release):
187 +- Fixed a bug in install_name_tool(1) that caused it to crash when the new
188 + load commands were smaller than the old load commands. Radar bug #3161586.
190 +Changes for the 5.12 release (the cctools-456 release):
191 +- Fixed a bug in the redo_prebinding code when the allow_missing_architectures
192 + parameter to the redo_prebinding() API is non-zero. In the routine
193 + load_library() an extra check is needed to not cause an error if we are
194 + allowing missing architectures. The case where this happens is when there
195 + is a fat file that the architecture we don't care about depends on a library
196 + in another fat file but the time stamps for the libraries don't match.
197 + Radar bug #3144552.
199 +Changes for the 5.12 release (the cctools-455 release):
200 +- Fixed a bug in the redo_prebinding code in the routine link_library_module()
201 + in redo_prebinding.c. The problem was that when a reference to a private
202 + extern was found only the module containing it was marked linked. A call
203 + to link_library_module() for that module was needed to pull in its
204 + dependencies and get those modules marked as LINKED. Radar bug #3126383.
206 +Changes for the 5.12 release (the cctools-454 release):
207 +- Fixed a bug where seg_addr_table doesn't catch when an address is assigned in
208 + the "alternate" area. seg_addr_table(1) was using the wrong constant to
209 + check the validity of newly assigned addresses, the fix is to use the correct
210 + constant. Radar bug #3138181.
212 +Changes for the 5.12 release (the cctools-452 release):
213 +- Fixed the bug fix done for Radar bug #3124262 below in the redo_prebinding
214 + code. The copied code from the above loop was wrong as it changed this:
215 + if(libs[i].module_states[j] == LINKED)
217 + if(libs[j].module_states[k] == LINKED ||
218 + (prebind_all_twolevel_modules == TRUE &&
219 + (libs[j].ofile->mh->flags & MH_TWOLEVEL) ==
221 + which should have been this:
222 + if(libs[i].module_states[j] == LINKED ||
223 + (prebind_all_twolevel_modules == TRUE &&
224 + (libs[i].ofile->mh->flags & MH_TWOLEVEL) ==
226 + which used the correct index variables. Radar bug #3133589.
228 +Changes for the 5.12 release (the cctools-451 release):
229 +- Fixed a bug in the redo_prebinding code that did not set the all the bits
230 + in the linked_modules bit vector for any new LC_PREBOUND_DYLIB load commands
231 + when prebind_all_twolevel_modules was TRUE. Radar bug #3124262.
233 +Changes for the 5.12 release (the cctools-448 release):
234 +- Added an entry stabnames[] array in nm.c for N_OPT that is emitted with
235 + gcc2_compiled and in gcc source. Radar bug #3104328.
237 +Changes for the 5.12 release (the cctools-447 release):
238 +- Fixed a bug in add_member() in libtool.c when get_arch_family_from_cputype()
241 +Changes for the 5.11 release (the cctools-446 release):
242 +- Added passing -x from libtool to ld. Radar bug #3088301.
244 +Changes for the 5.11 release (the cctools-444 release):
245 +- Added passing -exported_symbols_list & -unexported_symbols_list from libtool
246 + to ld. Radar bug #3083844.
247 +- Factored out some of the symbol list stuff out of strip.c into libstuff so
248 + ld(1)'s -exported_symbols_list and -unexported_symbols_list options can use
249 + it. Radar bug #3083844.
251 +Changes for the 5.11 release (the cctools-443 release):
252 +- Added passing -single_module & -multi_module from libtool to ld. Also added
253 + passing -u flags. Radar #3080780.
255 Changes for the 5.11 release (the cctools-440 release):
256 - Fixed the warnings about extra tokens at end of #endif directive in
257 check_hints.c, strip.c and make_defs.h (Radar bug #3072042).
258 Only in misc: pagestuff.c
259 Only in misc: redo_prebinding.c
260 Only in misc: seg_addr_table.c
261 diff -ubr misc/seg_hack.c misc/seg_hack.c
262 --- misc/seg_hack.c Fri Sep 6 18:28:06 2002
263 +++ misc/seg_hack.c Mon Aug 25 12:12:34 2003
270 char *input, *output;
272 unsigned long narchs;
273 Only in misc: segedit.c
275 Only in misc: strings.c
276 diff -ubr misc/strip.c misc/strip.c
277 --- misc/strip.c Tue Jan 14 23:35:30 2003
278 +++ misc/strip.c Mon Aug 25 22:02:32 2003
280 #include <mach-o/reloc.h>
281 #include <mach-o/nlist.h>
282 #include <mach-o/stab.h>
283 -#include <stuff/breakout.h>
284 -#include <stuff/allocate.h>
285 -#include <stuff/errors.h>
286 -#include <stuff/round.h>
287 +#include "stuff/breakout.h"
288 +#include "stuff/allocate.h"
289 +#include "stuff/errors.h"
290 +#include "stuff/round.h"
291 #include "stuff/reloc.h"
292 +#include "stuff/reloc.h"
293 +#include "stuff/symbol_list.h"
295 /* These are set from the command line arguments */
296 char *progname; /* name of the program for error messages (argv[0]) */
298 static long Sflag; /* -S strip only debugger symbols N_STAB */
299 static long xflag; /* -x strip non-globals */
300 static long Xflag; /* -X strip local symbols with 'L' names */
301 +static long cflag; /* -c strip section contents from dynamic libraries
302 + files to create stub libraries */
303 static long strip_all = 1;
305 * This is set on an object by object basis if the strip_all flag is still set
307 * save_symbols is the names of the symbols from the -s <file> argument.
308 * remove_symbols is the names of the symbols from the -R <file> argument.
310 -struct symbol_list {
311 - char *name; /* name of the global symbol */
312 - struct nlist *sym; /* pointer to the nlist structure for this symbol */
313 - enum bool seen; /* set if the symbol is seen in the input file */
315 static struct symbol_list *save_symbols = NULL;
316 static unsigned long nsave_symbols = 0;
317 static struct symbol_list *remove_symbols = NULL;
318 @@ -106,12 +105,12 @@
319 * and the new counts of local, defined external and undefined symbols.
321 static struct nlist *new_symbols = NULL;
322 -static long new_nsyms = 0;
323 +static unsigned long new_nsyms = 0;
324 static char *new_strings = NULL;
325 -static long new_strsize = 0;
326 -static long new_nlocalsym = 0;
327 -static long new_nextdefsym = 0;
328 -static long new_nundefsym = 0;
329 +static unsigned long new_strsize = 0;
330 +static unsigned long new_nlocalsym = 0;
331 +static unsigned long new_nextdefsym = 0;
332 +static unsigned long new_nundefsym = 0;
335 * These hold the new table of contents, reference table and module table for
337 struct member *member,
338 struct object *object,
339 struct nlist *symbols,
341 + unsigned long nsyms,
344 + unsigned long strsize,
345 struct dylib_table_of_contents *tocs,
347 struct dylib_module *mods,
349 struct member *member,
350 struct object *object,
351 struct nlist *symbols,
353 + unsigned long nsyms,
356 + unsigned long strsize,
357 struct dylib_table_of_contents *tocs,
359 struct dylib_module *mods,
361 unsigned long nextrefsyms);
364 -static void setup_symbol_list(
366 - struct symbol_list **list,
367 - unsigned long *size);
369 -static int cmp_qsort_name(
370 - const struct symbol_list *sym1,
371 - const struct symbol_list *sym2);
373 -static int cmp_bsearch(
375 - const struct symbol_list *sym);
378 static void setup_debug_filenames(
384 - unsigned long i, j, args_left, files_specified;
386 + unsigned long j, args_left, files_specified;
387 struct arch_flag *arch_flags;
388 unsigned long narch_flags;
392 #endif /* !defined(NMEDIT) */
401 error("unrecognized option: %s", argv[i]);
403 @@ -421,16 +414,16 @@
405 setup_symbol_list(Rfile, &remove_symbols, &nremove_symbols);
407 - for(i = 0; i < nremove_symbols ; i++){
408 - sp = bsearch(remove_symbols[i].name,
409 + for(j = 0; j < nremove_symbols ; j++){
410 + sp = bsearch(remove_symbols[j].name,
411 save_symbols, nsave_symbols,
412 sizeof(struct symbol_list),
413 (int (*)(const void *, const void *))
415 + symbol_list_bsearch);
417 error("symbol name: %s is listed in both -s %s and -R "
418 "%s files (can't be both saved and removed)",
419 - remove_symbols[i].name, sfile, Rfile);
420 + remove_symbols[j].name, sfile, Rfile);
427 * Now this arch[i] has been selected to be processed so process it
428 - * according to it's type.
429 + * according to its type.
431 if(archs[i].type == OFILE_ARCHIVE){
432 for(j = 0; j < archs[i].nmembers; j++){
434 unsigned long nextrefsyms;
435 unsigned long *indirectsyms;
436 unsigned long nindirectsyms;
438 + unsigned long i, j, k;
439 struct load_command *lc;
440 struct segment_command *sg;
443 strings = object->object_addr + object->st->stroff;
444 strsize = object->st->strsize;
447 + if(object->mh->filetype != MH_DYLIB && cflag)
448 + fatal_arch(arch, member, "-c can't be used on non-dynamic "
450 +#endif /* !(NMEDIT) */
451 + if(object->mh->filetype == MH_DYLIB_STUB)
452 + fatal_arch(arch, member, "dynamic stub library can't be changed "
455 if(object->mh->filetype == MH_DYLIB){
456 tocs = (struct dylib_table_of_contents *)
457 (object->object_addr + object->dyst->tocoff);
459 swap_dylib_module(mods, nmodtab, host_byte_sex);
460 swap_dylib_reference(refs, nextrefsyms, host_byte_sex);
464 + * In the -c flag is specified then strip the section contents of
465 + * this dynamic library and change it into a stub library. When
466 + * creating a stub library the timestamp is not changed.
469 + object->mh->filetype = MH_DYLIB_STUB;
470 + arch->dont_update_LC_ID_DYLIB_timestamp = TRUE;
472 + lc = object->load_commands;
473 + for(i = 0; i < object->mh->ncmds; i++){
474 + if(lc->cmd == LC_SEGMENT){
475 + sg = (struct segment_command *)lc;
476 + if(strcmp(sg->segname, SEG_LINKEDIT) != 0){
478 + * Zero out the section offset, reloff, and size
479 + * fields as the section contents are being removed.
481 + s = (struct section *)&sg[1];
482 + for(j = 0; j < sg->nsects; j++){
484 + * For section types with indirect tables we
485 + * do not zero out the section size in a stub
486 + * library. As the section size is needed to
487 + * know now many indirect table entries the
488 + * section has. This is a bit odd but programs
489 + * dealing with MH_DYLIB_STUB filetypes special
492 + section_type = s[j].flags & SECTION_TYPE;
493 + if(section_type != S_SYMBOL_STUBS &&
494 + section_type != S_LAZY_SYMBOL_POINTERS &&
495 + section_type != S_NON_LAZY_SYMBOL_POINTERS){
502 + /* zero out file offset and size in the segment */
507 + lc = (struct load_command *)((char *)lc + lc->cmdsize);
510 + * To get the right amount of the file copied out by writeout()
511 + * for the case when we are stripping out the section contents
512 + * we reduce the object size by the size of the section contents
513 + * including the padding after the load commands. Then this
514 + * size minus the size of the input symbolic information is
517 + object->object_size -= (object->seg_linkedit->fileoff -
518 + (sizeof(struct mach_header) + object->mh->sizeofcmds));
520 + * Set the file offset to the link edit information to be right
521 + * after the load commands.
523 + object->seg_linkedit->fileoff =
524 + sizeof(struct mach_header) + object->mh->sizeofcmds;
526 +#endif /* !(NMEDIT) */
534 - if(object->mh->filetype == MH_DYLIB){
536 + * If the -c option is specified the object's filetype will
537 + * have been changed from MH_DYLIB to MH_DYLIB_STUB above.
539 + if(object->mh->filetype == MH_DYLIB ||
540 + object->mh->filetype == MH_DYLIB_STUB){
541 object->output_tocs = new_tocs;
542 object->output_ntoc = new_ntoc;
545 object->dyst->ntoc * sizeof(struct dylib_table_of_contents)+
546 object->dyst->nmodtab * sizeof(struct dylib_module) +
547 object->dyst->nextrefsyms * sizeof(struct dylib_reference);
550 + * When stripping out the section contents to create a
551 + * dynamic library stub the relocation info also gets
555 +#endif /* !(NMEDIT) */
557 object->output_sym_info_size +=
558 object->dyst->nlocrel * sizeof(struct relocation_info) +
559 - object->dyst->nextrel * sizeof(struct relocation_info) +
560 + object->dyst->nextrel * sizeof(struct relocation_info);
562 + object->output_sym_info_size +=
563 object->dyst->nindirectsyms * sizeof(unsigned long) +
564 new_ntoc * sizeof(struct dylib_table_of_contents)+
565 object->dyst->nmodtab * sizeof(struct dylib_module) +
566 @@ -961,10 +1044,24 @@
567 if(object->dyst->nlocrel != 0){
568 object->output_loc_relocs = (struct relocation_info *)
569 (object->object_addr + object->dyst->locreloff);
572 + * When stripping out the section contents to create a
573 + * dynamic library stub the relocation info also gets
577 + object->dyst->nlocrel = 0;
578 + object->dyst->locreloff = 0;
581 +#endif /* defined(NMEDIT) */
583 object->dyst->locreloff = offset;
584 offset += object->dyst->nlocrel *
585 sizeof(struct relocation_info);
589 object->dyst->locreloff = 0;
591 @@ -990,10 +1087,24 @@
592 if(object->dyst->nextrel != 0){
593 object->output_ext_relocs = (struct relocation_info *)
594 (object->object_addr + object->dyst->extreloff);
597 + * When stripping out the section contents to create a
598 + * dynamic library stub the relocation info also gets
602 + object->dyst->nextrel = 0;
603 + object->dyst->extreloff = 0;
606 +#endif /* defined(NMEDIT) */
608 object->dyst->extreloff = offset;
609 offset += object->dyst->nextrel *
610 sizeof(struct relocation_info);
614 object->dyst->extreloff = 0;
616 @@ -1014,6 +1125,24 @@
617 object->dyst->tocoff = 0;
619 if(object->dyst->nmodtab != 0){
622 + * When stripping out the section contents to create a
623 + * dynamic library stub zero out the fields in the module
624 + * table for the sections and relocation information.
627 + /* Clear Objective-C address and size from modules. */
628 + for(k = 0; k < object->dyst->nmodtab; k++){
629 + mods[k].iinit_iterm = 0;
630 + mods[k].ninit_nterm = 0;
631 + mods[k].iextrel = 0;
632 + mods[k].nextrel = 0;
633 + mods[k].objc_module_info_addr = 0;
634 + mods[k].objc_module_info_size = 0;
637 +#endif /* !(NMEDIT) */
638 object->dyst->modtaboff = offset;
639 offset += object->dyst->nmodtab *
640 sizeof(struct dylib_module);
641 @@ -1423,120 +1552,6 @@
646 - * This is called to setup a symbol list from a file. It reads the file with
647 - * the strings in it and places them in an array of symbol_list structures and
648 - * then sorts them by name.
650 - * The file that contains the symbol names must have symbol names one per line,
651 - * leading and trailing white space is removed and lines starting with a '#'
652 - * and lines with only white space are ignored.
658 -struct symbol_list **list,
659 -unsigned long *size)
661 - int fd, i, j, len, strings_size;
662 - struct stat stat_buf;
663 - char *strings, *p, *line;
665 - if((fd = open(file, O_RDONLY)) < 0){
666 - system_error("can't open: %s", file);
669 - if(fstat(fd, &stat_buf) == -1){
670 - system_error("can't stat: %s", file);
674 - strings_size = stat_buf.st_size;
675 - strings = (char *)allocate(strings_size + 2);
676 - strings[strings_size] = '\n';
677 - strings[strings_size + 1] = '\0';
678 - if(read(fd, strings, strings_size) != strings_size){
679 - system_error("can't read: %s", file);
684 - * Change the newlines to '\0' and count the number of lines with
685 - * symbol names. Lines starting with '#' are comments and lines
686 - * contain all space characters do not contain symbol names.
690 - for(i = 0; i < strings_size + 1; i++){
691 - if(*p == '\n' || *p == '\r'){
694 - while(*line != '\0' && isspace(*line))
706 - *list = (struct symbol_list *)
707 - allocate((*size) * sizeof(struct symbol_list));
710 - * Place the strings in the list trimming leading and trailing spaces
711 - * from the lines with symbol names.
715 - for(i = 0; i < (*size); ){
716 - p += strlen(p) + 1;
717 - if(*line != '#' && *line != '\0'){
718 - while(*line != '\0' && isspace(*line))
721 - (*list)[i].name = line;
722 - (*list)[i].seen = FALSE;
724 - len = strlen(line);
726 - while(j > 0 && isspace(line[j])){
729 - if(j > 0 && j + 1 < len && isspace(line[j+1]))
736 - qsort(*list, *size, sizeof(struct symbol_list),
737 - (int (*)(const void *, const void *))cmp_qsort_name);
739 - /* remove duplicates on the list */
740 - for(i = 0; i < (*size); i++){
741 - if(i + 1 < (*size)){
742 - if(strcmp((*list)[i].name, (*list)[i+1].name) == 0){
743 - for(j = 1; j < ((*size) - i - 1); j++){
744 - (*list)[i + j].name = (*list)[i + j + 1].name;
752 - printf("symbol list:\n");
753 - for(i = 0; i < (*size); i++){
754 - printf("0x%x name = %s\n", &((*list)[i]),(*list)[i].name);
761 * This is called if there is a -d option specified. It reads the file with
762 @@ -1609,9 +1624,9 @@
763 struct member *member,
764 struct object *object,
765 struct nlist *symbols,
767 +unsigned long nsyms,
770 +unsigned long strsize,
771 struct dylib_table_of_contents *tocs,
773 struct dylib_module *mods,
774 @@ -1621,7 +1636,8 @@
775 unsigned long *indirectsyms,
776 unsigned long nindirectsyms)
778 - long i, j, k, n, inew_syms, save_debug, missing_syms, missing_symbols;
779 + unsigned long i, j, k, n, inew_syms, save_debug, missing_syms;
780 + unsigned long missing_symbols;
781 char *p, *q, **pp, *basename;
782 struct symbol_list *sp;
783 unsigned long new_ext_strsize, len, *changes, inew_undefsyms;
784 @@ -1686,7 +1702,7 @@
785 for(i = 0; i < nsyms; i++){
786 if(symbols[i].n_un.n_strx != 0){
787 if(symbols[i].n_un.n_strx < 0 ||
788 - symbols[i].n_un.n_strx > strsize){
789 + (unsigned long)symbols[i].n_un.n_strx > strsize){
790 error_arch(arch, member, "bad string index for symbol "
791 "table entry %ld in: ", i);
793 @@ -1838,7 +1854,7 @@
794 save_symbols, nsave_symbols,
795 sizeof(struct symbol_list),
796 (int (*)(const void *, const void *))
798 + symbol_list_bsearch);
801 sp->sym = &(symbols[i]);
802 @@ -1885,7 +1901,7 @@
803 remove_symbols, nremove_symbols,
804 sizeof(struct symbol_list),
805 (int (*)(const void *, const void *))
807 + symbol_list_bsearch);
809 if((symbols[i].n_type & N_TYPE) == N_UNDF ||
810 (symbols[i].n_type & N_TYPE) == N_PBUD){
811 @@ -1960,7 +1976,7 @@
812 save_symbols, nsave_symbols,
813 sizeof(struct symbol_list),
814 (int (*)(const void *, const void *))
816 + symbol_list_bsearch);
818 if(sp->sym != NULL &&
819 (sp->sym->n_type & N_PEXT) != N_PEXT){
820 @@ -2467,30 +2483,6 @@
822 #endif /* !defined(NMEDIT) */
825 - * Function for qsort for comparing symbol list names.
830 -const struct symbol_list *sym1,
831 -const struct symbol_list *sym2)
833 - return(strcmp(sym1->name, sym2->name));
837 - * Function for bsearch for finding a symbol.
843 -const struct symbol_list *sym)
845 - return(strcmp(name, sym->name));
850 * Function for qsort for comparing object names.
851 @@ -2525,9 +2517,9 @@
852 struct member *member,
853 struct object *object,
854 struct nlist *symbols,
856 +unsigned long nsyms,
859 +unsigned long strsize,
860 struct dylib_table_of_contents *tocs,
862 struct dylib_module *mods,
863 @@ -2667,7 +2659,7 @@
865 if(symbols[i].n_un.n_strx != 0){
866 if(symbols[i].n_un.n_strx < 0 ||
867 - symbols[i].n_un.n_strx > strsize){
868 + (unsigned long)symbols[i].n_un.n_strx > strsize){
869 error_arch(arch, member, "bad string index for symbol "
870 "table entry %lu in: ", i);
872 @@ -2695,7 +2687,7 @@
873 remove_symbols, nremove_symbols,
874 sizeof(struct symbol_list),
875 (int (*)(const void *, const void *))
877 + symbol_list_bsearch);
880 error_arch(arch, member, "more than one "
881 @@ -2719,7 +2711,7 @@
882 save_symbols, nsave_symbols,
883 sizeof(struct symbol_list),
884 (int (*)(const void *, const void *))
886 + symbol_list_bsearch);
889 error_arch(arch, member, "more than one "
890 @@ -2738,7 +2730,7 @@
891 remove_symbols, nremove_symbols,
892 sizeof(struct symbol_list),
893 (int (*)(const void *, const void *))
895 + symbol_list_bsearch);
898 error_arch(arch, member, "more than one symbol "
899 @@ -2777,7 +2769,7 @@
900 save_symbols, nsave_symbols,
901 sizeof(struct symbol_list),
902 (int (*)(const void *, const void *))
904 + symbol_list_bsearch);
907 error_arch(arch, member, "more than one symbol "
908 @@ -2910,19 +2902,19 @@
909 if((global_name[0] == '+' || global_name[0] == '-') &&
910 global_name[1] == '['){
912 - while(j + symbols[i].n_un.n_strx < strsize &&
913 + while(j + (unsigned long)symbols[i].n_un.n_strx < strsize &&
914 global_name[j] != ']')
916 - if(j + symbols[i].n_un.n_strx < strsize &&
917 + if(j + (unsigned long)symbols[i].n_un.n_strx < strsize &&
918 global_name[j] == ']')
923 - while(j + symbols[i].n_un.n_strx < strsize &&
924 + while(j + (unsigned long)symbols[i].n_un.n_strx < strsize &&
925 global_name[j] != ':')
927 - if(j + symbols[i].n_un.n_strx >= strsize){
928 + if(j + (unsigned long)symbols[i].n_un.n_strx >= strsize){
929 error_arch(arch, member, "bad N_STAB symbol name for entry "
930 "%lu (does not contain ':' separating name from type) "
932 @@ -2945,7 +2937,8 @@
933 symbols[i].n_sect = (*global_symbol)->n_sect;
934 symbols[i].n_value = (*global_symbol)->n_value;
935 symbols[i].n_desc = (*global_symbol)->n_desc;
936 - if(j + 1 + symbols[i].n_un.n_strx >= strsize ||
937 + if(j + 1 + (unsigned long)symbols[i].n_un.n_strx >=
939 global_name[j+1] != 'G'){
940 error_arch(arch, member, "bad N_GSYM symbol name "
941 "for entry %lu (does not have type 'G' after "
942 @@ -2955,7 +2948,8 @@
943 global_name[j+1] = 'S';
945 else{ /* symbols[i].n_type == N_FUN */
946 - if(j + 1 + symbols[i].n_un.n_strx >= strsize ||
947 + if(j + 1 + (unsigned long)symbols[i].n_un.n_strx >=
949 global_name[j+1] == 'F'){
950 global_name[j+1] = 'f';
952 Only in misc: vers_string