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
));
99 osf_core_core_file_p (abfd
)
105 struct core_filehdr core_header
;
108 val
= bfd_read ((PTR
)&core_header
, 1, sizeof core_header
, 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
, 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
;
127 val
= bfd_read ((PTR
)&core_scnhdr
, 1, sizeof core_scnhdr
, abfd
);
128 if (val
!= sizeof core_scnhdr
)
131 /* Skip empty sections. */
132 if (core_scnhdr
.size
== 0 || core_scnhdr
.scnptr
== 0)
135 switch (core_scnhdr
.scntype
)
138 /* OSF/1 has multiple data sections (data, bss and data/bss sections
139 for shared libraries), but bfd doesn't permit data sections with
140 the same name. Construct a unique section name. */
141 secname
= bfd_alloc (abfd
, 40);
142 sprintf (secname
, ".data%d", dseccnt
++);
151 fprintf (stderr
, "Unhandled OSF/1 core file section type %d\n",
152 core_scnhdr
.scntype
);
156 if (!make_bfd_asection (abfd
, secname
,
157 SEC_ALLOC
+SEC_LOAD
+SEC_HAS_CONTENTS
,
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
, *exec_bfd
;
189 return true; /* FIXME, We have no way of telling at this point */
192 /* No archive file support via this BFD */
193 #define osf_core_openr_next_archived_file bfd_generic_openr_next_archived_file
194 #define osf_core_generic_stat_arch_elt bfd_generic_stat_arch_elt
195 #define osf_core_slurp_armap bfd_false
196 #define osf_core_slurp_extended_name_table bfd_true
197 #define osf_core_write_armap (boolean (*) PARAMS \
198 ((bfd *arch, unsigned int elength, struct orl *map, \
199 unsigned int orl_count, int stridx))) bfd_false
200 #define osf_core_truncate_arname bfd_dont_truncate_arname
202 #define osf_core_close_and_cleanup bfd_generic_close_and_cleanup
203 #define osf_core_set_section_contents (boolean (*) PARAMS \
204 ((bfd *abfd, asection *section, PTR data, file_ptr offset, \
205 bfd_size_type count))) bfd_false
206 #define osf_core_get_section_contents bfd_generic_get_section_contents
207 #define osf_core_new_section_hook (boolean (*) PARAMS \
208 ((bfd *, sec_ptr))) bfd_true
209 #define osf_core_get_symtab_upper_bound bfd_0u
210 #define osf_core_get_symtab (unsigned int (*) PARAMS \
211 ((bfd *, struct symbol_cache_entry **))) bfd_0u
212 #define osf_core_get_reloc_upper_bound (unsigned int (*) PARAMS \
213 ((bfd *, sec_ptr))) bfd_0u
214 #define osf_core_canonicalize_reloc (unsigned int (*) PARAMS \
215 ((bfd *, sec_ptr, arelent **, struct symbol_cache_entry**))) bfd_0u
216 #define osf_core_print_symbol (void (*) PARAMS \
217 ((bfd *, PTR, struct symbol_cache_entry *, \
218 bfd_print_symbol_type))) bfd_false
219 #define osf_core_get_symbol_info (void (*) PARAMS \
220 ((bfd *, struct symbol_cache_entry *, \
221 symbol_info *))) bfd_false
222 #define osf_core_get_lineno (alent * (*) PARAMS \
223 ((bfd *, struct symbol_cache_entry *))) bfd_nullvoidptr
224 #define osf_core_set_arch_mach (boolean (*) PARAMS \
225 ((bfd *, enum bfd_architecture, unsigned long))) bfd_false
226 #define osf_core_find_nearest_line (boolean (*) PARAMS \
227 ((bfd *abfd, struct sec *section, \
228 struct symbol_cache_entry **symbols,bfd_vma offset, \
229 CONST char **file, CONST char **func, unsigned int *line))) bfd_false
230 #define osf_core_sizeof_headers (int (*) PARAMS \
231 ((bfd *, boolean))) bfd_0
233 #define osf_core_bfd_debug_info_start bfd_void
234 #define osf_core_bfd_debug_info_end bfd_void
235 #define osf_core_bfd_debug_info_accumulate (void (*) PARAMS \
236 ((bfd *, struct sec *))) bfd_void
237 #define osf_core_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
238 #define osf_core_bfd_relax_section bfd_generic_relax_section
239 #define osf_core_bfd_reloc_type_lookup \
240 ((CONST struct reloc_howto_struct *(*) PARAMS ((bfd *, bfd_reloc_code_real_type))) bfd_nullvoidptr)
241 #define osf_core_bfd_make_debug_symbol \
242 ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
243 #define osf_core_bfd_link_hash_table_create \
244 ((struct bfd_link_hash_table *(*) PARAMS ((bfd *))) bfd_nullvoidptr)
245 #define osf_core_bfd_link_add_symbols \
246 ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false)
247 #define osf_core_bfd_final_link \
248 ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false)
250 /* If somebody calls any byte-swapping routines, shoot them. */
254 abort(); /* This way doesn't require any declaration for ANSI to fuck up */
256 #define NO_GET ((bfd_vma (*) PARAMS (( bfd_byte *))) swap_abort )
257 #define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
258 #define NO_SIGNED_GET ((bfd_signed_vma (*) PARAMS ((bfd_byte *))) swap_abort )
260 bfd_target osf_core_vec
=
263 bfd_target_unknown_flavour
,
264 true, /* target byte order */
265 true, /* target headers byte order */
266 (HAS_RELOC
| EXEC_P
| /* object flags */
267 HAS_LINENO
| HAS_DEBUG
|
268 HAS_SYMS
| HAS_LOCALS
| WP_TEXT
| D_PAGED
),
269 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
270 0, /* symbol prefix */
271 ' ', /* ar_pad_char */
272 16, /* ar_max_namelen */
273 3, /* minimum alignment power */
274 NO_GET
, NO_SIGNED_GET
, NO_PUT
, /* 64 bit data */
275 NO_GET
, NO_SIGNED_GET
, NO_PUT
, /* 32 bit data */
276 NO_GET
, NO_SIGNED_GET
, NO_PUT
, /* 16 bit data */
277 NO_GET
, NO_SIGNED_GET
, NO_PUT
, /* 64 bit hdrs */
278 NO_GET
, NO_SIGNED_GET
, NO_PUT
, /* 32 bit hdrs */
279 NO_GET
, NO_SIGNED_GET
, NO_PUT
, /* 16 bit hdrs */
281 { /* bfd_check_format */
282 _bfd_dummy_target
, /* unknown format */
283 _bfd_dummy_target
, /* object file */
284 _bfd_dummy_target
, /* archive */
285 osf_core_core_file_p
/* a core file */
287 { /* bfd_set_format */
288 bfd_false
, bfd_false
,
291 { /* bfd_write_contents */
292 bfd_false
, bfd_false
,
296 JUMP_TABLE(osf_core
),
297 (PTR
) 0 /* backend_data */