+2014-06-26  Tom Tromey  <tromey@redhat.com>
+
+       * defs.h (generic_load): Update.
+       * m32r-rom.c (m32r_load_gen): Make "filename" const.
+       * monitor.c (monitor_load): Make "args" const.
+       * remote-m32r-sdi.c (m32r_load): Make "args" const.
+       * remote-mips.c (mips_load_srec, pmon_load_fast): Make "args"
+       const.
+       (mips_load): Make "file" const.
+       * remote-sim.c (gdbsim_load): Make "args" const.
+       * remote.c (remote_load): Make "name" const.
+       * symfile.c (generic_load): Make "args" const.
+       * target-delegates.c: Rebuild.
+       * target.c (target_load): Make "arg" const.
+       (debug_to_load): Make "args" const.
+       * target.h (struct target_ops) <to_load>: Make parameter const.
+       (target_load): Update.
+
 2014-06-26  Tom Tromey  <tromey@redhat.com>
 
        PR symtab/16902:
 
 extern void symbol_file_command (char *, int);
 
 /* * Remote targets may wish to use this as their load function.  */
-extern void generic_load (char *name, int from_tty);
+extern void generic_load (const char *name, int from_tty);
 
 /* * Report on STREAM the performance of memory transfer operation,
    such as 'load'.
 
 }
 
 static void
-m32r_load_gen (struct target_ops *self, char *filename, int from_tty)
+m32r_load_gen (struct target_ops *self, const char *filename, int from_tty)
 {
   generic_load (filename, from_tty);
 }
 
 /* monitor_load -- download a file.  */
 
 static void
-monitor_load (struct target_ops *self, char *args, int from_tty)
+monitor_load (struct target_ops *self, const char *args, int from_tty)
 {
   CORE_ADDR load_offset = 0;
   char **argv;
 
 }
 
 static void
-m32r_load (struct target_ops *self, char *args, int from_tty)
+m32r_load (struct target_ops *self, const char *args, int from_tty)
 {
-  struct cleanup *old_chain;
+  struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
   asection *section;
   bfd *pbfd;
   bfd_vma entry;
 
   while (*args != '\000')
     {
-      char *arg;
+      char *arg = extract_arg_const (&args);
 
-      args = skip_spaces (args);
-
-      arg = args;
-
-      while ((*args != '\000') && !isspace (*args))
-       args++;
-
-      if (*args != '\000')
-       *args++ = '\000';
+      if (arg == NULL)
+       break;
+      make_cleanup (xfree, arg);
 
       if (*arg != '-')
        filename = arg;
 
   pbfd = gdb_bfd_open (filename, gnutarget, -1);
   if (pbfd == NULL)
-    {
-      perror_with_name (filename);
-      return;
-    }
-  old_chain = make_cleanup_bfd_unref (pbfd);
+    perror_with_name (filename);
+  make_cleanup_bfd_unref (pbfd);
 
   if (!bfd_check_format (pbfd, bfd_object))
     error (_("\"%s\" is not an object file: %s"), filename,
 
 
 static void pmon_download (char *buffer, int length);
 
-static void pmon_load_fast (char *file);
-
-static void mips_load (struct target_ops *self, char *file, int from_tty);
+static void mips_load (struct target_ops *self, const char *file, int from_tty);
 
 static int mips_make_srec (char *buffer, int type, CORE_ADDR memaddr,
                           unsigned char *myaddr, int len);
 /*  Download a binary file by converting it to S records.  */
 
 static void
-mips_load_srec (char *args)
+mips_load_srec (const char *args)
 {
   bfd *abfd;
   asection *s;
    using the FastLoad format.  */
 
 static void
-pmon_load_fast (char *file)
+pmon_load_fast (const char *file)
 {
   bfd *abfd;
   asection *s;
 /* mips_load -- download a file.  */
 
 static void
-mips_load (struct target_ops *self, char *file, int from_tty)
+mips_load (struct target_ops *self, const char *file, int from_tty)
 {
   struct regcache *regcache;
 
 
 
 static void gdbsim_kill (struct target_ops *);
 
-static void gdbsim_load (struct target_ops *self, char *prog, int fromtty);
+static void gdbsim_load (struct target_ops *self, const char *prog,
+                        int fromtty);
 
 static void gdbsim_open (char *args, int from_tty);
 
    GDB's symbol tables to match.  */
 
 static void
-gdbsim_load (struct target_ops *self, char *args, int fromtty)
+gdbsim_load (struct target_ops *self, const char *args, int fromtty)
 {
   char **argv;
   const char *prog;
 
 /* Implementation of to_load.  */
 
 static void
-remote_load (struct target_ops *self, char *name, int from_tty)
+remote_load (struct target_ops *self, const char *name, int from_tty)
 {
   generic_load (name, from_tty);
 }
 
 }
 
 void
-generic_load (char *args, int from_tty)
+generic_load (const char *args, int from_tty)
 {
   bfd *loadfile_bfd;
   struct timeval start_time, end_time;
 
 }
 
 static void
-delegate_load (struct target_ops *self, char *arg1, int arg2)
+delegate_load (struct target_ops *self, const char *arg1, int arg2)
 {
   self = self->beneath;
   self->to_load (self, arg1, arg2);
 }
 
 static void
-tdefault_load (struct target_ops *self, char *arg1, int arg2)
+tdefault_load (struct target_ops *self, const char *arg1, int arg2)
 {
   tcomplain ();
 }
 
 
 static void debug_to_terminal_ours (struct target_ops *self);
 
-static void debug_to_load (struct target_ops *self, char *, int);
+static void debug_to_load (struct target_ops *self, const char *, int);
 
 static int debug_to_can_run (struct target_ops *self);
 
 }
 
 void
-target_load (char *arg, int from_tty)
+target_load (const char *arg, int from_tty)
 {
   target_dcache_invalidate ();
   (*current_target.to_load) (¤t_target, arg, from_tty);
 }
 
 static void
-debug_to_load (struct target_ops *self, char *args, int from_tty)
+debug_to_load (struct target_ops *self, const char *args, int from_tty)
 {
   debug_target.to_load (&debug_target, args, from_tty);
 
 
       TARGET_DEFAULT_FUNC (default_terminal_info);
     void (*to_kill) (struct target_ops *)
       TARGET_DEFAULT_NORETURN (noprocess ());
-    void (*to_load) (struct target_ops *, char *, int)
+    void (*to_load) (struct target_ops *, const char *, int)
       TARGET_DEFAULT_NORETURN (tcomplain ());
     /* Start an inferior process and set inferior_ptid to its pid.
        EXEC_FILE is the file to run.
    sections.  The target may define switches, or other non-switch
    arguments, as it pleases.  */
 
-extern void target_load (char *arg, int from_tty);
+extern void target_load (const char *arg, int from_tty);
 
 /* Some targets (such as ttrace-based HPUX) don't allow us to request
    notification of inferior events such as fork and vork immediately