Add detection of IMB and IMBRange SWIs.
[deliverable/binutils-gdb.git] / gdb / exec.c
index c20e2fcaefb16a453c9ea2930de2b7ee0fd4122f..d24c4b49bff0e2a873c12a4642a569af15673283 100644 (file)
@@ -64,8 +64,16 @@ static void bfdsec_to_vmap PARAMS ((bfd *, sec_ptr, PTR));
 
 static int ignore PARAMS ((CORE_ADDR, char *));
 
+static void init_exec_ops PARAMS ((void));
+
+void _initialize_exec PARAMS ((void));
+
 extern int info_verbose;
 
+/* The target vector for executable files.  */
+
+struct target_ops exec_ops;
+
 /* The Binary File Descriptor handle for the executable file.  */
 
 bfd *exec_bfd = NULL;
@@ -84,10 +92,6 @@ CORE_ADDR text_end   = 0;
 
 struct vmap *vmap;
 
-/* Forward decl */
-
-extern struct target_ops exec_ops;
-
 /* ARGSUSED */
 static void
 exec_close (quitting)
@@ -187,7 +191,7 @@ exec_file_attach (args, from_tty)
       if (argv == NULL)
        nomem (0);
 
-      make_cleanup ((make_cleanup_func) freeargv, (char *) argv);
+      make_cleanup_freeargv (argv);
 
       for (; (*argv != NULL) && (**argv == '-'); argv++) {;}
       if (*argv == NULL)
@@ -637,6 +641,44 @@ exec_files_info (t)
     }
 }
 
+/* msnyder 5/21/99:
+   exec_set_section_offsets sets the offsets of all the sections
+   in the exec objfile.  */
+
+void
+exec_set_section_offsets (text_off, data_off, bss_off)
+     bfd_signed_vma text_off;
+     bfd_signed_vma data_off;
+     bfd_signed_vma bss_off;
+{
+  struct section_table *sect;
+  for (sect = exec_ops.to_sections; 
+       sect < exec_ops.to_sections_end; 
+       sect++)
+    {
+      flagword flags;
+
+      flags = bfd_get_section_flags (exec_bfd, sect->the_bfd_section);
+
+      if (flags & SEC_CODE)
+       {
+         sect->addr    += text_off;
+         sect->endaddr += text_off;
+       }
+      else if (flags & (SEC_DATA | SEC_LOAD))
+       {
+         sect->addr    += data_off;
+         sect->endaddr += data_off;
+       }
+      else if (flags & SEC_ALLOC)
+       {
+         sect->addr    += bss_off;
+         sect->endaddr += bss_off;
+       }
+    }
+}
+
 static void
 set_section_command (args, from_tty)
      char *args;
@@ -678,7 +720,8 @@ set_section_command (args, from_tty)
 }
 
 /* If mourn is being called in all the right places, this could be say
-   `gdb internal error' (since generic_mourn calls breakpoint_init_inferior).  */
+   `gdb internal error' (since generic_mourn calls
+   breakpoint_init_inferior).  */
 
 static int
 ignore (addr, contents)
@@ -688,81 +731,39 @@ ignore (addr, contents)
   return 0;
 }
 
-struct target_ops exec_ops = {
-  "exec",                      /* to_shortname */
-  "Local exec file",           /* to_longname */
-  "Use an executable file as a target.\n\
-Specify the filename of the executable file.", /* to_doc */
-  exec_file_command,           /* to_open */
-  exec_close,                  /* to_close */
-  find_default_attach,         /* to_attach */
-  NULL,                         /* to_post_attach */
-  find_default_require_attach, /* to_require_attach */
-  0,                           /* to_detach */
-  find_default_require_detach, /* to_require_detach */
-  0,                           /* to_resume */
-  0,                           /* to_wait */
-  NULL,                         /* to_post_wait */
-  0,                           /* to_fetch_registers */
-  0,                           /* to_store_registers */
-  0,                           /* to_prepare_to_store */
-  xfer_memory,                 /* to_xfer_memory */
-  exec_files_info,             /* to_files_info */
-  ignore,                      /* to_insert_breakpoint */
-  ignore,                      /* to_remove_breakpoint */
-  0,                           /* to_terminal_init */
-  0,                           /* to_terminal_inferior */
-  0,                           /* to_terminal_ours_for_output */
-  0,                           /* to_terminal_ours */
-  0,                           /* to_terminal_info */
-  0,                           /* to_kill */
-  0,                           /* to_load */
-  0,                           /* to_lookup_symbol */
-  find_default_create_inferior,        /* to_create_inferior */
-  NULL,                         /* to_post_startup_inferior */
-  NULL,                         /* to_acknowledge_created_inferior */
-  find_default_clone_and_follow_inferior,     /* to_clone_and_follow_inferior */
-  NULL,                         /* to_post_follow_inferior_by_clone */
-  NULL,                         /* to_insert_fork_catchpoint */
-  NULL,                         /* to_remove_fork_catchpoint */
-  NULL,                         /* to_insert_vfork_catchpoint */
-  NULL,                         /* to_remove_vfork_catchpoint */
-  NULL,                         /* to_has_forked */
-  NULL,                         /* to_has_vforked */
-  NULL,                         /* to_can_follow_vfork_prior_to_exec */
-  NULL,                         /* to_post_follow_vfork */
-  NULL,                         /* to_insert_exec_catchpoint */
-  NULL,                         /* to_remove_exec_catchpoint */
-  NULL,                         /* to_has_execd */
-  NULL,                         /* to_reported_exec_events_per_exec_call */
-  NULL,                         /* to_has_syscall_event */
-  NULL,                         /* to_has_exited */
-  0,                           /* to_mourn_inferior */
-  0,                           /* to_can_run */
-  0,                           /* to_notice_signals */
-  0,                           /* to_thread_alive */
-  0,                           /* to_stop */
-  NULL,                         /* to_enable_exception_callback */
-  NULL,                         /* to_get_current_exception_event */
-  NULL,                         /* to_pid_to_exec_file */
-  NULL,                         /* to_core_file_to_sym_file */
-  file_stratum,                        /* to_stratum */
-  0,                           /* to_next */
-  0,                           /* to_has_all_memory */
-  1,                           /* to_has_memory */
-  0,                           /* to_has_stack */
-  0,                           /* to_has_registers */
-  0,                           /* to_has_execution */
-  0,                           /* to_sections */
-  0,                           /* to_sections_end */
-  OPS_MAGIC,                   /* to_magic */
-};
+/* Fill in the exec file target vector.  Very few entries need to be
+   defined.  */
+
+void
+init_exec_ops ()
+{
+  exec_ops.to_shortname = "exec";
+  exec_ops.to_longname = "Local exec file";
+  exec_ops.to_doc = "Use an executable file as a target.\n\
+Specify the filename of the executable file.";
+  exec_ops.to_open = exec_file_command;
+  exec_ops.to_close = exec_close;
+  exec_ops.to_attach = find_default_attach;
+  exec_ops.to_require_attach = find_default_require_attach;
+  exec_ops.to_require_detach = find_default_require_detach;
+  exec_ops.to_xfer_memory = xfer_memory;
+  exec_ops.to_files_info = exec_files_info;
+  exec_ops.to_insert_breakpoint = ignore;
+  exec_ops.to_remove_breakpoint = ignore;
+  exec_ops.to_create_inferior = find_default_create_inferior;
+  exec_ops.to_clone_and_follow_inferior = find_default_clone_and_follow_inferior;
+  exec_ops.to_stratum = file_stratum;
+  exec_ops.to_has_memory = 1;
+  exec_ops.to_magic = OPS_MAGIC;       
+}
 
 void
-_initialize_exec()
+_initialize_exec ()
 {
   struct cmd_list_element *c;
 
+  init_exec_ops ();
+
   if (!dbx_commands)
     {
       c = add_cmd ("file", class_files, file_command,
This page took 0.026521 seconds and 4 git commands to generate.