This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] fix as segv on alpha when --gdwarf2 is used


On Sat, Apr 19, 2003 at 01:47:03AM +0200, Julien LEMOINE wrote:
> Fix the segv on alpha when try to assemble test.s
> % cat /tmp/test.s
> .file 2 "axp.s"
> .ent qt_vstart
> jsr $26,qt_error
> .end qt_vstart
> % as --gdwarf2 foo.s
> zsh: segmentation fault (core dumped)  as --gdwarf2 foo.s

Your patch is not quite correct, since the source itself is
in error.  A correct fix yields:

z.s: Assembler messages:
z.s:4: Error: unassigned file number 1



r~


	* dwarf2dbg.c (get_filenum): Skip as-yet unassigned file numbers.
	(out_file_list): Assign non-null filename after generating error.

Index: dwarf2dbg.c
===================================================================
RCS file: /cvs/src/src/gas/dwarf2dbg.c,v
retrieving revision 1.61
diff -c -p -d -u -r1.61 dwarf2dbg.c
--- dwarf2dbg.c	11 Mar 2003 22:00:33 -0000	1.61
+++ dwarf2dbg.c	21 Apr 2003 18:20:18 -0000
@@ -411,6 +411,7 @@ get_filenum (filename, num)
     {
       for (i = 1; i < files_in_use; ++i)
 	if (files[i].dir == dir
+	    && files[i].filename
 	    && strcmp (file, files[i].filename) == 0)
 	  {
 	    last_used = i;
@@ -1089,6 +1090,8 @@ out_file_list ()
       if (files[i].filename == NULL)
 	{
 	  as_bad (_("unassigned file number %ld"), (long) i);
+	  /* Prevent a crash later, particularly for file 1.  */
+	  files[i].filename = "";
 	  continue;
 	}
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]