Gas vs irregular files

Ian Lance Taylor ian@wasabisystems.com
Thu Dec 18 17:54:00 GMT 2003


Nick Clifton <nickc@redhat.com> writes:

> Ok then, how about this patch ?  It removes the call to stat() and adds
> a code to detect an for an attempt to read a directory, but only if
> the read of the first character in the file fails.  I think that this
> extra check is helpful, since otherwise an attempt to assemble a
> directory would produce these error messages (on a RH9 box anyway):
> 
>   Error: can't open <name-of-directory> for reading
>   <name-of-directory>: No error

If fopen() fails, it should set errno.  A result like the above
suggests that as_bad() is somehow clobbering errno, so that
as_perror() doesn't see the right value.  The easy fix would be to
preserve errno around the call to as_bad().

That said, I don't have any objection to your patch, except that I
think you should change
  if (f_in == NULL || c == EOF)
to
  if (f_in == NULL || ferror (f_in))
Otherwise, I think you will get a bogus error on an attempt to
assemble an empty file.

Ian



More information about the Binutils mailing list