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