Patch for tlink.c [fwd]

Kamil Iskra kamil@dwd.interkom.pl
Sun Jan 25 02:47:00 GMT 1998


I'm forwarding an old patch that I sent to Jason Merrill a long time ago,
before EGCS was started. He's never responded to it, and I recently found
out that the patch is still not in.

--------------------------------------------------------------------------
To: Jason Merrill <jason@cygnus.com>
Subject: Patch for tlink.c

I've found a small bug in "tlink.c". In function
"scan_linker_output()", it fails to close fopen()ed files.

This doesn't hurt on UN*X-type hosts, but this makes "unlink()" fail
on hosts where opening a file prevents its unlinking, for example
under the AmigaOS.

As a result, "collect2" dumps "ld" output from the first invocation
even if the recompiling and the relinking went fine.

I've found a similar bug in "collect2.c", in "dump_file()", and sent a
patch to Richard Kenner.


Sun Oct 27 12:09:38 1996  Kamil Iskra  <iskra@student.uci.agh.edu.pl>

	* tlink.c (scan_linker_output): Call fclose() for opened files.


--- tlink.c.orig	Sun Oct 13 22:11:50 1996
+++ tlink.c	Sun Oct 27 12:06:39 1996
@@ -575,7 +575,10 @@
 	}
 
       if (sym && sym->tweaked)
-	return 0;
+	{
+	  fclose (stream);
+	  return 0;
+	}
       if (sym && !sym->tweaking)
 	{
 	  if (tlink_verbose >= 2)
@@ -588,6 +591,7 @@
       obstack_free (&temporary_obstack, temporary_firstobj);
     }
 
+  fclose (stream);
   return (file_stack != NULL);
 }
 

/ Kamil Iskra - AMIGA 1200, 68030 50MHz, HDD 1.6 GB, 18 MB RAM \
| iskra@student.uci.agh.edu.pl  kiskra@ernie.icslab.agh.edu.pl |
| http://student.uci.agh.edu.pl/~iskra                         |
\ PGP public key available via Finger or WWW                   /




More information about the Gcc-bugs mailing list