TODO (post MacWorld):
- Test coalesced symbols with -static code gen and with rld()?

TODO:
- If a two-level library is loaded the definition from the specified library
  is not loaded when there is another definition.  This can lead to ld not
  catching a multiply defined symbol in a flat library as dyld would cause.
  Test case in ~/bug_tests/Puma5D13.Sampler .
- Might be a bug in search_dynamic_libs() if it is searching an archive then
  it does not take into account -all_load or -Objc.
- The sreloc->r_address field is only 24-bits (16 meg) and can overflow
  producing bad relocation entries in the output file.  To test for this a
  handful of checks would need to be added to the *_reloc.c file after
  update_reloc and other files that put out relocation entries.
- The LC_PREBOUND_DYLIB commands do not have the modules used via N_INDR
  symbols marked in the linked_modules bit vector.
- Add check for undefined dyld_stub_binding_helper and __dyld_func_lookup if
  output_for_dyld is set.
- Think about how indirect section would be ordered if allowed.

Build problems:
- For i386 builds with -dynamic -fomit-frame-pointer produces bad code (bug
  #52986)
- For m68k builds -finline-functions crashes the compiler (used in the Makefile
  on the ld_build target).

Changes for the 5.9 release (the cctools-382 release):
- Fixed the change below for cctools-381.  The ifndef RLD should only have been
  around twolevel_namespace_hints_specified not twolevel_namespace_hints.
- Fixed the building of static_kld when $(SRCROOT) = . which needed otmp_obj
  after libmacho/otmp_obj in the Makefile.

Changes for the 5.9 release (the cctools-381 release):
- Added an ifndef RLD around the definition of twolevel_namespace_hints so that
  it would not get a warning when the ofiles_install target is built.

Changes for the 5.9 release (the cctools-380 release):
- Added the -twolevel_namespace_hints option which is off by default for bundles
  and on otherwise.  The changes are in ld.c, layout.c, symbols.c and pass2.c.
  Radar bug #2735266.

Changes for the 5.9 release (the cctools-377 release):
- Fixed a problem with the change below in cctools-376 to process_undefineds()
  in symbols.c that would not build when RLD was defined.

Changes for the 5.9 release (the cctools-376 release):
- Fixed a bug in search_dynamic_libs() in pass1.c that should not have free()'ed
  the "fake" merged_symbol when -Y was used.  This caused the code in
  process_undefineds() in symbols.c to crash.
- Fixed a bug in process_undefineds() in symbols.c that was not correctly
  reporting undefined symbols for the -Y flag correctly.  It should not have
  had the expression
      merged_symbol->twolevel_reference == TRUE
  when testing for undefined symbols.

Changes for the 5.9 release (the cctools-375 release):
- Fixed a bug in fine_reloc_output_sectnum() in objects.c where it should do
  the same thing for lazy pointer sections as well as non-lazy pointer
  sections.  This case showed up when a non-pic symbol stub was used for a local
  symbol.  In this case the relocation entry to the lazy pointer was not a
  scattered relocation entry so fine_reloc_output_sectnum() was being called
  by ppc_reloc.c.  In the case for a local symbol the lazy pointer will not be
  in the output so it does not even matter what the section number being
  returned is.
- Fixed ld(1) to correctly support the semantics of two-level namespace library
  references.  Radar bug #2716249.

  The basic approach is was to "fake" up a merged_symbol with the new
  twolevel_reference bit set and add it to the undefined list in
  merge_dylib_module_symbols() in symbols.c when it was merging a dylib module
  from a two-level namespace dylib.

  Then search_dynamic_libs() would look for these entries in the undefined list
  and search for the dylib module that defines them name call
  merge_dylib_module_symbols() to load the specified dynamic library.

  Changes to process_undefineds() in symbols.c were also needed to check for
  remaining two-level references and report them correctly.

  Changed search_dynamic_libs() in pass1.c to always set up the sub_images even
  if -twolevel_namespace is not in effect as it is needed when a two-level
  namespace library is used to resolve its references with the correct
  semantics.

  Added the twolevel_reference bit and the referencing_library field to the
  merged symbol struct in symbols.h.

- Removed a number of #ifndef RLD #endif pairs from symbols.c that were already
  inside an outer #ifndef RLD #endif pair.  These were inside the functions
  command_line_indr_symbol(), merge_dylib_module_symbols() and
  merge_bundle_loader_symbols() and all around the calls to
  tell_ProjectBuilder().

Changes for the 5.9 release (the cctools-373 release):
- Changed the default to -twolevel_namespace in ld.c.  Also adding setting
  twolevel_namespace to FALSE for -force_flat_namespace and -static.  Also
  removed some #ifdef notdef code after the testing of LD_TWOLEVEL_NAMESPACE.

Changes for the 5.9 release (the cctools-371 release):
- Added a log message ""[Logging for XBS] Referenced bundle loader: <path>" when
  the environment variable XBS_TRACE_BUNDLE_LOADER is set where <path> is the
  argument of -bundle_loader if set.  Radar bug #2710229.

Changes for the 5.9 release (the cctools-370 release):
- Added the -nomultidefs flag to ld(1) to set the MH_NOMULTIDEFS flag in the
  mach header.
- Added support in ld(1) for the two-level namespace hints optimization.  Radar
  bug #2558069.

  The following field was added to the struct merged_symbol in symbols.h:
    /*
     * For two-level namespace hints this is the index into the table of
     * contents for the definition symbol in the dylib it is defined in,
     */
    unsigned long itoc;

  In search_dynamic_libs() in pass1.c code was added to set the itoc field in
  the merged symbol after it was found in a DYLIB.
    if(twolevel_namespace == TRUE)
	undefined->merged_symbol->itoc = toc - q->tocs;

  Also in merge_dylib_module_symbols() in symbols.c the itoc of a merged
  symbol is set if not zero as the symbol in the merged symbol table could be
  a common or undefined.  This changed required the function dylib_bsearch() in
  pass1.c to now be __private_extern__ rather than static.  Also with this the
  variable strings and symbols were changed to bsearch_strings and
  bsearch_symbols in pass1.c and made __private_extern__ rather than static.

  The following new struct was added to layout.[ch] to hold info about the
  hints:
    /*
     * The output file's two level hints load command.
     */
    struct hints_info {
	struct twolevel_hints_command twolevel_hints_command;
    };
    __private_extern__ struct hints_info output_hints_info;

  In assign_output_symbol_indexes() in symbols.c number of hints was set based
  on the value of nundefsym.

  In layout_segments() in layout.c accounting for the size of the hints in the
  linkedit segment was done.

  Also in layout_segments() in layout.c code was added to account for the hints
  command and its size.

  Also in layout_segments() in layout.c the offsets to the hints table are set
  as to be just after the symbol table.

  In output_headers() in pass2.c the hints command is placed in the output.

  In setup_output_flush() in pass2.c the space between the end of the symbol
  table and the start of the hints is flushed and the offset is moved to the
  end of the hints table.

  In output_merged_symbols() in symbols.c at the end of the routine it outputs
  the two-level namespace hints.

  In check_cur_obj() in pass1.c added code to check a LC_TWOLEVEL_HINTS
  command.

Changes for the 5.9 release (the cctools-369 release):
- Added kld_load_from_memory & kld_load_basefile_from_memory for the dynamic
  build variant of libkld.  These APIs will be used by the Kernel's dynamic
  OSObject patch code.  Changes in rld.c .

Changes for the 5.9 release (the cctools-368 release):
- Fixed a bug with -bundle_loader and cross bytesex links.  Code to swap the
  symbol table of a BUNDLE_LOADER was added to search_dynamic_libs() in pass1.c.
- Also needed a test in merge() in pass1.c before add_dynamic_lib() was called
  for a BUNDLE_LOADER to make sure it has symbols as it could be of the wrong
  architecture and will cause later code in search_dynamic_libs() to crash.

Changes for the 5.9 release (the cctools-367 release):
- Added support for the -sub_library option. Radar bug #2697458.

  The following field was added to the struct dynamic_library in pass1.h:
    char *library_name;

  Added code in check_cur_obj() in pass1.c to check LC_SUB_LIBRARY command.

  Changed search_dynamic_libs() in pass1.c in the third major block of code that
  sets the library_ordinals to set the library_name field like the umbrella_name
  field of the dynamic_library struct.

  Added code to setup_sub_images() in pass1.c to handle sub_librarys as it
  handles sub_umbrellas.

  Changed set_sub_umbrella_ordinal() to set_sub_umbrella_sub_library_ordinal()
  to do both sub_umbrellas and sub_libraries.  And factor out the code that
  sets the index into the sub_images into the routine set_isub_image().

- Added support in ld(1) to build the two-level namespace sub images arrays for
  each dynamic library when -twolevel_namespace is in effect.  This is for the
  two-level namespace hints optimization.  Radar bug #2558069.

  The following fields were added to the struct dynamic_library in pass1.h:
    /* following are used when -twolevel_namespace is in effect */
    unsigned long ndependent_images;
    struct dynamic_library **dependent_images;
    enum bool sub_images_setup;
    unsigned long nsub_images;
    struct dynamic_library **sub_images;
    enum bool twolevel_searched;

  The following fields were added to the struct object_file in objects.h:
    unsigned long isub_image;   /* when -twolevel_name space is in effect */
				/*  this the sub_image index for recording */
    unsigned long nload_dylibs; /* Number of LC_LOAD_DYLIB commands */

  TODO: need to add code in check_cur_obj() to check LC_TWOLEVEL_HINTS command
  then the hints.

  Changed check_cur_obj() in pass1.c to increment nload_dylibs in the cur_obj
  for each LC_LOAD_DYLIB commands.

  Changed search_dynamic_libs() in pass1.c in the first major loop in
  to allocate the dependent_images as well as the second major loop for 
  dependent libraries when -twolevel_namespace is in effect.

  Changed search_dynamic_libs() in pass1.c in the second major loop in
  to fill in the dependent_images from the return value of add_dynamic_lib()
  when -twolevel_namespace is in effect.

  Changed search_dynamic_libs() in pass1.c in the third major block of code that
  sets the library_ordinals added a loop that calls the new routine 
  setup_sub_images() that has the same logic as in dyld's images.c.

  Added code in both set_sub_frameworks_ordinals() and
  set_sub_umbrella_ordinal() to set the isub_image for the libraries.

  Added code in search_dynamic_libs() when the debug 22 bit is set and
  -twolevel_namespace is in effect to printout the dependent and sub images.

  After the sub_images arrays are set up the main loop to search for undefined
  symbol in search_dynamic_libs() was changed to search all the sub_images of
  each DYLIB as it is encountered.  The new twolevel_searched field is first
  set to FALSE in all the dynamic_libray structs in the list and if a symbol is
  not found in a DYLIB then all the sub_images are searched in turn.  This same
  bit of logic is also done in the last loop that checks merged symbols coming
  from dynamic libraries.

- Fixed a bug where if only the -stack_size was set then the default stack
  address value used was not put into the thread state.  This change was in
  layout_segments() in layout.c where it now simply sets stack_addr_specified
  to TRUE after calling get_stack_addr_from_flag().

Changes for the 5.9 release (the cctools-361 release):
- Added the -prebind_allow_overlap flag as well as the LD_PREBIND_ALLOW_OVERLAP
  environment variable which allow prebinding to still be done even if some of
  the libraries overlap.  Changes in ld.c, ld.h and layout.c in check_overlap().
- Added the case for LC_PREBOUND_DYLIB in check_cur_obj() in pass1.c as it was
  missing and -bundle_loader arguments can have these load commands.
- Fixed a bug add_dynamic_lib() in pass1.c that changed the definition_obj of a
  dynamic_library struct when it was a sub-umbrella.  This was old code from
  the first attempt (cctools-344) to get the primary library stuff for
  two-level namespace working.  This bug caused a cross bytesex link to fail
  because when the symbolic info for each dylib was set up in
  search_dynamic_libs() it swapped the nlist structs more than once because
  more than one dynamic_library struct pointed to the same info.

Changes for the 5.9 release (the cctools-360 release):
- Ifdef'ed out the code that turns off -twolevel_namespace when the environment
  variable LD_TWOLEVEL_NAMESPACE is set and -undefined is specified that is not
  "error" or any -U flags are specified to cause hard errors for now.  This may
  have to be put back in at some point. But we want things to fail at first to
  find projects that use these flags.
- Added savestr() to ld.c to avoid a multiply defineds for allocate() and
  reallocate().
- Changed the Makefile so that static_kld build will use libmacho from the
  the $(SYMROOT) not from /usr/local/lib/system.
- Added a definition of savestr() to rld.c to avoid pulling in allocate.o from
  libstuff.
- Changed the Makefile so that the rld stuff does not get built for RC_OS being
  macos and RC_RELEASE being after Cheetah.

Changes for the 5.9 release (the cctools-359 release):
- Added the -multiply_defined flag for the treatment of two-level namespace
  multiply defined symbols.  It takes error, warning and suppress as arguments
  with warning being the default.
- Added the LD_TWOLEVEL_NAMESPACE environment variable to turn on
  -twolevel_namespace when -flat_namespace and -static are not specified.  It
  is also not turned on when -undefined is specified that is not "error" or any
  -U flags are specified but prints a warning that LD_TWOLEVEL_NAMESPACE is
  ignored.
- Changed check_overlap() in layout.c for the check that does not disable
  prebinding when there is an overlap with a split library's __LINKEDIT segment
  such that an executable can be linked where some it the libraries it links
  with split libraries that are not stripped it does not disable prebinding.
- Added checking force_flat_namespace when checking for MH_TWOLEVEL so that if
  forcing a flat name space the checking for multiply defined symbol is treated
  as an error even if a two-level namespace library is used.
- Changed check_dylibs_for_reference() in pass1.c to only check for references
  in flat libraries so that two-level namespace libaries can be used with
  different references and the resulting item being linked can be prebound
  except when -force_flat_namespace is also being used.
- Added the check and printing a message about unused multiply defined symbols
  when -twolevel_namespace is in effect.  This is done with the new routine
  twolevel_namespace_check_for_unused_dylib_symbols() defined in pass1.c and
  called from layout() in layout.c .  To implement it the routine
  check_dylibs_for_definition() in pass1.c was change to take two flags so it
  can be used for prebinding and two-level name space checks.
- Added the -bundle_loader <executable> and -private_bundle flags.  Along with
  many other changes this allows -bundle outputs to have their undefined symbols
  to be checked against the executable.  This is required for -bundle outputs
  and -twolevel_namespace when the bundle references symbols from the executable
  and EXECUTABLE_ORDINAL gets recorded for the library ordinal.
- Added -Wno-long-double to shutup the compiler for
  <architecture/m88k/fp_regs.h>.
- Added a check to make sure -U flags are not used when twolevel_namespace is
  in effect.
- Fixed a bug with or'ing in of REFERENCED_DYNAMICALLY in
  merge_dylib_module_symbols() in symbols.c on line 1965 which should not
  be or'ed in when the dynamic library is a MH_TWOLEVEL.
- Fixed a bug in merge_dylib_module_symbols() that incorrectly flagged a
  multiply defined symbol as an error not a warning when one symbol came from
  a flat library and one came from a two-level library and we were building an
  executable.

Changes for the 5.8 release (the cctools-355 release):
- Changed the include file <mach/vm_task.h> to <mach/vm_map.h> in rld.c and
  sets.c .  Radar bug #2579488.
- Changed the way -twolevel_namespace sets the primary ordinal and reports
  errors for illegally referenced indirect libraries from the cctools-344
  original implementation:

    In search_dynamic_libs() in pass1.c after all the dependents are added a
    set of loops were added to propagrate the library ordinals to the
    sub-frameworks and sub-umbrellas.  The new routines
    set_sub_frameworks_ordinals() and set_sub_umbrella_ordinal() are called
    from these loops.  These new routines are also defined in pass1.c.
    The new field umbrella_name was added to the dynamic_library struct in
    pass1.h .

    Then in merge_dylib_module_symbols() before the merged_symbol
    is updated to the definition of the symbol in the dylib a check
    is made to see if the symbol is referenced from an object going 
    into the image and will need the library ordinal recorded. If so
    a check to see if the library ordinal was assigned is done and
    if not an error for an illegal reference to a symbol defined
    in a indirectly referenced dynamic library is issued.
    The new field indirect_twolevel_ref_flagged was added to the
    dynamic_library struct in pass1.h .

    All the code added to the open_dylib() in pass1.c in the cctools-344
    implementation for twolevel-namespace was removed.

Changes for the 5.8 release (the cctools-353 release):
- Change ld(1) to allow section difference references to coalesced symbols where
  the symbol being referenced is private extern or local.  This is needed so
  that the zero overhead exception tables can make pic references to the 
  private extern symbols that the compiler creates for template functions.
  To do this the fine relocs created for coalesced symbols that are private
  externs are marked with local_symbol == TRUE in coalesced_section_merge() in
  coalesced_sections.c.  Then in legal_reference() in indirect_sections.c the
  first test had the additional conditional check to allow the reference when
  the reference was to a block that local_symbol == TRUE.  Then a change to
  fine_reloc_output_address() in objects.c to deal with a coalesced section
  where local_symbol == TRUE and use_contents == FALSE was made to pick out the
  merged_symbol pointer from the output_offset field.  Radar bug #2573679.
- Changed prebinding_check_for_dylib_override_symbols() in pass1.c to not
  continue when
    merged_symbol->defined_in_dylib == TRUE
  and go head and call check_dylibs_for_definition().  Then a change was made
  to check_dylibs_for_definition() that skipped merged symbols defined in a
  dylib for the current dylib being checked.  This allow catching symbols being
  overridden in a dylib from a different dylib.  This happens when both System
  and System_profile are linked (and have different prebound addresses).
  Radar bug #2564555.

Changes for the 5.8 release (the cctools-350 release):
- Added a call to vm_msync() in pass1() in pass1.c and pass2() in pass2.c under
  the #ifdef VM_SYNC_DEACTIVATE conditional.  Radar bug #2567196.

Changes for the 5.8 release (the cctools-349 release):
- Added code in pass2() in pass2.c to use fcntl() with the F_NOCACHE option to
  not cache the blocks of the output file.
- Fixed a bug in compiling the without -DDEBUG in count_relocs() in sections.c
  where the setting of map->nextrel and map->nlocrel where in ifdef DEBUG code
  that should not have been.

Changes for the 5.8 release (the cctools-347 release):
- Changed merge_dylib_module_symbols() in symbols.c for handling multiply
  defined symbols to treat them as warnings when building images when
  -twolevel_namespace is in effect and the symbol does not come from a dylib
  or if the symbol is coming from a dylib with MH_TWOLEVEL.

Changes for the 5.8 release (the cctools-346 release):
- Added the printing of why prebinding was disabled when environment variable
  RC_TRACE_PREBINDIND_DISABLED is set.  This also uses the new -final_output
  flag which the driver can pass as the actual name of the output file being
  created which is used in the message:
  [Logging for Build & Integration] prebinding disabled for <<-final_output 
	argument>> because REASON
  Radar bug #2550094.
- Fixed a bug in coalesced_section_merge() in coalesced_sections.c where it
  did not take into account the private extern bit of a merged symbol of an
  external relocation entry when the output is MH_BUNDLE.  Radar bug #2548925.

Changes for the 5.8 release (the cctools-345 release):
- Changed the setting of -segs_read_write_addr if picking zeros up both the 
  -segs_read_only_addr and -segs_read_write_addr then the value 0x10000000 is
  used for the -segs_read_write_addr.  Radar bug #2544818.
- Changed the segment overlap checking to not disable prebinding when building
  a split library and a segment overlaps a linkedit segment of any split
  library.  Radar bug #2543932.
- Fixed a bug in main() in ld.c where this line:
	if(client_name != NULL != 0)
  should have been:
	if(client_name != NULL)

Changes for the 5.8 release (the cctools-344 release):
- Added code for tracking and setting the library ordinal when
  -twolevel_namespace is in effect.  Radar bug #2538835.

    The ordinal for the "primary" library is assigned in 
    search_dynamic_libs() in pass1.c for the libraries on the list
    before any dependents are added.  This is stored in the
    object_file struct in the library_ordinal field.

    The routine search_dynamic_libs() in in pass1.c calls
    open_dylib() in pass1.c for the dependent dylibs which returns
    TRUE or FALSE as whether to keep the dependent lib on the list
    of dylibs to be searched.  The routine open_dylib() does the
    work of determing if a dependent dylib is to be kept when
    -twolevel_namespace is in effect.  It has the code to deal
    with sub-frameworks of umbrella frameworks and sub-umbrellas.
    It is the one that sets the library_ordinal from the primary
    library into the dependent dylib.

    The setting of the library ordinal in the n_desc field of a
    symbol is done in the routine merge_dylib_module_symbols() in
    symbols.c which is passed the struct dynamic_library for the
    library that the module comes from.  And is done with this
    code:
	if(twolevel_namespace == TRUE){
	    SET_LIBRARY_ORDINAL(merged_symbol->nlist.n_desc
		dynamic_library->definition_obj->library_ordinal);
	}

- Added a check to make sure -undefined error is used when -twolevel_namespace
  is in effect.  Radar bug #2538835.
- Added building kld_build for cctoolslib when RC_OS is macos and RC_RELASE is
  not Bunsen, Beaker, Gonzo or Kodiak.  The kernel Radar that install the libsa
  headers is 2537868.  The Radar for this change is 2538829.
- Fixed a bug with -keep_private_extern logic and coalesced symbols that did not
  generate an external relocation entry when it should.  The change was this:
    if((merged_symbol->nlist.n_type & N_PEXT) == N_PEXT ||
       keep_private_externs == TRUE || ...
  to this:
    if(((merged_symbol->nlist.n_type & N_PEXT) == N_PEXT &&
        keep_private_externs == FALSE) || ...
  in ppc_reloc.c, coalesced_sections.c, generic_reloc.c, hppa_reloc.c,
  i860_reloc.c, indirect_sections.c, m88k_reloc.c, and sparc_reloc.c.  Radar
  bug #2536788.
- Fixed a bug with checking the LC_SUB_UMBRELLA that caused it to crash as it
  was using the 'sub' variable for LC_SUB_FRAMEWORK load commands not the 'usub'
  variable.  This is in check_cur_obj() in pass1.c.  Radar bug #2538825.

Changes for the 5.8 release (the cctools-342 release):
- Fixed a problem with the change for Radar bug #2503688 that was in cctools-341
  that was in merged_symbol() that should have not changed to using the
  merged_symbol instead of the object_symbols for the setting of the reference
  type in a dynamic library.
- Fixed a bug with -keep_private_externs that was setting of the indirect table
  to INDIRECT_SYMBOL_LOCAL (or INDIRECT_SYMBOL_ABS) when it should not.  This
  shows up as a problem when the indirect table entry is for a private_extern
  symbol.  The change is in output_indirect_symbols() in indirect_sections.c to
  add a check for keep_private_externs == FALSE.  Radar bug #2534011.
- Fixed the another bug with a coalesced symbol that is a private extern (when
  -keep_private_externs is NOT in effect) in that the value of the non-lazy
  symbol pointer is not set to the value of the symbol (though the index is set
  to INDIRECT_SYMBOL_LOCAL).  The setting of the non-lazy symbol pointer is
  done in scatter_copy() in sections.c based on the fine_relocs indirect_defined
  field that is always FALSE for coalesced symbols (to keep indirection).
  The function is_pass2_merged_symbol_coalesced() was added and logic was added
  to scatter_copy() to use it and set the non-lazy symbol pointer.  Radar bug
  #2534011.
- Added support for -allowable_client and -client_name flags.  Radar bug
  #2533649.
- Added first bit of support for the -flatname_space, -twolevel_namespace,
  and -force_flat_namespace options.  Parsing the options and setting
  MH_TWOLEVEL and MH_FORCE_FLAT in the header's flags. Radar bug #2534043.

Changes for the 5.8 release (the cctools-341 release):
- Added the -sub_umbrella option Radar bug #2530028.
- Changed the Makefile to build libkld.a and libkld.dylib for cctoolslib builds.
  Many ifdefs were added and changed in rld.c to implement the kld APIs and 
  many ifdefs were added all the other files to build with the Kernel framework.
  Radar bug #2523649.
- Changed ld.c to initalize the value of arch_flag when KLD and __STATIC__ are
  defined so that code in pass1.c can avoid using host_info via
  get_arch_from_host() which is also ifdef'ed out when KLD and __STATIC__ are
  defined (see pass1_fat() in pass1.c).
- Changed merge_sections() in sections.c to not merge the section alignment
  from the base file for KLD.
- Changed the ifdef's in rld.c to make only sa_rld() and sa_rld_with_symtab()
  are left as externals for libsarld.a.  Also changed sa_rld_output_addr and
  sa_rld_output_size to private_externs.
- Removed the test to make sure -init is also specified when -run_init_lazily
  is specified as now module initialization routines can also be run lazily.
  Radar bug #2502941.
- Changed the final loops in search_dynamic_libs() in pass1.c that checks "all
  merged symbols coming from dynamic libraries from the first one defining the
  symbol" to ignore symbols with coalesced_defined_in_dylib as TRUE.
  Radar bug #2503703.
- Fixed a bug in merge_symbols() where the first symbol merged was a coalesced
  global symbol from a dynamic library and the next was from an object
  (libcc_dynamic.a) which was causing it to be a multiply defined
  symbol.  The field coalesced_defined_in_dylib also needed to be checked if
  defined_in_dylib is TRUE.  Radar bug #2503694.
- Fixed a yet another bug in merge_symbols() in symbol.c when a private
  extern coalesced symbol gets discarded.  The counts for cur_obj->nextdefsym
  was decremented in all cases when it should have only been decremented in
  the case the symbol was not a private extern.  Radar bug #2503688.

Changes for the 5.7 release (the cctools-337 release):
- Fixed two bugs in the handling of lower level error later causing an internal
  error.  The fix was to test errors for non-zero and return from the routine.
  this was added to output_section() in sections.c after the relocs routines
  and pass2 in pass2.c after output_section() call.
- Fixed a bug in print_whatsloaded() in objects.c where it did not print the
  archive name for extended format #1.
- Fixed a bug in coalesced_section_merge() in coalesced_sections.c where it
  did not take into account the private extern bit of a merged symbol of an
  external relocation entry when the output is MH_DYLIB.  Radar bug #2497954.

Changes for the 5.7 release (the cctools-335 release):
- Fixed a bug in merge_symbols() in symbol.c when a private extern coalesced
  symbol gets discarded.  The counts for cur_obj->nprivatesym and 
  nmerged_private_symbols need to be decremented in the case the coalesced
  symbol gets discarded.  Radar bug #2493452.
- Fixed a bug in literal_pointer_output() in literal_pointers.c for split
  libraries that did not correctly set the r_address field for literal pointer
  relocation entries. Radar bug #2493445.

Changes for the 5.7 release (the cctools-334 release):
- Changed guess_short_name()'s has_suffix argument to return a pointer
  to the suffix so checksyms could check for "_debug".  This effected
  ld(1)'s guess_short_name() two calls.
- Added the -run_init_lazily flag and the variable lazy_init so to mark the
  dynamic library with MH_LAZY_INIT.  Changes in ld.c, ld.h and layout.c.
  Radar bug #2490396.

Changes for the 5.7 release (the cctools-330 release):
- Changed merge_dylib_module_symbols() in symbols.c to have a last pass that
  looks for private undefined references and links them in.  To do this the
  dynamic_library struct needed to be passed to it.  This causes pass1.h to
  be needed before including symbols.h so many other files also have this
  change.  The change to merge_dylib_module_symbols() is needed so that dynamic
  libraries that have had nmedit run on them will get the proper semantics and
  detect multiply defined symbols at link time.  This also gets the
  LC_PREBOUND_DYLIB commands do have the modules used via private externs
  symbols marked in the linked_modules bit vector.  This is part of Radar bug
  #2420307.

Changes for the 5.7 release (the cctools-330 release):
- Changed the ifdef's for the standard_framework_dirs in pass1.c s
  that moving forward /Library/Frameworks is part of the default and
  /Local/Library/Frameworks is only used instead if __GONZO_BUNSEN_BEAKER__
  is defined for older DP4, DP3 & PR2 builds. Radar bug #2477862.
- Changed the call to netname_look_up() in check_for_ProjectBuilder() to
  bootstrap_look_up() when __OPENSTEP__ and __GONZO_BUNSEN_BEAKER__ is not
  defined (Radar bug #2473864).
- Fixes the error message about only using -umbrella when -dylib is used to use
  "-umbrella" where it was using "-sub_framework".  Radar bug #2477866.

Changes for the 5.7 release (the cctools-329 release):
- Changed iinit and ninit fields of the struct dylib_module in
  mod_section_merge() in mod_sections.c to iinit_iterm and ninit_nterm and added
  checks for overflow in there.  Also added in the code to handle setting the
  module table entries in output_dylib_tables() in symbols.c and is nolonger
  #ifdef'ed DYLIB_TERM.  Radar bug #2469527.

Changes for the 5.7 release (the cctools-328 release):
- Changed where the libraries get installed by default.  So going forward things
  get install in /usr/local/lib/system and /Local/Developer/System
  is only used for RC_OS=macos when RC_RELEASE is Gonzo, Bunsen, or Beaker.

Changes for the 5.7 release (the cctools-327 release):
- Changed back where ld(1) picks up its the System Framework's private headers.
  It will continue to look in
  /System/Library/Frameworks/System.framework/PrivateHeaders and may someday
  will lookin in
  /MacOSX/System/Frameworks/System.framework/PrivateHeaders in some post-DP4
  release.
- Changed where the libraries get installed by default.  So going forward things
  get install in /AppleInternal/Developer/System and /Local/Developer/System
  is only used for RC_OS=macos when RC_RELEASE is Gonzo, Bunsen, or Beaker.
- Changed the ifdef's for the standard_framework_dirs in pass1.c s
  that moving forward /MacOSX/Library/Frameworks is part of the default and
  /Local/Library/Frameworks is only used instead if __GONZO_BUNSEN_BEAKER__
  is defined for older DP4, DP3 & PR2 builds.

Changes for the 5.6 release (the cctools-325 release):
- Fixes a bug in merge_dylib_module_symbols() in symbols.c where it was using
  [i] as an index into the symbol table where it should have been using [j] in
  two places.  This was causing Gonzo1I10 ld's to crash via libtool with the
  message "/usr/bin/libtool: fatal error in ld".

Changes for the 5.6 release (the cctools-324 release):
- Fixed a bug in merge_symbols() in symbols.c in the BINCL/EINCL logic.  In the
  case where the there is a missing EINCL the logic will run into the global
  symbols and mistakenly count them as local symbols.  Thus causing an internal
  error: "output_local_symbols() inconsistent local symbol count".
- Fixed a bug in merge_dylib_module_symbols() where if a coalesced symbol only
  appears in dylibs then a multiply defined error resulted.  To make this fix
  a new bit, coalesced_defined_in_dylib,  in the merged_symbol struct in
  symbols.h was also added.

Changes for the 5.6 release (the cctools-323 release):
- Changed where the libraries get installed for the Space release in preparation
  of this "Half Plan" becoming the default for DP4 (Gonzo).  This directory
  /Local/Developer/System is changing to /AppleInternal/Developer/System.
- Changed the ifdef __SPACE__ for the standard_framework_dirs in pass1.c as the
  directory changes have been scaled back and changed.  In preparation of this
  "Half Plan" /Local/Library/Frameworks was changed to
  /MacOSX/Library/Frameworks and ifdef'ed __SPACE__.  In the second half of the
  plan (post-DP4) /System/Library/Frameworks will change to
  /MacOSX/System/Frameworks and this is ifdef'ed __SPACE2__.
- Changed back where ld picks up its the System Framework's private 
  headers back to /System/Library/Frameworks/System.framework/PrivateHeaders
  from /MacOSX/System/Frameworks/System.framework/PrivateHeaders for the Space
  release.  This won't change till post-DP4.

Changes for the 5.6 release (the cctools-322 release):
- Added ifdef'ed for __SPACE__ to the standard_framework_dirs in pass1.c in
  preparation for the directory changes. /System/Library changing to
  /MacOSX/System.

Changes for the 5.6 release (the cctools-320 release):
- Fixed a bug in open_dylib() in pass1.c where if more than one -dylib_file
  arguments were used and more than one dylib was linked and a dylib was then
  found in the -dylib_file the next call to open_dylib() would crash because
  the ':' was not restored after the first one was found.
- Added the -umbrella framework_name option to guarding against direct linking
  of non-umbrella frameworks.  Radar bug 2443212.

Changes for the 5.6 release (the cctools-319 release):
- Added the -seg_addr_table option and the LD_SEG_ADDR_TABLE environment
  variables as alternate ways to set the addresses of dynamic shared libraries.
- For MH_SPLIT_SEGS format the r_address field of relocation entries is to be
  relitive to the first read-write segment.  This is to deal with the fact that
  the r_address field in scattered relocation entries is 24 bits and this format
  is used for prebound lazy pointers.  So the changed for this was changing
  what the addr_adjust gets set to in reloc_output_for_dyld() in sections.c .
  This is possible as it is not legal to have relocation entries in read-only
  segements in this format.  So to enforce this main() in ld.c checks to make
  sure -read_only_relocs is set to error when -segs_read_only_addr is used.
- Removed a few unneeded tests for r_scattered after tests for r_extern in 
  reloc_output_for_dyld() in sections.c as scattered relocation entries are
  alwasys local.

Changes for the 5.6 release (the cctools-318 release):
- Fixed a bug in the Makefile that installed the archive libraries without the
  -p option.  This caused their table of contents to be out of date.  And is
  needed as the kern loader is linking with librld.a  .  Also changed the
  Makefile to install librld's into /usr/local/lib .  (Radar bug #2436955).

Changes for the 5.6 release (the cctools-316 release):
- Changed a check in indirect_sections.c in indirect_section_merge() where it
  was checking the relocation entries of lazy symbol pointer sections to make
  sure r_symbolnum was not R_ABS.  The change was to first check that r_extern
  is 0 and it is a local relocation entry before checking r_symbolnum == R_ABS
  as external relocation entries are legal with PowerPC code.  Was a problem
  when the r_symbolnum was 0 as that is the save value as R_ABS for local
  relocation entries.  (Radar bug #2431435).
- Added the -segs_read_only_addr and -segs_read_write_addr options for
  MH_SPLIT_SEGS.  Radar bug #2415906.

Changes for the 5.5 release (the cctools-312 release):
- Changed fine_reloc_output_address() in object.c to return the address of the
  merged_symbol for a S_SYMBOL_STUBS section when the merged symbol is defined
  in the cur_obj making the reference.  To do this a merged_symbol field was
  added to the fine_reloc structure and filled in in indirect_section_merge()
  in indirect_sections.c.  This is all needed to clean up after the compiler
  that generates calls through lazy stubs for symbols forward defined in
  the compliation unit.  This is needed so that the dynamic linker can fully
  bind library init routines without such references being called back into
  dyld and then causing the init calls to be interleaved.  Radar bug #2417690.

Changes for the 5.5 release (the cctools-311 release):
- Fixed a bug in merge_symbols() dealing with N_EXCL's seen as created by a
  previous ld -r pass.  This caused gdb to print <incomplete type>.  Radar bug
  2415697.

Changes for the 5.5 release (the cctools-310 release):
- Fixed a bug in search_dynamic_libs() in pass1.c where it was generating the
  warning message for use of -bind_at_load incorrectly.  Radar bug 2378121.
- Changed the order of the undefined symbols to not be sorted if -bind_at_load
  is used to correct for a case when -bind_at_load was used and the dynamic
  linker resolved the undefined symbols in a different order as to cause
  multiply defined symbols.  Radar bug 2378121.
- Fixed a bug in ld.c where it had a missing else so the -Sn ended up getting
  an error as an unknown flag.  Radar bug #2415456.

Changes for the 5.5 release (the cctools-308 release):
- Fixed a bug in lookup_and_enter_include() in symbols.c at the end where it
  was not correctly inserting the new hash bucket in the chain.  Also made 
  -Si the default stripping.  Radar bug #2410704.
- Also fixed a warning in coalesced_symbols.c when compiling for sparc on 
  Openstep 4.2.

Changes for the 5.5 release (the cctools-307 release):
- Added the -Si option for stripping duplicate include stab groups (N_BINCL and
  N_EINCL pairs).   Also added the -Sn option to get the STRIP_NONE option when
  the -Si option becomes the default.  Added the code at the end of
  merge_symbols() in symbols.c to determine which groups get excluded.  Also
  code was added in output_local_symbols() in symbols.c after the loop for
  looping over the symbols to update N_BINCL's and create N_EXCL's.  Radar bug
  #2410704.
- Support for coalesced symbols has been added. Radar bug #2411273.
- Add a warning suggesting the use of -bind_at_load in search_dynamic_libs() in
  pass1.c when lazy binding might produce different results when a definition of
  a symbol is used from a dynamic library and there is an earilier dynamic
  library that defines the same symbol. Radar bug #2378121.
- Added printing a line like "[Logging for Build & Integration] Used dynamic "
  "library: dylib_name", where dylib_name is a dynamic library being used in
  the link.  This is done when the environment variable RC_TRACE_DYLIBS is set
  and done in search_dynamic_libs() in pass1.c.  Radar bug #2389955.

Changes for the 5.4 release (the cctools-305 release):
- Fixed a bug when -U flags were used and LD_PREBIND was set the code in
  process_undefineds() in symbols.c was setting errors and causing ld to exit
  non-zero.

Changes for the 5.4 release (the cctools-302 release):
- Fixed a bug in assign_output_symbol_indexes() in symbols.c for assigning the
  output indexes of private extern symbols.  This cause calls to private_extern
  symbols through stubs to reference the wrong stub and thus call the wrong
  routine.  This showed up for calls to routines in libcc_dynamic.a when the
  call was in a dynamic library (Radar bug #2374465).  This resulted in throw()
  and dynamic_cast() to crash when in a shared library.  The Finder was the one
  having these problems (Radar bugs 2369470 and 2364994).

Changes for the 5.4 release (the cctools-301 release):
- Changed sections.c so that qsort_load_order_values() is not #ifdef'ed RLD
  because it is used by coalesced_section_merge().

Changes for the 5.4 release (the cctools-300 release):
- Added the -init <symbol_name> option for a dynamic shared library
  initialization routine.  This creates a new LC_ROUTINES load command to store
  this information.
- The initial work for coalesced symbols has been added.  This reads, deals
  with duplicate coalesced symbols and writes out the sections.  It does not
  yet deal with relocation in a coalesced section or relocation to a coalesced
  section.

Changes for the 5.4 release (the cctools-296 release):
- For RC_OS=macos no longer build librld_static.a, the librld_pg.a version is
  now copied as librld_profile.a and a link to librld_debug.a is made from
  librld.a.

Changes for the 5.3 release (the cctools-294 release):
- Fixed two bugs in scatter_copy() in sections.c that was trying to update the
  values for INDIRECT_SYMBOL_LOCAL entries.  There was a missing SWAP_LONG after
  the value was read.  Also after the call to error_with_cur_obj() it did not
  return and the program then crashed.

Changes for the 5.3 release (the cctools-292 release):
- Changed setting the default segment alignment to call get_segalign_from_flag()
  in layout.c in layout() to allow setting the default segment alignment
  to 4K for PowerPC and 8K for everything else.  Radar bug #2277625.
- Added some braces to get rid of the warning message from the egcs compiler
  "warning: suggest explicit braces to avoid ambiguous `else'".  This was done
  to pass1.c, sections.c and 8byte_literals.c .
- Changed the return type of main() in ld.c from void to int to remove a
  warning from the egcs compiler.  Also added a dummy return(0) to make the
  compiler happy.
- Added -I$(NEXT_ROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
  to the Makefile as the egcs compiler's cpp no longer searches this by default.
  This is needed to pick up <streams/streams.h> for use with the rld interface.

Changes for the 5.3 release (the cctools-291 release):
- Made a fix to the ld -r change in cctools-288.  The indirect entries should
  have only been changed for non-lazy sections.  This change is in
  output_indirect_symbols() in indirect_sections.c .  This problem would show
  up when executing a binary with the error from dyld:
    dyld: /System/Applications/MailViewer.app/MailViewer Undefined symbols:
    dyld_lazy_symbol_binding_entry_point
  The problem in this case was the Message framework built with the ld(1) that
  had the bug.  This also has been seen in Carbon apps, with the problem the
  libbase.

Changes for the 5.3 release (the cctools-288 release):
- Changed ld(1) when doing an ld -r with an indirect entry for a private_extern
  to change the indirect symbol to INDIRECT_SYMBOL_LOCAL or INDIRECT_SYMBOL_ABS.
  This problem showed up when building the Message framework and would get the
  error from ld: "ld: indirect symbol:_y can not be a private extern".
  And also showed up in building Carbon when using strip which would produce the
  error message from ld: "ld: x.o indirect symbol table entry 0 past the end of
  the symbol table".
- Fixed ld(1) so it would handle INDIRECT_SYMBOL_ABS and relocate the values
  of symbol pointers with INDIRECT_SYMBOL_LOCAL indirect table entries.
  Changes to sections.c and indirect_sections.c .  This problem could be run
  into in one of three ways when a global symbol is changed to a non-global,
  via private_extern and ld -r, via nmedit and via strip.
- Changed the message printed when the environment variable RC_TRACE_ARCHIVES
  is set from: "RC_TRACE_ARCHIVES archive_name" to: "[Logging for Build &
  Integration] Used static archive: archive_name".  Radar bug #2310273.

Changes for the 5.3 release (the cctools-286 release):
- Change the use of the i386 cpp macro to __i386__ and ppc to __ppc__
- Added the support for the module termination section.  This effected the files
  sections.c, pass1.c, mod_sections.c (renamed from modinit_sections.c),
  mod_sections.h (renamed from modinit_sections.h), pass2.c, and objects.h.
  The code to handle setting the module table entries in output_dylib_tables()
  in symbols.c is #ifdef'ed DYLIB_TERM and not compiled in yet.

Changes for the 5.3 release (the cctools-285 release):
- Removed a warning in ld.c that stated -keep_private_externs must be used with
  -dynamic.
- Fixed a bug in check_cur_obj() in pass1.c that was printing an error:
	"indirect symbol table entry 353 past the end of the symbol table"
  if an indirect symbol table entry had the value INDIRECT_SYMBOL_LOCAL or
  INDIRECT_SYMBOL_ABS which can get created by strip(1).  Found when the
  CoreGraphics framework was stripped removing two globals and then the
  resulting framework was linked against.
- Added printing a line like "RC_TRACE_ARCHIVES archive_name", where
  archive_name is a archive being used in the output of the link.
  This is done when the environment variable RC_TRACE_ARCHIVES is set.
  Radar bug #2303376.
- Changed the Makefile to build librld.a, librld_pg.a and librld_static.a in
  $(DSTROOT)/Local/Developer/System for MacOS X, that is when $(RC_OS) is macos.
  This to allow System framework to be built without using SUBLIBROOTS.
  Radar bug #2268413.

Changes for the 5.3 release, MacOS X bring up (the cctools-282 release):
- Changed task_self() to mach_task_self() for MacOS X.  Also included
  "stuff/openstep_mach.h" for macros to allow it to still build on Openstep.
  Also changed ifdef's __SLICK__ to __OPENSTEP__.
- Ifdef'ed __MACH30__ make.defs for mach_port_t vs mach_port.  Also ifdef'ed out
  netname_look_up() call and #include <servers/netname.h> for __MACH30__ in
  ld.c (these are not yet in the SDK).
- Changed the Makefile to allow for RC_OS=macos for MacOS X builds.
- Changed ld.c to #ifndef'ed __MACH30__ out #include <servers/netname.h>
- Changed make.defs to use mach_port_t instead of port_t .
- Changed the Makefile to use MIG = $(NEXT_ROOT)/usr/bin/mig and $(MIG).
- Chanded the Makefile to have mwcc use the -dependency-file option now that
  it does not cause build problems. 
- Changed the line rld_unload_all(FALSE, 1); to rld_unload_all(NULL, 1); in 
  sa_rld_internal() so it would compile with the MetroWerks compiler.

Changes for the 5.2 release (the cctools-275 release):
- Fixed a bug in layout_dylib_tables() in symbols.c that was still using the
  ar_name from the archive header when creating a dylib module name.  Now it
  uses the ar_name and ar_name_size fields from cur_obj. Radar bug #2239283.
 
Changes for the 5.2 release (the cctools-274 release):
- Changed the way segment addresses for segments without specified addresses are
  set.  In layout_segments() in layout.c the first segment is set to zero.
  Except in the MH_EXECUTE case with a pagezero segment in which it follows the
  pagezero segment.  Then for all other unassigned segments the addresses of
  is set to the next available address after the first segment that the vmsize
  if the segment will fit.  This is done in the new routine next_vmaddr().
  Radar bug #2237029.
- Added a test in reloc_output_for_dyld() in sections.c to detect the case when
  the r_address of a prebound lazy pointer relocation entry overflows because
  the first segment is too far away from the item to be relocated.  Radar bug
  #2237029.

Changes for the 5.2 release (the cctools-272 release):
- Added sa_rld_with_symtab() like sa_rld() but also passes the symbol table and
  string table in.  Radar bug #2231758.

Changes for the 5.2 release (the cctools-267 release):
- Made the source code compile with MetroWerks compiler. Radar bug #2227678.
- Changed the default for -read_only_reloc to error from warning.  Radar bug
  #2227470.
- Fixed a bug in layout_ordered_section() in sections.c on line 1143 and removed
  the code that was dealing specially with zero sized blocks. Radar bug
  #2226458.
- Added all the suport needed for the 4.4BSD extended format #1.  Radar bug
  #1670513.

Changes for the 5.1 release (the cctools-265 release):
- Changed the headerpad to the sizeof two section headers so objcunique will
  work.  Radar bug #2224571.

Changes for the 5.1 release (the cctools-260 release):
- Added -c to all the install commands in the Makefile.

Changes for the 5.1 release (the cctools-254 release):
- Added the rld function rld_write_symfile() to be used by the kern loader.

Changes for the 5.1 release (the cctools-253 release):
- Changed the Makefile so /bin is not created for Rhapsody builds.
- Changed the default Framework search path to match the new directory
  layout for Preimer.

Changes for the 5.1 release (the cctools-251 release):
- Corrected the cctools-249 fix to add_dynamic_lib() in pass1.c . Both the
  fields dylib_file and file_name needed to be set and only dylib_file was
  being set.

Changes for the 5.1 release (the cctools-249 release):
- Fixed a bug in layout_segments() in layout.c where MH_PREBOUND was getting
  set into the output mach header before check_for_overlapping_segments() was
  called which could turn off prebinding.
- Fixed a bug in add_dynamic_lib() in pass1.c when $NEXT_ROOT was set and
  prebinding was enabled.  The bug caused the library name with $NEXT_ROOT
  appended to be recorded in the LC_PREBOUND_DYLIB commands.  The fix was not
  to change dylib_name in add_dynamic_lib() but to set dylib_file with the
  prepended $NEXT_ROOT if set.
- Fixed a bug in output_merged_symbols() in symbols.c when indirect symbols are
  readied for output when prebinding is enabled.  Indirect symbols were
  incorrectly being turned in to prebound undefined symbols.  This would cause
  redo_prebinding to later fail because of undefined symbols (provided strip
  was run on the output and regrouped the symbol with the undefined symbols).
  This was causing the WindowServer to fail redo_prebinding with undefined
  symbols.

Changes for the 5.1 release (the cctools-247 release):
- Added MKDIRS if code to the Makefile to build native on Rhapsody.
- Changed the Makefile to use gnutar instead of tar because it works on Rhapsody
  where tar does not.
- Changed the Makefile so profiled objects get built for RC_OS teflon.
- Changed the Makefile to install the ld only in /usr/bin for RC_OS teflon
  and in /bin for RC_OS nextstep. Removed the creation of symbolic links
  (Radar 1672088).
- Changed the code ifdef __TEFLON__ to ifndef __SLICK__ (where __TEFLON__ will
  nolonger be defined for Rhapsody builds) so the default builds will be native
  Rhapsody builds.  The changes were to ld.c, pass1.c, rld.c and ld.h .

Changes for the 5.0 release (the cctools-246 release):
- Changed in ppc_reloc.c other_half from unsigned short to unsigned long so
  PPC_RELOC_JBSR can store 32 bit values there and target address are no longer
  truncated to 16 bits.

Changes for the 5.0 release (the cctools-245 release):
- Fixed the symbolic link from /usr/bin/ld to ../../bin/ld (Radar 1672088).

Changes for the 5.0 release (the cctools-243 release):
- Added a symbolic link from /usr/bin/ld to $(DSTROOT)/bin/ld (Radar 1672088).

Changes for the 5.0 release (the cctools-240 release):
- Fixed a bug in indirect_section_merge() in indirect_sections.c when prebinding
  PowerPC -dynamic code gen.  PowerPC relocation entries for lazy symbol
  pointers have external relocation entries.  This was not taken into account
  when counting the relocation entries in the case of prebinding.

Changes for the 5.0 release (the cctools-236 release):
- Added the sarld_build target to the lib_ofiles target.

Changes for the 5.0 release (the cctools-235 release):
- Added handling of PPC_RELOC_JBSR to ppc_reloc.c .
- Fixed the PPC_RELOC_BR24 to correctly check for overflow.  It now checks
  the top 7 (not 6) bits are the same. 
- Removed two warnings in pass1.c checking ran_off for less than zero (it is
  unsigned).

Changes for the 5.0 release (the cctools-234 release):
- Removed the last check in legal_reference() in indirect_sections.c which made
  sure a lazy symbol pointer pointed into a stub.  This is because for ppc lazy
  symbol pointers point to dyld_stub_binding_helper directly and there is no
  second half of the stub used (Radar #1661985).

Changes for the 5.0 release (the cctools-233 release):
- Removed the hack in layout_segments to ignore -seg1addr's greater than
  0x4000000 for dynamic libraries for PowerPC.

Changes for the 5.0 release (the cctools-225 release):
- Fixes a bug left from the NRW linker where executables did not have a
  __PAGEZERO segment.
- Added a hack in layout_segments to ignore -seg1addr's greater than 0x4000000
  for dynamic libraries for PowerPC.

Changes for the 5.0 release (the cctools-224 release):
- Fixed a bug in define_common_symbols() in symbols.c which when defining common
  symbols when a common section exists in the input .o files which has an
  alignment less than the alignment needed for the common symbols being defined
  by the link editor.
- Changed including <ranlib.h> to <mach-o/ranlib.h> which uses unsigned long
  instead of off_t (64 bits on Teflon).
- Fixed a warning in pass1.c.

Changes for the 5.0 release (the cctools-223 release):
- Put back the changes to rld.c ifdef __TEFLON__.

Changes for the 5.0 release (the cctools-222 release):
- Fixed a bug in ppc_reloc where it was not correctly calculating the immediate
  of a HA16 reloc by checking the 0x8000 bit of the other half and and sign
  extending it and adding it to form the correct immediate.
- Added -stack_size option to set the stack size.  This creates a __UNIXSTACK
  section.  The bulk of the work in in layout_segments() in layout.c with new
  functions added to arch.c in libstuff to support stack direction, default
  size and address.
- Added -stack_addr option to set the stack pointer.  Added a second state to
  the struct thread_info because the hppa's stack pointer is in another flavor
  of thread state.
- Removed a check in indirect_section_merge() in indirect_sections.c which was
  checking to make sure a local relocation entry for a lazy symbol pointer was
  pointing into a symbol stub section.  With the change to allow lazy symbol
  pointers to have external relocations (for PowerPC pointers using
  dyld_stub_binding_helper) after an object has been "ld -r" (in this case
  crt1.o) the lazy symbol pointer is a local relocation entry.

Changes for the 5.0 release (the cctools-221.6 and cctools-222 releases):
- Picked up changes to rld.c for use of _NXArgv and __mh_execute_header to use
  _NSGetArgv() and _NSGetMachExecuteHeader().

Changes for the 5.0 release (the cctools-221.2 and cctools-222 releases):
- Picked up changed layout.c to which changed the variable ppc to powerpc
  because the PowerPC compiler defines the cpp macro ppc to 1.

Changes for the 5.0 release (the cctools-221.1 and cctools-222 releases):
- Picked up changed to the Makefile to not build profile objects for teflon.
  This is because the PowerPC compiler core dumps with -pg.

Changes for the 5.0 release (the cctools-221 release):
- Picked up the changes for the correct Rhapsody thread state changes into
  layout.c.

Changes for the 5.0 release (the cctools-220 release):
- Fixed a bug in add_dynamic_lib() in pass1.c that was not prepending $NEXT_ROOT
  to the paths of dependent dynamic libraries.

Changes for the 5.0 release (the cctools-218 release):
- Added hacks to pad pure instruction sections of i386 outputs with nop's
  (opcode 0x90) to clean up dissassembly.  This is done in output_section()
  secions.c and in the new function nop_pure_instruction_scattered_sections()
  (bug #77806).
- Added .section_align <align_value> to like .section_offset <offset_value>.
  This causes the next item to be placed on the power of 2 alignment of
  align_value (bug #77807).

Changes for the 5.0 release (the cctools-218 release):
- Fixed a warning with "static jmp_buf rld_env's initializer" in rld.c which 
  needed an ifdef for i386.

Changes for the 5.0 release (the cctools-216 release):
- Made changes to allow external relocation entries for lazy symbol pointer
  sections.  First had to remove a test in indirect_section_merge() in
  indirect_sections.c which checked that relocation entries in lazy pointers
  sections must not have external relocation entries.  Just below that I added
  the checks needed for external relocation entries.  Second in each of the
  relocation routines I added just after the update_reloc: label the changing
  of an extern relocation to a prebound lazy pointer if needed.
- Changed ld.c to just include libc.h for Teflon.

Changes for the 5.0 release (the cctools-215 release):
- Added the $(RC_OS) trick to the all target as well as the lib_ofiles target so
  this will build on the Teflon SDK.
- Added #include <sys/fcntl.h> in ld.c on the #ifdef __TEFLON__ side so O_RDONLY
  does not come up undefined with the Teflon SDK.
- Added support for the PowerPC section difference HI16, LO16 and HA16
  relocation types.

Changes for the 4.2 & 5.0 releases (the cctools-213 & cctools-209.3 releases):
- Fixed a bug in check_dylibs_for_definition() where it was printing the module
  name of the dynamic library wrong because it was using strings where it should
  have been using p->strings.
- Fixed a typo in an error message in open_dylib() in pass1.c where "effected"
  should have been "affected" (bug #77070).
- Fixed a bug where prebinding was not getting done when a private extern was
  overridding a symbol in a dependent library.  The fix was not to check
  private externs in prebinding_check_for_dylib_override_symbols() in pass1.c

Changes for the 5.0 release (the cctools-212 release):
- Fixed a bug where $NEXT_ROOT did not prefix standard framework paths.  Also
  fixed -Z to not use standard framework paths.

Changes for the 5.0 release (the cctools-211 release):
- Integrated changes to allow teflon builds (RC_OS=teflon or RC_OS=nextstep) to
  not build shlib_ofiles in the Makefile.  Also changes in the sources to not
  include <libc.h> for __TEFLON__ builds.

Changes for the 5.0 release (the cctools-210 release):
- Changed the default starting address for ppc to 0 (layout.c).
- Changed m98k to ppc.

Changes for the 4.2 release (the cctools-209.1 release):
- Added -image_base as the same as -seg1addr.

Changes for the 5.0 release (the cctools-208 release):
- Added code to prepend the value of the environment variable NEXT_ROOT to the
  standard paths if it is set.  This is to support the TEFLON cross build
  environment.  All changes are in ld.c

Changes for the 4.2 and 4.1 patch release (the cctools-207 release):
- Ifdef'ed out the warning about an archive library following a dynamic shared
  library.  This is so that libcc_dynamic.a will not produce this warning when
  it is linked into all images.

Changes for the 4.2 release (the cctools-205 release):
- Added telling PB "Architecture Mismatch" when a error for -arch_errors_fatal
  gets printed.  (bug #74032)

Changes for the 4.2 release (the cctools-204 release):
- Fixed a typo in an error message in pass1.c.  "prebinding disabled because of
  symbols overridded in dependent dynamic shared libraries" where "overridded"
  was changed to "overridden" (bug #71334).

Changes for the 4.0 release (the cctools-201 release):
- Changed internal_rld_load() to call the constructors (and profiling stuff)
  only if the base file is the executable.  This was causing the debugger to
  crash when debugging a bundle with C++ constructors (bug #66200).

Changes for the 4.0 release (the cctools-200 release):
- Changed fine_reloc_output_address() to not cause an internal error when you
  have a fine reloc for a non-lazy symbol pointer section.  This can result with
  private externs and doing an ld -r first and then doing an ld on the result
  (bug #65823).

Changes for the 4.0 release (the cctools-199 release):
- Fix to bug fix 65292 in cctools-197 which was still wrong and causing all
  programs with these warnings to be fatal because error() was called and not
  warning().  More logic was added to fix this (bug #65633).

Changes for the 4.0 release (the cctools-198 release):
- Fix to ld that bug fix 65292 introduced in cctools-197 which was causing
  -fvmlibs to fail to build because of prebinding warnings (bug #65451).

Changes for the 4.0 release (the cctools-197 release):
- Changed ld so that when prebinding is being done and -U's are used for allowed
  undefined symbols these symbols are printed if prebinding is being disabled
  because of undefined symbols (bug #65292).
- Changed ld so that the warning message "ld: warning using file: x for
  reference to dynamic shared library from: y because no -dylib_file specified"
  because it is felt to be distracting (bug #65276).

Changes for the 4.0 release (the cctools-195 release):
- Fixed a bug reset_prebound_undefines() when dealing with indirect symbols that
  are defined when prebinding.  The desc field should not have been changed as
  it changes the type of reference (lazy or non-lazy) as well as the
  REFERENCED_DYNAMICALLY bit (bug #64885).

Changes for the 4.0 release (the cctools-192 release):
- Changed the default header pad from 0 to the sizeof a section struct so that
  /bin/objcunique can always add a section header (bug #63516).

Changes for the 4.0 release (the cctools-176 release):
- Change the default protection to not include execute unless the segment
  contains sections with instructions.  Also don't set execute on the linkedit
  segment (bug #58445).

Changes for the 4.0 release (the cctools-175 release):
- Disabled prebinding if -dynamic not set.  Also don't use LD_PREBIND if -r
  is set to avoid warnings.

Changes for the 4.0 release (the cctools-174 release):
- Added building dynamic_ofiles for the lib_ofiles (RC bootstrap) target in
  the Makefile.

Changes for the 4.0 release (the cctools-173 release):
- Disallowed -prebind with -bundle.
- Added the setting of -prebind via the environment variable LD_PREBIND.
- Added the LC_PREBOUND_DYLIB load command to record which modules were linked
  from a dynamic library that was prebound.
- Fixed a bug when an N_INDR symbol chain had symbols from both dylibs and
  non-dylibs.  The specific problem was when -i_os_fcvt:_fcvt was on the
  command line and there was an object in the dynamic libsys that defined _fcvt
  as an indirect for __fcvt.  Then both the indirect symbol table entry for
  _os_fcvt and the symbol table entry for _os_fcvt were bad because the symbol
  _fcvt from the dylib does not appear in the output file.  To fix this a
  structure of pairs of merged_symbols and indr_symbols was created in
  reduce_indr_symbols() and used in output_merged_symbols() and
  merge_indirect_sections().

Changes for the 4.0 release (the cctools-172 release):
- Fixed a bug in count_relocs() where it should not have reduced the N_INDR
  symbol if it was defined in a dylib (line 2720 in sections.c).
- Changed it so that when prebinding an executable the local relocation entries
  for lazy symbol pointers are saved.  This must be done even if prebinding
  fails after indirect_section_merge() has been call so that the number of
  relocation entries does not change after layout.  This effected layout.c
  by setting the new boolean save_lazy_symbol_pointer_relocs to the value of
  prebinding just before merge_literal_sections() is called.  Then this boolean
  is used in indirect_section_merge() and reloc_output_for_dyld() to count and
  put out the relocation entries.
- Fixed a bug in all the *_reloc.c relocation routines when updating the
  relocation entry.  The problem was when the relocation entry was an external
  and the merged symbol was a prebound undefined (N_PBUD) the relocation entry
  should not have been turned into a local relocation entry.
- Changed the checking that prebinding_check_for_dylib_override_symbols() does
  to only fail if the symbol is overridden and the the symbols is referenced in
  a dylib.  To do this the routine check_dylibs_for_reference() was added and
  called from check_dylibs_for_definition() in pass1.c.

Changes for the 4.0 release (the cctools-171 release):
- Fixed a in indirect_section_merge() in indirect_sections.c at line 277 where
  if the symbol is an N_INDR and not defined in a dylib the indirection needed
  to be reduced so the setting of indirect_defined is done correctly
  (bug #57113).

Changes for the 4.0 release (the cctools-170 release):
- Picked up a bug fix to sparc_reloc.c for SPARC_RELOC_HI22_SECTDIFF where
  immediate did not have value added to it but rather an incorrect expression.
- Added prebinding_check_for_dylib_override_symbols() to check when prebinding
  that no symbols in dependendent dylibs are overridden and if so disable
  prebinding and print a warning.  The call in made in layout.c and the routine
  is in pass1.c (since the searching stuff for dylibs in in there).
- Overlap checking of dylibs and the program being linked was added by first
  changing check_overlap() to take the bool argument prebind_check and if it is
  FALSE to do as it did and if TRUE print the over lap as a warning why
  prebinding is being disabled.  Second check_for_overlapping_segments() adding
  the dylib segments to the list if prebinding and adding a loop to check the
  segments with check_overlap() and prebind_check == TRUE.
- To allow prepare for overlap checking of dylibs and the program being linked:
  add_dylib_segment() was added to dylibs.c.   Then search_dynamic_libs() a had
  loop added to it to collect dylib segments.
- To allow prepare for overlap checking of dylibs and the program being linked
  process_undefineds() was broken up so the the reseting of prebound undefineds
  is now done in reset_prebound_undefines().  So reset_prebound_undefines() is
  called after layout_segments() where overlap checking will be done and may
  disable prebinding if there is overlap.  This turned up three problems.
  The first in assign_output_symbol_indexes() which needed to treat N_INDR
  from a defined in a dylib as an undefined symbol (this same problem was in
  count_relocs() and in one missed place in indirect_section_merge().  The
  second in count_relocs() which needed to treat an N_PBUD as an undefined
  symbol.
- Fix the problem with "link order" object for dyld output file being "loaded"
  twice warning when scattered loading.  This was a result of the common object
  and the module for the dylibs having the same name.  The change was to add
  quotes around the name "\"link order\"" for the common object so they would
  have different names.
- Changed scatter_copy() in sections.c to do the same for lazy symbol pointer
  sections as for non-lazy symbol pointer section if prebinding.  That is use
  the value of the indirect symbol.  This also required an if prebinding ==
  TRUE to be or'ed with indirect_defined test.  This also gets the value's
  of non-lazy symbol pointer set when prebinding.
- Changed the *_reloc.c routines for external relocation entries to use the
  n_value of the symbol for MH_DYLIB's when prebinding.  When updating the
  non-scattered local relocation entries if prebinding and it is a lazy symbol
  pointer section the relocation entry is turned into a _PB_LA_PTR relocation
  type with the non-prebound value of the lazy symbol pointer saved in r_value.
- Turned off prebinding in process_undefineds() in symbols.c when there are
  undefined symbols and print a warning.  Then if prebinding is still in effect
  the undefined symbols are not turned back into undefined symbols but left
  as prebound undefined symbols.
- Turned off prebinding when in search_dynamic_libs() when open_dylib() fails
  to open a dependent dynamic library and print a warning.  Also turned off
  if a dependent dynamic library is not prebound and print a warning.
- Turned off prebinding when -undefined suppress is set in ld.c and print a
  warning.
- Added -prebind and -noprebind options to ld.c and the global prebinding.

Changes for the 4.0 release (the cctools-169.2 release):
- Fixed a bug in the hppa relocation for JBSR's with fine relocation.  The fine
  reloc case was missing the check for r_extern == 1 in the case of MH_DYLIB
  which the non fine reloc case had (line 735).

Changes for the 4.0 release (the cctools-168 release):
- Added creating a symbolic link to dynamic_profile_obj from profile_obj.
- Added an optional suffix to "-framework Foo,suffix" which first searches for
  the framework with the suffix and then without.
- Change the version numbers of dynamic library to the form X[.Y[.Z]] to match
  how next does versioning of it's projects.  This effected libtool(1), ld(1),
  otool(1), dyld, libstuff(version_number.c) and man pages for ld and libtool
  bug #55627).  In here the changes were in ld.c .

Changes for the 4.0 PR1 release (the cctools-166.3 and cctools-167 releases):
- Changed the merge_symbols() routine to propagate the REFERENCED_DYNAMICALLY
  bit from undefined symbols in to the merged symbol table.  This is used to
  solve the problem with the symbols in crt1.o (and __mh_execute_header) in
  a dynamicly linked program where they are used by libsys via _dyld_lookup_
  and_bind() but get stripped by strip(1) because they don't have the
  REFERENCED_DYNAMICALLY bit set.  This also requires crt1.o to have this
  bit set for the symbols it defineds and for __mh_execute_header.  Which is
  done with the .desc assembler directive (bug #54660).

Changes for the 4.0 PR1 release (the cctools-166.1 and cctools-167 releases):
- Fixed a bug in lookup_symbol where the test case for the internal error of
  the lookup failing was off by one (bug #53390).

Changes for the 4.0 release (the cctools-166 release):
- Changed the reference to NXArgv and _mh_execute_header in rld.c to use
  _dyld_lookup_and_bind() in the case of __DYNAMIC__ .
- Changed the use of the cpp macro DYNAMIC (set by the Makefile) to __DYNAMIC__
  (set by the compiler when -dynamic is in effect).
- Removed -fomit-frame-pointer because of compiler bug with -dynamic (bug
  #52986).

Changes for the 4.0 release (the cctools-164 release):
- Fixed a bug in output_flush() in pass2.c that was causing the internal error
  "first block written_offset not 0" in final_output_flush().  The fix to
  output_flush() was to not set written_offset to the rounded offset, but rather
  zero, when the offset is less than the pagesize and nothing got written from
  the block.  This happens only for the first page.
- Added the -arch_errors_fatal flag to make mis-matching architectures errors
  fatal.

Changes for the 4.0 release (the cctools-163 release):
- Changed the default to -dynamic.  This is done in ld.c with:
    enum bool dynamic = TRUE;

Changes for the 4.0 release (the cctools-161 release):
- Added in the Makefile passing -DDYNAMIC for things built with -dynamic
  Then ifdef'ed out some const's in section.[ch] and symbols.c with DYNAMIC so
  that when this is put in a dynamic shared library it does not have relocation
  entries in a read-only section.
- Fixed a bug that caused the error message that an indirect symbol could not be
  a private_extern symbol when -keep_private_externs was on with -r.  The fix
  was in indirect_sections.c where the if condition for the error checked for
  private extern bit this "(...nlist.n_type & N_EXT) != N_EXT" condition was
  also added.
- Added checking for relocation entries in read only sections when the output
  is for the dynamic linker.  This is controled by the flag -read_only_relocs
  which takes arguments {error,warning,suppress} where warning is the default.
  This checking is done in reloc_output_for_dyld() in sections.c and has some
  functions in symbols.c to clear and flag symbols based on a bit in the merged
  symbol structure.

Changes for the 4.0 release (the cctools-157 release):
- Fixed a bug in ld that caused dynamic libraries built with dependent dynamic
  librarys to have bad table of contents.

Changes for the 4.0 release (the cctools-154 release):
- Added marking symbols defined in the output file referenced from a dylib with
  REFERENCED_DYNAMICALLY in the n_desc field.

Changes for the 4.0 release (the cctools-153 release):
- Fix a problem with the cctools-151 change that showed up in
  indirect_section_merge() because it was checking the section's flags for
  correctness and the "link editor" created object did not copy the flags.
  So the quick fix was to add if s->size == 0 then return.

Changes for the 4.0 release (the cctools-152 release):
- Fixed an error check in check_cur_obj() in pass1.c() that was checking the
  irefsym field of a module table entry against size of the symbol table
  instead of the size of the reference table.

Changes for the 4.0 release (the cctools-151 release):
- Fixed a bug in setting the value of non-lazy pointers for link editor defined
  symbols.  The problem was that indirect sections were merged before the 
  link editor defined symbols were set up so the appeared to not be defined and
  their value was never set in the non-lazy pointer.  The fix was in layout.c
  to just reorder the calls setup of these symbols before the merge of literal
  sections.

Changes for the 4.0 release (the cctools-150 release):
- Changed the profiled objects to be compiled with -dynamic.
- Changed everything to use __private_extern__ .
- Changed to allow private externs without the -dynamic flag.
- Added a check in indirect_section_merge() to treat an indirect symbol that
  turns out to be a private extern as an error.
- Added a vm_protect() call for the rld memory to turn on execute protection.
  This is needed as the kernel has changed to not include VM_PROT_EXECUTE on
  vm_allocate()'ed memory.  Without this it fails on the hppa which uses this
  in it's hardware (bug #50860)

Changes for the 4.0 release (the cctools-149 release):
- Fixed a problem with standard_framework_dirs[] that the strings did not
  contain a trailing /.
- Added the -filelist list[,dirname] option to ld (bug #50779).
- Added the -bind_at_load option that marks the output with MH_BINDATLOAD in
  the mach header.  This is not allowed for dynamic libraries.

Changes for the 4.0 release (the cctools-148 release):
- Changed how the librld builds.  It now builds 4 objects.  One for the
  following uses: static, dynamic, profiled and shlib.  Also added the -static
  flag to sarld building.
- Fixed a bug in fine_reloc_output_sectnum() in objects.c returned the wrong
  section number where if an indirect section's relocation entry refered to an
  merged_symbol who's n_type was N_INDR and the indirection was not removed.
  This resulted on getting an internal error in output_section() for the count
  of local relocation entries.  This was found when linking dyld when it was
  compiled with -dynamic.

Changes for the 4.0 release (the cctools-147 release):
- Changed -framework Foo and removed the .dylib at the end of the name to be
  search for.
- Fixed yet another problem with not getting the local relocation entrys right
  when output_for_dyld.  The problem was that code that was added in
  count_reloc() to fake the relocation to get the correct resulting r_symbolnum
  was not working.  In merge_section() only S_SYMBOL_STUBS sections were
  getting ms->output_sectnum set to 1 (a non-NO_SECT value) when all sections
  needed this.  So this is now done for all sections.

Changes for the 4.0 release (the cctools-146 release):
- Fixed a bug in linking dylibs across byte sex.  The symbol table was not
  swapped before it was used in searching in pass1.  This was added and a check
  for MH_DYLIB was added in symbols.c to not swap it again.
- Fixed a problem where creating sparc binaries on a little endian machine
  did not get the 6 reserved bits of the psw correct.  The fix was in libstuff
  swap_sparc_thread_state_regs() (bug #49685).  This was CCC approved for
  3.3risc and a cctools-142.1 clone with just this fix was submitted.

Changes for the 4.0 release (the cctools-144 release):
- Fixed a bug in in -preload introduced in cctools-143 when support for
  undefined checking against dylibs was added.

Changes for the 4.0 release (the cctools-143 release):
- Added support for undefined checking against dylibs.
- Made a change to parse_order_line() in sections.c to parse out an objective-C
  symbol name differently to handle the problem with 3.2 C++ compiler where the
  symbol name (McCaw's problem).  This should not really be in 4.0 as the 3.3
  and later C++ compilers do not have this problem.
- Fixed a bug in rld code in remove_objects() in objects.c where cur_obj was
  being used instead of object_file to test for the undefined_list and free
  it.

Changes for the 4.0 release (the cctools-142 release):
- Fixed the call to pass1() in rld.c to added the extra argument for frameworks.

Changes for the 4.0 release (the cctools-141 release):
- Made ld search all frameworks specified with -framework (e.g. -framework Foo)
  in the framework search path as Foo.framework/Foo.dylib.  Default path is
  /LocalLibrary/Frameworks, /NextLibrary/Frameworks . Additional search
  directories can be specified with -Fdir .
- Added the -no_arch_warnings for libtool to use which prevents warnings
  for file which don't have the correct architecture for the -arch flag.
- Fixed an edge case in all relocation routines for scattered relocation entries
  where the last address past then end of the last section is referenced.  In
  this case it was getting an out of range error when infact an address could be
  referenced as the last address of all of the sections if a lable exist with no
  data following it.
- Fixed the spelling of "compatibility" in the compatibility_version for dylibs.
- Fixed a bug in hppa_reloc() for MH_DYLIB files where a check on line 914 was
  checking merged_symbol's type  without checking r_extern == 1 to see if
  merged_symbol was valid (bug #48008).

Changes for the 4.0 release (the cctools-140 release):
- Picked up sparc changes to sparc_reloc.c which fixes scattered relocation
  problems.

Changes for the 4.0 release (the cctools-138 release):
- Added the MH_BUNDLE object file type to be used with NSLinkModule().
- Fixed a bug in reporting common symbols for -dylib where the wrong object file
  was referenced.  The fix was in merge_symbol() when an merged symbol changes
  from an undefined to a common the definition_object needed to be assigned to
  the current object.
- Fixed a bunch of bugs in getting the right relocation entries out for ld -r
  with indirect sections.  The approach now taken is to relocate all things
  who's contents are not used in the output to past the end of the section and
  then the r_address after relocation can be used to determine if the relocation
  entry is to be saved.

Changes for the 4.0 release (the cctools-137 release):
- Picked up sparc_reloc.c.
- Added the -Y n flag to print n references to undefined symbols (bug #46166).
- Fixed a problem with parsing -dynamic which ate the next argument (crt1.o in
  the case used by the driver).
- Fixed a bug when using -output_for_dyld and libsys local relocation entrys
  were not correct because a local relocation entry to a symbol stub that is
  eliminated because the symbol is defined as an N_ABS symbol causes the
  relocation entry to be need to be saved even though it started out as a local
  r_pcrel but now refers to an N_ABS symbol.  The fix was in count_reloc() in
  sections.c to fake doing the relocation on such an item to get the correct
  resulting r_symbolnum (which in this case is N_ABS) which will then be used
  to determine if the relocation entry is pic.
- Fixed a bug in sparc_reloc() for the SPARC_RELOC_WDISP30 relocation type for
  scattered loading which was a copy and paste error that did not set "value"
  but rather "offset" when picking up the item to be relocated for a local
  relocation entry with fine relocation.

Changes for the 4.0 release (the cctools-134 release):
- Fixed a bug in ld -M in printing the map that core dumps.  There was a use of
  cur_obj in a couple of places that should have been object_file in layout.c
  when testing the dylib and dylinker fields (bug #44619).

Changes for the 4.0 release (the cctools-133 release):
- Picked up sparc changes to layout.c for the name changes of the sparc thread.
- Fixed a bug in fine_reloc_output_address() in object.c that was testing for
  non-lazy not lazy section pointers and cause a fatal internal error when a
  defined symbol had a symbol stub entry and a lazy symbol.
- Changed it so that undefined symbols are not allowed if the output is a
  dynamic linker.
- Fixed a bug in rld that didn't get the alignment right because the header_size
  was not rounded to the maximium section alignment which was used as the
  starting address (bug #44241).
- Added three Project builder messages, "Link errors", "Undefined symbols" and
  "Multiply defined symbols" to ld (bug #40745).
- Fixed a bug for hppa in the relocation for JBSR's in MH_DYLIBS for external
  relocation entries.  This should not have relocated a JBSR to the defined
  external for MH_DYLIBS if the symbol was not a private_extern.

Changes for the 4.0 release (the cctools-132 release):
- Picked up sparc changes to sections.c for sparc relocation.
- Picked up sparc changes to layout.c for sparc thread.
- Picked up new sparc files sparc_reloc.h and sparc_reloc.c and change the
  Makefile.
- Added -dynamic to eventually replace -NEXTSTEP-deployment-target 3.3 and
  -static to eventually replace -NEXTSTEP-deployment-target 3.2.  Changed all
  the incompatiblity error messages to use -dynamic.
- Removed the private externs from the toc for dylibs and desided to leave them
  in the reference table.  They could be pulled from the reference table but
  then it would be harder to size and construct it as it would take another
  pass to determine if an undefined symbol mached up with a private extern.
  This still could be done later if space is an issue.  It also could be an
  issue if a library module with private externs wants to be unloaded or
  replaced which may not be possible.
- Changed the way private externs are handled.  Now the N_PEXT is never turned
  off and symbols with this bit are always saved with the -x flag.  This
  effected a number of places.  Also changed was the handling of non-lazy
  pointers to allow private externs as the indirect symbol.  This allowed
  a non-external symbol (that was previouly a private extern) to be an indirect
  symbol.  This caused all sorts of changes to indirect symbols and the handling
  of fine relocs.
- Changed hppa_reloc()'s handling of JBSR relocs for output_for_dyld for JBSR
  undefined symbols.  In this case the bl instruction is not changed so that
  it will continue to point at the long branch stub (which in the case of
  output_for_dyld should be targeted at symbol stub).
- Fixed a bug in hppa_reloc() for ld -r of JBSR reloc types for external
  relocation entries turning into local when the symbol was defined as a
  private extern with the N_SECT type.  The problem was that n_type & N_TYPE
  was not used but rather n_type == (N_EXT | N_SECT) when testing to determine
  if the other_half needed to be adjusted.  This same problem shows up in many
  other places which have been corrected.
- For the hppa corrected the output when the output is for dyld so JBSR relocs
  are never in the output.
  This effected count_relocs() and reloc_output_for_dyld() in sections.c .

Changes for the 3.3 release (the cctools-130 release):
- Fixed a problem with the CATS bug fix.  In remove_set() in sets.c it was doing
  a free() of the data structures not a memset() back to zero.

Changes for the 3.3 release (the cctools-128 release):
- Removed the make app stuff (bug #40745) effected ld.c.
- Fixed an rld bug that CATS software found when loading more than 10 objects
  with commons.  The bug was that the sets data structure was being realloced
  after 10 rld_load()'s and the merged_symbol structure for previous loaded
  common symbols had a definition_object pointer pointing to the old memory.
  The fix was to change the sets data structure and change the three structs
  in there to pointers to pointers to structs and allocate each of those
  structs. Effects sets.c sets.h symbols.c (bug #42703).
- Fixed a bug in rld where in set_merged_string_block_indexes() in pass2() was
  not being called because it got if'ndefed RLD out (bug #42283) introduced in
  cctools-122.

Changes for the 3.3 release (the cctools-127 release):
- Changed the order of the symbol information to optimize dyld's memory use.
  strip(1) has been changed to handle this new order.
- Fixed a bug where ld -r for indirect sections would not get the relocation
  entries put out.  The bug was in scatter_copy_relocs() that was calling
  fine_reloc_offset_in_output() which should have been calling
  fine_reloc_offset_in_output_for_output_offset().  Then the problem was that
  fine_reloc_offset_in_output_for_output_offset() was not mapping to the correct
  fine_reloc for use_contents == 0 because the output_offset was relocated using
  a fine_reloc that it's output_offset did matter and was zero.  This caused
  fine_reloc_offset_in_output_for_output_offset() not to map the relocated
  output_offset back to the correct fine_reloc.  The fix to this problem was to
  set output_offset in all the fine_relocs with use_contents == 0 before
  relocation to the output_section's size so later the correct fine_reloc would
  be mapped to and use_contents will have 0 for these.  This is done in
  output_section() in sections.c if the output is relocatable and it is for
  an indirect section.
- Changed the thread command of a MH_DYLINKER from a LC_UNIXTHREAD to an
  LC_THREAD (bug #42338).
- Fixed a bug where for MH_FVMLIB and MH_DYLIB formats commons were not traced
  when found in define_common_symbols().  I removed the if test that caused
  this routine to return for these formats I mistakenly added and not to drop
  in to the loop to define them and also to trace the symbols.

Changes for the 3.3 release (the cctools-125 release):
- Changed the temporary warning "current limitation: dynmaic linker used so
  undefined symbols not reported" in layout_merged_symbols() in symbols.c to
  not dependend on using a dylib but just rather having a dynamic linker
  command and being output for dyld.

Changes for the 3.3 release (the cctools-124 release):
- Temporarily added a the warning "current limitation: dynmaic linker used so
  undefined symbols not reported" in layout_merged_symbols() in symbols.c.
- Added allowing fat object files in archives when -all_load is specified.  This
  was done in pass1_archive() in pass1.c.  This was added to allow libtool to
  use it when creating libs with -dynamic.
- Added a check for private externs if the deployment target is 3.2 to flag it
  as incompatable.
- Changed define_common_symbols() in symbols.c to defined commons for when
  output_for_dyld is TRUE.

Changes for the 3.3 release (the cctools-122 release):
- Fixed a bug where the module names of a dylib did not have the right indexes.
  The assignment of merged string blocks index's was moved from the function
  output_merged_symbols() into a new function set_merged_string_block_indexes()
  and called in pass2.c before output_dylib_tables().
- Fixed a bug in reloc_output_for_dyld() for indirect sections where the call to
  fine_reloc_offset_in_output() did not work because the r_address had been
  relocated to the output address.  So a new function that takes an
  output_offset, fine_reloc_offset_in_output_for_output_offset(), was written
  and is now used.  This caused local relocation entries to be missing and the
  link editor to get an internal error.
- Fixed a bug in merged_symbol_string_index() for rld which was crashing when
  things got unloaded because the static var saved a pointer to a deallocated
  string block (bug #41376).
- Added the -NEXTSTEP-deployment-target flag.  Also added -k that implys 3.3.
- Added a bunch of checks based on the deployment target in the area of what
  flags could be used (-dylib, etc) and checks for new sections in the input
  files.  Also added for deployment on 3.2 the removal of section attributes
  so PURE_INSTRUCTION objects just work.
- Added searching for libx.dylib for -lx if deployment is not 3.2.

Changes for the 3.3 release (the cctools-120 release):
- Fixed a bug in fine_reloc_output_address() in objects.c when a symbol stub's
  indirect symbol table is for an N_INDR symbol the chain through the n_value
  being a (struct merged_symbol *) was not followed.
- Fixed a bug when building MH_DYLINKER format where setup_link_editor_symbols()
  should not have incremented dysymtab_command.nextrefsyms for MH_DYLINKER but
  only for MH_DYLIB.  This causes a flush overlap error.  This fix is needed to
  build the dynamic linker.
- Fixed a bug where the indirect symbol table was not swapped on cross links for
  differing bytesex.  The swaping was added in check_cur_obj() in pass1.c as
  well as checking each entry that it is in range.
- Fixed a in all the *_reloc() routines with respect to relocating a sectdiff
  entry where one of the values has fine relocation.  The bug was that the value
  that didn't have the fine relocation did not have it's *_map->offset (the
  offset into the output section where this object file's section starts) added
  in to calculate it's value.  This effected all *_reloc.c routines (except
  i860_reloc.c which has no fine relocs).
- Fixed a bug in generic_reloc() when pcrel_at_end_of_disp is TRUE (the i386
  case) for a pcrel external relocation entries in calculating the offset in the
  item to relocated.  Which is used to decide to create a scattered or local
  reloc.  This caused a flush overlap error when the relocation entry was tried
  to be created that was not to be there for output_for_dyld.

Changes for the 3.3 release (the cctools-119 release):
- Fixed the rld bug where C++ constructors/destructors were not called.  The
  fix is at the end of the internal_rld_load() where the it loops through the
  section and does the call or registers it with atexit() (bug #40616).
- Added the S_ATTR_EXT_RELOC and S_ATTR_LOC_RELOC attributes to sections so the
  dynamic linker can determine if it needs to vm_protect() it's segments.  This
  Was added in count_relocs() and layout_relocs_for_dyld() in sections.c.

Changes for the 3.3 release (the cctools-118 release):
- Fixed a bug that when an "ld -arch xx -ifoo:bar" was done the target byte
  sex was picked as the host bytesex not based on the -arch flag.  The fix was
  in ld.c to set target_byte_sex when a -arch flag was seen and later to not set
  it to the host_byte_sex if a -arch flag was specified.

Changes for the 3.3 release (the cctools-117 release):
- Fixes a bug in assign_output_symbol_indexes() in symbols.c for RLD which got
  the internal error "internal error: assign_output_symbol_indexes()
  inconsistent local symbol counts" because the loop that sets the indexes for
  the local symbols did not have an ifdef RLD for skiping the objects not in the
  current set.

Changes for the 3.3 release (the cctools-116 release):
- Fixed a bug in layout() that did not allow an entry point if the first segment
  did not have any non-zerofill segments and a -e option was specified.

Changes for the 3.3 release (the cctools-115 release):
- Fixed what was included for the SA_RLD code so the the time() and qsort()
  functions are not needed.  Dis-allow all indirect sections for SA_RLD code
  which allows merged_symbol_output_index() not to be needed and the symbol
  table not to be ordered so qsort() in not needed.  The need for time() was
  because of time stamp for creating dylibs which was ifdef'ed SA_RLD out.
- Fixed a bug in legal_reference() in indirect_sections.c to allow references
  to a symbol stub section not at the start of the stub by the symbol stub
  itself which is what happens in pic symbol stubs.
- Made a change to what is allowed for indirect symbols.  Previously only
  undefined external symbols were allowed.  Now
  1) Any external symbol is allowed as an indirect symbol (even if defined)
  2) A local symbol is allowed as an indirect symbol for a symbol stub and lazy
     pointer section (which the stub and pointer will then always get removed).

Changes for the 3.3 release (the cctools-114 release):
- Fixed a bug introduce in cctools-112 with command line created symbols, -i
  options, that produce warnings when scatter loaded because the object file
  "command line" was multiply loaded.
- Fifth major round of changes for the new shlib stuff.
  1) Added the code to produce and link with the dylinker format.
  2) Added the code to link with the dylib format (for now only the load command
     is copied to the output file).
  3) Added the optimization to the link editor to use the value of the symbol
     for a non-lazy pointer section if it is defined.  This will allow the
     compiler code generation to be developed and tested without the dynamic
     linker).

Changes for the 3.3 release (the cctools-113 release):
- Fixed a bug introduced in cctools-112 in outputing the relocatation entries
  for S_LITERAL_POINTERS sections.  Both ld -r and ld -output_for_dylib were
  broken.  The problem for ld -r was the counting of the relocation entries for
  literal pointers was wrong.  A new routine, count_relocs, was added in
  literal_pointers.c based on if the literal pointer as newly seen.

Changes for the 3.3 release (the cctools-112 release):
- Fixed a bug in the hppa reloc for scatter loading BL17 relocation types that
  was always 8 past the target.  "value -= 8;" was added in the local reloc case
  with fine relocs.
- Forth major round of changes for the new shlib stuff.
  1) Added the code to produce the dylib format.  New tables and relocation
     info changes.

Changes for the 3.3 release (the cctools-108 release):
- Third major round of changes for the new shlib stuff.
  1) Added the code to order the symbol table and string table.

Changes for the 3.3 release (the cctools-104 release):
- Second major round of changes for the new shlib stuff.
  1) Added support for indirect sections and relocation to them when indirect
     symbols get defined.
- Fixed a bug with the hppa JBSR reloc types (mostly when saving relocation
  entries, scattered loading and non-zero based sections).
- Found and fixed a bug in the 3.2 released link editor.  This bug happens when
  relocation entries are saved and there are scattered relocation entries which
  reference a section with fine relocation the r_value field is not updated
  correctly.  The code was:
    sreloc->r_value = fine_reloc_output_offset(local_map,
			    		       r_value - local_map->s->addr) +
		      local_map->output_section->s.addr + local_map->offset;
  which was corrected to:
    sreloc->r_value = fine_reloc_output_offset(local_map,
					       r_value - local_map->s->addr) +
		      local_map->output_section->s.addr;
  as the value of local_map->offset should not have been added.

Changes for the 3.3 release (the cctools-103 release):
- Removed the "__attribute__ ((format (printf, 1, 2))" from vprint in ld.h as
  it was incorrect and the new compiler treats this as an error.

Changes for the 3.3 release (the cctools-102 release):
- Integrated in the hppa support.
  * Added the SECTDIFF support for the hppa with the HI21 and LO14 SECTDIFF
    relocation types.
  * Fixed the use of calc_hppa_HILO() in hppa_reloc() in hppa_reloc.c to
    correctly pass the symbol value and offset value as the two first
    parameters.
different ld/Makefile (integrated for cctools-102)
     Using cctoolshppa-37.  New hppa files.
different ld/layout.c (integrated for cctools-102)
     Using cctoolshppa-37.  hppa thread stuff.
different ld/ld.h (NOT picked up for cctools-102)
     Using cctoolshppa-37.  The define CHECK_PRINTFS is ifndef'ed out hppa
     with the comment /* va_list defined differently for hppa.  Check this */
different ld/notes
     Using cctools-29. Late 3.2 fixes the hppa base did not have.
different ld/pass1.c
     Using cctools-29. Late 3.2 fixes the hppa base did not have.
different ld/rld.c
     Using cctools-29. Late 3.2 fixes the hppa base did not have.
different ld/sections.c (integrated for cctools-102)
     Using cctoolshppa-37.  hppa reloc call based on cpu type.
Only in cctoolshppa-37/ld: hppa_bitfuncs.c (NOT picked up for cctools-102)
     Pickup cctoolshppa-37/ld/hppa_bitfuncs.c from cctoolshppa-37.
Only in cctoolshppa-37/ld: hppa_bitfuncs.h (NOT picked up for cctools-102)
     Pickup cctoolshppa-37/ld/hppa_bitfuncs.h from cctoolshppa-37.
Only in cctoolshppa-37/ld: hppa_reloc.c (integrated for cctools-102)
     Pickup cctoolshppa-37/ld/hppa_reloc.c from cctoolshppa-37.
Only in cctoolshppa-37/ld: hppa_reloc.h (integrated for cctools-102)
     Pickup cctoolshppa-37/ld/hppa_reloc.h from cctoolshppa-37.

Changes for the 3.3 release (the cctools-101 release):
- Added code in the reloc routines to check that byte and short relocation
  fits.

Changes for the 3.3 release (the cctools-100 release):
- First major round of changes for the new shlib stuff.
  1) Support for spliting the sections flags field in to types and attributes.
     Lots of places that used flags now use (flags & SECTION_TYPE).
  2) Support for possition-independent code through the SECTDIFF relocataion
     type.  This effected all the *reloc.c sources.
  3) Support for .private_extern directive with -keep_private_externs.  Where
     the change from external to static happens in in layout_merged_symbols()
     in symbols.c.

Changes for the 3.1 release (the cctools-28 release):
- Fixed a bug where pass1_fat() cleared the error variable and caused multiple
  defined errors not to cause the link editor to exit and instead produce an
  output file (bug #37043).
  
Changes for the 3.1 release (the cctools-27 release):
- Fixed a bug in sarld's vprint() which did not advance the error buffer
  correctly.

Changes for the 3.1 release (the cctools-25 release):
- Fixed bug #36216 which did not issue a warning when -Ldir's don't exist.
- Added stand alone rld as libsarld.a which is supported by the ifdef SA_RLD.

Changes for the 3.1 release (the cctools-20 release):
- Changed the m98k seg1addr to 0x13a00000 for the m98k (-object too).

Changes for the 3.1 release (the cctools-19 release):
- Fixed a bug in output_literal_pointers() that was not swapping correctly.
  The problem was it was using set_long() which used cur_obj->swapped but at
  this point in the code cur_obj is not set.  So the change was to do the
  swaping based on host_byte_sex != target_byte_sex.

Changes for the 3.1 release (the cctools-16 release):
- Fixed a bug in the checking of BR24 relocation where a mask was 0xf8000000
  which should have been 0xfc000000.  Thus when a displacement of 0x04000000
  or greater was generated the relocation overflow was not caught.
- Changed the default seg1addr used for the m98k to 0x10000000 (which should be
  VM_MAX_ADDRESS in mach/m98k/vm_param.h but would require files to include
  that file).  This change was made in layout_segments() in layout.c.

Changes for the 3.1 release (the cctools-15 release):
- Changed not finding an arch in a fat file to a warning from an error and not
  finding an arch from a thin archive to a warning from an error (bug #30659).
- Fixed a bug in m98k_reloc() where HA16 was not relocated correctly because a
  constant was written 0x000080000 not 0x00008000 (has an extra 0 on the end).

Changes for the 3.1 release (the cctools-13 release):
- Added the m98k (PowerPC) architecture.  This includes a kludged
  mach/m98k/thread_status.h with only an entry point.

Changes for the 3.1 release (the cctools-10 release):
- Changed the handling of the cpusubtypes to support this design:
    The design allows each architecture family (m68k, m88k, i386) to have a
    cpusubtype that will run on all implementations of that architecture and
    have cpusubtypes that will run only on specific implementations of an
    architecture.  The design also gives the programmer the option to force the
    cpusubtype indicating all implementations (at build time with a flag) when
    using instructions that are implementation specific leaving it up to the
    program to runtime select the correct code to execute.

  The link editor operation in this design:
    By default the link editor will change it's operation (starting with
    cctools-10) as specified on the ld(1) man page from:
	If no -arch arch_type is specified and the first object file encountered
	on the link line is a "fat" file the output architecture is as follows:
	if the fat file contains only one architecture then that architecture is
	used else if the ``fat'' file contains the host architecture then the
	host architecture is used otherwise it is an error and an -arch
	arch_type must be specified.
    to:
	If no -arch arch_type is specified and the first object file encountered
	on the link line is a "fat" file the output architecture is as follows:
	if the fat file contains only one architecture then that architecture is
	used else if the ``fat'' file contains the an architecture that would
	execute on the host then the "best" architecture as defined by what the
	kernel exec(2) would select is used otherwise it is an error and an
	-arch arch_type must be specified.
    In addition the cpusubtype will be promoted from an ALL subtype to a
    specific cpusubtype if an object file with a specific cpusubtype is linked
    in and the resulting linked object file will have that specific cpusubtype.
    As this promotion occurs during the linking this effects the selection of
    which component of a fat file will be selected for linking for subsequent
    fat files encountered on the link line.

    When a -arch arch_type flag for an architecture family (m68k, i386, etc) is
    specified it has the effect as if the link editor is linking for that host
    architecture and the cpusubtype will be promoted as described above.  If a
    -arch arch_type flag for a specific implementation of an architecture
    (m68040, i486, etc.) is specified the result is an object file with that
    specific cpusubtype and any object that has a cpusubtype which will not
    promote to the cpusubtype for that -arch flag is an error.

    The link editor will also accept the optional -force_cpusubtype_ALL flag
    causing the cpusubtype to remain ALL an not be promoted.  This flag has
    precedence over any -arch arch_type flag for a specific implementation.
    Use of this flag has an effect on the selection of which component of a
    fat file will be selected for linking and the cpusubtype always remains
    the _ALL type.

    The link editor will change it's operation in this area (starting with
    cctools-10):
	Previously when a fat file was encountered during linking and there was
	no architecture in the fat file for the current architecture being
	linked the fat file is ignored without any error or message.
    This will change to:
	If a fat file is encountered during linking and there is no "best"
	architecture in the fat file for the current architecture being linked
	this is treated as an error.
    The selection of the "best" architecture will be the same as the kernel's
    exec(2) and is defined by the library function cpusubtype_findbestarch().

    During linking a "current cpusubtype" will be maintained and objects being
    linked will be combined with it based on the library function
    cpusubtype_combine() and will produce a new "current cpusubtype" or an
    error if the cpusubtypes can't be combined.  If the -force_cpusubtype_ALL
    flag is specified the above routine will not be used and the cpusubtypes
    will always be combined and the "current cpusubtype" will always remain the
    _ALL cpusubtype.
  The rld(3) operation in this design:
    For reasons of compatiblity and existing bugs in the the cpusubtype handling
    the rld(3) package will function as if -force_cpusubtype_ALL were specified.
    As of the 3.0 release the rld(3) package does not do the same checking as
    exec(2) does with reguard to the handling of the cpusubtype.  Specificly for
    the m68k if on an 030 an object file with the 040 cpusubtype is used with
    the rld(3) package no error is generated.  This "bug" has the effect of the
    functionality of the -force_cpusubtype_ALL flag but lacts the error
    detection supported by exec(2).  Since adding the error detection could
    break existing uses of rld(3) the rld(3) package will function as if
    -force_cpusubtype_ALL were specified.
  This effected ld.c, ld.h, pass1.c and rld.c.

Changes for the 3.1 release (the cctools-9 release):
- Fixed a bug introduced by adding the -pagezero_size option where -p was not
  recognized the same as -preload.

Changes for the 3.1 release (the cctools-8 release):
- Added a "-pagezero_size hex_value" argument at the request of the Lono team.
- Changed the default segment alignment to 0x2000 for the I386.  This effects
  check_cur_obj() in pass1.c.

Changes for the 3.1 release (the cctools-7 release):
- Fixed a bug in cross linking on a risc machine in generic_reloc.h in the
  {get,set}_{long,short} routines where the compiler was taking the 'long *'
  and the memcpy() and assuming it could do the copy in line and it was
  correctly aligned.  The change was to make the type a 'void *'.
- Changed the way the messages for -sectorder_detail is printed in the case a
  symbol is not specified in the load file so the output of ld can be cut and
  pasted into an order file (bug #26204).
- Allow multiple -arch flags of the same name (bug #26197).

Changes for the 3.1 release (the cctools-6 release):
- Added the -arch_multiple flag that will cause one line to printed before all
  error messages which will contain the architecture name.
- Added checks for m88k relocation overflows in m88k_reloc.c for PC16 and PC26.
- Maded the changes to handle cross bytesex linking.
- Changed the way the non-zero values of the i386 thread_state registers get set
  from an initialized struct to direct assignment.  This was also added to the
  ifdef RLD code.  These are the asignments:
    intel386.es = UDS_SEL;
    intel386.ds = UDS_SEL;
    intel386.ss = UDS_SEL;
    intel386.cs = UCS_SEL;
- Fixed a bug introduce in cctools-5 item:
      Changed the default order when all the symbols in an object file are not
      listed in an order file to caused that object to be loaded as it had a
      .section_all specification (nrw team request).
  The bug was that if object had a .section_all this new code would reassign the
  order.  Another condition was added to the if that trigers this new code to
  test for this case.
- Fixed a bug in the Makefile when more than on RC_ARCHS was set.  The change
  of "$(RC_ARCHS)" in the for loop to `cat $(RC_ARCHS)` was done to fix it.

Changes for the 3.1 release (the cctools-5 release):
- Picked up a change from the lono team where the variable named "i386" was 
  changed to "intel386" so that it wouldn't collide with the CPP macro named
  "i386" in layout.c .
- Picked up a fix from the lono team where calculating the output_pc was done
  incorrectly when doing pc relative offsets for the i386 in generic_reloc.c .
- Changed the default order when all the symbols in an object file are not
  listed in an order file to caused that object to be loaded as it had a
  .section_all specification (nrw team request).
- Fixed a bug where the relocation references in rld to sections with fine
  relocation entries was wrong because the fine relocation entries were free'ed
  too soon in pass2() in pass2.c (bug #22046).

Changes for the 3.1 release (the cctools-3 release):
- Changed the way the default segalign gets set.  It is now set when the
  output cputype is set in check_cur_obj() in pass1.c based on the cputype and
  not initialized to the cpp macro TARGET_PAGESIZE set via the Makefile but
  initialized to zero in ld.c.  This was done because it is different for the
  i386 architecture.
- Fixed a bug with generic_reloc where the a pcrel relocation entry on the i386
  is relative to the end of the displacement not the beginning.  This involved
  adding an extra argument to generic_reloc() and passing the correct argument
  in sections.c where this is called.
- Fixed a bug with librld.o needing to be linked with libstuff.a (Makefile
  change).

Changes for the 3.1 release (the cctools-3 release):
- Removed the M88K_TIME_HACK code in pass1.c
- Changed CPU_TYPE_I80x86 to CPU_TYPE_I386 in lipo.c

Changes for the 3.1 release (the cctool-2 release):
- Added support for fat files.  The -arch flag was added to help support this.
  The changes are in pass1.c for the fat stuff.  The global variables cputype
  and cpusubtype are now used out of the global struct arch_flag this effected
  a hand full of files.
- Removed the obsolete flags: -a, -T, -Ttext, -Tdata, -ident, -v, -g, -G, -D.

Changes for the 3.0 release (the -57 compiler release):
- Corrected the -whyload message in pass1.c for -all_load that printed -all
  (bug #20024).

Changes for the 3.0 release (the -56 compiler release):
- Added the -all_load flag that causes all of the members of archives to be
  loaded.  This effected ld.c, ld.h and pass1.c (bug #19644).
- Added the -ObjC flag that causes the members of archives that defined
  objective-C classes or categories to be loaded.  This effected ld.c, ld.h
  and pass1.c (bug #19643).
- Added the feature of ".section_offset <value>" in the load order file.  This
  as in layout_ordered_section() in sections.c .
- Fixed a bug in in lookup_load_order() in sections.c if the same named symbol
  appears more than once in the loaded objects (in the case of static symbols)
  and the sectorder file has that symbol listed more times than it appears in
  the objects being loaded.  So when lookup_load_order() is handed one of the
  lines for this symbol and all orders for those symbols have been assigned it
  failed to test for this and incorrectly dropped into the code that was
  assuming that there was multiple matches for this symbol and tried to return
  the first non-ordered match.  But since all the symbols were assigned there
  was non first non-ordered match and this caused an indirection through a NULL
  pointer.  So the fix was to add the following code:
	if(number_of_matches == 0)
            return(NULL);
  after the first loop that determined the number of non-ordered matches were
  left. (found by Stone Design in the 2.1 release) (bug #19640)

Changes for the 3.0 release (the -55 compiler release):
- Fixed a bug when ordering a section where two symbols had the same value.
  The problem caused a the block to not be written to the correct output
  offset leaving a hole of zeros.  The fix is to make sure that zero sized
  blocks get the output_offset size of the previous block.  The fix is in
  sections.c in layout_ordered_section() (see the use of prev_output_offset).
- Fixed the spelling of ambiguous in places it appeared abiguous and ambigious
  (bug #19353) in sections.c.
- Added a test to see if an archive member name could have been truncated before
  printing the warning saying it could be ambigious when used with -sectorder
  (bug #19352).

Changes for the 3.0 release (the -53 compiler release):
- For RLD internal_rld_load() in rld.c if the output_file is
  RLD_DEBUG_OUTPUT_FILENAME (used by the debugger for automatic debugging of
  rld using the rld_state stuff) the flag RLD_DEBUG_OUTPUT_FILENAME_flag is set
  so the code in layout_segments() in layout.c will know to pass address_func()
  the allocate_size (including the symbol table) so the debugger can save this
  and deallocate the memory correctly.
- For RLD in rld.c if the object file name is not a full path the fullpath is
  created and saved as the object file name.  This is so that the debugger can
  find the object when using the automatic debugging is done using the rld_state
  stuff.
- For RLD changed the enter_symbol() routines to use the string from the object
  if it is in the base file.
- For RLD allocate from an NXZone for all allocations.

Changes for the 3.0 release (the -52 compiler release):
- Added ignoring the new LC_PREPAGE load command (two places in pass1.c).
- Added the Make.app stuff (new files make.defs, make_defs.h, and notifyMake.c)
  This effected the Makefile and ld.c.

Changes for the 3.0 release (the -51 compiler release):
- Fixed a bug that did not pad out the string table to a multiple of 4 bytes.
  A output_strpad field was added to the symtab_info struct which was filled
  in layout_segments() and the size of the string table was changed to be
  rounded to 4 byte size.  Then the strpad was flushed in setup_output_flush().
  This effected layout.c, layout.h and pass2.c.
- Changed the m88k thread status to match the kernel struct (layout.c).

Changes for the 3.0 release (the -49 compiler release):
- Changed where ld3.1 gets installed it now gets installed in
  /usr/local/bin3.1/ld .
- Added LC_FVMFILE to pass1.c to be ignored.
- Changed the strip line for librld.o because it strips the rld_state the
  debugger needs and messes up the debugger when the debugging symbols are
  saved and some globals are stripped. It now uses nmedit.
- Changed the Makefile to meet the RC api.

Changes for the 3.0 release (the -47 compiler release):
- ld sources split in to ld and ld3.1 and all m88k and ix86 stuff removed.
- Added rld_forget_symbol() for Franz Inc. to use with Lisp.
- Changed shlib_ofiles and profile_ofiles to build one librld.o object using
  strip to limit the number of globals to only the api listed on the man page
  (bug #15808).
- Changed the alignment of .section_all blocks from using the merge section's
  alignment to using the original section's alignment.  (sections.c
  layout_ordered_section() second use of function round()).  This allows shlib's
  to stay compatible when the alignment of an ordered section increases.
- Added #include <errno.h> to ld.c to match header file changes.
- Changed the includes in layout.c to match the header file changes:
  m68k/mach/thread_status.h -> mach/m68k/thread_status.h
  m88k/mach/thread_status.h -> mach/m88k/thread_status.h
  ix86/mach/thread_status.h -> mach/ix86/thread_status.h
  i860/mach/thread_status.h -> mach/i860/thread_status.h

Changes for the 3.0 release (the -44 compiler release):
- Switch over to the new header file organization.  This also involed changing
  thread_status structure names and constants.

Changes for the 3.0 release (the -43 compiler release):
- Added support for the i386.
- Changed rld_load to fail if the output file for the debug file can't be
  created (bug #14799).
- Added rld_loaded_state for the debugger so it can automaticly debug things
  that use rld (the interface in in the header file rld_state.h) (bug #15163).
- Fixed all new warnings with the cc-37 compiler and added the __attribute__
  format stuff for all error messages.  This involved touching every file and
  all long declrations to be unsigned long.  This also involved touching most
  error strings for fix up.  This did find 6 or so real bugs.

Changes for the 3.0 release (the -37 compiler release):
- Added a check in pass1.c to check for old 88k objects based on the date this
  is installed internally to NeXT (Wed Jun 12 16:00:00 PST 1991 (676681200)).
  This is ifdef'ed M88K_TIME_HACK.
- Changed the RLD ifdefs in sections.c and m88k_reloc.c to allow 88k objects
  to be used with the RLD package.
- Removed all #error's and most uses of mc68000 in all the code.  The relocation
  routines now have static inline routines to get/set longs, shorts, and bytes
  reguardless of the alignment (see generic_reloc.h).  Other checking code in
  pass1.c has also been updated.  This effected pass1.c, *_reloc.c and
  literal_pointers.c
- Changed m88k_reloc() to handle scattered relocation and the change of storing
  the other half in pair relocation entries in the r_address field.
- Changed i860_reloc() to handle the change of storing the other half in pair
  relocation entries in the r_address field.
- Fixed a bug in generic_reloc() where if a pc-relative external relocation
  entry had an offset equal to it's pc and that symbol was defined (in another
  object being loaded) and relocation entries were saved a local relocation
  entry would be created where a scattered relocation entry should have been.
  For this bug to show up an 'ld -r' would be needed and then a scattered load
  where the symbol+offset did not end up in the same block.  The fix was to
  adjust the offset by the input_pc if the entry was pc-relative. (very obscure
  bug, found by reading the code).

Changes for the 3.0 release (the -36 compiler release):
- Fixed an obscure bug when ordering a section where two symbols have
  the same value.  The fix is in qsort_load_order_values() in sections.c .
  This fix makes the load_orders and the fine_relocs
  sorted by value end up in the same order even though the load_order
  sorted by name between their sorts by value.  Without this the
  blocks for the symbols at the same address get placed in the file
  in the wrong place because the subtraction of their input offsets
  does not yeild the size of the block in this case.  This is kinda
  a funky fix to avoid adding a size field to the fine reloc struct
  which would be very expensive in space.
- Fixed a bug in create_order_load_maps() in sections.c which used more
  order_load_maps than it allocated.  It used maps for sections that had
  no_load_order == TRUE.

Changes for the 3.0 release (the -34 compiler release):
- Fixed a bug where multiple pass1 errors were not processed because the code
  in merge() in pass1.c always returned if there had been any previous errors.
  The fix was to have merge() save and restore the previous errors and only
  return if an error happened while processing that file. (second bug in first
  released version).
- Added the -m flag to allow multiply defined symbols with a warning instead of
  treating them as a hard error.  In this case the first symbol is used for
  linking and is the value of the symbol.
- Added installsrc, installIBMsrc and installGNUsrc targets to the Makefile.
- Fixed a bug that would cause the output flush stuff to fail.  The problem was
  when a section in an object file had a size that was not a multiple of its
  alignment and the next object file loaded with that section had a size of
  zero the section would be padded to get the alignment but the routine out
  output the section returned when the size of the section was zero and thus
  the area was not flushed and ld got an internal error.  This was fixed in
  merge_section() in sections.c where the test for the section size being zero
  is made and the merged section size (ms->s.size) is not changed if the size
  of the section being merged is zero. (first bug in first released version)

Changes for the 3.0 release (the -33 compiler release):
- Added the support needed for the 88k and the i860 processors.
- Changed the use of r_reserved field of the relocation_info to match the
  change to r_type.  This effected only generic_reloc.c and literal_pointers.c .

Release 2.0
Changes for the Warp ?? release (the -30 compiler release):
- Allowed using -sectorder on zero fill sections (including the section for
  common symbols) and for all literal sections (each type of literal section
  has it's own format of the sectorder file) (bug #9404).
- Improved handling of sectorder file where the specifications don't exactly
  match the object names of what's loaded.  A hash table of symbol names is used
  to attempt to match up symbol names in the specifications to the symbol names
  in the object files loaded.  Also removed the requirement of a separating ':'
  between the object name and symbol name which allows just a symbol name to be
  specified.  Also removed the fatal error of the same object file loaded more
  than once with -sectorder and the same symbol in the same object file.  This
  introduces ambiguity but that exist anyway when the requirement of exact
  matches was removed.  Also improved the allocation of the name arrays data
  structure for better performance (bug #9403). 
- Fixed a bug in clean_archives that indexed the sets array with cur_set when
  cur_set was equal to -1 (bug #9402)
- Fixed a bug if any section specification was given for the (__DATA,__common)
  section it caused the common symbols not to be defined (bug #9401).
- Fixed a bug that caused ld to hang if processing an old library and a member
  had an error in the object file.  The fix was to add the expresion errors == 0
  to the while loop to terminate the algorithm in the case of an error.  The
  error was that an object contained an LC_SYMSEG which was handled as an error.
  This is now a warning and the message was changed to include "object produced
  by pre-1.0 compiler, please recompile" (bug #9141).

Changes for the Warp ?? release (the -29 compiler release):
- Fixed a bug in new_sets that did not zero out the entire structure when
  reallocating it (bug #8037).
- Replaced the buggy literal pointer code (literal_ptrs.[ch] got
  literal_pointers.[ch]) (bug #7994).
- Changed the sizes of the literal 4 and 8 tables from 20 to 60 which seems to
  be about the right number of literals so that a large program will have only
  one table.
- Changed the calls to map_fd again to match the current prototype in libc.h
  which now matches the NeXT documentation.  Casts for all the parameters were
  added.  Hopefully this will now remain correct.

Changes for the Warp ?? release (the -28 compiler release):
- Fixed bug #7770 where the logic around free() in the literal 8,4,pointers
  free code was wrong.

Changes for the Warp ?? release (the -27 compiler release):
- The first version of the literal pointers code was added.
- Fixed a bug that caused floating-point constants to be relocated wrong.  The
  output_offset for the fine relocation map for the first table entry of all
  second and larger tables got set wrong.
- Fixed a bug where if symbols were being traced with -y and common symbols
  were being allocated then some of the common symbols might not be allocated.
  The problem was in defined_common_symbols() where the loop that looped through
  the trace symbols and the loop that looped through the merged symbol list were
  using the same variable.
- Fixed a bug where the contents of a section was not placed in the output file
  at the right address.  This was caused by an zero sized section that had an
  alignment that caused it's address to be greater than its previous section.
  Then when the offsets were assigned to the sections a test for zero sized
  sections prevented the running "offset" to be incremented if the size of the
  section was zero even though the difference of the address of the section and
  the next section in this case was not zero.  This showed up with a zero sized
  literal8 section with rld because the section came from the basefile and was
  not in the loaded objects.

Changes for the Warp 3H release (the -26 compiler release):
- Fixed a bug in generic_reloc that produced scattered relocation entries for
  absolute symbols.
- Fixed a bug in the rld package and ld -A where the common section did not have
  the correct alignment.  The problem was in merge_sections if the base file was
  being merged the alignment was not propagated into the merged section.
- Fixed a bug in layout_sections that did not assign addresses to zerofill
  sections correctly aligned (it was fixed for content sections but not for
  zerofill sections).
- Fixed a bug in output_cstrings() when freeing up the data the loop was using
  a pointer to a free()'ed item.
- Changed the checks in check_symbol() to allow stabs to have any of the N_TYPE
  bits on and treated like N_SECT (their n_sect feild checked).
- Added 4 byte and 8 byte literals.
- Added a test in allocate() so that if a size of zero is asked for then NULL
  is returned and malloc is not called.  This allows malloc() to return NULL 
  if a zero size is requested and not to be flagged as an error.
- Added a comma between the perror string and the printing of errno = x in the
  error routines.

Changes for the Warp 3 (OS update) release (the -25 compiler release):
- Added rld_load_from_memory() and fixed a vm_allocate leak for the input object
  file when an error ocurred.
- Added scattered relocation entries to generic_reloc() in generic_reloc.c.
  See the comments in <reloc.h>.  This allows scattered loading to work
  relibly.
- Fixed bug 6264 which produced a error with an archive that had zero ranlib
  structures in it.  It now prints a warning.
- Fixed bug 6261 which printed the linkedit segment has zero size when using -s
  and the no seglinkedit flag was specified.  It is no longer printed in this
  case but is printed when the -seglinkedit flag is specified.

Changes for the Warp 3 release (the -24 compiler release):
- Fixed a bug in lookup_fvmlib() which did not bzero the memory it allocated
  for a merged_fvmlib structure causing a bogus next pointer in that struct.
- Fixed a bug in rld_load_basefile() that is not set the host_pagesize which
  caused enter_string to allocate each string in it's own string block.
- Fixed a bug where the <segment>__end symbols did not get the correct value
  because their section number was set to the last section in their segment
  and not their first as they should have been.
- Removed all compiler "might be" warning messages for -DDEBUG and -DRLD.
- Implemented scattered loading vi -sectorder <segname> <sectname> <orderfile>
  (and added the -sectorder_detail option along with this).  This has NOT been
  put on the man page because of the relocation limititations it can't detect.
- Removed "mach_missing.h" (mach_error_string from <mach_error.h> and map_fd
  from libc.h (brain damaged but there)).
- Added one argument (headers_size) to the function passed to rld_address_func.
- Moved rld.h to ../include and it will be installed in /usr/include.
- Added a -w flag to suppress warnings.
- Added saving away errno in the system_{error,fatal} routines before doing any
  thing that could cause a system call (like a print).  This is in hope to get
  rid of the wrong error string (Inapropate ioctl for device) when it can't open
  a file (the value of errno is also printed).

Changes for the Warp 1 release (the -23 compiler release):
- Added the -headerpad <hex value> option to pad the header for MH_EXECUTE
  files.  The header is allways padded for MH_EXECUTE by the greater of this or
  the round off due to the segment rounding.
- Fixed a bug in clean_archives() when an rld_load_basefile() was called there
  are no sets so the the loop in clean_archives() was wrapped with an
  if(sets != NULL) .
- Fixed a bug that merge_literal_sections() merged the sections contents from
  the base file.
- Now is linked with libsys.
- Made created seglinkedit by default for object formats that can have it and
  set the default init protect to r-x.  Also added the -noseglinkedit option
  to turn this off.
- Added a message to the rld() calls when they return failure because of
  previous fatal errors (otherwise they print nothing and it fails).

Changes for the 2.0 impulse X.X release (the -22 compiler release):
- Added the ablity to link from archives with rld_load().
- Fixed a memory leak in the rld package when an rld_load() failed before
  pass2() and it was never called then the undefined_maps for that object set
  were not free()'ed.  Remove object now also frees these maps if they are not
  already free.

Changes for the 2.0 impulse X.X release (the -21 compiler release):
- Changed the default format if -A is specified and no filetype is specified,
  it now is MH_OBJECT.
- Added the following functions to the rld package: rld_unload_all,
  rld_load_basefile, rld_address_func and added another argument to rld_load
  which is the output name of the debugging file for gdb.
- Fixed -X to not strip stab symbols that start with 'L'.
- Added the -b flag to strip the base symbols from the output file when doing
  an ld -A.  This results in a much smaller output file which should still be
  useful for gdb(1)'s addfile command.
- Added coded in pass1() and rld_load() to handle the bug in the kernel that
  will not allow map_fd() to map a file with zero length.

Changes for the 2.0 impulse X.X release (the -20 compiler release):
- Added the -sectobjectsymbols <segname> <sectname> option to produce the
  file.o symbols.
- Fixed some nits in pass1() in some error cases printing the member name with
  out trimming the trailing blanks.
- Fixed two bugs in generic_reloc() in the error case when an external
  relocation entry's r_symbolnum is not found in the undefined_map and then
  the wrong index (i) was used instead of (symbolnum) to index the symbol table
  and determine the error in the object file.

Changes for the 2.0 impulse X.X release (the -19 compiler release):
- Fixed a bug in the rld package to correctly unload common symbols allocated
  in a set of objects loaded.
- Fixed a bug in the rld package to not enter undefined, common and indirect
  symbols from the base program (this causes the hash table to be in an
  incorrect state if a dymnamicly loaded object defines one of these symbols
  and it is unloaded).
- Added a check to make sure the string table ends with a '\0'.
- ld is no longer installed as ld-<version_number> to match the rest of the
  project.
- Changed so that no longer allow two absolute symbols with the same value to
  not cause a multiply defined symbol.
- Updated for the changes to CPU_TYPE and CPU_SUBTYPE with the changes to
  <sys/machine.h>
- Fixed a bug in layout() that didn't get the addresses of sections right (and
  then possibly the filesizes of segments right).  This was cause by setting
  the section address to the rounded 
