--- ./binutils/debug.c.orig	Thu Mar  3 12:46:12 2005
+++ ./binutils/debug.c	Thu Jun 30 22:41:15 2005
@@ -553,6 +553,19 @@
   struct debug_type *t;
 };
 
+/* Simple list, used for pathname translations. */
+struct xlat_list
+{
+  /* Next string on list. */
+  struct xlat_list *next;
+  /* Old part to match against. */
+  const char *old;
+  size_t olen;
+  /* New part to replace. */
+  const char *newstr;
+  size_t nlen;
+};
+
 /* Local functions.  */
 
 static void debug_error (const char *);
@@ -589,6 +602,11 @@
   (struct debug_handle *, struct debug_type *, struct debug_type *);
 static bfd_boolean debug_class_type_samep
   (struct debug_handle *, struct debug_type *, struct debug_type *);
+static const char *debug_xlat_pathname (const char *);
+
+/* List of pathname translations. */
+static struct xlat_list *xlat, *xltail;
+static bfd_boolean xlat_basename;
 
 /* Issue an error message.  */
 
@@ -681,6 +699,8 @@
 
   if (name == NULL)
     name = "";
+  else
+    name = debug_xlat_pathname (name);
 
   nfile = (struct debug_file *) xmalloc (sizeof *nfile);
   memset (nfile, 0, sizeof *nfile);
@@ -721,6 +741,8 @@
 
   if (name == NULL)
     name = "";
+  else
+    name = debug_xlat_pathname (name);
 
   if (info->current_unit == NULL)
     {
@@ -3370,4 +3392,70 @@
     }
 
   return TRUE;
+}
+
+/* Register a pathname translation. */
+void
+debug_register_pathname_xlat (oname, nname)
+     const char *oname;
+     const char *nname;
+{
+  struct xlat_list *xlp;
+
+  /* Special case: if oname is given as NULL, this means the
+     --basename option has been given to objcopy. */
+  if (oname == NULL)
+    {
+      xlat_basename = TRUE;
+      return;
+    }
+
+  xlp = (struct xlat_list *) xmalloc (sizeof (struct xlat_list));
+  xlp->next = NULL;
+  if (xlat == NULL)
+    xlat = xltail = xlp;
+  else
+    {
+      xltail->next = xlp;
+      xltail = xlp;
+    }
+  xlp->old = oname;
+  xlp->newstr = nname;
+  xlp->olen = strlen (oname);
+  xlp->nlen = strlen (nname);
+}
+
+/* Try to translate a pathname. */
+static const char *
+debug_xlat_pathname (oname)
+     const char *oname;
+{
+  struct xlat_list *xlp;
+  char *cp;
+  size_t olen;
+
+  if (xlat_basename)
+    return bu_basename (oname);  
+
+  olen = strlen (oname);
+  for (xlp = xlat; xlp; xlp = xlp->next)
+    {
+      if (xlp->olen > olen)
+	/* This cannot be our turn. */
+	continue;
+      /* Since we have pre-computed all our length values to avoid
+	 repetitively computing them, just use memcmp() since it's
+	 faster than strcmp(). */
+      if (memcmp (xlp->old, oname, xlp->olen) == 0)
+	{
+	  cp = (char *) xmalloc (olen + xlp->nlen - xlp->olen + 1);
+	  memcpy (cp, xlp->newstr, xlp->nlen);
+	  memcpy (cp + xlp->nlen, oname + xlp->olen,
+		  olen - xlp->olen + 1);
+	  return cp;
+	}
+    }
+
+  /* Not found, pass the original name on. */
+  return oname;
 }

