[gnu.g++.bug] ld.c patch

beihl%cadillac.cad.mcc.com@MCC.COM (Gary Beihl) (10/01/88)

Here's a patch to ld.c which returns a non-zero
exit status if multiply-defined symbols are found
or if undefined symbols are found when non-relocatable
output is desired.

*** ld.c.orig	Fri Sep 30 15:04:36 1988
--- ld.c	Fri Sep 30 15:09:15 1988
***************
*** 452,457 ****
--- 452,460 ----
  /* Nonzero means should make the output file executable when done.  */
  /* Cleared by nonfatal errors.  */
  int make_executable;
+ 
+ /* Value to return upon termination */
+ int return_status;
  
  /* C++: Take care of global constructors and destructors.  */
  void symtab_init_for_cplusplus ();
***************
*** 578,583 ****
--- 581,587 ----
    T_flag_specified = 0;
    magic = ZMAGIC;
    make_executable = 1;
+   return_status = 0;
  
    /* Initialize the cumulative counts of symbols.  */
  
***************
*** 642,648 ****
    if (cplusplus && unlink (ctor_and_dtor_filename))
      perror_file (&file_table[number_of_files-1]);
  
!   return 0;
  }
  
  void decode_option ();
--- 646,652 ----
    if (cplusplus && unlink (ctor_and_dtor_filename))
      perror_file (&file_table[number_of_files-1]);
  
!   return return_status;
  }
  
  void decode_option ();
***************
*** 2154,2159 ****
--- 2158,2164 ----
  		  if (defs++ && sp->value != p->n_value)
  		    if (!erred++)
  		      {
+                         return_status = 1;
  		        make_executable = 0;
  			error ("multiple definitions of symbol %s", sp->name);
  		      }
***************
*** 2361,2368 ****
  
    if (count)
      fprintf (outfile, "\n");
!   if (count)
      make_executable = 0;
  }
  
  /* Write the output file */ 
--- 2366,2376 ----
  
    if (count)
      fprintf (outfile, "\n");
!   if (count) 
!     {
      make_executable = 0;
+     return_status = 1;
+     }
  }
  
  /* Write the output file */