2008-06-09 Andreas Schwab * opncls.c (find_separate_debug_file): Use the canonical absolute directory of the bfd filename for finding the debug file in the global debugfile directory. --- bfd/opncls.c.~1.52.~ 2008-03-28 10:38:17.000000000 +0100 +++ bfd/opncls.c 2008-06-09 17:06:46.000000000 +0200 @@ -1,6 +1,6 @@ /* opncls.c -- open and close a BFD. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, - 2001, 2002, 2003, 2004, 2005, 2006, 2007 + 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. Written by Cygnus Support. @@ -1224,9 +1224,10 @@ find_separate_debug_file (bfd *abfd, con char *basename; char *dir; char *debugfile; + char *canon_dir; unsigned long crc32; - int i; size_t dirlen; + size_t canon_dirlen; BFD_ASSERT (abfd); if (debug_file_directory == NULL) @@ -1263,8 +1264,12 @@ find_separate_debug_file (bfd *abfd, con memcpy (dir, abfd->filename, dirlen); dir[dirlen] = '\0'; + canon_dir = lrealpath (dir[0] != '\0' ? dir : "."); + canon_dirlen = strlen (canon_dir); + debugfile = bfd_malloc (strlen (debug_file_directory) + 1 - + dirlen + + (canon_dirlen + 1 > dirlen + ? canon_dirlen + 1 : dirlen) + strlen (".debug/") + strlen (basename) + 1); @@ -1272,6 +1277,7 @@ find_separate_debug_file (bfd *abfd, con { free (basename); free (dir); + free (canon_dir); return NULL; } @@ -1283,6 +1289,7 @@ find_separate_debug_file (bfd *abfd, con { free (basename); free (dir); + free (canon_dir); return debugfile; } @@ -1295,29 +1302,33 @@ find_separate_debug_file (bfd *abfd, con { free (basename); free (dir); + free (canon_dir); return debugfile; } /* Then try in the global debugfile directory. */ strcpy (debugfile, debug_file_directory); - i = strlen (debug_file_directory) - 1; - if (i > 0 - && debug_file_directory[i] != '/' - && dir[0] != '/') + dirlen = strlen (debug_file_directory) - 1; + if (dirlen > 0 + && debug_file_directory[dirlen] != '/' + && canon_dir[0] != '/') strcat (debugfile, "/"); - strcat (debugfile, dir); + strcat (debugfile, canon_dir); + strcat (debugfile, "/"); strcat (debugfile, basename); if (separate_debug_file_exists (debugfile, crc32)) { free (basename); free (dir); + free (canon_dir); return debugfile; } free (debugfile); free (basename); free (dir); + free (canon_dir); return NULL; }