2 diff -rub misc/Makefile misc/Makefile
3 --- misc/Makefile Tue Jan 14 23:35:29 2003
4 +++ misc/Makefile Sat Sep 6 20:17:36 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__LITTLE_ENDIAN__ -U__BIG_ENDIAN__ -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
99 Only in misc/: inout.c
100 Only in misc/: install_name_tool.c
101 Only in misc/: kern_tool.c
102 Only in misc/: libtool.c
103 Only in misc/: lipo.c
104 Only in misc/: main.c
106 diff -rub 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 Only in misc/: seg_hack
262 Only in misc/: seg_hack.NEW
263 diff -rub misc/seg_hack.c misc/seg_hack.c
264 --- misc/seg_hack.c Fri Sep 6 18:28:06 2002
265 +++ misc/seg_hack.c Mon Aug 25 12:12:34 2003
272 char *input, *output;
274 unsigned long narchs;
275 Only in misc/: seg_hack.o
276 Only in misc/: seg_hack.private.o
277 Only in misc/: segedit.c
278 Only in misc/: size.c
279 Only in misc/: strings.c
280 Only in misc/: strip.NEW
281 diff -rub misc/strip.c misc/strip.c
282 --- misc/strip.c Tue Jan 14 23:35:30 2003
283 +++ misc/strip.c Mon Aug 25 22:02:32 2003
285 #include <mach-o/reloc.h>
286 #include <mach-o/nlist.h>
287 #include <mach-o/stab.h>
288 -#include <stuff/breakout.h>
289 -#include <stuff/allocate.h>
290 -#include <stuff/errors.h>
291 -#include <stuff/round.h>
292 +#include "stuff/breakout.h"
293 +#include "stuff/allocate.h"
294 +#include "stuff/errors.h"
295 +#include "stuff/round.h"
296 #include "stuff/reloc.h"
297 +#include "stuff/reloc.h"
298 +#include "stuff/symbol_list.h"
300 /* These are set from the command line arguments */
301 char *progname; /* name of the program for error messages (argv[0]) */
303 static long Sflag; /* -S strip only debugger symbols N_STAB */
304 static long xflag; /* -x strip non-globals */
305 static long Xflag; /* -X strip local symbols with 'L' names */
306 +static long cflag; /* -c strip section contents from dynamic libraries
307 + files to create stub libraries */
308 static long strip_all = 1;
310 * This is set on an object by object basis if the strip_all flag is still set
312 * save_symbols is the names of the symbols from the -s <file> argument.
313 * remove_symbols is the names of the symbols from the -R <file> argument.
315 -struct symbol_list {
316 - char *name; /* name of the global symbol */
317 - struct nlist *sym; /* pointer to the nlist structure for this symbol */
318 - enum bool seen; /* set if the symbol is seen in the input file */
320 static struct symbol_list *save_symbols = NULL;
321 static unsigned long nsave_symbols = 0;
322 static struct symbol_list *remove_symbols = NULL;
323 @@ -106,12 +105,12 @@
324 * and the new counts of local, defined external and undefined symbols.
326 static struct nlist *new_symbols = NULL;
327 -static long new_nsyms = 0;
328 +static unsigned long new_nsyms = 0;
329 static char *new_strings = NULL;
330 -static long new_strsize = 0;
331 -static long new_nlocalsym = 0;
332 -static long new_nextdefsym = 0;
333 -static long new_nundefsym = 0;
334 +static unsigned long new_strsize = 0;
335 +static unsigned long new_nlocalsym = 0;
336 +static unsigned long new_nextdefsym = 0;
337 +static unsigned long new_nundefsym = 0;
340 * These hold the new table of contents, reference table and module table for
342 struct member *member,
343 struct object *object,
344 struct nlist *symbols,
346 + unsigned long nsyms,
349 + unsigned long strsize,
350 struct dylib_table_of_contents *tocs,
352 struct dylib_module *mods,
354 struct member *member,
355 struct object *object,
356 struct nlist *symbols,
358 + unsigned long nsyms,
361 + unsigned long strsize,
362 struct dylib_table_of_contents *tocs,
364 struct dylib_module *mods,
366 unsigned long nextrefsyms);
369 -static void setup_symbol_list(
371 - struct symbol_list **list,
372 - unsigned long *size);
374 -static int cmp_qsort_name(
375 - const struct symbol_list *sym1,
376 - const struct symbol_list *sym2);
378 -static int cmp_bsearch(
380 - const struct symbol_list *sym);
383 static void setup_debug_filenames(
389 - unsigned long i, j, args_left, files_specified;
391 + unsigned long j, args_left, files_specified;
392 struct arch_flag *arch_flags;
393 unsigned long narch_flags;
397 #endif /* !defined(NMEDIT) */
406 error("unrecognized option: %s", argv[i]);
408 @@ -421,16 +414,16 @@
410 setup_symbol_list(Rfile, &remove_symbols, &nremove_symbols);
412 - for(i = 0; i < nremove_symbols ; i++){
413 - sp = bsearch(remove_symbols[i].name,
414 + for(j = 0; j < nremove_symbols ; j++){
415 + sp = bsearch(remove_symbols[j].name,
416 save_symbols, nsave_symbols,
417 sizeof(struct symbol_list),
418 (int (*)(const void *, const void *))
420 + symbol_list_bsearch);
422 error("symbol name: %s is listed in both -s %s and -R "
423 "%s files (can't be both saved and removed)",
424 - remove_symbols[i].name, sfile, Rfile);
425 + remove_symbols[j].name, sfile, Rfile);
432 * Now this arch[i] has been selected to be processed so process it
433 - * according to it's type.
434 + * according to its type.
436 if(archs[i].type == OFILE_ARCHIVE){
437 for(j = 0; j < archs[i].nmembers; j++){
439 unsigned long nextrefsyms;
440 unsigned long *indirectsyms;
441 unsigned long nindirectsyms;
443 + unsigned long i, j, k;
444 struct load_command *lc;
445 struct segment_command *sg;
448 strings = object->object_addr + object->st->stroff;
449 strsize = object->st->strsize;
452 + if(object->mh->filetype != MH_DYLIB && cflag)
453 + fatal_arch(arch, member, "-c can't be used on non-dynamic "
455 +#endif /* !(NMEDIT) */
456 + if(object->mh->filetype == MH_DYLIB_STUB)
457 + fatal_arch(arch, member, "dynamic stub library can't be changed "
460 if(object->mh->filetype == MH_DYLIB){
461 tocs = (struct dylib_table_of_contents *)
462 (object->object_addr + object->dyst->tocoff);
464 swap_dylib_module(mods, nmodtab, host_byte_sex);
465 swap_dylib_reference(refs, nextrefsyms, host_byte_sex);
469 + * In the -c flag is specified then strip the section contents of
470 + * this dynamic library and change it into a stub library. When
471 + * creating a stub library the timestamp is not changed.
474 + object->mh->filetype = MH_DYLIB_STUB;
475 + arch->dont_update_LC_ID_DYLIB_timestamp = TRUE;
477 + lc = object->load_commands;
478 + for(i = 0; i < object->mh->ncmds; i++){
479 + if(lc->cmd == LC_SEGMENT){
480 + sg = (struct segment_command *)lc;
481 + if(strcmp(sg->segname, SEG_LINKEDIT) != 0){
483 + * Zero out the section offset, reloff, and size
484 + * fields as the section contents are being removed.
486 + s = (struct section *)&sg[1];
487 + for(j = 0; j < sg->nsects; j++){
489 + * For section types with indirect tables we
490 + * do not zero out the section size in a stub
491 + * library. As the section size is needed to
492 + * know now many indirect table entries the
493 + * section has. This is a bit odd but programs
494 + * dealing with MH_DYLIB_STUB filetypes special
497 + section_type = s[j].flags & SECTION_TYPE;
498 + if(section_type != S_SYMBOL_STUBS &&
499 + section_type != S_LAZY_SYMBOL_POINTERS &&
500 + section_type != S_NON_LAZY_SYMBOL_POINTERS){
507 + /* zero out file offset and size in the segment */
512 + lc = (struct load_command *)((char *)lc + lc->cmdsize);
515 + * To get the right amount of the file copied out by writeout()
516 + * for the case when we are stripping out the section contents
517 + * we reduce the object size by the size of the section contents
518 + * including the padding after the load commands. Then this
519 + * size minus the size of the input symbolic information is
522 + object->object_size -= (object->seg_linkedit->fileoff -
523 + (sizeof(struct mach_header) + object->mh->sizeofcmds));
525 + * Set the file offset to the link edit information to be right
526 + * after the load commands.
528 + object->seg_linkedit->fileoff =
529 + sizeof(struct mach_header) + object->mh->sizeofcmds;
531 +#endif /* !(NMEDIT) */
539 - if(object->mh->filetype == MH_DYLIB){
541 + * If the -c option is specified the object's filetype will
542 + * have been changed from MH_DYLIB to MH_DYLIB_STUB above.
544 + if(object->mh->filetype == MH_DYLIB ||
545 + object->mh->filetype == MH_DYLIB_STUB){
546 object->output_tocs = new_tocs;
547 object->output_ntoc = new_ntoc;
550 object->dyst->ntoc * sizeof(struct dylib_table_of_contents)+
551 object->dyst->nmodtab * sizeof(struct dylib_module) +
552 object->dyst->nextrefsyms * sizeof(struct dylib_reference);
555 + * When stripping out the section contents to create a
556 + * dynamic library stub the relocation info also gets
560 +#endif /* !(NMEDIT) */
562 object->output_sym_info_size +=
563 object->dyst->nlocrel * sizeof(struct relocation_info) +
564 - object->dyst->nextrel * sizeof(struct relocation_info) +
565 + object->dyst->nextrel * sizeof(struct relocation_info);
567 + object->output_sym_info_size +=
568 object->dyst->nindirectsyms * sizeof(unsigned long) +
569 new_ntoc * sizeof(struct dylib_table_of_contents)+
570 object->dyst->nmodtab * sizeof(struct dylib_module) +
571 @@ -961,10 +1044,24 @@
572 if(object->dyst->nlocrel != 0){
573 object->output_loc_relocs = (struct relocation_info *)
574 (object->object_addr + object->dyst->locreloff);
577 + * When stripping out the section contents to create a
578 + * dynamic library stub the relocation info also gets
582 + object->dyst->nlocrel = 0;
583 + object->dyst->locreloff = 0;
586 +#endif /* defined(NMEDIT) */
588 object->dyst->locreloff = offset;
589 offset += object->dyst->nlocrel *
590 sizeof(struct relocation_info);
594 object->dyst->locreloff = 0;
596 @@ -990,10 +1087,24 @@
597 if(object->dyst->nextrel != 0){
598 object->output_ext_relocs = (struct relocation_info *)
599 (object->object_addr + object->dyst->extreloff);
602 + * When stripping out the section contents to create a
603 + * dynamic library stub the relocation info also gets
607 + object->dyst->nextrel = 0;
608 + object->dyst->extreloff = 0;
611 +#endif /* defined(NMEDIT) */
613 object->dyst->extreloff = offset;
614 offset += object->dyst->nextrel *
615 sizeof(struct relocation_info);
619 object->dyst->extreloff = 0;
621 @@ -1014,6 +1125,24 @@
622 object->dyst->tocoff = 0;
624 if(object->dyst->nmodtab != 0){
627 + * When stripping out the section contents to create a
628 + * dynamic library stub zero out the fields in the module
629 + * table for the sections and relocation information.
632 + /* Clear Objective-C address and size from modules. */
633 + for(k = 0; k < object->dyst->nmodtab; k++){
634 + mods[k].iinit_iterm = 0;
635 + mods[k].ninit_nterm = 0;
636 + mods[k].iextrel = 0;
637 + mods[k].nextrel = 0;
638 + mods[k].objc_module_info_addr = 0;
639 + mods[k].objc_module_info_size = 0;
642 +#endif /* !(NMEDIT) */
643 object->dyst->modtaboff = offset;
644 offset += object->dyst->nmodtab *
645 sizeof(struct dylib_module);
646 @@ -1423,120 +1552,6 @@
651 - * This is called to setup a symbol list from a file. It reads the file with
652 - * the strings in it and places them in an array of symbol_list structures and
653 - * then sorts them by name.
655 - * The file that contains the symbol names must have symbol names one per line,
656 - * leading and trailing white space is removed and lines starting with a '#'
657 - * and lines with only white space are ignored.
663 -struct symbol_list **list,
664 -unsigned long *size)
666 - int fd, i, j, len, strings_size;
667 - struct stat stat_buf;
668 - char *strings, *p, *line;
670 - if((fd = open(file, O_RDONLY)) < 0){
671 - system_error("can't open: %s", file);
674 - if(fstat(fd, &stat_buf) == -1){
675 - system_error("can't stat: %s", file);
679 - strings_size = stat_buf.st_size;
680 - strings = (char *)allocate(strings_size + 2);
681 - strings[strings_size] = '\n';
682 - strings[strings_size + 1] = '\0';
683 - if(read(fd, strings, strings_size) != strings_size){
684 - system_error("can't read: %s", file);
689 - * Change the newlines to '\0' and count the number of lines with
690 - * symbol names. Lines starting with '#' are comments and lines
691 - * contain all space characters do not contain symbol names.
695 - for(i = 0; i < strings_size + 1; i++){
696 - if(*p == '\n' || *p == '\r'){
699 - while(*line != '\0' && isspace(*line))
711 - *list = (struct symbol_list *)
712 - allocate((*size) * sizeof(struct symbol_list));
715 - * Place the strings in the list trimming leading and trailing spaces
716 - * from the lines with symbol names.
720 - for(i = 0; i < (*size); ){
721 - p += strlen(p) + 1;
722 - if(*line != '#' && *line != '\0'){
723 - while(*line != '\0' && isspace(*line))
726 - (*list)[i].name = line;
727 - (*list)[i].seen = FALSE;
729 - len = strlen(line);
731 - while(j > 0 && isspace(line[j])){
734 - if(j > 0 && j + 1 < len && isspace(line[j+1]))
741 - qsort(*list, *size, sizeof(struct symbol_list),
742 - (int (*)(const void *, const void *))cmp_qsort_name);
744 - /* remove duplicates on the list */
745 - for(i = 0; i < (*size); i++){
746 - if(i + 1 < (*size)){
747 - if(strcmp((*list)[i].name, (*list)[i+1].name) == 0){
748 - for(j = 1; j < ((*size) - i - 1); j++){
749 - (*list)[i + j].name = (*list)[i + j + 1].name;
757 - printf("symbol list:\n");
758 - for(i = 0; i < (*size); i++){
759 - printf("0x%x name = %s\n", &((*list)[i]),(*list)[i].name);
766 * This is called if there is a -d option specified. It reads the file with
767 @@ -1609,9 +1624,9 @@
768 struct member *member,
769 struct object *object,
770 struct nlist *symbols,
772 +unsigned long nsyms,
775 +unsigned long strsize,
776 struct dylib_table_of_contents *tocs,
778 struct dylib_module *mods,
779 @@ -1621,7 +1636,8 @@
780 unsigned long *indirectsyms,
781 unsigned long nindirectsyms)
783 - long i, j, k, n, inew_syms, save_debug, missing_syms, missing_symbols;
784 + unsigned long i, j, k, n, inew_syms, save_debug, missing_syms;
785 + unsigned long missing_symbols;
786 char *p, *q, **pp, *basename;
787 struct symbol_list *sp;
788 unsigned long new_ext_strsize, len, *changes, inew_undefsyms;
789 @@ -1686,7 +1702,7 @@
790 for(i = 0; i < nsyms; i++){
791 if(symbols[i].n_un.n_strx != 0){
792 if(symbols[i].n_un.n_strx < 0 ||
793 - symbols[i].n_un.n_strx > strsize){
794 + (unsigned long)symbols[i].n_un.n_strx > strsize){
795 error_arch(arch, member, "bad string index for symbol "
796 "table entry %ld in: ", i);
798 @@ -1838,7 +1854,7 @@
799 save_symbols, nsave_symbols,
800 sizeof(struct symbol_list),
801 (int (*)(const void *, const void *))
803 + symbol_list_bsearch);
806 sp->sym = &(symbols[i]);
807 @@ -1885,7 +1901,7 @@
808 remove_symbols, nremove_symbols,
809 sizeof(struct symbol_list),
810 (int (*)(const void *, const void *))
812 + symbol_list_bsearch);
814 if((symbols[i].n_type & N_TYPE) == N_UNDF ||
815 (symbols[i].n_type & N_TYPE) == N_PBUD){
816 @@ -1960,7 +1976,7 @@
817 save_symbols, nsave_symbols,
818 sizeof(struct symbol_list),
819 (int (*)(const void *, const void *))
821 + symbol_list_bsearch);
823 if(sp->sym != NULL &&
824 (sp->sym->n_type & N_PEXT) != N_PEXT){
825 @@ -2467,30 +2483,6 @@
827 #endif /* !defined(NMEDIT) */
830 - * Function for qsort for comparing symbol list names.
835 -const struct symbol_list *sym1,
836 -const struct symbol_list *sym2)
838 - return(strcmp(sym1->name, sym2->name));
842 - * Function for bsearch for finding a symbol.
848 -const struct symbol_list *sym)
850 - return(strcmp(name, sym->name));
855 * Function for qsort for comparing object names.
856 @@ -2525,9 +2517,9 @@
857 struct member *member,
858 struct object *object,
859 struct nlist *symbols,
861 +unsigned long nsyms,
864 +unsigned long strsize,
865 struct dylib_table_of_contents *tocs,
867 struct dylib_module *mods,
868 @@ -2667,7 +2659,7 @@
870 if(symbols[i].n_un.n_strx != 0){
871 if(symbols[i].n_un.n_strx < 0 ||
872 - symbols[i].n_un.n_strx > strsize){
873 + (unsigned long)symbols[i].n_un.n_strx > strsize){
874 error_arch(arch, member, "bad string index for symbol "
875 "table entry %lu in: ", i);
877 @@ -2695,7 +2687,7 @@
878 remove_symbols, nremove_symbols,
879 sizeof(struct symbol_list),
880 (int (*)(const void *, const void *))
882 + symbol_list_bsearch);
885 error_arch(arch, member, "more than one "
886 @@ -2719,7 +2711,7 @@
887 save_symbols, nsave_symbols,
888 sizeof(struct symbol_list),
889 (int (*)(const void *, const void *))
891 + symbol_list_bsearch);
894 error_arch(arch, member, "more than one "
895 @@ -2738,7 +2730,7 @@
896 remove_symbols, nremove_symbols,
897 sizeof(struct symbol_list),
898 (int (*)(const void *, const void *))
900 + symbol_list_bsearch);
903 error_arch(arch, member, "more than one symbol "
904 @@ -2777,7 +2769,7 @@
905 save_symbols, nsave_symbols,
906 sizeof(struct symbol_list),
907 (int (*)(const void *, const void *))
909 + symbol_list_bsearch);
912 error_arch(arch, member, "more than one symbol "
913 @@ -2910,19 +2902,19 @@
914 if((global_name[0] == '+' || global_name[0] == '-') &&
915 global_name[1] == '['){
917 - while(j + symbols[i].n_un.n_strx < strsize &&
918 + while(j + (unsigned long)symbols[i].n_un.n_strx < strsize &&
919 global_name[j] != ']')
921 - if(j + symbols[i].n_un.n_strx < strsize &&
922 + if(j + (unsigned long)symbols[i].n_un.n_strx < strsize &&
923 global_name[j] == ']')
928 - while(j + symbols[i].n_un.n_strx < strsize &&
929 + while(j + (unsigned long)symbols[i].n_un.n_strx < strsize &&
930 global_name[j] != ':')
932 - if(j + symbols[i].n_un.n_strx >= strsize){
933 + if(j + (unsigned long)symbols[i].n_un.n_strx >= strsize){
934 error_arch(arch, member, "bad N_STAB symbol name for entry "
935 "%lu (does not contain ':' separating name from type) "
937 @@ -2945,7 +2937,8 @@
938 symbols[i].n_sect = (*global_symbol)->n_sect;
939 symbols[i].n_value = (*global_symbol)->n_value;
940 symbols[i].n_desc = (*global_symbol)->n_desc;
941 - if(j + 1 + symbols[i].n_un.n_strx >= strsize ||
942 + if(j + 1 + (unsigned long)symbols[i].n_un.n_strx >=
944 global_name[j+1] != 'G'){
945 error_arch(arch, member, "bad N_GSYM symbol name "
946 "for entry %lu (does not have type 'G' after "
947 @@ -2955,7 +2948,8 @@
948 global_name[j+1] = 'S';
950 else{ /* symbols[i].n_type == N_FUN */
951 - if(j + 1 + symbols[i].n_un.n_strx >= strsize ||
952 + if(j + 1 + (unsigned long)symbols[i].n_un.n_strx >=
954 global_name[j+1] == 'F'){
955 global_name[j+1] = 'f';
957 Only in misc/: strip.o
958 Only in misc/: strip.private.o
959 Only in misc/: vers.c
960 Only in misc/: vers.o
961 Only in misc/: vers_string