* sparcl-tdep.c (send_resp, sparclite_serial_start,
authorMark Alexander <marka@cygnus>
Wed, 28 Oct 1998 16:08:02 +0000 (16:08 +0000)
committerMark Alexander <marka@cygnus>
Wed, 28 Oct 1998 16:08:02 +0000 (16:08 +0000)
sparclite_serial_write): Use remote_timeout instead of hardcoded
two second timeout.
(download): Fix adjustment of a.out load addresses.

gdb/ChangeLog
gdb/sparcl-tdep.c

index 1aa1f21f8ed072d044d24e15682d2332500e0084..40e6fc16f4c61bae9ed4689912cf1f7d5753a7d3 100644 (file)
@@ -1,3 +1,10 @@
+Wed Oct 28 08:01:38 1998  Mark Alexander  <marka@cygnus.com>
+
+       * sparcl-tdep.c (send_resp, sparclite_serial_start,
+       sparclite_serial_write): Use remote_timeout instead of hardcoded
+       two second timeout.
+       (download): Fix adjustment of a.out load addresses.
+
 Wed Oct 28 12:32:58 1998  Andrew Cagney  <cagney@b1.cygnus.com>
 
        * configure.in (--enable-build-warnings): Finish rename from
index e50fdce46e6790be64dc22df99be44e4503e86e9..6c349384d4d4705881ee0282108fd3de25ef0f75 100644 (file)
@@ -355,7 +355,7 @@ send_resp (desc, c)
      char c;
 {
   debug_serial_write (desc, &c, 1);
-  return readchar (desc, 2);
+  return readchar (desc, remote_timeout);
 }
 
 static void
@@ -623,15 +623,42 @@ download (target_name, args, from_tty, write_routine, start_routine)
     {
       if (bfd_get_section_flags (pbfd, section) & SEC_LOAD)
        {
-         bfd_vma section_address;
+         bfd_vma       section_address;
          bfd_size_type section_size;
-         file_ptr fptr;
+         file_ptr      fptr;
+         const char   *section_name;
+
+         section_name = bfd_get_section_name(pbfd, section);
 
          section_address = bfd_get_section_vma (pbfd, section);
+
          /* Adjust sections from a.out files, since they don't
             carry their addresses with.  */
          if (bfd_get_flavour (pbfd) == bfd_target_aout_flavour)
-           section_address += LOAD_ADDRESS;
+           {
+             if (strcmp (section_name, ".text") == 0)
+               section_address = bfd_get_start_address (pbfd);
+             else if (strcmp (section_name, ".data") == 0)
+               {
+                 /* Read the first 8 bytes of the data section.
+                    There should be the string 'DaTa' followed by
+                    a word containing the actual section address. */
+                 struct data_marker
+                 {
+                   char signature[4];  /* 'DaTa' */
+                   unsigned char sdata[4];     /* &sdata */
+                 } marker;
+                 bfd_get_section_contents (pbfd, section, &marker, 0,
+                                           sizeof (marker));
+                 if (strncmp (marker.signature, "DaTa", 4) == 0)
+                   {
+                     if (TARGET_BYTE_ORDER == BIG_ENDIAN)
+                       section_address = bfd_getb32 (marker.sdata);
+                     else
+                       section_address = bfd_getl32 (marker.sdata);
+                   }
+               }
+           }
 
          section_size = bfd_get_section_size_before_reloc (section);
 
@@ -691,7 +718,7 @@ sparclite_serial_start (entry)
   store_unsigned_integer (buffer + 1, 4, entry);
 
   debug_serial_write (remote_desc, buffer, 1 + 4);
-  i = readchar (remote_desc, 2);
+  i = readchar (remote_desc, remote_timeout);
   if (i != 0x55)
     error ("Can't start SparcLite.  Error code %d\n", i);
 }
@@ -723,7 +750,7 @@ sparclite_serial_write (from_bfd, from_sec, from_addr, to_addr, len)
     error ("Bad response from load command (0x%x)", i);
 
   debug_serial_write (remote_desc, buffer, 4 + 4 + len);
-  i = readchar (remote_desc, 2);
+  i = readchar (remote_desc, remote_timeout);
 
   if (i != checksum)
     error ("Bad checksum from load command (0x%x)", i);