1 /* BFD back-end for HP/UX core files.
2 Copyright 1993 Free Software Foundation, Inc.
3 Written by Stu Grossman, Cygnus Support.
4 Converted to back-end form by Ian Lance Taylor, Cygnus SUpport
6 This file is part of BFD, the Binary File Descriptor library.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
22 /* This file can only be compiled on systems which use HP/UX style
23 core files. In the config/XXXXXX.mh file for such a system add
32 #if defined (HOST_HPPAHPUX) || defined (HOST_HP300HPUX)
34 /* FIXME: sys/core.h doesn't exist for HPUX version 7. HPUX version
35 5, 6, and 7 core files seem to be standard trad-core.c type core
36 files; can we just use trad-core.c in addition to this file? */
39 #include <sys/utsname.h>
41 #endif /* HOST_HPPAHPUX */
45 /* Not a very swift place to put it, but that's where the BSD port
47 #include "/hpux/usr/include/sys/core.h"
49 #endif /* HOST_HPPABSD */
52 #include <sys/types.h>
53 #include <sys/param.h>
56 #include <machine/reg.h>
57 #include <sys/user.h> /* After a.out.h */
61 /* These are stored in the bfd's tdata */
63 struct hpux_core_struct
66 char cmd
[MAXCOMLEN
+ 1];
67 asection
*data_section
;
68 asection
*stack_section
;
69 asection
*reg_section
;
72 #define core_hdr(bfd) ((bfd)->tdata.hpux_core_data)
73 #define core_signal(bfd) (core_hdr(bfd)->sig)
74 #define core_command(bfd) (core_hdr(bfd)->cmd)
75 #define core_datasec(bfd) (core_hdr(bfd)->data_section)
76 #define core_stacksec(bfd) (core_hdr(bfd)->stack_section)
77 #define core_regsec(bfd) (core_hdr(bfd)->reg_section)
80 make_bfd_asection (abfd
, name
, flags
, _raw_size
, vma
, alignment_power
)
84 bfd_size_type _raw_size
;
86 unsigned int alignment_power
;
90 asect
= bfd_make_section (abfd
, name
);
95 asect
->_raw_size
= _raw_size
;
97 asect
->filepos
= bfd_tell (abfd
);
98 asect
->alignment_power
= alignment_power
;
104 hpux_core_make_empty_symbol (abfd
)
107 asymbol
*new = (asymbol
*) bfd_zalloc (abfd
, sizeof (asymbol
));
114 hpux_core_core_file_p (abfd
)
117 core_hdr (abfd
) = (struct hpux_core_struct
*)
118 bfd_zalloc (abfd
, sizeof (struct hpux_core_struct
));
119 if (!core_hdr (abfd
))
125 struct corehead core_header
;
127 val
= bfd_read ((void *) &core_header
, 1, sizeof core_header
, abfd
);
130 switch (core_header
.type
)
134 bfd_seek (abfd
, core_header
.len
, SEEK_CUR
); /* Just skip this */
138 struct proc_exec proc_exec
;
139 bfd_read ((void *) &proc_exec
, 1, core_header
.len
, abfd
);
140 strncpy (core_command (abfd
), proc_exec
.cmd
, MAXCOMLEN
+ 1);
145 struct proc_info proc_info
;
146 core_regsec (abfd
) = make_bfd_asection (abfd
, ".reg",
147 SEC_ALLOC
+ SEC_HAS_CONTENTS
,
149 (int) &proc_info
- (int) &proc_info
.hw_regs
,
151 bfd_read (&proc_info
, 1, core_header
.len
, abfd
);
152 core_signal (abfd
) = proc_info
.sig
;
154 if (!core_regsec (abfd
))
158 core_datasec (abfd
) = make_bfd_asection (abfd
, ".data",
159 SEC_ALLOC
+ SEC_LOAD
+ SEC_HAS_CONTENTS
,
163 if (!core_datasec (abfd
))
165 bfd_seek (abfd
, core_header
.len
, SEEK_CUR
);
168 core_stacksec (abfd
) = make_bfd_asection (abfd
, ".stack",
169 SEC_ALLOC
+ SEC_LOAD
+ SEC_HAS_CONTENTS
,
173 if (!core_stacksec (abfd
))
175 bfd_seek (abfd
, core_header
.len
, SEEK_CUR
);
178 /* Falling into here is an error and should prevent this
179 target from matching. That way systems which use hpux
180 cores along with other formats can still work. */
185 /* OK, we believe you. You're a core file (sure, sure). */
191 hpux_core_core_file_failing_command (abfd
)
194 return core_command (abfd
);
199 hpux_core_core_file_failing_signal (abfd
)
202 return core_signal (abfd
);
207 hpux_core_core_file_matches_executable_p (core_bfd
, exec_bfd
)
208 bfd
*core_bfd
, *exec_bfd
;
210 return true; /* FIXME, We have no way of telling at this point */
213 /* No archive file support via this BFD */
214 #define hpux_core_openr_next_archived_file bfd_generic_openr_next_archived_file
215 #define hpux_core_generic_stat_arch_elt bfd_generic_stat_arch_elt
216 #define hpux_core_slurp_armap bfd_false
217 #define hpux_core_slurp_extended_name_table bfd_true
218 #define hpux_core_write_armap (boolean (*) PARAMS \
219 ((bfd *arch, unsigned int elength, struct orl *map, \
220 unsigned int orl_count, int stridx))) bfd_false
221 #define hpux_core_truncate_arname bfd_dont_truncate_arname
223 #define hpux_core_close_and_cleanup bfd_generic_close_and_cleanup
224 #define hpux_core_set_section_contents (boolean (*) PARAMS \
225 ((bfd *abfd, asection *section, PTR data, file_ptr offset, \
226 bfd_size_type count))) bfd_generic_set_section_contents
227 #define hpux_core_get_section_contents bfd_generic_get_section_contents
228 #define hpux_core_new_section_hook (boolean (*) PARAMS \
229 ((bfd *, sec_ptr))) bfd_true
230 #define hpux_core_get_symtab_upper_bound bfd_0l
231 #define hpux_core_get_symtab (long (*) PARAMS \
232 ((bfd *, struct symbol_cache_entry **))) bfd_0l
233 #define hpux_core_get_reloc_upper_bound (long (*) PARAMS \
234 ((bfd *, sec_ptr))) bfd_0l
235 #define hpux_core_canonicalize_reloc (long (*) PARAMS \
236 ((bfd *, sec_ptr, arelent **, struct symbol_cache_entry**))) bfd_0l
237 #define hpux_core_print_symbol (void (*) PARAMS \
238 ((bfd *, PTR, struct symbol_cache_entry *, \
239 bfd_print_symbol_type))) bfd_false
240 #define hpux_core_get_symbol_info (void (*) PARAMS \
241 ((bfd *, struct symbol_cache_entry *, \
242 symbol_info *))) bfd_false
243 #define hpux_core_get_lineno (alent * (*) PARAMS \
244 ((bfd *, struct symbol_cache_entry *))) bfd_nullvoidptr
245 #define hpux_core_set_arch_mach (boolean (*) PARAMS \
246 ((bfd *, enum bfd_architecture, unsigned long))) bfd_false
247 #define hpux_core_find_nearest_line (boolean (*) PARAMS \
248 ((bfd *abfd, struct sec *section, \
249 struct symbol_cache_entry **symbols,bfd_vma offset, \
250 CONST char **file, CONST char **func, unsigned int *line))) bfd_false
251 #define hpux_core_sizeof_headers (int (*) PARAMS \
252 ((bfd *, boolean))) bfd_0
254 #define hpux_core_bfd_debug_info_start bfd_void
255 #define hpux_core_bfd_debug_info_end bfd_void
256 #define hpux_core_bfd_debug_info_accumulate (void (*) PARAMS \
257 ((bfd *, struct sec *))) bfd_void
258 #define hpux_core_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
259 #define hpux_core_bfd_relax_section bfd_generic_relax_section
260 #define hpux_core_bfd_reloc_type_lookup \
261 ((CONST struct reloc_howto_struct *(*) PARAMS ((bfd *, bfd_reloc_code_real_type))) bfd_nullvoidptr)
262 #define hpux_core_bfd_make_debug_symbol \
263 ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
264 #define hpux_core_bfd_link_hash_table_create \
265 ((struct bfd_link_hash_table *(*) PARAMS ((bfd *))) bfd_nullvoidptr)
266 #define hpux_core_bfd_link_add_symbols \
267 ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false)
268 #define hpux_core_bfd_final_link \
269 ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false)
270 #define hpux_core_bfd_copy_private_section_data \
271 ((boolean (*) PARAMS ((bfd *, asection *, bfd *, asection *))) bfd_false)
272 #define hpux_core_bfd_copy_private_bfd_data \
273 ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_false)
274 #define hpux_core_bfd_is_local_label \
275 ((boolean (*) PARAMS ((bfd *, asymbol *))) bfd_false)
277 /* If somebody calls any byte-swapping routines, shoot them. */
281 abort(); /* This way doesn't require any declaration for ANSI to fuck up */
283 #define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
284 #define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
285 #define NO_SIGNED_GET \
286 ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
288 bfd_target hpux_core_vec
=
291 bfd_target_unknown_flavour
,
292 true, /* target byte order */
293 true, /* target headers byte order */
294 (HAS_RELOC
| EXEC_P
| /* object flags */
295 HAS_LINENO
| HAS_DEBUG
|
296 HAS_SYMS
| HAS_LOCALS
| WP_TEXT
| D_PAGED
),
297 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
298 0, /* symbol prefix */
299 ' ', /* ar_pad_char */
300 16, /* ar_max_namelen */
301 3, /* minimum alignment power */
302 NO_GET
, NO_SIGNED_GET
, NO_PUT
, /* 64 bit data */
303 NO_GET
, NO_SIGNED_GET
, NO_PUT
, /* 32 bit data */
304 NO_GET
, NO_SIGNED_GET
, NO_PUT
, /* 16 bit data */
305 NO_GET
, NO_SIGNED_GET
, NO_PUT
, /* 64 bit hdrs */
306 NO_GET
, NO_SIGNED_GET
, NO_PUT
, /* 32 bit hdrs */
307 NO_GET
, NO_SIGNED_GET
, NO_PUT
, /* 16 bit hdrs */
309 { /* bfd_check_format */
310 _bfd_dummy_target
, /* unknown format */
311 _bfd_dummy_target
, /* object file */
312 _bfd_dummy_target
, /* archive */
313 hpux_core_core_file_p
/* a core file */
315 { /* bfd_set_format */
316 bfd_false
, bfd_false
,
319 { /* bfd_write_contents */
320 bfd_false
, bfd_false
,
324 JUMP_TABLE(hpux_core
),
325 (PTR
) 0 /* backend_data */