Name change (It's hitacho micro systems, not hitachi data systems)
[deliverable/binutils-gdb.git] / gdb / exec.c
index c478e9cc5d169523028d6cb806d84139ca83d459..33e5e72b1a794e45d05425603336c2ce65dd820e 100644 (file)
@@ -1,5 +1,5 @@
 /* Work with executable files, for GDB. 
-   Copyright (C) 1988, 1989 Free Software Foundation, Inc.
+   Copyright 1988, 1989, 1991 Free Software Foundation, Inc.
 
 This file is part of GDB.
 
@@ -19,7 +19,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #include <stdio.h>
 #include "defs.h"
-#include "param.h"
 #include "frame.h"
 #include "inferior.h"
 #include "target.h"
@@ -50,6 +49,13 @@ bfd *exec_bfd = NULL;
 
 int write_files = 0;
 
+/* Text start and end addresses (KLUDGE) if needed */
+
+#ifdef NEED_TEXT_START_END
+CORE_ADDR text_start = 0;
+CORE_ADDR text_end   = 0;
+#endif
+
 /* Forward decl */
 
 extern struct target_ops exec_ops;
@@ -104,39 +110,26 @@ exec_file_command (filename, from_tty)
        error ("\"%s\": not in executable format: %s.",
               scratch_pathname, bfd_errmsg (bfd_error));
 
-#if FIXME
-/* This code needs to be incorporated into BFD */
-#ifdef COFF_ENCAPSULATE
-       /* If we have a coff header, it can give us better values for
-          text_start and exec_data_start.  This is particularly useful
-          for remote debugging of embedded systems.  */
-       if (N_FLAGS(exec_aouthdr) & N_FLAGS_COFF_ENCAPSULATE)
-       {
-               struct coffheader ch;
-               int val;
-               val = lseek (execchan, -(sizeof (AOUTHDR) + sizeof (ch)), 1);
-               if (val == -1)
-                       perror_with_name (filename);
-               val = myread (execchan, &ch, sizeof (ch));
-               if (val < 0)
-                       perror_with_name (filename);
-               text_start = ch.text_start;
-               exec_data_start = ch.data_start;
-       } else
-#endif
-              {
-               text_start =
-                 IS_OBJECT_FILE (exec_aouthdr) ? 0 : N_TXTADDR (exec_aouthdr);
-               exec_data_start = IS_OBJECT_FILE (exec_aouthdr)
-                 ? exec_aouthdr.a_text : N_DATADDR (exec_aouthdr);
-       }
-#endif FIXME
-
       if (build_section_table (exec_bfd, &exec_ops.sections,
                                &exec_ops.sections_end))
        error ("Can't find the file sections in `%s': %s", 
                exec_bfd->filename, bfd_errmsg (bfd_error));
 
+#ifdef NEED_TEXT_START_END
+      /* This is a KLUDGE (FIXME) because a few places in a few ports
+        (29K springs to mind) need this info for now.  */
+      {
+       struct section_table *p;
+       for (p = exec_ops.sections; p < exec_ops.sections_end; p++)
+         if (!strcmp (".text", bfd_section_name (p->bfd, p->sec_ptr)))
+           {
+             text_start = p->addr;
+             text_end   = p->endaddr;
+             break;
+           }
+      }
+#endif
+
       validate_files ();
 
       push_target (&exec_ops);
@@ -182,6 +175,8 @@ add_to_section_table (abfd, asect, table_pp_char)
   /* FIXME, we need to handle BSS segment here...it alloc's but doesn't load */
   if (!(aflag & SEC_LOAD))
     return;
+  if (0 == bfd_section_size (abfd, asect))
+    return;
   (*table_pp)->bfd = abfd;
   (*table_pp)->sec_ptr = asect;
   (*table_pp)->addr = bfd_section_vma (abfd, asect);
@@ -299,12 +294,16 @@ exec_files_info ()
 {
   struct section_table *p;
 
-  printf ("\tExecutable file `%s'.\n", bfd_get_filename(exec_bfd));
+  printf_filtered ("\t`%s', ", bfd_get_filename(exec_bfd));
+  wrap_here ("        ");
+  printf_filtered ("file type %s.\n", bfd_get_target(exec_bfd));
 
-  for (p = exec_ops.sections; p < exec_ops.sections_end; p++)
-    printf("\texecutable from 0x%08x to 0x%08x is %s\n",
-       p->addr, p->endaddr,
+  for (p = exec_ops.sections; p < exec_ops.sections_end; p++) {
+    printf_filtered ("\t%s", local_hex_string_custom (p->addr, "08"));
+    printf_filtered (" - %s is %s\n",
+       local_hex_string_custom (p->endaddr, "08"),
        bfd_section_name (exec_bfd, p->sec_ptr));
+  }
 }
 
 static void
This page took 0.024719 seconds and 4 git commands to generate.