/* 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.
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include "target.h"
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;
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);
/* 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);
{
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