]>
Commit | Line | Data |
---|---|---|
3c8a3c56 JG |
1 | /* A.out "format 1" file handling code |
2 | Copyright (C) 1990-1991 Free Software Foundation, Inc. | |
3 | Written by Cygnus Support. | |
7ed4093a | 4 | |
3c8a3c56 | 5 | This file is part of BFD, the Binary File Descriptor library. |
7ed4093a | 6 | |
3c8a3c56 | 7 | This program is free software; you can redistribute it and/or modify |
7ed4093a | 8 | it under the terms of the GNU General Public License as published by |
3c8a3c56 JG |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | |
7ed4093a | 11 | |
3c8a3c56 | 12 | This program is distributed in the hope that it will be useful, |
7ed4093a SC |
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 | |
3c8a3c56 JG |
18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
6f715d66 | 20 | |
7ed4093a SC |
21 | #include <ansidecl.h> |
22 | #include <sysdep.h> | |
23 | struct external_exec; | |
24 | #include <a.out.sun4.h> | |
25 | #include "bfd.h" | |
359f1dee | 26 | #include "libaout.h" |
7ed4093a SC |
27 | #include "libbfd.h" |
28 | ||
7ed4093a SC |
29 | #include "aout64.h" |
30 | #include "stab.gnu.h" | |
31 | #include "ar.h" | |
32 | ||
6f715d66 | 33 | /* |
6f715d66 SC |
34 | The file @code{aoutf1.h} contains the code for BFD's |
35 | a.out back end. Control over the generated back end is given by these | |
4f8b8627 | 36 | two preprocessor names: |
6f715d66 | 37 | @table @code |
4f8b8627 | 38 | @item ARCH_SIZE |
6f715d66 SC |
39 | This value should be either 32 or 64, depending upon the size of an |
40 | int in the target format. It changes the sizes of the structs which | |
41 | perform the memory/disk mapping of structures. | |
42 | ||
43 | The 64 bit backend may only be used if the host compiler supports 64 | |
4f8b8627 JG |
44 | ints (eg long long with gcc), by defining the name @code{HOST_64_BIT} in @code{bfd.h}. |
45 | With this name defined, @emph{all} bfd operations are performed with 64bit | |
6f715d66 SC |
46 | arithmetic, not just those to a 64bit target. |
47 | ||
48 | @item TARGETNAME | |
4f8b8627 | 49 | The name put into the target vector. |
6f715d66 | 50 | @item |
4f8b8627 | 51 | @end table |
6f715d66 SC |
52 | |
53 | */ | |
7ed4093a SC |
54 | |
55 | void (*bfd_error_trap)(); | |
56 | ||
57 | static bfd_target *sunos4_callback (); | |
58 | ||
59 | /*SUPPRESS558*/ | |
60 | /*SUPPRESS529*/ | |
61 | ||
62 | bfd_target * | |
63 | DEFUN(NAME(sunos,object_p), (abfd), | |
64 | bfd *abfd) | |
65 | { | |
66 | unsigned char magicbuf[4]; /* Raw bytes of magic number from file */ | |
67 | unsigned long magic; /* Swapped magic number */ | |
68 | ||
69 | bfd_error = system_call_error; | |
70 | ||
71 | if (bfd_read ((PTR)magicbuf, 1 , 4, abfd) != | |
72 | sizeof (magicbuf)) | |
73 | return 0; | |
74 | magic = bfd_h_get_32 (abfd, magicbuf); | |
75 | ||
76 | if (N_BADMAG (*((struct internal_exec *) &magic))) return 0; | |
77 | ||
78 | return NAME(aout,some_aout_object_p) (abfd, sunos4_callback); | |
79 | } | |
80 | ||
81 | /* Determine the size of a relocation entry, based on the architecture */ | |
82 | static void | |
83 | DEFUN(choose_reloc_size,(abfd), | |
84 | bfd *abfd) | |
85 | { | |
86 | switch (abfd->obj_arch) { | |
87 | case bfd_arch_sparc: | |
88 | case bfd_arch_a29k: | |
89 | obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE; | |
90 | break; | |
91 | default: | |
92 | obj_reloc_entry_size (abfd) = RELOC_STD_SIZE; | |
93 | break; | |
94 | } | |
95 | } | |
96 | ||
97 | /* Set parameters about this a.out file that are machine-dependent. | |
98 | This routine is called from some_aout_object_p just before it returns. */ | |
99 | ||
100 | static bfd_target * | |
101 | sunos4_callback (abfd) | |
102 | bfd *abfd; | |
103 | { | |
104 | struct internal_exec *execp = exec_hdr (abfd); | |
105 | ||
106 | WORK_OUT_FILE_POSITIONS(abfd, execp); | |
c0e5039e | 107 | |
7ed4093a SC |
108 | /* Determine the architecture and machine type of the object file. */ |
109 | switch (N_MACHTYPE (*exec_hdr (abfd))) { | |
110 | ||
111 | case M_UNKNOWN: | |
112 | abfd->obj_arch = bfd_arch_unknown; | |
113 | abfd->obj_machine = 0; | |
114 | break; | |
115 | ||
116 | case M_68010: | |
117 | abfd->obj_arch = bfd_arch_m68k; | |
118 | abfd->obj_machine = 68010; | |
119 | break; | |
120 | ||
121 | case M_68020: | |
122 | abfd->obj_arch = bfd_arch_m68k; | |
123 | abfd->obj_machine = 68020; | |
124 | break; | |
125 | ||
126 | case M_SPARC: | |
127 | abfd->obj_arch = bfd_arch_sparc; | |
128 | abfd->obj_machine = 0; | |
129 | break; | |
130 | ||
131 | case M_386: | |
132 | abfd->obj_arch = bfd_arch_i386; | |
133 | abfd->obj_machine = 0; | |
134 | break; | |
135 | ||
136 | case M_29K: | |
137 | abfd->obj_arch = bfd_arch_a29k; | |
138 | abfd->obj_machine = 0; | |
139 | break; | |
140 | ||
141 | default: | |
142 | abfd->obj_arch = bfd_arch_obscure; | |
143 | abfd->obj_machine = 0; | |
144 | break; | |
145 | } | |
146 | ||
147 | choose_reloc_size(abfd); | |
148 | return abfd->xvec; | |
149 | } | |
150 | ||
151 | ||
152 | /* Write an object file in SunOS format. | |
153 | Section contents have already been written. We write the | |
154 | file header, symbols, and relocation. */ | |
155 | ||
156 | boolean | |
157 | DEFUN(NAME(aout,sunos4_write_object_contents),(abfd), | |
158 | bfd *abfd) | |
159 | ||
160 | { | |
161 | bfd_size_type data_pad = 0; | |
162 | struct external_exec exec_bytes; | |
163 | struct internal_exec *execp = exec_hdr (abfd); | |
164 | ||
165 | ||
166 | ||
167 | execp->a_text = obj_textsec (abfd)->size; | |
168 | ||
169 | /* Magic number, maestro, please! */ | |
170 | switch (bfd_get_architecture(abfd)) { | |
171 | case bfd_arch_m68k: | |
172 | switch (bfd_get_machine(abfd)) { | |
173 | case 68010: | |
174 | N_SET_MACHTYPE(*execp, M_68010); | |
175 | break; | |
176 | default: | |
177 | case 68020: | |
178 | N_SET_MACHTYPE(*execp, M_68020); | |
179 | break; | |
180 | } | |
181 | break; | |
182 | case bfd_arch_sparc: | |
183 | N_SET_MACHTYPE(*execp, M_SPARC); | |
184 | break; | |
185 | case bfd_arch_i386: | |
186 | N_SET_MACHTYPE(*execp, M_386); | |
187 | break; | |
188 | case bfd_arch_a29k: | |
189 | N_SET_MACHTYPE(*execp, M_29K); | |
190 | break; | |
191 | default: | |
192 | N_SET_MACHTYPE(*execp, M_UNKNOWN); | |
193 | } | |
194 | ||
195 | choose_reloc_size(abfd); | |
196 | ||
197 | /* FIXME */ | |
6f715d66 | 198 | N_SET_FLAGS (*execp, 0x1); |
7ed4093a SC |
199 | |
200 | WRITE_HEADERS(abfd, execp); | |
201 | ||
202 | return true; | |
203 | } | |
204 | \f | |
205 | /* core files */ | |
206 | ||
207 | #define CORE_MAGIC 0x080456 | |
208 | #define CORE_NAMELEN 16 | |
209 | ||
210 | /* The core structure is taken from the Sun documentation. | |
211 | Unfortunately, they don't document the FPA structure, or at least I | |
212 | can't find it easily. Fortunately the core header contains its own | |
213 | length. So this shouldn't cause problems, except for c_ucode, which | |
214 | so far we don't use but is easy to find with a little arithmetic. */ | |
215 | ||
216 | /* But the reg structure can be gotten from the SPARC processor handbook. | |
217 | This really should be in a GNU include file though so that gdb can use | |
218 | the same info. */ | |
219 | struct regs { | |
220 | int r_psr; | |
221 | int r_pc; | |
222 | int r_npc; | |
223 | int r_y; | |
224 | int r_g1; | |
225 | int r_g2; | |
226 | int r_g3; | |
227 | int r_g4; | |
228 | int r_g5; | |
229 | int r_g6; | |
230 | int r_g7; | |
231 | int r_o0; | |
232 | int r_o1; | |
233 | int r_o2; | |
234 | int r_o3; | |
235 | int r_o4; | |
236 | int r_o5; | |
237 | int r_o6; | |
238 | int r_o7; | |
239 | }; | |
240 | ||
241 | /* Taken from Sun documentation: */ | |
242 | ||
243 | /* FIXME: It's worse than we expect. This struct contains TWO substructs | |
244 | neither of whose size we know, WITH STUFF IN BETWEEN THEM! We can't | |
245 | even portably access the stuff in between! */ | |
246 | ||
4f8b8627 | 247 | struct external_sparc_core { |
7ed4093a SC |
248 | int c_magic; /* Corefile magic number */ |
249 | int c_len; /* Sizeof (struct core) */ | |
4f8b8627 JG |
250 | #define SPARC_CORE_LEN 432 |
251 | int c_regs[19]; /* General purpose registers -- MACHDEP SIZE */ | |
252 | struct external_exec c_aouthdr; /* A.out header */ | |
7ed4093a SC |
253 | int c_signo; /* Killing signal, if any */ |
254 | int c_tsize; /* Text size (bytes) */ | |
255 | int c_dsize; /* Data size (bytes) */ | |
256 | int c_ssize; /* Stack size (bytes) */ | |
257 | char c_cmdname[CORE_NAMELEN + 1]; /* Command name */ | |
258 | double fp_stuff[1]; /* external FPU state (size unknown by us) */ | |
259 | /* The type "double" is critical here, for alignment. | |
260 | SunOS declares a struct here, but the struct's alignment | |
261 | is double since it contains doubles. */ | |
262 | int c_ucode; /* Exception no. from u_code */ | |
263 | /* (this member is not accessible by name since we don't | |
264 | portably know the size of fp_stuff.) */ | |
265 | }; | |
266 | ||
4f8b8627 JG |
267 | struct external_sun3_core { |
268 | int c_magic; /* Corefile magic number */ | |
269 | int c_len; /* Sizeof (struct core) */ | |
270 | #define SUN3_CORE_LEN 826 /* As of SunOS 4.1.1 */ | |
271 | int c_regs[18]; /* General purpose registers -- MACHDEP SIZE */ | |
272 | struct external_exec c_aouthdr; /* A.out header */ | |
273 | int c_signo; /* Killing signal, if any */ | |
274 | int c_tsize; /* Text size (bytes) */ | |
275 | int c_dsize; /* Data size (bytes) */ | |
276 | int c_ssize; /* Stack size (bytes) */ | |
277 | char c_cmdname[CORE_NAMELEN + 1]; /* Command name */ | |
278 | double fp_stuff[1]; /* external FPU state (size unknown by us) */ | |
279 | /* The type "double" is critical here, for alignment. | |
280 | SunOS declares a struct here, but the struct's alignment | |
281 | is double since it contains doubles. */ | |
282 | int c_ucode; /* Exception no. from u_code */ | |
283 | /* (this member is not accessible by name since we don't | |
284 | portably know the size of fp_stuff.) */ | |
285 | }; | |
286 | ||
287 | struct internal_sunos_core { | |
288 | int c_magic; /* Corefile magic number */ | |
289 | int c_len; /* Sizeof (struct core) */ | |
290 | long c_regs_pos; /* file offset of General purpose registers */ | |
291 | int c_regs_size; /* size of General purpose registers */ | |
292 | struct internal_exec c_aouthdr; /* A.out header */ | |
293 | int c_signo; /* Killing signal, if any */ | |
294 | int c_tsize; /* Text size (bytes) */ | |
295 | int c_dsize; /* Data size (bytes) */ | |
296 | int c_ssize; /* Stack size (bytes) */ | |
297 | long c_stacktop; /* Stack top (address) */ | |
298 | char c_cmdname[CORE_NAMELEN + 1]; /* Command name */ | |
299 | long fp_stuff_pos; /* file offset of external FPU state (regs) */ | |
300 | int fp_stuff_size; /* Size of it */ | |
301 | int c_ucode; /* Exception no. from u_code */ | |
302 | }; | |
7ed4093a | 303 | |
4f8b8627 JG |
304 | /* byte-swap in the Sun-3 core structure */ |
305 | static void | |
306 | DEFUN(swapcore_sun3,(abfd, ext, intcore), | |
307 | bfd *abfd AND | |
308 | char *ext; | |
309 | struct internal_sunos_core *intcore) | |
310 | { | |
311 | struct external_exec exec_bytes; | |
312 | struct external_sun3_core *extcore = (struct external_sun3_core *)ext; | |
313 | ||
314 | intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_magic); | |
315 | intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_len ); | |
316 | intcore->c_regs_pos = (long) (((struct external_sun3_core *)0)->c_regs); | |
317 | intcore->c_regs_size = sizeof (extcore->c_regs); | |
318 | NAME(aout,swap_exec_header_in)(abfd, &extcore->c_aouthdr,&intcore->c_aouthdr); | |
319 | intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_signo); | |
320 | intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_tsize); | |
321 | intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_dsize); | |
322 | intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_ssize); | |
323 | bcopy (extcore->c_cmdname, intcore->c_cmdname, sizeof (intcore->c_cmdname)); | |
324 | intcore->fp_stuff_pos = (long) (((struct external_sun3_core *)0)->fp_stuff); | |
325 | /* FP stuff takes up whole rest of struct, except c_ucode. */ | |
326 | intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) - | |
327 | (file_ptr)(((struct external_sun3_core *)0)->fp_stuff); | |
328 | /* Ucode is the last thing in the struct -- just before the end */ | |
329 | intcore->c_ucode = bfd_h_get_32 (abfd, | |
330 | intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *)extcore); | |
331 | intcore->c_stacktop = 0x0E000000; /* By experimentation */ | |
332 | } | |
333 | ||
334 | ||
335 | /* byte-swap in the Sun-3 core structure */ | |
336 | static void | |
337 | DEFUN(swapcore_sparc,(abfd, ext, intcore), | |
338 | bfd *abfd AND | |
339 | char *ext; | |
340 | struct internal_sunos_core *intcore) | |
341 | { | |
342 | struct external_sparc_core *extcore = (struct external_sparc_core *)ext; | |
343 | ||
344 | intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_magic); | |
345 | intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_len ); | |
346 | intcore->c_regs_pos = (long) (((struct external_sparc_core *)0)->c_regs); | |
347 | intcore->c_regs_size = sizeof (extcore->c_regs); | |
348 | NAME(aout,swap_exec_header_in)(abfd, &extcore->c_aouthdr,&intcore->c_aouthdr); | |
349 | intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_signo); | |
350 | intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_tsize); | |
351 | intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_dsize); | |
352 | intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_ssize); | |
353 | bcopy (extcore->c_cmdname, intcore->c_cmdname, sizeof (intcore->c_cmdname)); | |
354 | intcore->fp_stuff_pos = (long) (((struct external_sparc_core *)0)->fp_stuff); | |
355 | /* FP stuff takes up whole rest of struct, except c_ucode. */ | |
356 | intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) - | |
357 | (file_ptr)(((struct external_sparc_core *)0)->fp_stuff); | |
358 | /* Ucode is the last thing in the struct -- just before the end */ | |
359 | intcore->c_ucode = bfd_h_get_32 (abfd, | |
360 | intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *)extcore); | |
361 | /* Supposedly the user stack grows downward from the bottom of kernel memory. | |
362 | Presuming that this remains true, this definition will work. */ | |
363 | #define USRSTACK (-(128*1024*1024)) | |
364 | intcore->c_stacktop = USRSTACK; /* By experimentation */ | |
365 | #undef USRSTACK | |
366 | } | |
7ed4093a | 367 | |
4f8b8627 JG |
368 | /* need this cast because ptr is really void * */ |
369 | #define core_hdr(bfd) (((struct suncoredata *) (bfd->tdata))->hdr) | |
370 | #define core_datasec(bfd) (((struct suncoredata *) ((bfd)->tdata))->data_section) | |
371 | #define core_stacksec(bfd) (((struct suncoredata*)((bfd)->tdata))->stack_section) | |
372 | #define core_regsec(bfd) (((struct suncoredata *) ((bfd)->tdata))->reg_section) | |
373 | #define core_reg2sec(bfd) (((struct suncoredata *) ((bfd)->tdata))->reg2_section) | |
7ed4093a SC |
374 | |
375 | /* These are stored in the bfd's tdata */ | |
4f8b8627 JG |
376 | struct suncoredata { |
377 | struct internal_sunos_core *hdr; /* core file header */ | |
378 | asection *data_section; | |
379 | asection *stack_section; | |
380 | asection *reg_section; | |
381 | asection *reg2_section; | |
7ed4093a SC |
382 | }; |
383 | ||
384 | static bfd_target * | |
385 | DEFUN(sunos4_core_file_p,(abfd), | |
386 | bfd *abfd) | |
387 | { | |
388 | unsigned char longbuf[4]; /* Raw bytes of various header fields */ | |
389 | int core_size; | |
390 | int core_mag; | |
4f8b8627 JG |
391 | struct internal_sunos_core *core; |
392 | char *extcore; | |
7ed4093a | 393 | char *rawptr; |
4f8b8627 JG |
394 | struct mergem { |
395 | struct suncoredata suncoredata; | |
396 | struct internal_sunos_core internal_sunos_core; | |
397 | char external_core[1]; | |
398 | } *mergem; | |
7ed4093a SC |
399 | |
400 | bfd_error = system_call_error; | |
401 | ||
402 | if (bfd_read ((PTR)longbuf, 1, sizeof (longbuf), abfd) != | |
403 | sizeof (longbuf)) | |
404 | return 0; | |
405 | core_mag = bfd_h_get_32 (abfd, longbuf); | |
406 | ||
407 | if (core_mag != CORE_MAGIC) return 0; | |
408 | ||
409 | /* SunOS core headers can vary in length; second word is size; */ | |
410 | if (bfd_read ((PTR)longbuf, 1, sizeof (longbuf), abfd) != | |
411 | sizeof (longbuf)) | |
412 | return 0; | |
413 | core_size = bfd_h_get_32 (abfd, longbuf); | |
414 | /* Sanity check */ | |
415 | if (core_size > 20000) | |
416 | return 0; | |
417 | ||
418 | if (bfd_seek (abfd, 0L, false) < 0) return 0; | |
419 | ||
4f8b8627 JG |
420 | mergem = (struct mergem *)bfd_zalloc (abfd, core_size + sizeof (struct mergem)); |
421 | if (mergem == NULL) { | |
7ed4093a SC |
422 | bfd_error = no_memory; |
423 | return 0; | |
424 | } | |
425 | ||
4f8b8627 | 426 | extcore = mergem->external_core; |
7ed4093a | 427 | |
4f8b8627 | 428 | if ((bfd_read ((PTR) extcore, 1, core_size, abfd)) != core_size) { |
7ed4093a | 429 | bfd_error = system_call_error; |
4f8b8627 JG |
430 | bfd_release (abfd, (char *)mergem); |
431 | return 0; | |
432 | } | |
433 | ||
434 | /* Validate that it's a core file we know how to handle, due to sun | |
435 | botching the positioning of registers and other fields in a machine | |
436 | dependent way. */ | |
437 | core = &mergem->internal_sunos_core; | |
438 | switch (core_size) { | |
439 | case SPARC_CORE_LEN: | |
440 | swapcore_sparc (abfd, extcore, core); | |
441 | break; | |
442 | case SUN3_CORE_LEN: | |
443 | swapcore_sun3 (abfd, extcore, core); | |
444 | break; | |
445 | default: | |
446 | bfd_error = system_call_error; /* FIXME */ | |
447 | bfd_release (abfd, (char *)mergem); | |
7ed4093a SC |
448 | return 0; |
449 | } | |
450 | ||
4f8b8627 | 451 | set_tdata (abfd, &mergem->suncoredata); |
7ed4093a SC |
452 | core_hdr (abfd) = core; |
453 | ||
454 | /* create the sections. This is raunchy, but bfd_close wants to reclaim | |
455 | them */ | |
456 | core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); | |
457 | if (core_stacksec (abfd) == NULL) { | |
458 | loser: | |
459 | bfd_error = no_memory; | |
460 | bfd_release (abfd, rawptr); | |
461 | return 0; | |
462 | } | |
463 | core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); | |
464 | if (core_datasec (abfd) == NULL) { | |
465 | loser1: | |
466 | bfd_release (abfd, core_stacksec (abfd)); | |
467 | goto loser; | |
468 | } | |
469 | core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); | |
470 | if (core_regsec (abfd) == NULL) { | |
471 | loser2: | |
472 | bfd_release (abfd, core_datasec (abfd)); | |
473 | goto loser1; | |
474 | } | |
475 | core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); | |
476 | if (core_reg2sec (abfd) == NULL) { | |
477 | bfd_release (abfd, core_regsec (abfd)); | |
478 | goto loser2; | |
479 | } | |
480 | ||
481 | core_stacksec (abfd)->name = ".stack"; | |
482 | core_datasec (abfd)->name = ".data"; | |
483 | core_regsec (abfd)->name = ".reg"; | |
484 | core_reg2sec (abfd)->name = ".reg2"; | |
485 | ||
486 | core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD; | |
487 | core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD; | |
488 | core_regsec (abfd)->flags = SEC_ALLOC; | |
489 | core_reg2sec (abfd)->flags = SEC_ALLOC; | |
490 | ||
491 | core_stacksec (abfd)->size = core->c_ssize; | |
492 | core_datasec (abfd)->size = core->c_dsize; | |
4f8b8627 JG |
493 | core_regsec (abfd)->size = core->c_regs_size; |
494 | core_reg2sec (abfd)->size = core->fp_stuff_size; | |
7ed4093a | 495 | |
4f8b8627 | 496 | core_stacksec (abfd)->vma = (core->c_stacktop - core->c_ssize); |
7ed4093a SC |
497 | core_datasec (abfd)->vma = N_DATADDR(core->c_aouthdr); |
498 | core_regsec (abfd)->vma = -1; | |
499 | core_reg2sec (abfd)->vma = -1; | |
500 | ||
501 | core_stacksec (abfd)->filepos = core->c_len + core->c_dsize; | |
502 | core_datasec (abfd)->filepos = core->c_len; | |
4f8b8627 JG |
503 | /* We'll access the regs afresh in the core file, like any section: */ |
504 | core_regsec (abfd)->filepos = (file_ptr)core->c_regs_pos; | |
505 | core_reg2sec (abfd)->filepos = (file_ptr)core->fp_stuff_pos; | |
7ed4093a SC |
506 | |
507 | /* Align to word at least */ | |
508 | core_stacksec (abfd)->alignment_power = 2; | |
509 | core_datasec (abfd)->alignment_power = 2; | |
510 | core_regsec (abfd)->alignment_power = 2; | |
511 | core_reg2sec (abfd)->alignment_power = 2; | |
512 | ||
513 | abfd->sections = core_stacksec (abfd); | |
514 | core_stacksec (abfd)->next = core_datasec (abfd); | |
515 | core_datasec (abfd)->next = core_regsec (abfd); | |
516 | core_regsec (abfd)->next = core_reg2sec (abfd); | |
517 | ||
518 | abfd->section_count = 4; | |
519 | ||
520 | return abfd->xvec; | |
521 | } | |
522 | ||
523 | static char *sunos4_core_file_failing_command (abfd) | |
524 | bfd *abfd; | |
525 | { | |
526 | return core_hdr (abfd)->c_cmdname; | |
527 | } | |
528 | ||
529 | static int | |
530 | DEFUN(sunos4_core_file_failing_signal,(abfd), | |
531 | bfd *abfd) | |
532 | { | |
533 | return core_hdr (abfd)->c_signo; | |
534 | } | |
535 | ||
536 | static boolean | |
537 | DEFUN(sunos4_core_file_matches_executable_p, (core_bfd, exec_bfd), | |
538 | bfd *core_bfd AND | |
539 | bfd *exec_bfd) | |
540 | { | |
541 | if (core_bfd->xvec != exec_bfd->xvec) { | |
542 | bfd_error = system_call_error; | |
543 | return false; | |
544 | } | |
545 | ||
546 | return (bcmp ((char *)&core_hdr (core_bfd), (char*) &exec_hdr (exec_bfd), | |
547 | sizeof (struct internal_exec)) == 0) ? true : false; | |
548 | } | |
7ed4093a SC |
549 | \f |
550 | /* We use BFD generic archive files. */ | |
551 | #define aout_32_openr_next_archived_file bfd_generic_openr_next_archived_file | |
552 | #define aout_32_generic_stat_arch_elt bfd_generic_stat_arch_elt | |
553 | #define aout_32_slurp_armap bfd_slurp_bsd_armap | |
554 | #define aout_32_slurp_extended_name_table bfd_true | |
555 | #define aout_32_write_armap bsd_write_armap | |
556 | #define aout_32_truncate_arname bfd_bsd_truncate_arname | |
557 | #define aout_32_machine_type sunos_machine_type | |
558 | ||
559 | #define aout_32_core_file_failing_command sunos4_core_file_failing_command | |
560 | #define aout_32_core_file_failing_signal sunos4_core_file_failing_signal | |
561 | #define aout_32_core_file_matches_executable_p sunos4_core_file_matches_executable_p | |
562 | ||
563 | ||
564 | #define aout_64_openr_next_archived_file bfd_generic_openr_next_archived_file | |
565 | #define aout_64_generic_stat_arch_elt bfd_generic_stat_arch_elt | |
566 | #define aout_64_slurp_armap bfd_slurp_bsd_armap | |
567 | #define aout_64_slurp_extended_name_table bfd_true | |
568 | #define aout_64_write_armap bsd_write_armap | |
569 | #define aout_64_truncate_arname bfd_bsd_truncate_arname | |
570 | #define aout_64_machine_type sunos_machine_type | |
571 | ||
572 | #define aout_64_core_file_failing_command sunos4_core_file_failing_command | |
573 | #define aout_64_core_file_failing_signal sunos4_core_file_failing_signal | |
574 | #define aout_64_core_file_matches_executable_p sunos4_core_file_matches_executable_p | |
575 | ||
6f715d66 SC |
576 | #define aout_64_bfd_debug_info_start bfd_void |
577 | #define aout_64_bfd_debug_info_end bfd_void | |
578 | #define aout_64_bfd_debug_info_accumulate bfd_void | |
579 | ||
580 | #define aout_32_bfd_debug_info_start bfd_void | |
581 | #define aout_32_bfd_debug_info_end bfd_void | |
3c8a3c56 | 582 | #define aout_32_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void |
6f715d66 SC |
583 | |
584 | ||
585 | ||
7ed4093a SC |
586 | /* We implement these routines ourselves, rather than using the generic |
587 | a.out versions. */ | |
588 | #define aout_write_object_contents sunos4_write_object_contents | |
589 | ||
590 | bfd_target VECNAME = | |
591 | { | |
6f715d66 SC |
592 | TARGETNAME, |
593 | bfd_target_aout_flavour_enum, | |
594 | true, /* target byte order */ | |
595 | true, /* target headers byte order */ | |
596 | (HAS_RELOC | EXEC_P | /* object flags */ | |
597 | HAS_LINENO | HAS_DEBUG | | |
598 | HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), | |
599 | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ | |
600 | ' ', /* ar_pad_char */ | |
601 | 16, /* ar_max_namelen */ | |
602 | 3, /* minimum alignment power */ | |
603 | _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */ | |
604 | _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */ | |
605 | ||
606 | {_bfd_dummy_target, NAME(sunos,object_p), | |
607 | bfd_generic_archive_p, sunos4_core_file_p}, | |
608 | {bfd_false, NAME(aout,mkobject), | |
609 | _bfd_generic_mkarchive, bfd_false}, | |
610 | {bfd_false, NAME(aout,sunos4_write_object_contents), /* bfd_write_contents */ | |
611 | _bfd_write_archive_contents, bfd_false}, | |
612 | ||
613 | JUMP_TABLE(JNAME(aout)) | |
614 | }; |