This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Don't try to execute directories
- To: Ian Lance Taylor <ian at zembu dot com>
- Subject: Re: Don't try to execute directories
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Wed, 04 Aug 1999 01:43:41 -0600
- cc: egcs-patches at egcs dot cygnus dot com, ian at airs dot com
- Reply-To: law at cygnus dot com
In message <19990613062219.28286.qmail@daffy.airs.com>you write:
> If you put `.' early in your PATH, and you run gcc in a binutils
> object directory, then gcc will attempt to execute the ld directory
> when doing a link.
>
> This bug is easy to recreate, assuming ld is not in a special
> directory which gcc searches first. ld is in a special directory on
> most Solaris systems, but on many systems, including most GNU/Linux
> systems, ld is not in a special directory, so this bug will occur.
>
> mkdir ld
> export PATH=.:$PATH
> echo 'int main() { }' > foo.c
> gcc foo.c
>
> It is possible to construct a somewhat different version of this bug
> using the -B option:
>
> mkdir as
> echo 'int main() { }' > foo.c
> gcc -B./ -c foo.c
>
> or
>
> mkdir ld
> echo 'int main() { }' > foo.c
> gcc -B./ foo.c
>
> In general, when gcc searches for a file using a list of directories,
> it will accept a directory as executable, even though it can not
> actually be executed. The shell does not make this mistake, and gcc
> shouldn't either.
>
> This patch fixes this shortcoming.
>
> Ian
>
>
> Sun Jun 13 02:09:43 1999 Ian Lance Taylor <ian@zembu.com>
>
> * gcc.c (access_check): New static function.
> (find_a_file): Use it when searching a directory list.
> * collect2.c (find_a_file): Don't accept directories found when
> searching a directory list.
Thanks. I installed this into the mainline sources.
jeff