diff -urN gcc-4.3.2-clean/libiberty/make-relative-prefix.c gcc-4.3.2/libiberty/make-relative-prefix.c --- gcc-4.3.2-clean/libiberty/make-relative-prefix.c 2009-01-21 22:35:14.000000000 +0000 +++ gcc-4.3.2/libiberty/make-relative-prefix.c 2009-01-25 15:26:02.000000000 +0000 @@ -57,6 +57,9 @@ #ifdef HAVE_UNISTD_H #include #endif +#ifdef HAVE_SYS_STAT_H +#include +#endif #include @@ -254,6 +257,7 @@ { if (*endp == PATH_SEPARATOR || *endp == 0) { + struct stat st; if (endp == startp) { nstore[0] = '.'; @@ -271,10 +275,11 @@ else nstore[endp - startp] = 0; } + strcat (nstore, progname); - if (! access (nstore, X_OK) + if ((! stat(nstore, &st) && S_ISREG (st.st_mode) && ! access (nstore, X_OK)) #ifdef HAVE_HOST_EXECUTABLE_SUFFIX - || ! access (strcat (nstore, HOST_EXECUTABLE_SUFFIX), X_OK) + || (! stat (strcat (nstore, HOST_EXECUTABLE_SUFFIX)) && S_ISREG (st.st_mode) && ! access (nstore, X_OK)) #endif ) {