1 /* BFD back-end for HPPA BSD 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 Written by the Center for Software Science at the University of Utah
21 and by Cygnus Support.
23 The core file structure for the Utah 4.3BSD and OSF1 ports on the
24 PA is a mix between traditional cores and hpux cores -- just
25 different enough that supporting this format would tend to add
26 gross hacks to trad-core.c or hpux-core.c. So instead we keep any
27 gross hacks isolated to this file. */
30 /* This file can only be compiled on systems which use HPPA-BSD style
31 core files. In the config/XXXXXX.mh file for such a system add
32 HDEFINES=-DHPPABSD_CORE
33 HDEPFILES=hppabsd-core.o
35 I would not expect this to be of use to any other host/target, but
42 #if defined (HOST_HPPABSD)
44 #include "machine/vmparam.h"
47 #include <sys/types.h>
48 #include <sys/param.h>
51 #include <machine/reg.h>
52 #include <sys/user.h> /* After a.out.h */
56 static asection
*make_bfd_asection
PARAMS ((bfd
*, CONST
char *,
57 flagword
, bfd_size_type
,
58 bfd_vma
, unsigned int));
59 static asymbol
*hppabsd_core_make_empty_symbol
PARAMS ((bfd
*));
60 static bfd_target
*hppabsd_core_core_file_p
PARAMS ((bfd
*));
61 static char *hppabsd_core_core_file_failing_command
PARAMS ((bfd
*));
62 static int hppabsd_core_core_file_failing_signal
PARAMS ((bfd
*));
63 static boolean hppabsd_core_core_file_matches_executable_p
64 PARAMS ((bfd
*, bfd
*));
65 static void swap_abort
PARAMS ((void));
67 /* These are stored in the bfd's tdata. */
69 struct hppabsd_core_struct
72 char cmd
[MAXCOMLEN
+ 1];
73 asection
*data_section
;
74 asection
*stack_section
;
75 asection
*reg_section
;
78 #define core_hdr(bfd) ((bfd)->tdata.hppabsd_core_data)
79 #define core_signal(bfd) (core_hdr(bfd)->sig)
80 #define core_command(bfd) (core_hdr(bfd)->cmd)
81 #define core_datasec(bfd) (core_hdr(bfd)->data_section)
82 #define core_stacksec(bfd) (core_hdr(bfd)->stack_section)
83 #define core_regsec(bfd) (core_hdr(bfd)->reg_section)
86 make_bfd_asection (abfd
, name
, flags
, _raw_size
, vma
, alignment_power
)
90 bfd_size_type _raw_size
;
92 unsigned int alignment_power
;
96 asect
= bfd_make_section (abfd
, name
);
100 asect
->flags
= flags
;
101 asect
->_raw_size
= _raw_size
;
103 asect
->filepos
= bfd_tell (abfd
);
104 asect
->alignment_power
= alignment_power
;
110 hppabsd_core_make_empty_symbol (abfd
)
113 asymbol
*new = (asymbol
*) bfd_zalloc (abfd
, sizeof (asymbol
));
119 hppabsd_core_core_file_p (abfd
)
124 struct hppabsd_core_struct
*coredata
;
127 /* Try to read in the u-area. We will need information from this
128 to know how to grok the rest of the core structures. */
129 val
= bfd_read ((void *) &u
, 1, sizeof u
, abfd
);
132 bfd_error
= wrong_format
;
136 /* Get the page size out of the u structure. This will be different
137 for PA 1.0 machines and PA 1.1 machines. Yuk! */
138 clicksz
= u
.u_pcb
.pcb_pgsz
;
140 /* Sanity checks. Make sure the size of the core file matches the
141 the size computed from information within the core itself. */
143 FILE *stream
= bfd_cache_lookup (abfd
);
145 if (stream
== NULL
|| fstat (fileno (stream
), &statbuf
) < 0)
147 bfd_error
= system_call_error
;
150 if (NBPG
* (UPAGES
+ u
.u_dsize
+ u
.u_ssize
) > statbuf
.st_size
)
152 bfd_error
= file_truncated
;
155 if (clicksz
* (UPAGES
+ u
.u_dsize
+ u
.u_ssize
) < statbuf
.st_size
)
157 /* The file is too big. Maybe it's not a core file
158 or we otherwise have bad values for u_dsize and u_ssize). */
159 bfd_error
= wrong_format
;
164 /* OK, we believe you. You're a core file (sure, sure). */
166 coredata
= (struct hppabsd_core_struct
*)
167 bfd_zalloc (abfd
, sizeof (struct hppabsd_core_struct
));
169 /* Make the core data and available via the tdata part of the BFD. */
170 abfd
->tdata
.hppabsd_core_data
= coredata
;
172 /* Create the sections. */
173 core_stacksec (abfd
) = make_bfd_asection (abfd
, ".stack",
174 SEC_ALLOC
+ SEC_HAS_CONTENTS
,
176 NBPG
* (USIZE
+ KSTAKSIZE
)
177 + clicksz
* u
.u_dsize
, 2);
178 core_stacksec (abfd
)->vma
= USRSTACK
;
180 core_datasec (abfd
) = make_bfd_asection (abfd
, ".data",
184 NBPG
* (USIZE
+ KSTAKSIZE
), 2);
185 core_datasec (abfd
)->vma
= UDATASEG
;
187 core_regsec (abfd
) = make_bfd_asection (abfd
, ".reg",
188 SEC_ALLOC
+ SEC_HAS_CONTENTS
,
191 core_regsec (abfd
)->vma
= 0;
193 strncpy (core_command (abfd
), u
.u_comm
, MAXCOMLEN
+ 1);
194 core_signal (abfd
) = u
.u_code
;
199 hppabsd_core_core_file_failing_command (abfd
)
202 return core_command (abfd
);
207 hppabsd_core_core_file_failing_signal (abfd
)
210 return core_signal (abfd
);
215 hppabsd_core_core_file_matches_executable_p (core_bfd
, exec_bfd
)
216 bfd
*core_bfd
, *exec_bfd
;
218 /* There's no way to know this... */
223 /* No archive file support via this BFD */
224 #define hppabsd_core_openr_next_archived_file \
225 bfd_generic_openr_next_archived_file
226 #define hppabsd_core_generic_stat_arch_elt bfd_generic_stat_arch_elt
227 #define hppabsd_core_slurp_armap bfd_false
228 #define hppabsd_core_slurp_extended_name_table bfd_true
229 #define hppabsd_core_write_armap (boolean (*) PARAMS \
230 ((bfd *arch, unsigned int elength, struct orl *map, \
231 unsigned int orl_count, int stridx))) bfd_false
232 #define hppabsd_core_truncate_arname bfd_dont_truncate_arname
234 #define hppabsd_core_close_and_cleanup bfd_generic_close_and_cleanup
235 #define hppabsd_core_set_section_contents (boolean (*) PARAMS \
236 ((bfd *abfd, asection *section, PTR data, file_ptr offset, \
237 bfd_size_type count))) bfd_false
238 #define hppabsd_core_get_section_contents \
239 bfd_generic_get_section_contents
240 #define hppabsd_core_new_section_hook (boolean (*) PARAMS \
241 ((bfd *, sec_ptr))) bfd_true
242 #define hppabsd_core_get_symtab_upper_bound bfd_0u
243 #define hppabsd_core_get_symtab (unsigned int (*) PARAMS \
244 ((bfd *, struct symbol_cache_entry **))) bfd_0u
245 #define hppabsd_core_get_reloc_upper_bound (unsigned int (*) PARAMS \
246 ((bfd *, sec_ptr))) bfd_0u
247 #define hppabsd_core_canonicalize_reloc (unsigned int (*) PARAMS \
248 ((bfd *, sec_ptr, arelent **, struct symbol_cache_entry**))) bfd_0u
249 #define hppabsd_core_print_symbol (void (*) PARAMS \
250 ((bfd *, PTR, struct symbol_cache_entry *, \
251 bfd_print_symbol_type))) bfd_false
252 #define hppabsd_core_get_symbol_info (void (*) PARAMS \
253 ((bfd *, struct symbol_cache_entry *, \
254 symbol_info *))) bfd_false
255 #define hppabsd_core_get_lineno (alent * (*) PARAMS \
256 ((bfd *, struct symbol_cache_entry *))) bfd_nullvoidptr
257 #define hppabsd_core_set_arch_mach (boolean (*) PARAMS \
258 ((bfd *, enum bfd_architecture, unsigned long))) bfd_false
259 #define hppabsd_core_find_nearest_line (boolean (*) PARAMS \
260 ((bfd *abfd, struct sec *section, \
261 struct symbol_cache_entry **symbols,bfd_vma offset, \
262 CONST char **file, CONST char **func, unsigned int *line))) bfd_false
263 #define hppabsd_core_sizeof_headers (int (*) PARAMS \
264 ((bfd *, boolean))) bfd_0
266 #define hppabsd_core_bfd_debug_info_start bfd_void
267 #define hppabsd_core_bfd_debug_info_end bfd_void
268 #define hppabsd_core_bfd_debug_info_accumulate (void (*) PARAMS \
269 ((bfd *, struct sec *))) bfd_void
270 #define hppabsd_core_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
271 #define hppabsd_core_bfd_relax_section bfd_generic_relax_section
272 #define hppabsd_core_bfd_reloc_type_lookup \
273 ((CONST struct reloc_howto_struct *(*) PARAMS ((bfd *, bfd_reloc_code_real_type))) bfd_nullvoidptr)
274 #define hppabsd_core_bfd_make_debug_symbol \
275 ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
276 #define hppabsd_core_bfd_link_hash_table_create \
277 ((struct bfd_link_hash_table *(*) PARAMS ((bfd *))) bfd_nullvoidptr)
278 #define hppabsd_core_bfd_link_add_symbols \
279 ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false)
280 #define hppabsd_core_bfd_final_link \
281 ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false)
283 /* If somebody calls any byte-swapping routines, shoot them. */
287 /* This way doesn't require any declaration for ANSI to fuck up. */
291 #define NO_GET ((bfd_vma (*) PARAMS (( bfd_byte *))) swap_abort )
292 #define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
293 #define NO_SIGNED_GET ((bfd_signed_vma (*) PARAMS ((bfd_byte *))) swap_abort )
295 bfd_target hppabsd_core_vec
=
298 bfd_target_unknown_flavour
,
299 true, /* target byte order */
300 true, /* target headers byte order */
301 (HAS_RELOC
| EXEC_P
| /* object flags */
302 HAS_LINENO
| HAS_DEBUG
|
303 HAS_SYMS
| HAS_LOCALS
| DYNAMIC
| WP_TEXT
| D_PAGED
),
304 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
305 0, /* symbol prefix */
306 ' ', /* ar_pad_char */
307 16, /* ar_max_namelen */
308 3, /* minimum alignment power */
309 NO_GET
, NO_SIGNED_GET
, NO_PUT
, /* 64 bit data */
310 NO_GET
, NO_SIGNED_GET
, NO_PUT
, /* 32 bit data */
311 NO_GET
, NO_SIGNED_GET
, NO_PUT
, /* 16 bit data */
312 NO_GET
, NO_SIGNED_GET
, NO_PUT
, /* 64 bit hdrs */
313 NO_GET
, NO_SIGNED_GET
, NO_PUT
, /* 32 bit hdrs */
314 NO_GET
, NO_SIGNED_GET
, NO_PUT
, /* 16 bit hdrs */
316 { /* bfd_check_format */
317 _bfd_dummy_target
, /* unknown format */
318 _bfd_dummy_target
, /* object file */
319 _bfd_dummy_target
, /* archive */
320 hppabsd_core_core_file_p
/* a core file */
322 { /* bfd_set_format */
323 bfd_false
, bfd_false
,
326 { /* bfd_write_contents */
327 bfd_false
, bfd_false
,
331 JUMP_TABLE(hppabsd_core
),
332 (PTR
) 0 /* backend_data */