1 /* BFD back-end for OSF/1 core files.
2 Copyright 1993, 1994 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
32 /* forward declarations */
35 make_bfd_asection PARAMS ((bfd *, CONST char *, flagword, bfd_size_type,
38 osf_core_make_empty_symbol PARAMS ((bfd *));
39 static const bfd_target *
40 osf_core_core_file_p PARAMS ((bfd *));
42 osf_core_core_file_failing_command PARAMS ((bfd *));
44 osf_core_core_file_failing_signal PARAMS ((bfd *));
46 osf_core_core_file_matches_executable_p PARAMS ((bfd *, bfd *));
48 swap_abort PARAMS ((void));
50 /* These are stored in the bfd's tdata */
52 struct osf_core_struct
55 char cmd[MAXCOMLEN + 1];
58 #define core_hdr(bfd) ((bfd)->tdata.osf_core_data)
59 #define core_signal(bfd) (core_hdr(bfd)->sig)
60 #define core_command(bfd) (core_hdr(bfd)->cmd)
63 make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos)
67 bfd_size_type _raw_size;
73 asect = bfd_make_section_anyway (abfd, name);
78 asect->_raw_size = _raw_size;
80 asect->filepos = filepos;
81 asect->alignment_power = 8;
87 osf_core_make_empty_symbol (abfd)
90 asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
96 static const bfd_target *
97 osf_core_core_file_p (abfd)
103 struct core_filehdr core_header;
105 val = bfd_read ((PTR)&core_header, 1, sizeof core_header, abfd);
106 if (val != sizeof core_header)
109 if (strncmp (core_header.magic, "Core", 4) != 0)
112 core_hdr (abfd) = (struct osf_core_struct *)
113 bfd_zalloc (abfd, sizeof (struct osf_core_struct));
114 if (!core_hdr (abfd))
117 strncpy (core_command (abfd), core_header.name, MAXCOMLEN + 1);
118 core_signal (abfd) = core_header.signo;
120 for (i = 0; i < core_header.nscns; i++)
122 struct core_scnhdr core_scnhdr;
125 val = bfd_read ((PTR)&core_scnhdr, 1, sizeof core_scnhdr, abfd);
126 if (val != sizeof core_scnhdr)
129 /* Skip empty sections. */
130 if (core_scnhdr.size == 0 || core_scnhdr.scnptr == 0)
133 switch (core_scnhdr.scntype)
137 flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
141 flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
145 flags = SEC_HAS_CONTENTS;
148 fprintf (stderr, "Unhandled OSF/1 core file section type %d\n",
149 core_scnhdr.scntype);
153 if (!make_bfd_asection (abfd, secname, flags,
154 (bfd_size_type) core_scnhdr.size,
155 (bfd_vma) core_scnhdr.vaddr,
156 (file_ptr) core_scnhdr.scnptr))
160 /* OK, we believe you. You're a core file (sure, sure). */
166 osf_core_core_file_failing_command (abfd)
169 return core_command (abfd);
174 osf_core_core_file_failing_signal (abfd)
177 return core_signal (abfd);
182 osf_core_core_file_matches_executable_p (core_bfd, exec_bfd)
183 bfd *core_bfd, *exec_bfd;
185 return true; /* FIXME, We have no way of telling at this point */
188 #define osf_core_get_symtab_upper_bound _bfd_nosymbols_get_symtab_upper_bound
189 #define osf_core_get_symtab _bfd_nosymbols_get_symtab
190 #define osf_core_print_symbol _bfd_nosymbols_print_symbol
191 #define osf_core_get_symbol_info _bfd_nosymbols_get_symbol_info
192 #define osf_core_bfd_is_local_label _bfd_nosymbols_bfd_is_local_label
193 #define osf_core_get_lineno _bfd_nosymbols_get_lineno
194 #define osf_core_find_nearest_line _bfd_nosymbols_find_nearest_line
195 #define osf_core_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
196 #define osf_core_read_minisymbols _bfd_nosymbols_read_minisymbols
197 #define osf_core_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
199 /* If somebody calls any byte-swapping routines, shoot them. */
203 abort(); /* This way doesn't require any declaration for ANSI to fuck up */
205 #define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
206 #define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
207 #define NO_SIGNED_GET \
208 ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
210 const bfd_target osf_core_vec =
213 bfd_target_unknown_flavour,
214 true, /* target byte order */
215 true, /* target headers byte order */
216 (HAS_RELOC | EXEC_P | /* object flags */
217 HAS_LINENO | HAS_DEBUG |
218 HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
219 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
220 0, /* symbol prefix */
221 ' ', /* ar_pad_char */
222 16, /* ar_max_namelen */
223 NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
224 NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
225 NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
226 NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */
227 NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */
228 NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */
230 { /* bfd_check_format */
231 _bfd_dummy_target, /* unknown format */
232 _bfd_dummy_target, /* object file */
233 _bfd_dummy_target, /* archive */
234 osf_core_core_file_p /* a core file */
236 { /* bfd_set_format */
237 bfd_false, bfd_false,
240 { /* bfd_write_contents */
241 bfd_false, bfd_false,
245 BFD_JUMP_TABLE_GENERIC (_bfd_generic),
246 BFD_JUMP_TABLE_COPY (_bfd_generic),
247 BFD_JUMP_TABLE_CORE (osf_core),
248 BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
249 BFD_JUMP_TABLE_SYMBOLS (osf_core),
250 BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
251 BFD_JUMP_TABLE_WRITE (_bfd_generic),
252 BFD_JUMP_TABLE_LINK (_bfd_nolink),
253 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
255 (PTR) 0 /* backend_data */