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]

Re: zerosize result


Hi Axel,

: > : Another question, if my assembler fails it produces a zero size
: > : file.  Well this is especially nasty for make, as it does not
: > : process this file again :(
: > 
: > That is a bug.  The assembler is not supposed to produce an output 
: > file if it sees any errors (unless the -Z command line option has been
: > used).  Can you send a test case that reproduces this problem ?
: 
: Okay, I've tried to reduce my errorneous file as much as possible,
: resultion to this:
: ------------------------------------------------------------------
: a: S
: 	.align	4
: a: T
: ------------------------------------------------------------------

Thanks - I can now reproduce this problem.  The reason for this
behavior is that GAS is encountering a fatal error:

   3: Fatal error: Symbol a already defined.

Fatal errors cause the assembler to terminate immediately, without
performing any kind of tidy up.  (The assembler does return an error
exit code however).

A simple patch to fix this is shown below - it causes the 'already
defined' symbol message to be an ordinary error, not a fatal error.

This is not a real solution however as there are lots of other
potential ways that the assembler could encounter a fatal error, and
so leave an empty, or only partially filled, object file behind.

Another solution would be to have the fatal error handler delete any
output file.  The second patch below does this.

I am opening this discussion up to the binutils mailing list, before
applying either patch, in case anyone else has anything they wish to
add.


Cheers
	Nick

----------------------patch 1------------------------------------
2001-01-12  Nick Clifton  <nickc@redhat.com>

	* symbols.c (colon): Change 'already defined symbol' from a
	fatal error to an ordinary error.  This allows the assembly of
	sources files containing this error to complete, and so
	prevents an empty output object file from being produced.

Index: gas/symbols.c
===================================================================
RCS file: /cvs/src//src/gas/symbols.c,v
retrieving revision 1.15
diff -p -r1.15 symbols.c
*** symbols.c	2001/01/11 01:32:35	1.15
--- symbols.c	2001/01/12 18:42:42
*************** colon (sym_name)		/* Just seen "x:" - ra
*** 453,460 ****
  	  if (!(frag_now == symbolP->sy_frag
  		&& S_GET_VALUE (symbolP) == frag_now_fix ()
  		&& S_GET_SEGMENT (symbolP) == now_seg))
! 	    as_fatal (_("Symbol %s already defined."), sym_name);
! 	}			/* if this symbol is not yet defined  */
  
      }
  #ifdef BFD_ASSEMBLER
--- 453,460 ----
  	  if (!(frag_now == symbolP->sy_frag
  		&& S_GET_VALUE (symbolP) == frag_now_fix ()
  		&& S_GET_SEGMENT (symbolP) == now_seg))
! 	    as_bad (_("Symbol %s already defined."), sym_name);
! 	}
  
      }
  #ifdef BFD_ASSEMBLER

----------------------patch 2------------------------------------
2001-01-12  Nick Clifton  <nickc@redhat.com>

	* message.c (as_fatal): Delete output file, if one has been
	created. 

Index: gas/messages.c
===================================================================
RCS file: /cvs/src//src/gas/messages.c,v
retrieving revision 1.3
diff -p -r1.3 messages.c
*** messages.c	2000/11/07 01:18:45	1.3
--- messages.c	2001/01/12 19:07:01
*************** as_fatal (const char *format, ...)
*** 414,419 ****
--- 414,423 ----
    vfprintf (stderr, format, args);
    (void) putc ('\n', stderr);
    va_end (args);
+   /* Delete the output file, if it exists.  This will prevent make from
+      thinking that a file was created and so does not need rebuilding.  */
+   if (out_file_name != NULL)
+     unlink (out_file_name);
    xexit (EXIT_FAILURE);
  }
  #else

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