Add support to GDB for the Renesas rl78 architecture.
[external/binutils.git] / gas / remap.c
index ae07896..ae9b9dd 100644 (file)
@@ -19,6 +19,7 @@
    02110-1301, USA.  */
 
 #include "as.h"
+#include "filenames.h"
 
 /* Structure recording the mapping from source file and directory
    names at compile time to those to be embedded in debug
@@ -52,7 +53,7 @@ add_debug_prefix_map (const char *arg)
       as_fatal (_("invalid argument '%s' to -fdebug-prefix-map"), arg);
       return;
     }
-  map = xmalloc (sizeof (debug_prefix_map));
+  map = (struct debug_prefix_map *) xmalloc (sizeof (debug_prefix_map));
   o = xstrdup (arg);
   map->old_prefix = o;
   map->old_len = p - arg;
@@ -64,8 +65,9 @@ add_debug_prefix_map (const char *arg)
   debug_prefix_maps = map;
 }
 
-/* Perform user-specified mapping of debug filename prefixes.  Return
-   the new name corresponding to FILENAME.  */
+/* Perform user-specified mapping of debug filename prefixes.  Returns
+   a newly allocated buffer containing the name corresponding to FILENAME.
+   It is the caller's responsibility to free the buffer.  */
 
 const char *
 remap_debug_filename (const char *filename)
@@ -76,10 +78,10 @@ remap_debug_filename (const char *filename)
   size_t name_len;
 
   for (map = debug_prefix_maps; map; map = map->next)
-    if (strncmp (filename, map->old_prefix, map->old_len) == 0)
+    if (filename_ncmp (filename, map->old_prefix, map->old_len) == 0)
       break;
   if (!map)
-    return filename;
+    return xstrdup (filename);
   name = filename + map->old_len;
   name_len = strlen (name) + 1;
   s = (char *) alloca (name_len + map->new_len);