1 /* BFD back-end for OSF/1 core files.
2 Copyright 1993, 1994, 1995, 1998, 1999, 2001
3 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 /* This file can only be compiled on systems which use OSF/1 style
31 /* forward declarations */
34 make_bfd_asection PARAMS ((bfd *, const char *, flagword, bfd_size_type,
37 osf_core_make_empty_symbol PARAMS ((bfd *));
38 static const bfd_target *
39 osf_core_core_file_p PARAMS ((bfd *));
41 osf_core_core_file_failing_command PARAMS ((bfd *));
43 osf_core_core_file_failing_signal PARAMS ((bfd *));
45 osf_core_core_file_matches_executable_p PARAMS ((bfd *, bfd *));
47 swap_abort PARAMS ((void));
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, _raw_size, vma, filepos)
66 bfd_size_type _raw_size;
72 asect = bfd_make_section_anyway (abfd, name);
77 asect->_raw_size = _raw_size;
79 asect->filepos = filepos;
80 asect->alignment_power = 8;
86 osf_core_make_empty_symbol (abfd)
91 new = (asymbol *) bfd_zalloc (abfd, (bfd_size_type) sizeof (asymbol));
97 static const bfd_target *
98 osf_core_core_file_p (abfd)
104 struct core_filehdr core_header;
107 amt = sizeof core_header;
108 val = bfd_bread ((PTR) &core_header, amt, abfd);
109 if (val != sizeof core_header)
112 if (strncmp (core_header.magic, "Core", 4) != 0)
115 core_hdr (abfd) = (struct osf_core_struct *)
116 bfd_zalloc (abfd, (bfd_size_type) sizeof (struct osf_core_struct));
117 if (!core_hdr (abfd))
120 strncpy (core_command (abfd), core_header.name, MAXCOMLEN + 1);
121 core_signal (abfd) = core_header.signo;
123 for (i = 0; i < core_header.nscns; i++)
125 struct core_scnhdr core_scnhdr;
128 amt = sizeof core_scnhdr;
129 val = bfd_bread ((PTR) &core_scnhdr, amt, abfd);
130 if (val != sizeof core_scnhdr)
133 /* Skip empty sections. */
134 if (core_scnhdr.size == 0 || core_scnhdr.scnptr == 0)
137 switch (core_scnhdr.scntype)
141 flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
145 flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
149 flags = SEC_HAS_CONTENTS;
152 (*_bfd_error_handler) (_("Unhandled OSF/1 core file section type %d\n"),
153 core_scnhdr.scntype);
157 if (!make_bfd_asection (abfd, secname, flags,
158 (bfd_size_type) core_scnhdr.size,
159 (bfd_vma) core_scnhdr.vaddr,
160 (file_ptr) core_scnhdr.scnptr))
164 /* OK, we believe you. You're a core file (sure, sure). */
170 osf_core_core_file_failing_command (abfd)
173 return core_command (abfd);
178 osf_core_core_file_failing_signal (abfd)
181 return core_signal (abfd);
186 osf_core_core_file_matches_executable_p (core_bfd, exec_bfd)
187 bfd *core_bfd ATTRIBUTE_UNUSED;
188 bfd *exec_bfd ATTRIBUTE_UNUSED;
190 return true; /* FIXME, We have no way of telling at this point */
193 #define osf_core_get_symtab_upper_bound _bfd_nosymbols_get_symtab_upper_bound
194 #define osf_core_get_symtab _bfd_nosymbols_get_symtab
195 #define osf_core_print_symbol _bfd_nosymbols_print_symbol
196 #define osf_core_get_symbol_info _bfd_nosymbols_get_symbol_info
197 #define osf_core_bfd_is_local_label_name _bfd_nosymbols_bfd_is_local_label_name
198 #define osf_core_get_lineno _bfd_nosymbols_get_lineno
199 #define osf_core_find_nearest_line _bfd_nosymbols_find_nearest_line
200 #define osf_core_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
201 #define osf_core_read_minisymbols _bfd_nosymbols_read_minisymbols
202 #define osf_core_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
204 /* If somebody calls any byte-swapping routines, shoot them. */
208 abort(); /* This way doesn't require any declaration for ANSI to fuck up */
210 #define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
211 #define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
212 #define NO_SIGNED_GET \
213 ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
215 const bfd_target osf_core_vec =
218 bfd_target_unknown_flavour,
219 BFD_ENDIAN_BIG, /* target byte order */
220 BFD_ENDIAN_BIG, /* target headers byte order */
221 (HAS_RELOC | EXEC_P | /* object flags */
222 HAS_LINENO | HAS_DEBUG |
223 HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
224 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
225 0, /* symbol prefix */
226 ' ', /* ar_pad_char */
227 16, /* ar_max_namelen */
228 NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
229 NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
230 NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
231 NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */
232 NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */
233 NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */
235 { /* bfd_check_format */
236 _bfd_dummy_target, /* unknown format */
237 _bfd_dummy_target, /* object file */
238 _bfd_dummy_target, /* archive */
239 osf_core_core_file_p /* a core file */
241 { /* bfd_set_format */
242 bfd_false, bfd_false,
245 { /* bfd_write_contents */
246 bfd_false, bfd_false,
250 BFD_JUMP_TABLE_GENERIC (_bfd_generic),
251 BFD_JUMP_TABLE_COPY (_bfd_generic),
252 BFD_JUMP_TABLE_CORE (osf_core),
253 BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
254 BFD_JUMP_TABLE_SYMBOLS (osf_core),
255 BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
256 BFD_JUMP_TABLE_WRITE (_bfd_generic),
257 BFD_JUMP_TABLE_LINK (_bfd_nolink),
258 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
262 (PTR) 0 /* backend_data */