1 /* BFD back-end for OSF/1 core files.
2 Copyright 1993, 94, 95, 97, 1998 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 /* This file can only be compiled on systems which use OSF/1 style
30 /* forward declarations */
33 make_bfd_asection PARAMS ((bfd *, CONST char *, flagword, bfd_size_type,
36 osf_core_make_empty_symbol PARAMS ((bfd *));
37 static const bfd_target *
38 osf_core_core_file_p PARAMS ((bfd *));
40 osf_core_core_file_failing_command PARAMS ((bfd *));
42 osf_core_core_file_failing_signal PARAMS ((bfd *));
44 osf_core_core_file_matches_executable_p PARAMS ((bfd *, bfd *));
46 swap_abort PARAMS ((void));
48 /* These are stored in the bfd's tdata */
50 struct osf_core_struct
53 char cmd[MAXCOMLEN + 1];
56 #define core_hdr(bfd) ((bfd)->tdata.osf_core_data)
57 #define core_signal(bfd) (core_hdr(bfd)->sig)
58 #define core_command(bfd) (core_hdr(bfd)->cmd)
61 make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos)
65 bfd_size_type _raw_size;
71 asect = bfd_make_section_anyway (abfd, name);
76 asect->_raw_size = _raw_size;
78 asect->filepos = filepos;
79 asect->alignment_power = 8;
85 osf_core_make_empty_symbol (abfd)
88 asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
94 static const bfd_target *
95 osf_core_core_file_p (abfd)
101 struct core_filehdr core_header;
103 val = bfd_read ((PTR)&core_header, 1, sizeof core_header, abfd);
104 if (val != sizeof core_header)
107 if (strncmp (core_header.magic, "Core", 4) != 0)
110 core_hdr (abfd) = (struct osf_core_struct *)
111 bfd_zalloc (abfd, sizeof (struct osf_core_struct));
112 if (!core_hdr (abfd))
115 strncpy (core_command (abfd), core_header.name, MAXCOMLEN + 1);
116 core_signal (abfd) = core_header.signo;
118 for (i = 0; i < core_header.nscns; i++)
120 struct core_scnhdr core_scnhdr;
123 val = bfd_read ((PTR)&core_scnhdr, 1, sizeof core_scnhdr, abfd);
124 if (val != sizeof core_scnhdr)
127 /* Skip empty sections. */
128 if (core_scnhdr.size == 0 || core_scnhdr.scnptr == 0)
131 switch (core_scnhdr.scntype)
135 flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
139 flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
143 flags = SEC_HAS_CONTENTS;
146 (*_bfd_error_handler) (_("Unhandled OSF/1 core file section type %d\n"),
147 core_scnhdr.scntype);
151 if (!make_bfd_asection (abfd, secname, flags,
152 (bfd_size_type) core_scnhdr.size,
153 (bfd_vma) core_scnhdr.vaddr,
154 (file_ptr) core_scnhdr.scnptr))
158 /* OK, we believe you. You're a core file (sure, sure). */
164 osf_core_core_file_failing_command (abfd)
167 return core_command (abfd);
172 osf_core_core_file_failing_signal (abfd)
175 return core_signal (abfd);
180 osf_core_core_file_matches_executable_p (core_bfd, exec_bfd)
181 bfd *core_bfd, *exec_bfd;
183 return true; /* FIXME, We have no way of telling at this point */
186 #define osf_core_get_symtab_upper_bound _bfd_nosymbols_get_symtab_upper_bound
187 #define osf_core_get_symtab _bfd_nosymbols_get_symtab
188 #define osf_core_print_symbol _bfd_nosymbols_print_symbol
189 #define osf_core_get_symbol_info _bfd_nosymbols_get_symbol_info
190 #define osf_core_bfd_is_local_label_name _bfd_nosymbols_bfd_is_local_label_name
191 #define osf_core_get_lineno _bfd_nosymbols_get_lineno
192 #define osf_core_find_nearest_line _bfd_nosymbols_find_nearest_line
193 #define osf_core_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
194 #define osf_core_read_minisymbols _bfd_nosymbols_read_minisymbols
195 #define osf_core_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
197 /* If somebody calls any byte-swapping routines, shoot them. */
201 abort(); /* This way doesn't require any declaration for ANSI to fuck up */
203 #define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
204 #define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
205 #define NO_SIGNED_GET \
206 ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
208 const bfd_target osf_core_vec =
211 bfd_target_unknown_flavour,
212 BFD_ENDIAN_BIG, /* target byte order */
213 BFD_ENDIAN_BIG, /* target headers byte order */
214 (HAS_RELOC | EXEC_P | /* object flags */
215 HAS_LINENO | HAS_DEBUG |
216 HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
217 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
218 0, /* symbol prefix */
219 ' ', /* ar_pad_char */
220 16, /* ar_max_namelen */
221 NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
222 NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
223 NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
224 NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */
225 NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */
226 NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */
228 { /* bfd_check_format */
229 _bfd_dummy_target, /* unknown format */
230 _bfd_dummy_target, /* object file */
231 _bfd_dummy_target, /* archive */
232 osf_core_core_file_p /* a core file */
234 { /* bfd_set_format */
235 bfd_false, bfd_false,
238 { /* bfd_write_contents */
239 bfd_false, bfd_false,
243 BFD_JUMP_TABLE_GENERIC (_bfd_generic),
244 BFD_JUMP_TABLE_COPY (_bfd_generic),
245 BFD_JUMP_TABLE_CORE (osf_core),
246 BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
247 BFD_JUMP_TABLE_SYMBOLS (osf_core),
248 BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
249 BFD_JUMP_TABLE_WRITE (_bfd_generic),
250 BFD_JUMP_TABLE_LINK (_bfd_nolink),
251 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
253 (PTR) 0 /* backend_data */