* elflink.h (elf_bfd_final_link): Check if dynobj is not NULL
[binutils-gdb.git] / gdb / symtab.c
index ef4db9dad2598103744f99f0ceb0d03a11d27a72..2353ae5a8c0c4fc91f3f95c01ba655b49e309e3f 100644 (file)
@@ -141,14 +141,38 @@ lookup_symtab (const char *name)
   register struct symtab *s;
   register struct partial_symtab *ps;
   register struct objfile *objfile;
+  char *real_path = NULL;
+
+  /* Here we are interested in canonicalizing an absolute path, not
+     absolutizing a relative path.  */
+  if (IS_ABSOLUTE_PATH (name))
+    real_path = gdb_realpath (name);
 
 got_symtab:
 
   /* First, search for an exact match */
 
   ALL_SYMTABS (objfile, s)
+  {
     if (FILENAME_CMP (name, s->filename) == 0)
-      return s;
+      {
+       xfree (real_path);
+       return s;
+      }
+    /* If the user gave us an absolute path, try to find the file in
+       this symtab and use its absolute path.  */
+    if (real_path != NULL)
+      {
+       char *rp = symtab_to_filename (s);
+       if (FILENAME_CMP (real_path, rp) == 0)
+         {
+           xfree (real_path);
+           return s;
+         }
+      }
+  }
+
+  xfree (real_path);
 
   /* Now, search for a matching tail (only if name doesn't have any dirs) */
 
@@ -195,15 +219,37 @@ lookup_partial_symtab (const char *name)
 {
   register struct partial_symtab *pst;
   register struct objfile *objfile;
+  char *real_path = NULL;
+
+  /* Here we are interested in canonicalizing an absolute path, not
+     absolutizing a relative path.  */
+  if (IS_ABSOLUTE_PATH (name))
+    real_path = gdb_realpath (name);
 
   ALL_PSYMTABS (objfile, pst)
   {
     if (FILENAME_CMP (name, pst->filename) == 0)
       {
+       xfree (real_path);
        return (pst);
       }
+    /* If the user gave us an absolute path, try to find the file in
+       this symtab and use its absolute path.  */
+    if (real_path != NULL)
+      {
+       if (pst->fullname == NULL)
+         source_full_path_of (pst->filename, &pst->fullname);
+       if (pst->fullname != NULL
+           && FILENAME_CMP (real_path, pst->fullname) == 0)
+         {
+           xfree (real_path);
+           return pst;
+         }
+      }
   }
 
+  xfree (real_path);
+
   /* Now, search for a matching tail (only if name doesn't have any dirs) */
 
   if (lbasename (name) == name)
@@ -2421,7 +2467,7 @@ search_symbols (char *regexp, namespace_enum kind, int nfiles, char *files[],
          /* If wrong number of spaces, fix it. */
          if (fix >= 0)
            {
-             char *tmp = (char *) alloca (strlen (regexp) + fix);
+             char *tmp = (char *) alloca (8 + fix + strlen (opname) + 1);
              sprintf (tmp, "operator%.*s%s", fix, " ", opname);
              regexp = tmp;
            }