From: megacz Date: Fri, 30 Jan 2004 07:05:13 +0000 (+0000) Subject: 2003/09/07 05:30:43 X-Git-Tag: RC3~690 X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=commitdiff_plain;h=96800aae0504d5fe1e3bfa2c739c45ffac156eb2 2003/09/07 05:30:43 darcs-hash:20040130070513-2ba56-f4b9fee3471e7ab8e6612cfc44c31c753cb559dc.gz --- diff --git a/upstream/darwin-linker/patches/misc.patch b/upstream/darwin-linker/patches/misc.patch deleted file mode 100644 index 2363a1e..0000000 --- a/upstream/darwin-linker/patches/misc.patch +++ /dev/null @@ -1,961 +0,0 @@ -Only in misc/: CVS -diff -rub misc/Makefile misc/Makefile ---- misc/Makefile Tue Jan 14 23:35:29 2003 -+++ misc/Makefile Sat Sep 6 20:17:36 2003 -@@ -2,11 +2,11 @@ - OFLAG = -O - RC_OS = macos - ifeq "macos" "$(RC_OS)" -- X_CFLAGS := $(shell if [ "$(RC_RELEASE)" != "Beaker" ] && \ -+ X_CFLAGS := $(shell if [ `uname` != "Linux" ] && [ "$(RC_RELEASE)" != "Beaker" ] && \ - [ "$(RC_RELEASE)" != "Bunsen" ] && \ - [ "$(RC_RELEASE)" != "Gonzo" ] && \ - [ "$(RC_RELEASE)" != "Kodiak" ]; then \ -- echo -Wno-long-double -no-cpp-precomp; \ -+ echo -Wno-long-double -no-cpp-precomp ; \ - fi; ) - endif - -@@ -14,11 +14,16 @@ - CFLAGS = $(OFLAG) -g \ - -I$(SRCROOT) -I$(SRCROOT)/../include -I$(OFILE_DIR) - else -- CFLAGS = $(OFLAG) -g -Wall -Wno-precomp $(X_CFLAGS) \ -+ ifeq "Linux" "$(shell uname)" -+ CFLAGS = $(OFLAG) -g -Wall $(X_CFLAGS) \ -+ -I$(SRCROOT) -I$(SRCROOT)/../include -I$(OFILE_DIR) -D__LITTLE_ENDIAN__ -U__BIG_ENDIAN__ -D__ppc__ -I/usr/include -I../../macosx-include -+ else -+ CFLAGS = $(OFLAG) -g -Wall $(X_CFLAGS) \ - -I$(SRCROOT) -I$(SRCROOT)/../include -I$(OFILE_DIR) -+ endif - endif - --USE_DEPENDENCY_FILE := $(shell if [ "$(notdir $(CC))" != "mwccppc" ]; then \ -+USE_DEPENDENCY_FILE := $(shell if [ `uname` != "Linux" ] && [ "$(notdir $(CC))" != "mwccppc" ]; then \ - echo YES ; else echo NO ; \ - fi; ) - -@@ -44,10 +49,7 @@ - LOCLIBDIR = /usr/local/lib - - CFILES1 = libtool.c --CFILES2 = main.c lipo.c size.c strings.c nm.c checksyms.c inout.c \ -- indr.c strip.c atom.c segedit.c kern_tool.c cmpdylib.c \ -- dylib_pcsampler.c pagestuff.c redo_prebinding.c seg_addr_table.c \ -- check_dylib.c seg_hack.c check_hints.c install_name_tool.c -+CFILES2 = seg_hack.c strip.c - ifeq "nextstep" "$(RC_OS)" - CFILES3 = file.c ar.c - endif -@@ -56,11 +58,7 @@ - notes - - --PROGS = lipo.NEW size.NEW strings.NEW nm.NEW \ -- libtool.NEW checksyms.NEW indr.NEW strip.NEW nmedit.NEW \ -- segedit.NEW kern_tool.NEW cmpdylib.NEW \ -- dylib_pcsampler.NEW pagestuff.NEW redo_prebinding.NEW \ -- seg_addr_table.NEW check_dylib.NEW seg_hack.NEW install_name_tool.NEW -+PROGS = seg_hack.NEW strip.NEW - - teflon_all macos_all: $(PROGS) - -@@ -71,7 +69,7 @@ - lib_ofiles: $(OFILE_DIR) $(SYMROOT) libredo_prebinding.a - - vers.c: -- vers_string -c $(VERS_STRING_FLAGS) cctools_misc > $(OFILE_DIR)/$@ -+ ./vers_string -c $(VERS_STRING_FLAGS) cctools_misc > $(OFILE_DIR)/$@ - - ifeq "NO" "$(USE_DEPENDENCY_FILE)" - .c.o: -@@ -222,6 +220,7 @@ - $(OFILE_DIR)/seg_hack.o $(OFILE_DIR)/vers.o $(LIBSTUFF) - $(CC) $(CFLAGS) $(RC_CFLAGS) -o $(SYMROOT)/seg_hack.NEW \ - $(OFILE_DIR)/seg_hack.private.o -+ cp $(SYMROOT)/seg_hack.NEW $(SYMROOT)/seg_hack - - install_name_tool.NEW: install_name_tool.o vers.o - $(CC) $(CFLAGS) $(RC_CFLAGS) -nostdlib -r \ -@@ -331,7 +330,8 @@ - $(SYMROOT)/redo_prebinding.NEW \ - $(SYMROOT)/libredo_prebinding.a \ - $(SYMROOT)/kern_tool.NEW \ -- $(SYMROOT)/cmpdylib.NEW -+ $(SYMROOT)/cmpdylib.NEW \ -+ $(SYMROOT)/seg_hack - - shlib_clean: - -rm -f \ -Only in misc/: ar.c -Only in misc/: atom.c -Only in misc/: check_dylib.c -Only in misc/: check_hints.c -Only in misc/: checksyms.c -Only in misc/: cmpdylib.c -Only in misc/: dylib_pcsampler.c -Only in misc/: file.c -Only in misc/: indr.c -Only in misc/: inout.c -Only in misc/: install_name_tool.c -Only in misc/: kern_tool.c -Only in misc/: libtool.c -Only in misc/: lipo.c -Only in misc/: main.c -Only in misc/: nm.c -diff -rub misc/notes misc/notes ---- misc/notes Tue Jan 14 23:35:29 2003 -+++ misc/notes Mon Aug 25 12:12:34 2003 -@@ -7,6 +7,148 @@ - could have been set otherwise and does not print the next line. - - Maybe add fat support for segedit(1) - -+Changes for the 5.12 release (the cctools-474 release): -+- Fixed a bug in redo_prebinding that was leaking memory if the -+ allow_missing_architectures parameter was used and the fat file did not -+ contain an architecture. The fix was in load_library() in 4 places it -+ checks to see if the missing architecure is allowed to be missing and it now -+ unmap's the ofile before returning. Radar bug #3144803. -+ -+Changes for the 5.12 release (the cctools-472 release): -+- Fixed a bug in seg_addr_table(1) when run with -relayout the <<< Next split -+ address to assign >>> isn't getting set properly. The fix in in main() to add -+ relayout == FALSE to the if() condition for the code that loops and updates -+ the NEXT_SPLIT_ADDRESS_TO_ASSIGN. Radar bug #3245958. -+ -+Changes for the 5.12 release (the cctools-470 release): -+- Added the -c option to strip(1) to strip the section contents of a dynamic -+ shared library and create a stub library. Radar bug #3235093. -+- Changed install_name_tool(1) to not change MH_DYLIB_STUB filetypes. -+ Radar bug #3235093. -+- Added the flag -search_paths_first to cause -lx flags to search each path -+ for .dylib then .a before searching next path to libtool(1). Radar bug -+ #3176974. -+ - Added the enum bool variable search_paths_first to the cmd_flags struct and -+ code to parse out the option, set variable and add it to the ldflags[] in -+ main() . -+ - The new static routines search_paths_for_lname() and search_path_for_lname() -+ were added. -+ - In file_name_from_l_flag() a test of the new search_paths_first variable is -+ done and if TRUE then search_paths_for_lname() is called. -+ -+Changes for the 5.12 release (the cctools-469 release): -+- Added support for the -weak-lx, -weak_library and -weak_framework flags to -+ libtool(1). Radar bug #3069758. -+- Fixed a bug seg_addr_table(1) in next_flat_seg1addr() where the variable i -+ was previously changed to unsigned. The second loop uses this varaiable as -+ signed and thus this change was causing the loop to never terminate. Radar -+ bug 3225931. -+ -+Changes for the 5.12 release (the cctools-466 release): -+- Fixed a bug in libtool(1) for the -static option that caused it to crash if -+ the objects contained no symbols to put in the table of contents. Radar bug -+ #3217471. -+- Fixed the incorrect casts on the comparison of the nlist struct's n_strx field -+ where the value being compared to was casted to a long. The correct fix was -+ to cast n_strx to an unsigned long. -+- Changed print_mach_symbols() in nm.c to print "(dynamically looked up)" for -+ the library ordinal DYNAMIC_LOOKUP_ORDINAL which are looked up dynamically -+ with flat namespace semantics in two-level namespace images. Radar bug -+ #3210803. -+- Changed get_primary_lib() in redo_prebinding.c to check for the library -+ ordinal DYNAMIC_LOOKUP_ORDINAL and return NULL. Radar bug #3210803. -+ -+Changes for the 5.12 release (the cctools-464 release): -+- Made changes to build cleanly with gcc3.3 -+ - Removed -Wno-precomp from the Makefile -+ - Fixed warnings for "comparison between signed and unsigned" in lipo.c, -+ size.c, strings.c, nm.c, libtool.c, checksyms.c, indr.c, strip.c, segedit.c, -+ kern_tool.c, cmpdylib.c, dylib_pcsampler.c, pagestuff.c, redo_prebinding.c, -+ seg_addr_table.c, check_dylib.c, seg_hack.c and install_name_tool.c. -+ -+Changes for the 5.12 release (the cctools-463 release): -+- Added support for MH_DYLIB_STUB libraries. Radar bug #3193744. -+ - Added the testing for MH_DYLIB_STUB along with MH_DYLIB in add_member() -+ in libtool.c . -+ - Added the testing for MH_DYLIB_STUB along with MH_DYLIB in -+ translate_object() in indr.c in the error check. -+ - Added a case for MH_DYLIB_STUB in type_buf() in file.c (note this is the -+ old file(1) command and is no longer used). -+ - Added the testing for MH_DYLIB_STUB along with MH_DYLIB in check_dylib() -+ in cmpdylib.c in 2 places. -+ - Added the testing for MH_DYLIB_STUB along with MH_DYLIB in checksyms() and -+ in check_dynamic_binary() in checksyms.c in 3 places in all. -+ - Added the testing for MH_DYLIB_STUB along with MH_DYLIB in check_hints.c . -+ -+Changes for the 5.12 release (the cctools-461 release): -+- Fixed a bug in install_name_tool(1) that caused it to crash when the new -+ load commands were smaller than the old load commands. Radar bug #3161586. -+ -+Changes for the 5.12 release (the cctools-456 release): -+- Fixed a bug in the redo_prebinding code when the allow_missing_architectures -+ parameter to the redo_prebinding() API is non-zero. In the routine -+ load_library() an extra check is needed to not cause an error if we are -+ allowing missing architectures. The case where this happens is when there -+ is a fat file that the architecture we don't care about depends on a library -+ in another fat file but the time stamps for the libraries don't match. -+ Radar bug #3144552. -+ -+Changes for the 5.12 release (the cctools-455 release): -+- Fixed a bug in the redo_prebinding code in the routine link_library_module() -+ in redo_prebinding.c. The problem was that when a reference to a private -+ extern was found only the module containing it was marked linked. A call -+ to link_library_module() for that module was needed to pull in its -+ dependencies and get those modules marked as LINKED. Radar bug #3126383. -+ -+Changes for the 5.12 release (the cctools-454 release): -+- Fixed a bug where seg_addr_table doesn't catch when an address is assigned in -+ the "alternate" area. seg_addr_table(1) was using the wrong constant to -+ check the validity of newly assigned addresses, the fix is to use the correct -+ constant. Radar bug #3138181. -+ -+Changes for the 5.12 release (the cctools-452 release): -+- Fixed the bug fix done for Radar bug #3124262 below in the redo_prebinding -+ code. The copied code from the above loop was wrong as it changed this: -+ if(libs[i].module_states[j] == LINKED) -+ to this: -+ if(libs[j].module_states[k] == LINKED || -+ (prebind_all_twolevel_modules == TRUE && -+ (libs[j].ofile->mh->flags & MH_TWOLEVEL) == -+ MH_TWOLEVEL)) -+ which should have been this: -+ if(libs[i].module_states[j] == LINKED || -+ (prebind_all_twolevel_modules == TRUE && -+ (libs[i].ofile->mh->flags & MH_TWOLEVEL) == -+ MH_TWOLEVEL)) -+ which used the correct index variables. Radar bug #3133589. -+ -+Changes for the 5.12 release (the cctools-451 release): -+- Fixed a bug in the redo_prebinding code that did not set the all the bits -+ in the linked_modules bit vector for any new LC_PREBOUND_DYLIB load commands -+ when prebind_all_twolevel_modules was TRUE. Radar bug #3124262. -+ -+Changes for the 5.12 release (the cctools-448 release): -+- Added an entry stabnames[] array in nm.c for N_OPT that is emitted with -+ gcc2_compiled and in gcc source. Radar bug #3104328. -+ -+Changes for the 5.12 release (the cctools-447 release): -+- Fixed a bug in add_member() in libtool.c when get_arch_family_from_cputype() -+ returns NULL. -+ -+Changes for the 5.11 release (the cctools-446 release): -+- Added passing -x from libtool to ld. Radar bug #3088301. -+ -+Changes for the 5.11 release (the cctools-444 release): -+- Added passing -exported_symbols_list & -unexported_symbols_list from libtool -+ to ld. Radar bug #3083844. -+- Factored out some of the symbol list stuff out of strip.c into libstuff so -+ ld(1)'s -exported_symbols_list and -unexported_symbols_list options can use -+ it. Radar bug #3083844. -+ -+Changes for the 5.11 release (the cctools-443 release): -+- Added passing -single_module & -multi_module from libtool to ld. Also added -+ passing -u flags. Radar #3080780. -+ - Changes for the 5.11 release (the cctools-440 release): - - Fixed the warnings about extra tokens at end of #endif directive in - check_hints.c, strip.c and make_defs.h (Radar bug #3072042). -Only in misc/: pagestuff.c -Only in misc/: redo_prebinding.c -Only in misc/: seg_addr_table.c -Only in misc/: seg_hack -Only in misc/: seg_hack.NEW -diff -rub misc/seg_hack.c misc/seg_hack.c ---- misc/seg_hack.c Fri Sep 6 18:28:06 2002 -+++ misc/seg_hack.c Mon Aug 25 12:12:34 2003 -@@ -58,7 +58,7 @@ - char **argv, - char **envp) - { -- unsigned long i; -+ int i; - char *input, *output; - struct arch *archs; - unsigned long narchs; -Only in misc/: seg_hack.o -Only in misc/: seg_hack.private.o -Only in misc/: segedit.c -Only in misc/: size.c -Only in misc/: strings.c -Only in misc/: strip.NEW -diff -rub misc/strip.c misc/strip.c ---- misc/strip.c Tue Jan 14 23:35:30 2003 -+++ misc/strip.c Mon Aug 25 22:02:32 2003 -@@ -38,11 +38,13 @@ - #include - #include - #include --#include --#include --#include --#include -+#include "stuff/breakout.h" -+#include "stuff/allocate.h" -+#include "stuff/errors.h" -+#include "stuff/round.h" - #include "stuff/reloc.h" -+#include "stuff/reloc.h" -+#include "stuff/symbol_list.h" - - /* These are set from the command line arguments */ - char *progname; /* name of the program for error messages (argv[0]) */ -@@ -62,6 +64,8 @@ - static long Sflag; /* -S strip only debugger symbols N_STAB */ - static long xflag; /* -x strip non-globals */ - static long Xflag; /* -X strip local symbols with 'L' names */ -+static long cflag; /* -c strip section contents from dynamic libraries -+ files to create stub libraries */ - static long strip_all = 1; - /* - * This is set on an object by object basis if the strip_all flag is still set -@@ -76,11 +80,6 @@ - * save_symbols is the names of the symbols from the -s argument. - * remove_symbols is the names of the symbols from the -R argument. - */ --struct symbol_list { -- char *name; /* name of the global symbol */ -- struct nlist *sym; /* pointer to the nlist structure for this symbol */ -- enum bool seen; /* set if the symbol is seen in the input file */ --}; - static struct symbol_list *save_symbols = NULL; - static unsigned long nsave_symbols = 0; - static struct symbol_list *remove_symbols = NULL; -@@ -106,12 +105,12 @@ - * and the new counts of local, defined external and undefined symbols. - */ - static struct nlist *new_symbols = NULL; --static long new_nsyms = 0; -+static unsigned long new_nsyms = 0; - static char *new_strings = NULL; --static long new_strsize = 0; --static long new_nlocalsym = 0; --static long new_nextdefsym = 0; --static long new_nundefsym = 0; -+static unsigned long new_strsize = 0; -+static unsigned long new_nlocalsym = 0; -+static unsigned long new_nextdefsym = 0; -+static unsigned long new_nundefsym = 0; - - /* - * These hold the new table of contents, reference table and module table for -@@ -169,9 +168,9 @@ - struct member *member, - struct object *object, - struct nlist *symbols, -- long nsyms, -+ unsigned long nsyms, - char *strings, -- long strsize, -+ unsigned long strsize, - struct dylib_table_of_contents *tocs, - unsigned long ntoc, - struct dylib_module *mods, -@@ -202,9 +201,9 @@ - struct member *member, - struct object *object, - struct nlist *symbols, -- long nsyms, -+ unsigned long nsyms, - char *strings, -- long strsize, -+ unsigned long strsize, - struct dylib_table_of_contents *tocs, - unsigned long ntoc, - struct dylib_module *mods, -@@ -213,19 +212,6 @@ - unsigned long nextrefsyms); - #endif /* NMEDIT */ - --static void setup_symbol_list( -- char *file, -- struct symbol_list **list, -- unsigned long *size); -- --static int cmp_qsort_name( -- const struct symbol_list *sym1, -- const struct symbol_list *sym2); -- --static int cmp_bsearch( -- const char *name, -- const struct symbol_list *sym); -- - #ifndef NMEDIT - static void setup_debug_filenames( - char *dfile); -@@ -260,7 +246,8 @@ - char *argv[], - char *envp[]) - { -- unsigned long i, j, args_left, files_specified; -+ int i; -+ unsigned long j, args_left, files_specified; - struct arch_flag *arch_flags; - unsigned long narch_flags; - enum bool all_archs; -@@ -388,6 +375,12 @@ - strip_all = 0; - #endif /* !defined(NMEDIT) */ - break; -+#ifndef NMEDIT -+ case 'c': -+ cflag = 1; -+ strip_all = 0; -+ break; -+#endif /* NMEDIT */ - default: - error("unrecognized option: %s", argv[i]); - usage(); -@@ -421,16 +414,16 @@ - if(Rfile){ - setup_symbol_list(Rfile, &remove_symbols, &nremove_symbols); - if(sfile){ -- for(i = 0; i < nremove_symbols ; i++){ -- sp = bsearch(remove_symbols[i].name, -+ for(j = 0; j < nremove_symbols ; j++){ -+ sp = bsearch(remove_symbols[j].name, - save_symbols, nsave_symbols, - sizeof(struct symbol_list), - (int (*)(const void *, const void *)) -- cmp_bsearch); -+ symbol_list_bsearch); - if(sp != NULL){ - error("symbol name: %s is listed in both -s %s and -R " - "%s files (can't be both saved and removed)", -- remove_symbols[i].name, sfile, Rfile); -+ remove_symbols[j].name, sfile, Rfile); - } - } - if(errors) -@@ -635,7 +628,7 @@ - - /* - * Now this arch[i] has been selected to be processed so process it -- * according to it's type. -+ * according to its type. - */ - if(archs[i].type == OFILE_ARCHIVE){ - for(j = 0; j < archs[i].nmembers; j++){ -@@ -753,7 +746,7 @@ - unsigned long nextrefsyms; - unsigned long *indirectsyms; - unsigned long nindirectsyms; -- long i, j, k; -+ unsigned long i, j, k; - struct load_command *lc; - struct segment_command *sg; - struct section *s; -@@ -780,6 +773,15 @@ - strings = object->object_addr + object->st->stroff; - strsize = object->st->strsize; - -+#ifndef NMEDIT -+ if(object->mh->filetype != MH_DYLIB && cflag) -+ fatal_arch(arch, member, "-c can't be used on non-dynamic " -+ "library: "); -+#endif /* !(NMEDIT) */ -+ if(object->mh->filetype == MH_DYLIB_STUB) -+ fatal_arch(arch, member, "dynamic stub library can't be changed " -+ "once created: "); -+ - if(object->mh->filetype == MH_DYLIB){ - tocs = (struct dylib_table_of_contents *) - (object->object_addr + object->dyst->tocoff); -@@ -795,6 +797,71 @@ - swap_dylib_module(mods, nmodtab, host_byte_sex); - swap_dylib_reference(refs, nextrefsyms, host_byte_sex); - } -+#ifndef NMEDIT -+ /* -+ * In the -c flag is specified then strip the section contents of -+ * this dynamic library and change it into a stub library. When -+ * creating a stub library the timestamp is not changed. -+ */ -+ if(cflag){ -+ object->mh->filetype = MH_DYLIB_STUB; -+ arch->dont_update_LC_ID_DYLIB_timestamp = TRUE; -+ -+ lc = object->load_commands; -+ for(i = 0; i < object->mh->ncmds; i++){ -+ if(lc->cmd == LC_SEGMENT){ -+ sg = (struct segment_command *)lc; -+ if(strcmp(sg->segname, SEG_LINKEDIT) != 0){ -+ /* -+ * Zero out the section offset, reloff, and size -+ * fields as the section contents are being removed. -+ */ -+ s = (struct section *)&sg[1]; -+ for(j = 0; j < sg->nsects; j++){ -+ /* -+ * For section types with indirect tables we -+ * do not zero out the section size in a stub -+ * library. As the section size is needed to -+ * know now many indirect table entries the -+ * section has. This is a bit odd but programs -+ * dealing with MH_DYLIB_STUB filetypes special -+ * case this. -+ */ -+ section_type = s[j].flags & SECTION_TYPE; -+ if(section_type != S_SYMBOL_STUBS && -+ section_type != S_LAZY_SYMBOL_POINTERS && -+ section_type != S_NON_LAZY_SYMBOL_POINTERS){ -+ s[j].size = 0; -+ } -+ s[j].addr = 0; -+ s[j].offset = 0; -+ s[j].reloff = 0; -+ } -+ /* zero out file offset and size in the segment */ -+ sg->fileoff = 0; -+ sg->filesize = 0; -+ } -+ } -+ lc = (struct load_command *)((char *)lc + lc->cmdsize); -+ } -+ /* -+ * To get the right amount of the file copied out by writeout() -+ * for the case when we are stripping out the section contents -+ * we reduce the object size by the size of the section contents -+ * including the padding after the load commands. Then this -+ * size minus the size of the input symbolic information is -+ * copied out. -+ */ -+ object->object_size -= (object->seg_linkedit->fileoff - -+ (sizeof(struct mach_header) + object->mh->sizeofcmds)); -+ /* -+ * Set the file offset to the link edit information to be right -+ * after the load commands. -+ */ -+ object->seg_linkedit->fileoff = -+ sizeof(struct mach_header) + object->mh->sizeofcmds; -+ } -+#endif /* !(NMEDIT) */ - } - else{ - tocs = NULL; -@@ -877,7 +944,12 @@ - - } - -- if(object->mh->filetype == MH_DYLIB){ -+ /* -+ * If the -c option is specified the object's filetype will -+ * have been changed from MH_DYLIB to MH_DYLIB_STUB above. -+ */ -+ if(object->mh->filetype == MH_DYLIB || -+ object->mh->filetype == MH_DYLIB_STUB){ - object->output_tocs = new_tocs; - object->output_ntoc = new_ntoc; - #ifdef NMEDIT -@@ -910,9 +982,20 @@ - object->dyst->ntoc * sizeof(struct dylib_table_of_contents)+ - object->dyst->nmodtab * sizeof(struct dylib_module) + - object->dyst->nextrefsyms * sizeof(struct dylib_reference); -+#ifndef NMEDIT -+ /* -+ * When stripping out the section contents to create a -+ * dynamic library stub the relocation info also gets -+ * stripped. -+ */ -+ if(!cflag) -+#endif /* !(NMEDIT) */ -+ { - object->output_sym_info_size += - object->dyst->nlocrel * sizeof(struct relocation_info) + -- object->dyst->nextrel * sizeof(struct relocation_info) + -+ object->dyst->nextrel * sizeof(struct relocation_info); -+ } -+ object->output_sym_info_size += - object->dyst->nindirectsyms * sizeof(unsigned long) + - new_ntoc * sizeof(struct dylib_table_of_contents)+ - object->dyst->nmodtab * sizeof(struct dylib_module) + -@@ -961,10 +1044,24 @@ - if(object->dyst->nlocrel != 0){ - object->output_loc_relocs = (struct relocation_info *) - (object->object_addr + object->dyst->locreloff); -+#ifndef NMEDIT -+ /* -+ * When stripping out the section contents to create a -+ * dynamic library stub the relocation info also gets -+ * stripped. -+ */ -+ if(cflag){ -+ object->dyst->nlocrel = 0; -+ object->dyst->locreloff = 0; -+ } -+ else -+#endif /* defined(NMEDIT) */ -+ { - object->dyst->locreloff = offset; - offset += object->dyst->nlocrel * - sizeof(struct relocation_info); - } -+ } - else - object->dyst->locreloff = 0; - -@@ -990,10 +1087,24 @@ - if(object->dyst->nextrel != 0){ - object->output_ext_relocs = (struct relocation_info *) - (object->object_addr + object->dyst->extreloff); -+#ifndef NMEDIT -+ /* -+ * When stripping out the section contents to create a -+ * dynamic library stub the relocation info also gets -+ * stripped. -+ */ -+ if(cflag){ -+ object->dyst->nextrel = 0; -+ object->dyst->extreloff = 0; -+ } -+ else -+#endif /* defined(NMEDIT) */ -+ { - object->dyst->extreloff = offset; - offset += object->dyst->nextrel * - sizeof(struct relocation_info); - } -+ } - else - object->dyst->extreloff = 0; - -@@ -1014,6 +1125,24 @@ - object->dyst->tocoff = 0; - - if(object->dyst->nmodtab != 0){ -+#ifndef NMEDIT -+ /* -+ * When stripping out the section contents to create a -+ * dynamic library stub zero out the fields in the module -+ * table for the sections and relocation information. -+ */ -+ if(cflag){ -+ /* Clear Objective-C address and size from modules. */ -+ for(k = 0; k < object->dyst->nmodtab; k++){ -+ mods[k].iinit_iterm = 0; -+ mods[k].ninit_nterm = 0; -+ mods[k].iextrel = 0; -+ mods[k].nextrel = 0; -+ mods[k].objc_module_info_addr = 0; -+ mods[k].objc_module_info_size = 0; -+ } -+ } -+#endif /* !(NMEDIT) */ - object->dyst->modtaboff = offset; - offset += object->dyst->nmodtab * - sizeof(struct dylib_module); -@@ -1423,120 +1552,6 @@ - } - } - --/* -- * This is called to setup a symbol list from a file. It reads the file with -- * the strings in it and places them in an array of symbol_list structures and -- * then sorts them by name. -- * -- * The file that contains the symbol names must have symbol names one per line, -- * leading and trailing white space is removed and lines starting with a '#' -- * and lines with only white space are ignored. -- */ --static --void --setup_symbol_list( --char *file, --struct symbol_list **list, --unsigned long *size) --{ -- int fd, i, j, len, strings_size; -- struct stat stat_buf; -- char *strings, *p, *line; -- -- if((fd = open(file, O_RDONLY)) < 0){ -- system_error("can't open: %s", file); -- return; -- } -- if(fstat(fd, &stat_buf) == -1){ -- system_error("can't stat: %s", file); -- close(fd); -- return; -- } -- strings_size = stat_buf.st_size; -- strings = (char *)allocate(strings_size + 2); -- strings[strings_size] = '\n'; -- strings[strings_size + 1] = '\0'; -- if(read(fd, strings, strings_size) != strings_size){ -- system_error("can't read: %s", file); -- close(fd); -- return; -- } -- /* -- * Change the newlines to '\0' and count the number of lines with -- * symbol names. Lines starting with '#' are comments and lines -- * contain all space characters do not contain symbol names. -- */ -- p = strings; -- line = p; -- for(i = 0; i < strings_size + 1; i++){ -- if(*p == '\n' || *p == '\r'){ -- *p = '\0'; -- if(*line != '#'){ -- while(*line != '\0' && isspace(*line)) -- line++; -- if(*line != '\0') -- (*size)++; -- } -- p++; -- line = p; -- } -- else{ -- p++; -- } -- } -- *list = (struct symbol_list *) -- allocate((*size) * sizeof(struct symbol_list)); -- -- /* -- * Place the strings in the list trimming leading and trailing spaces -- * from the lines with symbol names. -- */ -- p = strings; -- line = p; -- for(i = 0; i < (*size); ){ -- p += strlen(p) + 1; -- if(*line != '#' && *line != '\0'){ -- while(*line != '\0' && isspace(*line)) -- line++; -- if(*line != '\0'){ -- (*list)[i].name = line; -- (*list)[i].seen = FALSE; -- i++; -- len = strlen(line); -- j = len - 1; -- while(j > 0 && isspace(line[j])){ -- j--; -- } -- if(j > 0 && j + 1 < len && isspace(line[j+1])) -- line[j+1] = '\0'; -- } -- } -- line = p; -- } -- -- qsort(*list, *size, sizeof(struct symbol_list), -- (int (*)(const void *, const void *))cmp_qsort_name); -- -- /* remove duplicates on the list */ -- for(i = 0; i < (*size); i++){ -- if(i + 1 < (*size)){ -- if(strcmp((*list)[i].name, (*list)[i+1].name) == 0){ -- for(j = 1; j < ((*size) - i - 1); j++){ -- (*list)[i + j].name = (*list)[i + j + 1].name; -- } -- *size = *size - 1; -- } -- } -- } -- --#ifdef DEBUG -- printf("symbol list:\n"); -- for(i = 0; i < (*size); i++){ -- printf("0x%x name = %s\n", &((*list)[i]),(*list)[i].name); -- } --#endif /* DEBUG */ --} -- - #ifndef NMEDIT - /* - * This is called if there is a -d option specified. It reads the file with -@@ -1609,9 +1624,9 @@ - struct member *member, - struct object *object, - struct nlist *symbols, --long nsyms, -+unsigned long nsyms, - char *strings, --long strsize, -+unsigned long strsize, - struct dylib_table_of_contents *tocs, - unsigned long ntoc, - struct dylib_module *mods, -@@ -1621,7 +1636,8 @@ - unsigned long *indirectsyms, - unsigned long nindirectsyms) - { -- long i, j, k, n, inew_syms, save_debug, missing_syms, missing_symbols; -+ unsigned long i, j, k, n, inew_syms, save_debug, missing_syms; -+ unsigned long missing_symbols; - char *p, *q, **pp, *basename; - struct symbol_list *sp; - unsigned long new_ext_strsize, len, *changes, inew_undefsyms; -@@ -1686,7 +1702,7 @@ - for(i = 0; i < nsyms; i++){ - if(symbols[i].n_un.n_strx != 0){ - if(symbols[i].n_un.n_strx < 0 || -- symbols[i].n_un.n_strx > strsize){ -+ (unsigned long)symbols[i].n_un.n_strx > strsize){ - error_arch(arch, member, "bad string index for symbol " - "table entry %ld in: ", i); - return(FALSE); -@@ -1838,7 +1854,7 @@ - save_symbols, nsave_symbols, - sizeof(struct symbol_list), - (int (*)(const void *, const void *)) -- cmp_bsearch); -+ symbol_list_bsearch); - if(sp != NULL){ - if(sp->sym == NULL){ - sp->sym = &(symbols[i]); -@@ -1885,7 +1901,7 @@ - remove_symbols, nremove_symbols, - sizeof(struct symbol_list), - (int (*)(const void *, const void *)) -- cmp_bsearch); -+ symbol_list_bsearch); - if(sp != NULL){ - if((symbols[i].n_type & N_TYPE) == N_UNDF || - (symbols[i].n_type & N_TYPE) == N_PBUD){ -@@ -1960,7 +1976,7 @@ - save_symbols, nsave_symbols, - sizeof(struct symbol_list), - (int (*)(const void *, const void *)) -- cmp_bsearch); -+ symbol_list_bsearch); - if(sp != NULL){ - if(sp->sym != NULL && - (sp->sym->n_type & N_PEXT) != N_PEXT){ -@@ -2467,30 +2483,6 @@ - } - #endif /* !defined(NMEDIT) */ - --/* -- * Function for qsort for comparing symbol list names. -- */ --static --int --cmp_qsort_name( --const struct symbol_list *sym1, --const struct symbol_list *sym2) --{ -- return(strcmp(sym1->name, sym2->name)); --} -- --/* -- * Function for bsearch for finding a symbol. -- */ --static --int --cmp_bsearch( --const char *name, --const struct symbol_list *sym) --{ -- return(strcmp(name, sym->name)); --} -- - #ifndef NMEDIT - /* - * Function for qsort for comparing object names. -@@ -2525,9 +2517,9 @@ - struct member *member, - struct object *object, - struct nlist *symbols, --long nsyms, -+unsigned long nsyms, - char *strings, --long strsize, -+unsigned long strsize, - struct dylib_table_of_contents *tocs, - unsigned long ntoc, - struct dylib_module *mods, -@@ -2667,7 +2659,7 @@ - len = 0; - if(symbols[i].n_un.n_strx != 0){ - if(symbols[i].n_un.n_strx < 0 || -- symbols[i].n_un.n_strx > strsize){ -+ (unsigned long)symbols[i].n_un.n_strx > strsize){ - error_arch(arch, member, "bad string index for symbol " - "table entry %lu in: ", i); - return(FALSE); -@@ -2695,7 +2687,7 @@ - remove_symbols, nremove_symbols, - sizeof(struct symbol_list), - (int (*)(const void *, const void *)) -- cmp_bsearch); -+ symbol_list_bsearch); - if(sp != NULL){ - if(sp->sym != NULL){ - error_arch(arch, member, "more than one " -@@ -2719,7 +2711,7 @@ - save_symbols, nsave_symbols, - sizeof(struct symbol_list), - (int (*)(const void *, const void *)) -- cmp_bsearch); -+ symbol_list_bsearch); - if(sp != NULL){ - if(sp->sym != NULL){ - error_arch(arch, member, "more than one " -@@ -2738,7 +2730,7 @@ - remove_symbols, nremove_symbols, - sizeof(struct symbol_list), - (int (*)(const void *, const void *)) -- cmp_bsearch); -+ symbol_list_bsearch); - if(sp != NULL){ - if(sp->sym != NULL){ - error_arch(arch, member, "more than one symbol " -@@ -2777,7 +2769,7 @@ - save_symbols, nsave_symbols, - sizeof(struct symbol_list), - (int (*)(const void *, const void *)) -- cmp_bsearch); -+ symbol_list_bsearch); - if(sp != NULL){ - if(sp->sym != NULL){ - error_arch(arch, member, "more than one symbol " -@@ -2910,19 +2902,19 @@ - if((global_name[0] == '+' || global_name[0] == '-') && - global_name[1] == '['){ - j = 2; -- while(j + symbols[i].n_un.n_strx < strsize && -+ while(j + (unsigned long)symbols[i].n_un.n_strx < strsize && - global_name[j] != ']') - j++; -- if(j + symbols[i].n_un.n_strx < strsize && -+ if(j + (unsigned long)symbols[i].n_un.n_strx < strsize && - global_name[j] == ']') - j++; - } - else - j = 0; -- while(j + symbols[i].n_un.n_strx < strsize && -+ while(j + (unsigned long)symbols[i].n_un.n_strx < strsize && - global_name[j] != ':') - j++; -- if(j + symbols[i].n_un.n_strx >= strsize){ -+ if(j + (unsigned long)symbols[i].n_un.n_strx >= strsize){ - error_arch(arch, member, "bad N_STAB symbol name for entry " - "%lu (does not contain ':' separating name from type) " - "in: ", i); -@@ -2945,7 +2937,8 @@ - symbols[i].n_sect = (*global_symbol)->n_sect; - symbols[i].n_value = (*global_symbol)->n_value; - symbols[i].n_desc = (*global_symbol)->n_desc; -- if(j + 1 + symbols[i].n_un.n_strx >= strsize || -+ if(j + 1 + (unsigned long)symbols[i].n_un.n_strx >= -+ strsize || - global_name[j+1] != 'G'){ - error_arch(arch, member, "bad N_GSYM symbol name " - "for entry %lu (does not have type 'G' after " -@@ -2955,7 +2948,8 @@ - global_name[j+1] = 'S'; - } - else{ /* symbols[i].n_type == N_FUN */ -- if(j + 1 + symbols[i].n_un.n_strx >= strsize || -+ if(j + 1 + (unsigned long)symbols[i].n_un.n_strx >= -+ strsize || - global_name[j+1] == 'F'){ - global_name[j+1] = 'f'; - } -Only in misc/: strip.o -Only in misc/: strip.private.o -Only in misc/: vers.c -Only in misc/: vers.o -Only in misc/: vers_string