* main.c (main): Remove calls to {pre,post}_add_symbol_hooks.
[external/binutils.git] / gdb / exec.c
1 /* Work with executable files, for GDB. 
2    Copyright 1988, 1989, 1991, 1992, 1993, 1994, 1997
3              Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
20
21 #include "defs.h"
22 #include "frame.h"
23 #include "inferior.h"
24 #include "target.h"
25 #include "gdbcmd.h"
26 #include "language.h"
27 #include "symfile.h"
28 #include "objfiles.h"
29
30 #ifdef USG
31 #include <sys/types.h>
32 #endif
33
34 #include <fcntl.h>
35 #include "gdb_string.h"
36
37 #include "gdbcore.h"
38
39 #include <ctype.h>
40 #include "gdb_stat.h"
41 #ifndef O_BINARY
42 #define O_BINARY 0
43 #endif
44
45 #include "xcoffsolib.h"
46
47 struct vmap *map_vmap PARAMS ((bfd *, bfd *));
48
49 void (*file_changed_hook) PARAMS ((char *));
50
51 /* Prototypes for local functions */
52
53 static void add_to_section_table PARAMS ((bfd *, sec_ptr, PTR));
54
55 static void exec_close PARAMS ((int));
56
57 static void file_command PARAMS ((char *, int));
58
59 static void set_section_command PARAMS ((char *, int));
60
61 static void exec_files_info PARAMS ((struct target_ops *));
62
63 static void bfdsec_to_vmap PARAMS ((bfd *, sec_ptr, PTR));
64
65 static int ignore PARAMS ((CORE_ADDR, char *));
66
67 extern int info_verbose;
68
69 /* The Binary File Descriptor handle for the executable file.  */
70
71 bfd *exec_bfd = NULL;
72
73 /* Whether to open exec and core files read-only or read-write.  */
74
75 int write_files = 0;
76
77 /* Text start and end addresses (KLUDGE) if needed */
78
79 #ifdef NEED_TEXT_START_END
80 CORE_ADDR text_start = 0;
81 CORE_ADDR text_end   = 0;
82 #endif
83
84 struct vmap *vmap;
85
86 /* Forward decl */
87
88 extern struct target_ops exec_ops;
89
90 /* ARGSUSED */
91 static void
92 exec_close (quitting)
93      int quitting;
94 {
95   int need_symtab_cleanup = 0;
96   struct vmap *vp, *nxt;
97   
98   for (nxt = vmap; nxt != NULL; )
99     {
100       vp = nxt;
101       nxt = vp->nxt;
102
103       /* if there is an objfile associated with this bfd,
104          free_objfile() will do proper cleanup of objfile *and* bfd. */
105                    
106       if (vp->objfile)
107         {
108           free_objfile (vp->objfile);
109           need_symtab_cleanup = 1;
110         }
111       else if (vp->bfd != exec_bfd)
112         /* FIXME-leak: We should be freeing vp->name too, I think.  */
113         if (!bfd_close (vp->bfd))
114           warning ("cannot close \"%s\": %s",
115                    vp->name, bfd_errmsg (bfd_get_error ()));
116
117       /* FIXME: This routine is #if 0'd in symfile.c.  What should we
118          be doing here?  Should we just free everything in
119          vp->objfile->symtabs?  Should free_objfile do that?
120          FIXME-as-well: free_objfile already free'd vp->name, so it isn't
121          valid here.  */
122       free_named_symtabs (vp->name);
123       free (vp);
124     }
125
126   vmap = NULL;
127
128   if (exec_bfd)
129     {
130       char *name = bfd_get_filename (exec_bfd);
131
132       if (!bfd_close (exec_bfd))
133         warning ("cannot close \"%s\": %s",
134                  name, bfd_errmsg (bfd_get_error ()));
135       free (name);
136       exec_bfd = NULL;
137     }
138
139   if (exec_ops.to_sections)
140     {
141       free ((PTR)exec_ops.to_sections);
142       exec_ops.to_sections = NULL;
143       exec_ops.to_sections_end = NULL;
144     }
145 }
146
147 /*  Process the first arg in ARGS as the new exec file.
148
149     Note that we have to explicitly ignore additional args, since we can
150     be called from file_command(), which also calls symbol_file_command()
151     which can take multiple args. */
152
153 void
154 exec_file_command (args, from_tty)
155      char *args;
156      int from_tty;
157 {
158   char **argv;
159   char *filename;
160
161   target_preopen (from_tty);
162
163   /* Remove any previous exec file.  */
164   unpush_target (&exec_ops);
165
166   /* Now open and digest the file the user requested, if any.  */
167
168   if (args)
169     {
170       char *scratch_pathname;
171       int scratch_chan;
172       
173       /* Scan through the args and pick up the first non option arg
174          as the filename.  */
175
176       argv = buildargv (args);
177       if (argv == NULL)
178         nomem (0);
179
180       make_cleanup (freeargv, (char *) argv);
181
182       for (; (*argv != NULL) && (**argv == '-'); argv++) {;}
183       if (*argv == NULL)
184         error ("no exec file name was specified");
185
186       filename = tilde_expand (*argv);
187       make_cleanup (free, filename);
188       
189       scratch_chan = openp (getenv ("PATH"), 1, filename, 
190                             write_files? O_RDWR|O_BINARY: O_RDONLY|O_BINARY, 0,
191                             &scratch_pathname);
192 #if defined(__GO32__) || defined(_WIN32)
193       if (scratch_chan < 0)
194       {
195         char *exename = alloca (strlen (filename) + 5);
196         strcat (strcpy (exename, filename), ".exe");
197         scratch_chan = openp (getenv ("PATH"), 1, exename, write_files ?
198                 O_RDWR|O_BINARY : O_RDONLY|O_BINARY, 0, &scratch_pathname);
199       }
200 #endif
201       if (scratch_chan < 0)
202         perror_with_name (filename);
203       exec_bfd = bfd_fdopenr (scratch_pathname, gnutarget, scratch_chan);
204
205       if (!exec_bfd)
206         error ("\"%s\": could not open as an executable file: %s",
207                scratch_pathname, bfd_errmsg (bfd_get_error ()));
208
209       /* At this point, scratch_pathname and exec_bfd->name both point to the
210          same malloc'd string.  However exec_close() will attempt to free it
211          via the exec_bfd->name pointer, so we need to make another copy and
212          leave exec_bfd as the new owner of the original copy. */
213       scratch_pathname = strdup (scratch_pathname);
214       make_cleanup (free, scratch_pathname);
215       
216       if (!bfd_check_format (exec_bfd, bfd_object))
217         {
218           /* Make sure to close exec_bfd, or else "run" might try to use
219              it.  */
220           exec_close (0);
221           error ("\"%s\": not in executable format: %s",
222                  scratch_pathname, bfd_errmsg (bfd_get_error ()));
223         }
224
225       /* FIXME - This should only be run for RS6000, but the ifdef is a poor
226          way to accomplish.  */
227 #ifdef IBM6000_TARGET
228       /* Setup initial vmap. */
229
230       map_vmap (exec_bfd, 0);
231       if (vmap == NULL)
232         {
233           /* Make sure to close exec_bfd, or else "run" might try to use
234              it.  */
235           exec_close (0);
236           error ("\"%s\": can't find the file sections: %s",
237                  scratch_pathname, bfd_errmsg (bfd_get_error ()));
238         }
239 #endif /* IBM6000_TARGET */
240
241       if (build_section_table (exec_bfd, &exec_ops.to_sections,
242                                 &exec_ops.to_sections_end))
243         {
244           /* Make sure to close exec_bfd, or else "run" might try to use
245              it.  */
246           exec_close (0);
247           error ("\"%s\": can't find the file sections: %s", 
248                  scratch_pathname, bfd_errmsg (bfd_get_error ()));
249         }
250
251 #ifdef NEED_TEXT_START_END
252
253       /* text_end is sometimes used for where to put call dummies.  A
254          few ports use these for other purposes too.  */
255
256       {
257         struct section_table *p;
258
259         /* Set text_start to the lowest address of the start of any
260            readonly code section and set text_end to the highest
261            address of the end of any readonly code section.  */
262         /* FIXME: The comment above does not match the code.  The code
263            checks for sections with are either code *or* readonly.  */
264
265         text_start = ~(CORE_ADDR)0;
266         text_end = (CORE_ADDR)0;
267         for (p = exec_ops.to_sections; p < exec_ops.to_sections_end; p++)
268           if (bfd_get_section_flags (p->bfd, p->the_bfd_section)
269               & (SEC_CODE | SEC_READONLY))
270             {
271               if (text_start > p->addr) 
272                 text_start = p->addr;
273               if (text_end < p->endaddr)
274                 text_end = p->endaddr;
275             }
276       }
277 #endif
278
279       validate_files ();
280
281       set_endian_from_file (exec_bfd);
282       set_architecture_from_file (exec_bfd);
283
284       push_target (&exec_ops);
285
286       /* Tell display code (if any) about the changed file name.  */
287       if (exec_file_display_hook)
288         (*exec_file_display_hook) (filename);
289     }
290   else if (from_tty)
291     printf_unfiltered ("No executable file now.\n");
292 }
293
294 /* Set both the exec file and the symbol file, in one command.  
295    What a novelty.  Why did GDB go through four major releases before this
296    command was added?  */
297
298 static void
299 file_command (arg, from_tty)
300      char *arg;
301      int from_tty;
302 {
303   /* FIXME, if we lose on reading the symbol file, we should revert
304      the exec file, but that's rough.  */
305   exec_file_command (arg, from_tty);
306   symbol_file_command (arg, from_tty);
307   if (file_changed_hook)
308     file_changed_hook (arg);
309 }
310
311 \f
312 /* Locate all mappable sections of a BFD file. 
313    table_pp_char is a char * to get it through bfd_map_over_sections;
314    we cast it back to its proper type.  */
315
316 static void
317 add_to_section_table (abfd, asect, table_pp_char)
318      bfd *abfd;
319      sec_ptr asect;
320      PTR table_pp_char;
321 {
322   struct section_table **table_pp = (struct section_table **)table_pp_char;
323   flagword aflag;
324
325   aflag = bfd_get_section_flags (abfd, asect);
326   if (!(aflag & SEC_ALLOC))
327     return;
328   if (0 == bfd_section_size (abfd, asect))
329     return;
330   (*table_pp)->bfd = abfd;
331   (*table_pp)->the_bfd_section = asect;
332   (*table_pp)->addr = bfd_section_vma (abfd, asect);
333   (*table_pp)->endaddr = (*table_pp)->addr + bfd_section_size (abfd, asect);
334   (*table_pp)++;
335 }
336
337 /* Builds a section table, given args BFD, SECTABLE_PTR, SECEND_PTR.
338    Returns 0 if OK, 1 on error.  */
339
340 int
341 build_section_table (some_bfd, start, end)
342      bfd *some_bfd;
343      struct section_table **start, **end;
344 {
345   unsigned count;
346
347   count = bfd_count_sections (some_bfd);
348   if (*start)
349     free ((PTR)*start);
350   *start = (struct section_table *) xmalloc (count * sizeof (**start));
351   *end = *start;
352   bfd_map_over_sections (some_bfd, add_to_section_table, (char *)end);
353   if (*end > *start + count)
354     abort();
355   /* We could realloc the table, but it probably loses for most files.  */
356   return 0;
357 }
358 \f
359 static void
360 bfdsec_to_vmap(abfd, sect, arg3) 
361      bfd *abfd;
362      sec_ptr sect;
363      PTR arg3;
364 {
365   struct vmap_and_bfd *vmap_bfd = (struct vmap_and_bfd *) arg3;
366   struct vmap *vp;
367
368   vp = vmap_bfd->pvmap;
369
370   if ((bfd_get_section_flags (abfd, sect) & SEC_LOAD) == 0)
371     return;
372
373   if (STREQ (bfd_section_name (abfd, sect), ".text"))
374     {
375       vp->tstart = bfd_section_vma (abfd, sect);
376       vp->tend = vp->tstart + bfd_section_size (abfd, sect);
377       vp->tvma = bfd_section_vma (abfd, sect);
378       vp->toffs = sect->filepos;
379     }
380   else if (STREQ (bfd_section_name (abfd, sect), ".data"))
381     {
382       vp->dstart = bfd_section_vma (abfd, sect);
383       vp->dend = vp->dstart + bfd_section_size (abfd, sect);
384       vp->dvma = bfd_section_vma (abfd, sect);
385     }
386   /* Silently ignore other types of sections. (FIXME?)  */
387 }
388
389 /* Make a vmap for ABFD which might be a member of the archive ARCH.
390    Return the new vmap.  */
391
392 struct vmap *
393 map_vmap (abfd, arch)
394      bfd *abfd;
395      bfd *arch;
396 {
397   struct vmap_and_bfd vmap_bfd;
398   struct vmap *vp, **vpp;
399
400   vp = (struct vmap *) xmalloc (sizeof (*vp));
401   memset ((char *) vp, '\0', sizeof (*vp));
402   vp->nxt = 0;
403   vp->bfd = abfd;
404   vp->name = bfd_get_filename (arch ? arch : abfd);
405   vp->member = arch ? bfd_get_filename (abfd) : "";
406   
407   vmap_bfd.pbfd = arch;
408   vmap_bfd.pvmap = vp;
409   bfd_map_over_sections (abfd, bfdsec_to_vmap, &vmap_bfd);
410
411   /* Find the end of the list and append. */
412   for (vpp = &vmap; *vpp; vpp = &(*vpp)->nxt)
413     ;
414   *vpp = vp;
415
416   return vp;
417 }
418 \f
419 /* Read or write the exec file.
420
421    Args are address within a BFD file, address within gdb address-space,
422    length, and a flag indicating whether to read or write.
423
424    Result is a length:
425
426         0:    We cannot handle this address and length.
427         > 0:  We have handled N bytes starting at this address.
428               (If N == length, we did it all.)  We might be able
429               to handle more bytes beyond this length, but no
430               promises.
431         < 0:  We cannot handle this address, but if somebody
432               else handles (-N) bytes, we can start from there.
433
434     The same routine is used to handle both core and exec files;
435     we just tail-call it with more arguments to select between them.  */
436
437 int
438 xfer_memory (memaddr, myaddr, len, write, target)
439      CORE_ADDR memaddr;
440      char *myaddr;
441      int len;
442      int write;
443      struct target_ops *target;
444 {
445   boolean res;
446   struct section_table *p;
447   CORE_ADDR nextsectaddr, memend;
448   boolean (*xfer_fn) PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type));
449   asection *section;
450
451   if (len <= 0)
452     abort();
453
454   if (overlay_debugging)
455     {
456       section = find_pc_overlay (memaddr);
457       if (pc_in_unmapped_range (memaddr, section))
458         memaddr = overlay_mapped_address (memaddr, section);
459     }
460
461   memend = memaddr + len;
462   xfer_fn = write ? bfd_set_section_contents : bfd_get_section_contents;
463   nextsectaddr = memend;
464
465 #if 0 /* Stu's implementation */
466 /* If a section has been specified, try to use it.  Note that we cannot use the
467    specified section directly.  This is because it usually comes from the
468    symbol file, which may be different from the exec or core file.  Instead, we
469    have to lookup the specified section by name in the bfd associated with
470    to_sections.  */
471
472   if (target_memory_bfd_section)
473     {
474       asection *s;
475       bfd *abfd;
476       asection *target_section;
477       bfd *target_bfd;
478
479       s = target_memory_bfd_section;
480       abfd = s->owner;
481
482       target_bfd = target->to_sections->bfd;
483       target_section = bfd_get_section_by_name (target_bfd, bfd_section_name (abfd, s));
484
485       if (target_section)
486         {
487           bfd_vma sec_addr;
488           bfd_size_type sec_size;
489
490           sec_addr = bfd_section_vma (target_bfd, target_section);
491           sec_size = target_section->_raw_size;
492
493           /* Make sure the requested memory starts inside the section.  */
494
495           if (memaddr >= sec_addr
496               && memaddr < sec_addr + sec_size)
497             {
498               /* Cut back length in case request overflows the end of the section. */
499               len = min (len, sec_addr + sec_size - memaddr);
500
501               res = xfer_fn (target_bfd, target_section, myaddr, memaddr - sec_addr, len);
502
503               return res ? len : 0;
504             }
505         }
506     }
507 #endif /* 0, Stu's implementation */
508   for (p = target->to_sections; p < target->to_sections_end; p++)
509     {
510       if (overlay_debugging && section && p->the_bfd_section &&
511           strcmp (section->name, p->the_bfd_section->name) != 0)
512         continue;       /* not the section we need */
513       if (memaddr >= p->addr)
514         if (memend <= p->endaddr)
515           {
516             /* Entire transfer is within this section.  */
517             res = xfer_fn (p->bfd, p->the_bfd_section, myaddr,
518                            memaddr - p->addr, len);
519             return (res != 0) ? len : 0;
520           }
521         else if (memaddr >= p->endaddr)
522           {
523             /* This section ends before the transfer starts.  */
524             continue;
525           }
526         else 
527           {
528             /* This section overlaps the transfer.  Just do half.  */
529             len = p->endaddr - memaddr;
530             res = xfer_fn (p->bfd, p->the_bfd_section, myaddr,
531                            memaddr - p->addr, len);
532             return (res != 0) ? len : 0;
533           }
534       else
535         nextsectaddr = min (nextsectaddr, p->addr);
536     }
537
538   if (nextsectaddr >= memend)
539     return 0;                           /* We can't help */
540   else
541     return - (nextsectaddr - memaddr);  /* Next boundary where we can help */
542 }
543
544 #ifdef FIXME
545 #ifdef REG_STACK_SEGMENT
546 /* MOVE TO BFD... */
547     /* Pyramids and AM29000s have an extra segment in the virtual address space
548        for the (control) stack of register-window frames.  The AM29000 folk
549        call it the "register stack" rather than the "memory stack".  */
550     else if (memaddr >= reg_stack_start && memaddr < reg_stack_end)
551       {
552         i = min (len, reg_stack_end - memaddr);
553         fileptr = memaddr - reg_stack_start + reg_stack_offset;
554         wanna_xfer = coredata;
555       }
556 #endif                          /* REG_STACK_SEGMENT */
557 #endif /* FIXME */
558 \f
559 void
560 print_section_info (t, abfd)
561   struct target_ops *t;
562   bfd *abfd;
563 {
564   struct section_table *p;
565
566   printf_filtered ("\t`%s', ", bfd_get_filename(abfd));
567   wrap_here ("        ");
568   printf_filtered ("file type %s.\n", bfd_get_target(abfd));
569   if (abfd == exec_bfd)
570     {
571       printf_filtered ("\tEntry point: ");
572       print_address_numeric (bfd_get_start_address (abfd), 1, gdb_stdout);
573       printf_filtered ("\n");
574     }
575   for (p = t->to_sections; p < t->to_sections_end; p++)
576     {
577       /* FIXME-32x64 need a print_address_numeric with field width */
578       printf_filtered ("\t%s", local_hex_string_custom ((unsigned long) p->addr, "08l"));
579       printf_filtered (" - %s", local_hex_string_custom ((unsigned long) p->endaddr, "08l"));
580       if (info_verbose)
581         printf_filtered (" @ %s",
582                          local_hex_string_custom ((unsigned long) p->the_bfd_section->filepos, "08l"));
583       printf_filtered (" is %s", bfd_section_name (p->bfd, p->the_bfd_section));
584       if (p->bfd != abfd)
585         {
586           printf_filtered (" in %s", bfd_get_filename (p->bfd));
587         }
588       printf_filtered ("\n");
589     }
590 }
591
592 static void
593 exec_files_info (t)
594      struct target_ops *t;
595 {
596   print_section_info (t, exec_bfd);
597
598   if (vmap)
599     {
600       struct vmap *vp;
601
602       printf_unfiltered ("\tMapping info for file `%s'.\n", vmap->name);
603       printf_unfiltered ("\t  %8.8s   %8.8s   %8.8s   %8.8s %8.8s %s\n",
604                        "tstart", "tend", "dstart", "dend", "section",
605                        "file(member)");
606
607     for (vp = vmap; vp; vp = vp->nxt)
608       printf_unfiltered ("\t0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x %s%s%s%s\n",
609                          vp->tstart, vp->tend, vp->dstart, vp->dend, vp->name,
610                          *vp->member ? "(" : "", vp->member,
611                          *vp->member ? ")" : "");
612     }
613 }
614
615 static void
616 set_section_command (args, from_tty)
617      char *args;
618      int from_tty;
619 {
620   struct section_table *p;
621   char *secname;
622   unsigned seclen;
623   unsigned long secaddr;
624   char secprint[100];
625   long offset;
626
627   if (args == 0)
628     error ("Must specify section name and its virtual address");
629
630   /* Parse out section name */
631   for (secname = args; !isspace(*args); args++) ;
632   seclen = args - secname;
633
634   /* Parse out new virtual address */
635   secaddr = parse_and_eval_address (args);
636
637   for (p = exec_ops.to_sections; p < exec_ops.to_sections_end; p++) {
638     if (!strncmp (secname, bfd_section_name (exec_bfd, p->the_bfd_section), seclen)
639         && bfd_section_name (exec_bfd, p->the_bfd_section)[seclen] == '\0') {
640       offset = secaddr - p->addr;
641       p->addr += offset;
642       p->endaddr += offset;
643       if (from_tty)
644         exec_files_info(&exec_ops);
645       return;
646     }
647   } 
648   if (seclen >= sizeof (secprint))
649     seclen = sizeof (secprint) - 1;
650   strncpy (secprint, secname, seclen);
651   secprint[seclen] = '\0';
652   error ("Section %s not found", secprint);
653 }
654
655 /* If mourn is being called in all the right places, this could be say
656    `gdb internal error' (since generic_mourn calls breakpoint_init_inferior).  */
657
658 static int
659 ignore (addr, contents)
660      CORE_ADDR addr;
661      char *contents;
662 {
663   return 0;
664 }
665
666 struct target_ops exec_ops = {
667   "exec",                       /* to_shortname */
668   "Local exec file",            /* to_longname */
669   "Use an executable file as a target.\n\
670 Specify the filename of the executable file.", /* to_doc */
671   exec_file_command,            /* to_open */
672   exec_close,                   /* to_close */
673   find_default_attach,          /* to_attach */
674   0,                            /* to_detach */
675   0,                            /* to_resume */
676   0,                            /* to_wait */
677   0,                            /* to_fetch_registers */
678   0,                            /* to_store_registers */
679   0,                            /* to_prepare_to_store */
680   xfer_memory,                  /* to_xfer_memory */
681   exec_files_info,              /* to_files_info */
682   ignore,                       /* to_insert_breakpoint */
683   ignore,                       /* to_remove_breakpoint */
684   0,                            /* to_terminal_init */
685   0,                            /* to_terminal_inferior */
686   0,                            /* to_terminal_ours_for_output */
687   0,                            /* to_terminal_ours */
688   0,                            /* to_terminal_info */
689   0,                            /* to_kill */
690   0,                            /* to_load */
691   0,                            /* to_lookup_symbol */
692   find_default_create_inferior, /* to_create_inferior */
693   0,                            /* to_mourn_inferior */
694   0,                            /* to_can_run */
695   0,                            /* to_notice_signals */
696   0,                            /* to_thread_alive */
697   0,                            /* to_stop */
698   file_stratum,                 /* to_stratum */
699   0,                            /* to_next */
700   0,                            /* to_has_all_memory */
701   1,                            /* to_has_memory */
702   0,                            /* to_has_stack */
703   0,                            /* to_has_registers */
704   0,                            /* to_has_execution */
705   0,                            /* to_sections */
706   0,                            /* to_sections_end */
707   OPS_MAGIC,                    /* to_magic */
708 };
709
710 void
711 _initialize_exec()
712 {
713   struct cmd_list_element *c;
714
715   c = add_cmd ("file", class_files, file_command,
716                "Use FILE as program to be debugged.\n\
717 It is read for its symbols, for getting the contents of pure memory,\n\
718 and it is the program executed when you use the `run' command.\n\
719 If FILE cannot be found as specified, your execution directory path\n\
720 ($PATH) is searched for a command of that name.\n\
721 No arg means to have no executable file and no symbols.", &cmdlist);
722   c->completer = filename_completer;
723
724   c = add_cmd ("exec-file", class_files, exec_file_command,
725            "Use FILE as program for getting contents of pure memory.\n\
726 If FILE cannot be found as specified, your execution directory path\n\
727 is searched for a command of that name.\n\
728 No arg means have no executable file.", &cmdlist);
729   c->completer = filename_completer;
730
731   add_com ("section", class_files, set_section_command,
732    "Change the base address of section SECTION of the exec file to ADDR.\n\
733 This can be used if the exec file does not contain section addresses,\n\
734 (such as in the a.out format), or when the addresses specified in the\n\
735 file itself are wrong.  Each section must be changed separately.  The\n\
736 ``info files'' command lists all the sections and their addresses.");
737
738   add_show_from_set
739     (add_set_cmd ("write", class_support, var_boolean, (char *)&write_files,
740                   "Set writing into executable and core files.",
741                   &setlist),
742      &showlist);
743   
744   add_target (&exec_ops);
745 }