This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: gas --statistics segfault
On Tue, Feb 07, 2006 at 06:43:04AM +0800, Dasn Clainst wrote:
> On Sun, Feb 05, 2006 at 09:02:19PM +0800, Dasn Clainst wrote:
> > ===================================================================
> > RCS file: /cvs/src/src/gas/as.c,v
> > retrieving revision 1.67
> > diff -u -p -r1.67 as.c
> > --- as.c 30 Oct 2005 18:08:52 -0000 1.67
> > +++ as.c 5 Feb 2006 12:41:27 -0000
> > @@ -1170,7 +1170,7 @@ main (int argc, char ** argv)
> > #endif
> >
> > #ifndef OBJ_VMS /* Does its own file handling. */
> > - output_file_close (out_file_name);
> > + /* output_file_close (out_file_name); */
> > #endif
> >
> > if (flag_fatal_warnings && had_warnings () > 0 && had_errors () == 0)
>
> Please forget this patch, it's just an opinion of my own.
>
We have
if (segment_name (frchp->frch_seg)[0] == '*')
in subsegs_print_statistics. segment_name is defined as
define segment_name(SEG) bfd_get_section_name (stdoutput, SEG)
SEG is allocated with stdoutput. We are using stdoutput after
stdoutput is closed. We should call output_file_close after
dump_statistics. This patch should fix it.
May I suggest you open a bug report at
http://www.sourceware.org/bugzilla/
next time?
Thanks.
H.J.
----
2006-02-07 H.J. Lu <hongjiu.lu@intel.com>
* as.c (close_output_file): New.
(main): Register close_output_file with xatexit before
dump_statistics. Don't call output_file_close.
--- gas/as.c.exit 2005-11-01 21:20:38.000000000 -0800
+++ gas/as.c 2006-02-07 10:04:39.000000000 -0800
@@ -930,6 +930,14 @@ dump_statistics (void)
#endif
}
+#ifndef OBJ_VMS
+static void
+close_output_file (void)
+{
+ output_file_close (out_file_name);
+}
+#endif
+
/* The interface between the macro code and gas expression handling. */
static int
@@ -1081,6 +1089,11 @@ main (int argc, char ** argv)
input_scrub_begin ();
expr_begin ();
+#ifndef OBJ_VMS /* Does its own file handling. */
+ /* It has to be called after dump_statistics (). */
+ xatexit (close_output_file);
+#endif
+
if (flag_print_statistics)
xatexit (dump_statistics);
@@ -1169,10 +1182,6 @@ main (int argc, char ** argv)
listing_print (listing_filename);
#endif
-#ifndef OBJ_VMS /* Does its own file handling. */
- output_file_close (out_file_name);
-#endif
-
if (flag_fatal_warnings && had_warnings () > 0 && had_errors () == 0)
as_bad (_("%d warnings, treating warnings as errors"), had_warnings ());