2007-06-13 Markus Deuling <deuling@de.ibm.com>
[deliverable/binutils-gdb.git] / gdb / exec.c
index 31dd636d4aa9f4cddc09155972d8f4581b7e8446..4e68d1cf4435cd61321371299753be6a4016532d 100644 (file)
@@ -1,8 +1,7 @@
 /* Work with executable files, for GDB. 
 
-   Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
-   1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation,
-   Inc.
+   Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
+   1998, 1999, 2000, 2001, 2002, 2003, 2007 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -42,9 +41,6 @@
 
 #include <ctype.h>
 #include "gdb_stat.h"
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
 
 #include "xcoffsolib.h"
 
@@ -62,8 +58,6 @@ static void set_section_command (char *, int);
 
 static void exec_files_info (struct target_ops *);
 
-static int ignore (CORE_ADDR, bfd_byte *);
-
 static void init_exec_ops (void);
 
 void _initialize_exec (void);
@@ -90,7 +84,7 @@ show_write_files (struct ui_file *file, int from_tty,
 
 struct vmap *vmap;
 
-void
+static void
 exec_open (char *args, int from_tty)
 {
   target_preopen (from_tty);
@@ -193,6 +187,8 @@ exec_file_attach (char *filename, int from_tty)
     {
       if (from_tty)
         printf_unfiltered (_("No executable file now.\n"));
+
+      set_gdbarch_from_file (NULL);
     }
   else
     {
@@ -291,8 +287,11 @@ exec_file_command (char *args, int from_tty)
 {
   char **argv;
   char *filename;
-  
-  target_preopen (from_tty);
+
+  if (from_tty && target_has_execution
+      && !query (_("A program is being debugged already.\n"
+                  "Are you sure you want to change the file? ")))
+    error (_("File not changed."));
 
   if (args)
     {
@@ -346,11 +345,15 @@ add_to_section_table (bfd *abfd, struct bfd_section *asect,
   struct section_table **table_pp = (struct section_table **) table_pp_char;
   flagword aflag;
 
+  /* Check the section flags, but do not discard zero-length sections, since
+     some symbols may still be attached to this section.  For instance, we
+     encountered on sparc-solaris 2.10 a shared library with an empty .bss
+     section to which a symbol named "_end" was attached.  The address
+     of this symbol still needs to be relocated.  */
   aflag = bfd_get_section_flags (abfd, asect);
   if (!(aflag & SEC_ALLOC))
     return;
-  if (0 == bfd_section_size (abfd, asect))
-    return;
+
   (*table_pp)->bfd = abfd;
   (*table_pp)->the_bfd_section = asect;
   (*table_pp)->addr = bfd_section_vma (abfd, asect);
@@ -529,8 +532,8 @@ void
 print_section_info (struct target_ops *t, bfd *abfd)
 {
   struct section_table *p;
-  /* FIXME: 16 is not wide enough when TARGET_ADDR_BIT > 64.  */
-  int wid = TARGET_ADDR_BIT <= 32 ? 8 : 16;
+  /* FIXME: 16 is not wide enough when gdbarch_addr_bit > 64.  */
+  int wid = gdbarch_addr_bit (current_gdbarch) <= 32 ? 8 : 16;
 
   printf_filtered ("\t`%s', ", bfd_get_filename (abfd));
   wrap_here ("        ");
@@ -694,7 +697,7 @@ exec_set_section_address (const char *filename, int index, CORE_ADDR address)
    breakpoint_init_inferior).  */
 
 static int
-ignore (CORE_ADDR addr, bfd_byte *contents)
+ignore (struct bp_target_info *bp_tgt)
 {
   return 0;
 }
This page took 0.024919 seconds and 4 git commands to generate.