1 /* BFD back end for traditional Unix core files (U-area and raw sections)
2 Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc.
3 Written by John Gilmore of Cygnus Support.
5 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
21 /* This file does not define a particular back-end, but it defines routines
22 that can be used by other back-ends. */
26 /* No core file support yet on any iris, so dump all this code.
27 We don't appear to grok foreign core files on any system, since u
28 will have different sizes on different machines anyway. */
29 #if (HOST_SYS != IRIX3_SYS) && (HOST_SYS != IRIX4_SYS)
35 #include "libaout.h" /* BFD a.out internal data structures */
37 #include <sys/types.h>
38 #include <sys/param.h>
41 #include <machine/reg.h>
43 #include <sys/user.h> /* After a.out.h */
48 /* need this cast b/c ptr is really void * */
49 #define core_hdr(bfd) (((struct core_data *) (bfd->tdata))->hdr)
50 #define core_datasec(bfd) (((struct core_data *) ((bfd)->tdata))->data_section)
51 #define core_stacksec(bfd) (((struct core_data*)((bfd)->tdata))->stack_section)
52 #define core_regsec(bfd) (((struct core_data *) ((bfd)->tdata))->reg_section)
53 #define core_upage(bfd) (((struct core_data *) ((bfd)->tdata))->upage)
55 /* These are stored in the bfd's tdata */
57 struct user *upage; /* core file header */
58 asection *data_section;
59 asection *stack_section;
60 asection *reg_section;
65 trad_unix_core_file_p (abfd)
68 #if HOST_SYS == SUN4_SYS
74 unsigned int reg_offset, fp_reg_offset;
76 /* 4.2-style (and perhaps also sysV-style) core dump file. */
78 val = bfd_read ((void *)&u, 1, sizeof u, abfd);
80 return 0; /* Too small to be a core file */
82 /* Sanity check perhaps??? */
83 if (u.u_dsize > 0x1000000) /* Remember, it's in pages... */
85 if (u.u_ssize > 0x1000000)
87 /* Check that the size claimed is no greater than the file size. FIXME. */
89 /* OK, we believe you. You're a core file (sure, sure). */
91 /* Allocate both the upage and the struct core_data at once, so
92 a single free() will free them both. */
93 rawptr = (char *)zalloc (sizeof (u) + sizeof (struct core_data));
95 bfd_error = no_memory;
99 set_tdata (abfd, (struct core_data *)rawptr);
100 core_upage (abfd) = (struct user *)(rawptr + sizeof (struct core_data));
101 *core_upage (abfd) = u; /* Save that upage! */
103 /* create the sections. This is raunchy, but bfd_close wants to reclaim
105 core_stacksec (abfd) = (asection *) zalloc (sizeof (asection));
106 if (core_stacksec (abfd) == NULL) {
108 bfd_error = no_memory;
109 free ((void *)rawptr);
112 core_datasec (abfd) = (asection *) zalloc (sizeof (asection));
113 if (core_datasec (abfd) == NULL) {
115 free ((void *)core_stacksec (abfd));
118 core_regsec (abfd) = (asection *) zalloc (sizeof (asection));
119 if (core_regsec (abfd) == NULL) {
121 free ((void *)core_datasec (abfd));
125 core_stacksec (abfd)->name = ".stack";
126 core_datasec (abfd)->name = ".data";
127 core_regsec (abfd)->name = ".reg";
129 core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD;
130 core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD;
131 core_regsec (abfd)->flags = SEC_ALLOC;
133 core_datasec (abfd)->size = NBPG * u.u_dsize;
134 core_stacksec (abfd)->size = NBPG * u.u_ssize;
135 core_regsec (abfd)->size = NBPG * UPAGES; /* Larger than sizeof struct u */
137 /* What a hack... we'd like to steal it from the exec file,
138 since the upage does not seem to provide it. FIXME. */
139 #ifdef HOST_DATA_START_ADDR
140 core_datasec (abfd)->vma = HOST_DATA_START_ADDR;
142 core_datasec (abfd)->vma = HOST_TEXT_START_ADDR + (NBPG * u.u_tsize);
144 core_stacksec (abfd)->vma = HOST_STACK_END_ADDR - (NBPG * u.u_ssize);
145 core_regsec (abfd)->vma = -1;
147 core_datasec (abfd)->filepos = NBPG * UPAGES;
148 core_stacksec (abfd)->filepos = (NBPG * UPAGES) + NBPG * u.u_dsize;
149 core_regsec (abfd)->filepos = 0; /* Register segment is the upage */
151 /* Align to word at least */
152 core_stacksec (abfd)->alignment_power = 2;
153 core_datasec (abfd)->alignment_power = 2;
154 core_regsec (abfd)->alignment_power = 2;
156 abfd->sections = core_stacksec (abfd);
157 core_stacksec (abfd)->next = core_datasec (abfd);
158 core_datasec (abfd)->next = core_regsec (abfd);
159 abfd->section_count = 3;
166 trad_unix_core_file_failing_command (abfd)
169 if (*core_upage (abfd)->u_comm)
170 return core_upage (abfd)->u_comm;
177 trad_unix_core_file_failing_signal (ignore_abfd)
180 return -1; /* FIXME, where is it? */
185 trad_unix_core_file_matches_executable_p (core_bfd, exec_bfd)
186 bfd *core_bfd, *exec_bfd;
188 return true; /* FIXME, We have no way of telling at this point */
191 #endif /* (HOST_SYS != IRIX3_SYS) && (HOST_SYS != IRIX4_SYS) */