* gdb/exec.c (exec_set_section_address): Always update the
	section's address.
	* gdb/objfiles.c (objfile_relocate): Also relocate the
	target sections table.
	* gdb/Makefile.in (objfiles.o): Update.

	* gdb/remote.c (remote_xfer_partial): Fail if the target is not
	running.
diff --git a/ChangeLog.csl b/ChangeLog.csl
index 0958cc2..a34a21d 100644
--- a/ChangeLog.csl
+++ b/ChangeLog.csl
@@ -1,5 +1,16 @@
 2006-06-01  Daniel Jacobowitz  <dan@codesourcery.com>
 
+	* gdb/exec.c (exec_set_section_address): Always update the
+	section's address.
+	* gdb/objfiles.c (objfile_relocate): Also relocate the
+	target sections table.
+	* gdb/Makefile.in (objfiles.o): Update.
+
+	* gdb/remote.c (remote_xfer_partial): Fail if the target is not
+	running.
+
+2006-06-01  Daniel Jacobowitz  <dan@codesourcery.com>
+
 	* gdb/remote.c (remote_download_command): Use FILEIO_O_TRUNC.
 
 2006-06-01  Daniel Jacobowitz  <dan@codesourcery.com>
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index c709939..c3f8b4a 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -2417,7 +2417,7 @@
 	$(objfiles_h) $(gdb_string_h) $(target_h) $(gdbcore_h) $(gdbcmd_h) \
 	$(frame_h) $(gdb_regex_h) $(regcache_h) $(block_h) $(infcall_h) \
 	$(valprint_h) $(gdb_assert_h)
-objfiles.o: objfiles.c $(defs_h) $(bfd_h) $(symtab_h) $(symfile_h) \
+objfiles.o: objfiles.c $(defs_h) $(bfd_h) $(symtab_h) $(symfile_h) $(exec_h) \
 	$(objfiles_h) $(gdb_stabs_h) $(target_h) $(bcache_h) $(mdebugread_h) \
 	$(gdb_assert_h) $(gdb_stat_h) $(gdb_obstack_h) $(gdb_string_h) \
 	$(hashtab_h) $(breakpoint_h) $(block_h) $(dictionary_h)
diff --git a/gdb/exec.c b/gdb/exec.c
index a919442..ebd534c 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -674,12 +674,19 @@
 
   for (p = exec_ops.to_sections; p < exec_ops.to_sections_end; p++)
     {
+      /* FIXME drow/2006-06-01: This used to say "&& p->addr == 0".
+	 But that messes up multiple qOffsets responses relocating an
+	 executable; the previous relocated value doesn't matter.
+	 Removing it makes qOffsets attempt to override "set section".
+	 There should be a user-specified flag - or else we should
+	 just use the objfile's sections, or something like that.
+
+	 This deserves more thought before a merge to mainline.  */
       if (strcmp (filename, p->bfd->filename) == 0
-	  && index == p->the_bfd_section->index
-	  && p->addr == 0)
+	  && index == p->the_bfd_section->index)
 	{
+	  p->endaddr += address - p->addr;
 	  p->addr = address;
-	  p->endaddr += address;
 	}
     }
 }
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 3419c6d..bee81a6 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -27,6 +27,7 @@
 
 #include "defs.h"
 #include "bfd.h"		/* Binary File Description */
+#include "exec.h"
 #include "symtab.h"
 #include "symfile.h"
 #include "objfiles.h"
@@ -652,6 +653,11 @@
 	
 	s->addr += ANOFFSET (delta, idx);
 	s->endaddr += ANOFFSET (delta, idx);
+
+	/* FIXME: The exec file uses a completely different table from
+	   any objfile, unfortunately.  A nice improvement would
+	   be to unify those.  */
+	exec_set_section_address (bfd_get_filename (abfd), idx, s->addr);
       }
   }
 
diff --git a/gdb/remote.c b/gdb/remote.c
index a1341d7..70fb27e 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -5652,6 +5652,12 @@
       int xfered;
       errno = 0;
 
+      /* If the remote target is connected but not running, we should
+	 pass this request down to a lower stratum (e.g. the executable
+	 file).  */
+      if (!target_has_execution)
+	return 0;
+
       if (writebuf != NULL)
 	{
 	  void *buffer = xmalloc (len);