section_size = bfd_get_section_size_before_reloc (section);
section_size = bfd_get_section_size (section);
e7000_load (char *args, int from_tty){  struct cleanup *old_chain;  asection *section;  bfd *pbfd;  bfd_vma entry;#define WRITESIZE 0x1000  char buf[2 + 4 + 4 + WRITESIZE];	/* `DT' + <addr> + <len> + <data> */  char *filename;  int quiet;  int nostart;  time_t start_time, end_time;	/* Start and end times of download */  unsigned long data_count;	/* Number of bytes transferred to memory */  int oldtimeout = timeout;  timeout = remote_timeout;  /* FIXME! change test to test for type of download */  if (!using_tcp)    {      generic_load (args, from_tty);      return;    }  /* for direct tcp connections, we can do a fast binary download */  buf[0] = 'D';  buf[1] = 'T';  quiet = 0;  nostart = 0;  filename = NULL;  while (*args != '\000')    {      char *arg;      while (isspace (*args))	args++;      arg = args;      while ((*args != '\000') && !isspace (*args))	args++;      if (*args != '\000')	*args++ = '\000';      if (*arg != '-')	filename = arg;      else if (strncmp (arg, "-quiet", strlen (arg)) == 0)	quiet = 1;      else if (strncmp (arg, "-nostart", strlen (arg)) == 0)	nostart = 1;      else	error ("unknown option `%s'", arg);    }  if (!filename)    filename = get_exec_file (1);  pbfd = bfd_openr (filename, gnutarget);  if (pbfd == NULL)    {      perror_with_name (filename);      return;    }  old_chain = make_cleanup_bfd_close (pbfd);  if (!bfd_check_format (pbfd, bfd_object))    error ("\"%s\" is not an object file: %s", filename,	   bfd_errmsg (bfd_get_error ()));  start_time = time (NULL);  data_count = 0;  puts_e7000debug ("mw\r");  expect ("\nOK");  for (section = pbfd->sections; section; section = section->next)    {      if (bfd_get_section_flags (pbfd, section) & SEC_LOAD)	{	  bfd_vma section_address;	  bfd_size_type section_size;	  file_ptr fptr;	  section_address = bfd_get_section_vma (pbfd, section);	  section_size = bfd_get_section_size_before_reloc (section);	  if (!quiet)	    printf_filtered ("[Loading section %s at 0x%s (%s bytes)]\n",			     bfd_get_section_name (pbfd, section),			     paddr_nz (section_address),			     paddr_u (section_size));	  fptr = 0;	  data_count += section_size;	  while (section_size > 0)	    {	      int count;	      static char inds[] = "|/-\\";	      static int k = 0;	      QUIT;	      count = min (section_size, WRITESIZE);	      buf[2] = section_address >> 24;	      buf[3] = section_address >> 16;	      buf[4] = section_address >> 8;	      buf[5] = section_address;	      buf[6] = count >> 24;	      buf[7] = count >> 16;	      buf[8] = count >> 8;	      buf[9] = count;	      bfd_get_section_contents (pbfd, section, buf + 10, fptr, count);	      if (serial_write (e7000_desc, buf, count + 10))		fprintf_unfiltered (gdb_stderr,				    "e7000_load: serial_write failed: %s\n",				    safe_strerror (errno));	      expect ("OK");	      if (!quiet)		{		  printf_unfiltered ("\r%c", inds[k++ % 4]);		  gdb_flush (gdb_stdout);		}	      section_address += count;	      fptr += count;	      section_size -= count;	    }	}    }  write_e7000 ("ED");  expect_prompt ();  end_time = time (NULL);/* Finally, make the PC point at the start address */  if (exec_bfd)    write_pc (bfd_get_start_address (exec_bfd));  inferior_ptid = null_ptid;	/* No process now *//* This is necessary because many things were based on the PC at the time that   we attached to the monitor, which is no longer valid now that we have loaded   new code (and just changed the PC).  Another way to do this might be to call   normal_stop, except that the stack may not be valid, and things would get   horribly confused... */  clear_symtab_users ();  if (!nostart)    {      entry = bfd_get_start_address (pbfd);      if (!quiet)	printf_unfiltered ("[Starting %s at 0x%s]\n", filename, paddr_nz (entry));/*      start_routine (entry); */    }  report_transfer_performance (data_count, start_time, end_time);  do_cleanups (old_chain);  timeout = oldtimeout;}