1 /* BFD back-end for OSF/1 core files.
2 Copyright 1993 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
20 /* This file can only be compiled on systems which use OSF/1 style
21 core files. In the config/XXXXXX.mh file for such a system add
35 /* forward declarations */
38 make_bfd_asection PARAMS ((bfd *, CONST char *, flagword, bfd_size_type,
41 osf_core_make_empty_symbol PARAMS ((bfd *));
43 osf_core_core_file_p PARAMS ((bfd *));
45 osf_core_core_file_failing_command PARAMS ((bfd *));
47 osf_core_core_file_failing_signal PARAMS ((bfd *));
49 osf_core_core_file_matches_executable_p PARAMS ((bfd *, bfd *));
51 swap_abort PARAMS ((void));
53 /* These are stored in the bfd's tdata */
55 struct osf_core_struct
58 char cmd[MAXCOMLEN + 1];
61 #define core_hdr(bfd) ((bfd)->tdata.osf_core_data)
62 #define core_signal(bfd) (core_hdr(bfd)->sig)
63 #define core_command(bfd) (core_hdr(bfd)->cmd)
66 make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos)
70 bfd_size_type _raw_size;
76 asect = bfd_make_section (abfd, name);
81 asect->_raw_size = _raw_size;
83 asect->filepos = filepos;
84 asect->alignment_power = 8;
90 osf_core_make_empty_symbol (abfd)
93 asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
100 osf_core_core_file_p (abfd)
106 struct core_filehdr core_header;
109 val = bfd_read ((PTR)&core_header, 1, sizeof core_header, abfd);
110 if (val != sizeof core_header)
113 if (strncmp (core_header.magic, "Core", 4) != 0)
116 core_hdr (abfd) = (struct osf_core_struct *)
117 bfd_zalloc (abfd, sizeof (struct osf_core_struct));
118 if (!core_hdr (abfd))
121 strncpy (core_command (abfd), core_header.name, MAXCOMLEN + 1);
122 core_signal (abfd) = core_header.signo;
124 for (i = 0; i < core_header.nscns; i++)
126 struct core_scnhdr core_scnhdr;
128 val = bfd_read ((PTR)&core_scnhdr, 1, sizeof core_scnhdr, abfd);
129 if (val != sizeof core_scnhdr)
132 /* Skip empty sections. */
133 if (core_scnhdr.size == 0 || core_scnhdr.scnptr == 0)
136 switch (core_scnhdr.scntype)
139 /* OSF/1 has multiple data sections (data, bss and data/bss sections
140 for shared libraries), but bfd doesn't permit data sections with
141 the same name. Construct a unique section name. */
142 secname = bfd_alloc (abfd, 40);
145 bfd_set_error (bfd_error_no_memory);
148 sprintf (secname, ".data%d", dseccnt++);
157 fprintf (stderr, "Unhandled OSF/1 core file section type %d\n",
158 core_scnhdr.scntype);
162 if (!make_bfd_asection (abfd, secname,
163 SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS,
164 (bfd_size_type) core_scnhdr.size,
165 (bfd_vma) core_scnhdr.vaddr,
166 (file_ptr) core_scnhdr.scnptr))
170 /* OK, we believe you. You're a core file (sure, sure). */
176 osf_core_core_file_failing_command (abfd)
179 return core_command (abfd);
184 osf_core_core_file_failing_signal (abfd)
187 return core_signal (abfd);
192 osf_core_core_file_matches_executable_p (core_bfd, exec_bfd)
193 bfd *core_bfd, *exec_bfd;
195 return true; /* FIXME, We have no way of telling at this point */
198 #define osf_core_get_symtab_upper_bound _bfd_nosymbols_get_symtab_upper_bound
199 #define osf_core_get_symtab _bfd_nosymbols_get_symtab
200 #define osf_core_print_symbol _bfd_nosymbols_print_symbol
201 #define osf_core_get_symbol_info _bfd_nosymbols_get_symbol_info
202 #define osf_core_bfd_is_local_label _bfd_nosymbols_bfd_is_local_label
203 #define osf_core_get_lineno _bfd_nosymbols_get_lineno
204 #define osf_core_find_nearest_line _bfd_nosymbols_find_nearest_line
205 #define osf_core_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
207 /* If somebody calls any byte-swapping routines, shoot them. */
211 abort(); /* This way doesn't require any declaration for ANSI to fuck up */
213 #define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
214 #define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
215 #define NO_SIGNED_GET \
216 ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
218 bfd_target osf_core_vec =
221 bfd_target_unknown_flavour,
222 true, /* target byte order */
223 true, /* target headers byte order */
224 (HAS_RELOC | EXEC_P | /* object flags */
225 HAS_LINENO | HAS_DEBUG |
226 HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
227 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
228 0, /* symbol prefix */
229 ' ', /* ar_pad_char */
230 16, /* ar_max_namelen */
231 3, /* minimum alignment power */
232 NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
233 NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
234 NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
235 NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */
236 NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */
237 NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */
239 { /* bfd_check_format */
240 _bfd_dummy_target, /* unknown format */
241 _bfd_dummy_target, /* object file */
242 _bfd_dummy_target, /* archive */
243 osf_core_core_file_p /* a core file */
245 { /* bfd_set_format */
246 bfd_false, bfd_false,
249 { /* bfd_write_contents */
250 bfd_false, bfd_false,
254 BFD_JUMP_TABLE_GENERIC (_bfd_generic),
255 BFD_JUMP_TABLE_COPY (_bfd_generic),
256 BFD_JUMP_TABLE_CORE (osf_core),
257 BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
258 BFD_JUMP_TABLE_SYMBOLS (osf_core),
259 BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
260 BFD_JUMP_TABLE_WRITE (_bfd_generic),
261 BFD_JUMP_TABLE_LINK (_bfd_nolink),
263 (PTR) 0 /* backend_data */