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: Gas vs irregular files


Nick Clifton <nickc@redhat.com> writes:

> Secondly I still think that GAS should complain if it is asked to
> assemble a directory as opposed to a file.

I don't agree.  I don't think the assembler should make a special
effort to detect whether it is opening a directory.  The assembler is
at heart a simple text processing program.  As far as I know, no other
text processing program checks first whether it is about to open a
directory.

Of course, on some Unix systems (e.g., GNU/Linux), fopen() of a
directory will fail anyhow, with errno set to EISDIR.  It's true that
on some systems the fopen will succeed; in that case, the assembler
will fail as it attempts to read the directory entries as assembler
statements.  I really don't see a need to check beforehand whether the
input file is a directory.

> I do not think that the
> idea that it should open the directory and search it for files to
> assemble is a good one.

I agree that that is a terrible idea.

> I would like to propose this alternative
> patch:

I still see no reason to call stat() at all.  Just call fopen().

> Which would allow special files (such as /dev/null) to work, as well
> as symbolic links and so on.  I realise that this means that we still
> have the call to stat() present, but I am not sure how else we can
> determine if the input file is a directory.  fopen() will not fail on
> it, nor will fread().

On those systems where fopen() of a directory will succeed, I still
don't see any reason why we need to have the assembler check for it.
It's no different than running the assembler on any other file which
happens to not be an assembler source file.  No special harm will be
done by trying to assemble a directory.  The user will just get an
error message.  I don't see any reason to make the assembler watch out
for a rather unlikely error case, when that error case will not cause
any significant damage.

Ian


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