1 /* BFD back-end for OSF/1 core files.
2 Copyright 1993, 1994, 1995, 1998, 1999, 2001, 2002, 2003, 2004, 2006,
3 2007 Free Software Foundation, Inc.
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 3 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., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
23 /* This file can only be compiled on systems which use OSF/1 style
35 /* forward declarations */
37 static asection
*make_bfd_asection
38 PARAMS ((bfd
*, const char *, flagword
, bfd_size_type
, bfd_vma
, file_ptr
));
39 static const bfd_target
*osf_core_core_file_p
41 static char *osf_core_core_file_failing_command
43 static int osf_core_core_file_failing_signal
45 #define osf_core_core_file_matches_executable_p generic_core_file_matches_executable_p
46 static void swap_abort
49 /* These are stored in the bfd's tdata */
51 struct osf_core_struct
54 char cmd
[MAXCOMLEN
+ 1];
57 #define core_hdr(bfd) ((bfd)->tdata.osf_core_data)
58 #define core_signal(bfd) (core_hdr(bfd)->sig)
59 #define core_command(bfd) (core_hdr(bfd)->cmd)
62 make_bfd_asection (abfd
, name
, flags
, size
, vma
, filepos
)
72 asect
= bfd_make_section_anyway_with_flags (abfd
, name
, flags
);
78 asect
->filepos
= filepos
;
79 asect
->alignment_power
= 8;
84 static const bfd_target
*
85 osf_core_core_file_p (abfd
)
91 struct core_filehdr core_header
;
94 amt
= sizeof core_header
;
95 val
= bfd_bread ((PTR
) &core_header
, amt
, abfd
);
96 if (val
!= sizeof core_header
)
99 if (! CONST_STRNEQ (core_header
.magic
, "Core"))
102 core_hdr (abfd
) = (struct osf_core_struct
*)
103 bfd_zalloc (abfd
, (bfd_size_type
) sizeof (struct osf_core_struct
));
104 if (!core_hdr (abfd
))
107 strncpy (core_command (abfd
), core_header
.name
, MAXCOMLEN
+ 1);
108 core_signal (abfd
) = core_header
.signo
;
110 for (i
= 0; i
< core_header
.nscns
; i
++)
112 struct core_scnhdr core_scnhdr
;
115 amt
= sizeof core_scnhdr
;
116 val
= bfd_bread ((PTR
) &core_scnhdr
, amt
, abfd
);
117 if (val
!= sizeof core_scnhdr
)
120 /* Skip empty sections. */
121 if (core_scnhdr
.size
== 0 || core_scnhdr
.scnptr
== 0)
124 switch (core_scnhdr
.scntype
)
128 flags
= SEC_ALLOC
+ SEC_LOAD
+ SEC_HAS_CONTENTS
;
132 flags
= SEC_ALLOC
+ SEC_LOAD
+ SEC_HAS_CONTENTS
;
136 flags
= SEC_HAS_CONTENTS
;
139 (*_bfd_error_handler
) (_("Unhandled OSF/1 core file section type %d\n"),
140 core_scnhdr
.scntype
);
144 if (!make_bfd_asection (abfd
, secname
, flags
,
145 (bfd_size_type
) core_scnhdr
.size
,
146 (bfd_vma
) core_scnhdr
.vaddr
,
147 (file_ptr
) core_scnhdr
.scnptr
))
151 /* OK, we believe you. You're a core file (sure, sure). */
156 bfd_release (abfd
, core_hdr (abfd
));
157 core_hdr (abfd
) = NULL
;
158 bfd_section_list_clear (abfd
);
163 osf_core_core_file_failing_command (abfd
)
166 return core_command (abfd
);
170 osf_core_core_file_failing_signal (abfd
)
173 return core_signal (abfd
);
176 /* If somebody calls any byte-swapping routines, shoot them. */
180 abort(); /* This way doesn't require any declaration for ANSI to fuck up */
183 #define NO_GET ((bfd_vma (*) (const void *)) swap_abort)
184 #define NO_PUT ((void (*) (bfd_vma, void *)) swap_abort)
185 #define NO_GETS ((bfd_signed_vma (*) (const void *)) swap_abort)
186 #define NO_GET64 ((bfd_uint64_t (*) (const void *)) swap_abort)
187 #define NO_PUT64 ((void (*) (bfd_uint64_t, void *)) swap_abort)
188 #define NO_GETS64 ((bfd_int64_t (*) (const void *)) swap_abort)
190 const bfd_target osf_core_vec
=
193 bfd_target_unknown_flavour
,
194 BFD_ENDIAN_LITTLE
, /* target byte order */
195 BFD_ENDIAN_LITTLE
, /* target headers byte order */
196 (HAS_RELOC
| EXEC_P
| /* object flags */
197 HAS_LINENO
| HAS_DEBUG
|
198 HAS_SYMS
| HAS_LOCALS
| WP_TEXT
| D_PAGED
),
199 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
200 0, /* symbol prefix */
201 ' ', /* ar_pad_char */
202 16, /* ar_max_namelen */
203 NO_GET64
, NO_GETS64
, NO_PUT64
, /* 64 bit data */
204 NO_GET
, NO_GETS
, NO_PUT
, /* 32 bit data */
205 NO_GET
, NO_GETS
, NO_PUT
, /* 16 bit data */
206 NO_GET64
, NO_GETS64
, NO_PUT64
, /* 64 bit hdrs */
207 NO_GET
, NO_GETS
, NO_PUT
, /* 32 bit hdrs */
208 NO_GET
, NO_GETS
, NO_PUT
, /* 16 bit hdrs */
210 { /* bfd_check_format */
211 _bfd_dummy_target
, /* unknown format */
212 _bfd_dummy_target
, /* object file */
213 _bfd_dummy_target
, /* archive */
214 osf_core_core_file_p
/* a core file */
216 { /* bfd_set_format */
217 bfd_false
, bfd_false
,
220 { /* bfd_write_contents */
221 bfd_false
, bfd_false
,
225 BFD_JUMP_TABLE_GENERIC (_bfd_generic
),
226 BFD_JUMP_TABLE_COPY (_bfd_generic
),
227 BFD_JUMP_TABLE_CORE (osf_core
),
228 BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive
),
229 BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols
),
230 BFD_JUMP_TABLE_RELOCS (_bfd_norelocs
),
231 BFD_JUMP_TABLE_WRITE (_bfd_generic
),
232 BFD_JUMP_TABLE_LINK (_bfd_nolink
),
233 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic
),
237 (PTR
) 0 /* backend_data */