Commit | Line | Data |
---|---|---|
e3c01e92 SG |
1 | /* bfd back-end for HP PA-RISC SOM objects. |
2 | Copyright (C) 1990-1991 Free Software Foundation, Inc. | |
3 | ||
4 | Contributed by the Center for Software Science at the | |
5 | University of Utah (pa-gdb-bugs@cs.utah.edu). | |
6 | ||
7 | This file is part of BFD, the Binary File Descriptor library. | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation; either version 2 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program; if not, write to the Free Software | |
21 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
22 | ||
e3c01e92 | 23 | #include "bfd.h" |
76c7e44d | 24 | #include "sysdep.h" |
205d660d SG |
25 | |
26 | #ifdef HOST_HPPAHPUX | |
27 | ||
e3c01e92 SG |
28 | #include "libbfd.h" |
29 | #include "libhppa.h" | |
30 | ||
e3c01e92 SG |
31 | #include <stdio.h> |
32 | #include <sys/types.h> | |
33 | #include <sys/param.h> | |
34 | #include <sys/dir.h> | |
35 | #include <signal.h> | |
36 | #include <machine/reg.h> | |
e3c01e92 | 37 | #include <sys/user.h> /* After a.out.h */ |
e3c01e92 SG |
38 | #include <sys/file.h> |
39 | #include <errno.h> | |
40 | ||
41 | struct container { | |
42 | struct header f; | |
43 | struct som_exec_auxhdr e; | |
44 | }; | |
45 | ||
edff0587 SG |
46 | static bfd_target * |
47 | hppa_object_setup (abfd, file_hdrp, aux_hdrp) | |
e3c01e92 | 48 | bfd *abfd; |
edff0587 SG |
49 | struct header *file_hdrp; |
50 | struct som_exec_auxhdr *aux_hdrp; | |
e3c01e92 SG |
51 | { |
52 | struct container *rawptr; | |
53 | struct header *f; | |
54 | struct hppa_data_struct *rawptr1; | |
edff0587 SG |
55 | asection *dbx, *dbx_strings; |
56 | ||
57 | dbx = bfd_get_section_by_name (abfd, "$GDB_SYMBOLS$"); | |
58 | dbx_strings = bfd_get_section_by_name (abfd, "$GDB_STRINGS$"); | |
e3c01e92 SG |
59 | |
60 | rawptr = (struct container *) bfd_zalloc (abfd, sizeof (struct container)); | |
61 | if (rawptr == NULL) { | |
62 | bfd_error = no_memory; | |
63 | return 0; | |
64 | } | |
65 | ||
66 | rawptr1 = (struct hppa_data_struct *) bfd_zalloc (abfd, sizeof (struct hppa_data_struct)); | |
67 | if (rawptr1 == NULL) { | |
68 | bfd_error = no_memory; | |
69 | return 0; | |
70 | } | |
71 | ||
72 | abfd->tdata.hppa_data = rawptr1; | |
73 | obj_file_hdr (abfd) = &rawptr->f; | |
74 | obj_aux_hdr (abfd) = &rawptr->e; | |
75 | *obj_file_hdr (abfd) = *file_hdrp; | |
76 | *obj_aux_hdr (abfd) = *aux_hdrp; | |
77 | ||
78 | /* Set the file flags */ | |
79 | abfd->flags = NO_FLAGS; | |
80 | if (file_hdrp->entry_offset) | |
81 | abfd->flags |= HAS_RELOC; | |
82 | if (file_hdrp->symbol_total) | |
83 | abfd->flags |= HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS; | |
84 | ||
85 | bfd_get_start_address (abfd) = aux_hdrp->exec_entry; | |
86 | ||
87 | obj_hp_symbol_entry_size (abfd) = sizeof(struct symbol_dictionary_record); | |
88 | obj_dbx_symbol_entry_size (abfd) = 12; | |
89 | ||
90 | obj_pa_symbols (abfd) = (hppa_symbol_type *)NULL; | |
91 | obj_hp_sym_count (abfd) = file_hdrp->symbol_total; | |
edff0587 | 92 | obj_dbx_sym_count (abfd) = bfd_section_size (abfd, dbx) / |
e3c01e92 SG |
93 | obj_dbx_symbol_entry_size (abfd); |
94 | bfd_get_symcount (abfd) = obj_hp_sym_count (abfd) + obj_dbx_sym_count (abfd); | |
95 | ||
96 | bfd_default_set_arch_mach(abfd, bfd_arch_hppa, 0); | |
97 | ||
98 | /* create the sections. This is raunchy, but bfd_close wants to reclaim | |
99 | them */ | |
100 | obj_textsec (abfd) = (asection *)NULL; | |
101 | obj_datasec (abfd) = (asection *)NULL; | |
102 | obj_bsssec (abfd) = (asection *)NULL; | |
103 | (void)bfd_make_section(abfd, ".text"); | |
104 | (void)bfd_make_section(abfd, ".data"); | |
105 | (void)bfd_make_section(abfd, ".bss"); | |
106 | ||
edff0587 | 107 | #if 0 |
e3c01e92 SG |
108 | abfd->sections = obj_textsec (abfd); |
109 | obj_textsec (abfd)->next = obj_datasec (abfd); | |
110 | obj_datasec (abfd)->next = obj_bsssec (abfd); | |
edff0587 | 111 | #endif |
e3c01e92 SG |
112 | |
113 | obj_datasec (abfd)->_raw_size = aux_hdrp->exec_dsize; | |
114 | obj_bsssec (abfd)->_raw_size = aux_hdrp->exec_bsize; | |
115 | obj_textsec (abfd)->_raw_size = aux_hdrp->exec_tsize; | |
116 | ||
117 | obj_textsec (abfd)->flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS); | |
118 | obj_datasec (abfd)->flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS); | |
119 | obj_bsssec (abfd)->flags = SEC_ALLOC; | |
120 | ||
121 | /* The virtual memory addresses of the sections */ | |
122 | obj_datasec (abfd)->vma = aux_hdrp->exec_dmem; | |
123 | obj_bsssec (abfd)->vma = aux_hdrp->exec_bfill; | |
124 | obj_textsec (abfd)->vma = aux_hdrp->exec_tmem; | |
125 | ||
126 | /* The file offsets of the sections */ | |
127 | obj_textsec (abfd)->filepos = aux_hdrp->exec_tfile; | |
128 | obj_datasec (abfd)->filepos = aux_hdrp->exec_dfile; | |
129 | ||
130 | /* The file offsets of the relocation info */ | |
131 | obj_textsec (abfd)->rel_filepos = 0; | |
132 | obj_datasec (abfd)->rel_filepos = 0; | |
133 | ||
134 | /* The file offsets of the string table and symbol table. */ | |
135 | obj_hp_sym_filepos (abfd) = file_hdrp->symbol_location; | |
136 | obj_hp_str_filepos (abfd) = file_hdrp->symbol_strings_location; | |
edff0587 SG |
137 | obj_dbx_sym_filepos (abfd) = dbx->filepos; |
138 | obj_dbx_str_filepos (abfd) = dbx_strings->filepos; | |
e3c01e92 | 139 | obj_hp_stringtab_size (abfd) = file_hdrp->symbol_strings_size; |
edff0587 | 140 | obj_dbx_stringtab_size (abfd) = bfd_section_size (abfd, dbx_strings); |
e3c01e92 SG |
141 | |
142 | return abfd->xvec; | |
143 | } | |
144 | ||
edff0587 SG |
145 | /* Create a new BFD section for NAME. If NAME already exists, then create a |
146 | new unique name, with NAME as the prefix. This exists because SOM .o files | |
147 | created by the native compiler can have a $CODE$ section for each | |
148 | subroutine. | |
149 | */ | |
150 | ||
151 | static asection * | |
152 | make_unique_section (abfd, name, num) | |
153 | bfd *abfd; | |
154 | CONST char *name; | |
155 | int num; | |
156 | { | |
157 | asection *sect; | |
158 | char *newname; | |
159 | char altname[100]; | |
160 | ||
161 | sect = bfd_make_section (abfd, name); | |
162 | while (!sect) | |
163 | { | |
164 | sprintf(altname, "%s-%d", name, num++); | |
165 | sect = bfd_make_section (abfd, altname); | |
166 | } | |
167 | ||
168 | newname = bfd_alloc (abfd, strlen(sect->name) + 1); | |
169 | strcpy (newname, sect->name); | |
170 | ||
171 | sect->name = newname; | |
172 | return sect; | |
173 | } | |
174 | ||
175 | /* Convert all of the space and subspace info into BFD sections. Each space | |
176 | contains a number of subspaces, which in turn describe the mapping between | |
177 | regions of the exec file, and the address space that the program runs in. | |
178 | BFD sections which correspond to spaces will overlap the sections for the | |
179 | associated subspaces. */ | |
180 | ||
181 | static int | |
182 | setup_sections (abfd, file_hdr) | |
183 | bfd *abfd; | |
184 | struct header *file_hdr; | |
185 | { | |
186 | char *space_strings; | |
187 | int space_index; | |
188 | ||
189 | /* First, read in space names */ | |
190 | ||
191 | space_strings = alloca (file_hdr->space_strings_size); | |
192 | if (!space_strings) | |
193 | return 0; | |
194 | ||
195 | if (bfd_seek (abfd, file_hdr->space_strings_location, SEEK_SET) < 0) | |
196 | return 0; | |
197 | if (bfd_read (space_strings, 1, file_hdr->space_strings_size, abfd) | |
198 | != file_hdr->space_strings_size) | |
199 | return 0; | |
200 | ||
201 | /* Loop over all of the space dictionaries, building up sections */ | |
202 | ||
203 | for (space_index = 0; space_index < file_hdr->space_total; space_index++) | |
204 | { | |
205 | struct space_dictionary_record space; | |
206 | struct subspace_dictionary_record subspace; | |
207 | int subspace_index, tmp; | |
208 | asection *space_asect; | |
209 | ||
210 | /* Read the space dictionary element */ | |
211 | if (bfd_seek (abfd, file_hdr->space_location | |
212 | + space_index * sizeof space, SEEK_SET) < 0) | |
213 | return 0; | |
214 | if (bfd_read (&space, 1, sizeof space, abfd) != sizeof space) | |
215 | return 0; | |
216 | ||
217 | /* Setup the space name string */ | |
218 | space.name.n_name = space.name.n_strx + space_strings; | |
219 | ||
220 | /* Make a section out of it */ | |
221 | space_asect = make_unique_section (abfd, space.name.n_name, space_index); | |
222 | if (!space_asect) | |
223 | return 0; | |
224 | ||
225 | /* Now, read in the first subspace for this space */ | |
226 | if (bfd_seek (abfd, file_hdr->subspace_location | |
227 | + space.subspace_index * sizeof subspace, | |
228 | SEEK_SET) < 0) | |
229 | return 0; | |
230 | if (bfd_read (&subspace, 1, sizeof subspace, abfd) != sizeof subspace) | |
231 | return 0; | |
232 | /* Seek back to the start of the subspaces for loop below */ | |
233 | if (bfd_seek (abfd, file_hdr->subspace_location | |
234 | + space.subspace_index * sizeof subspace, | |
235 | SEEK_SET) < 0) | |
236 | return 0; | |
237 | ||
238 | /* Setup the section flags as appropriate (this is somewhat bogus, as | |
239 | there isn't a clear mapping between what's in the space record, and | |
240 | what BFD can describe here). */ | |
241 | if (space.is_loadable) | |
242 | space_asect->flags |= SEC_ALLOC; | |
243 | if (space.is_defined) | |
244 | space_asect->flags |= SEC_LOAD; | |
245 | ||
246 | /* Setup the start address and file loc from the first subspace record */ | |
247 | space_asect->vma = subspace.subspace_start; | |
248 | space_asect->filepos = subspace.file_loc_init_value; | |
249 | space_asect->alignment_power = subspace.alignment; | |
250 | ||
251 | /* Loop over the rest of the subspaces, building up more sections */ | |
252 | for (subspace_index = 0; subspace_index < space.subspace_quantity; | |
253 | subspace_index++) | |
254 | { | |
255 | asection *subspace_asect; | |
256 | ||
257 | /* Read in the next subspace */ | |
258 | if (bfd_read (&subspace, 1, sizeof subspace, abfd) | |
259 | != sizeof subspace) | |
260 | return 0; | |
261 | ||
262 | /* Setup the subspace name string */ | |
263 | subspace.name.n_name = subspace.name.n_strx + space_strings; | |
264 | ||
265 | /* Make a section out of this subspace */ | |
266 | subspace_asect = make_unique_section (abfd, subspace.name.n_name, | |
267 | space.subspace_index + subspace_index); | |
268 | ||
269 | if (!subspace_asect) | |
270 | return 0; | |
271 | ||
272 | if (subspace.is_loadable) | |
273 | subspace_asect->flags |= SEC_ALLOC | SEC_LOAD; | |
274 | if (subspace.code_only) | |
275 | subspace_asect->flags |= SEC_CODE; | |
276 | ||
277 | subspace_asect->vma = subspace.subspace_start; | |
278 | subspace_asect->_cooked_size = subspace.subspace_length; | |
279 | subspace_asect->_raw_size = subspace.initialization_length; | |
280 | subspace_asect->alignment_power = subspace.alignment; | |
281 | subspace_asect->filepos = subspace.file_loc_init_value; | |
282 | ||
283 | } | |
284 | /* Setup the sizes for the space section based upon the info in the | |
285 | last subspace of the space. */ | |
286 | space_asect->_cooked_size = (subspace.subspace_start - space_asect->vma) | |
287 | + subspace.subspace_length; | |
288 | space_asect->_raw_size = (subspace.file_loc_init_value | |
289 | - space_asect->filepos) | |
290 | + subspace.initialization_length; | |
291 | } | |
292 | } | |
293 | ||
294 | static bfd_target * | |
295 | hppa_object_p (abfd) | |
296 | bfd *abfd; | |
e3c01e92 SG |
297 | { |
298 | struct header file_hdr; | |
299 | struct som_exec_auxhdr aux_hdr; | |
300 | struct subspace_dictionary_record dbx_subspace; | |
301 | struct subspace_dictionary_record dbx_strings_subspace; | |
302 | ||
303 | if (bfd_read ((PTR) &file_hdr, 1, FILE_HDR_SIZE, abfd) != FILE_HDR_SIZE) | |
edff0587 SG |
304 | return 0; |
305 | ||
306 | if (!_PA_RISC_ID (file_hdr.system_id)) | |
e3c01e92 SG |
307 | { |
308 | bfd_error = wrong_format; | |
309 | return 0; | |
310 | } | |
205d660d | 311 | |
205d660d SG |
312 | switch (file_hdr.a_magic) |
313 | { | |
edff0587 | 314 | case RELOC_MAGIC: /* I'm not really sure about all of these types... */ |
205d660d SG |
315 | case EXEC_MAGIC: |
316 | case SHARE_MAGIC: | |
317 | case DEMAND_MAGIC: | |
318 | case DL_MAGIC: | |
319 | case SHL_MAGIC: | |
320 | break; | |
321 | default: | |
edff0587 | 322 | bfd_error = wrong_format; |
205d660d SG |
323 | return 0; |
324 | } | |
325 | ||
edff0587 SG |
326 | if (file_hdr.version_id != VERSION_ID |
327 | && file_hdr.version_id != NEW_VERSION_ID) | |
e3c01e92 SG |
328 | { |
329 | bfd_error = wrong_format; | |
330 | return 0; | |
331 | } | |
e3c01e92 | 332 | |
edff0587 SG |
333 | if (bfd_read ((PTR) &aux_hdr, 1, AUX_HDR_SIZE, abfd) != AUX_HDR_SIZE) |
334 | bfd_error = wrong_format; | |
e3c01e92 | 335 | |
edff0587 SG |
336 | if (!setup_sections (abfd, &file_hdr)) |
337 | return 0; | |
338 | ||
339 | return hppa_object_setup(abfd, &file_hdr, &aux_hdr); | |
340 | } | |
e3c01e92 SG |
341 | |
342 | static boolean | |
343 | DEFUN(hppa_mkobject,(abfd), | |
344 | bfd *abfd) | |
345 | { | |
346 | fprintf (stderr, "hppa_mkobject unimplemented\n"); | |
347 | fflush (stderr); | |
348 | abort (); | |
349 | return (false); | |
350 | } | |
351 | ||
352 | boolean | |
353 | DEFUN(hppa_write_object_contents,(abfd), | |
354 | bfd *abfd) | |
355 | { | |
356 | fprintf (stderr, "hppa_write_object_contents unimplemented\n"); | |
357 | fflush (stderr); | |
358 | abort (); | |
359 | return (false); | |
360 | } | |
361 | ||
edff0587 SG |
362 | static unsigned int |
363 | hppa_get_symtab_upper_bound (abfd) | |
364 | bfd *abfd; | |
e3c01e92 SG |
365 | { |
366 | fprintf (stderr, "hppa_get_symtab_upper_bound unimplemented\n"); | |
367 | fflush (stderr); | |
368 | abort (); | |
369 | return (0); | |
370 | } | |
371 | ||
edff0587 SG |
372 | static unsigned int |
373 | hppa_get_reloc_upper_bound (abfd, asect) | |
374 | bfd *abfd; | |
375 | sec_ptr asect; | |
e3c01e92 SG |
376 | { |
377 | fprintf (stderr, "hppa_get_reloc_upper_bound unimplemented\n"); | |
378 | fflush (stderr); | |
379 | abort (); | |
380 | return (0); | |
381 | } | |
382 | ||
edff0587 SG |
383 | static unsigned int |
384 | hppa_canonicalize_reloc (abfd, section, relptr, symbols) | |
385 | bfd *abfd; | |
386 | sec_ptr section; | |
387 | arelent **relptr; | |
388 | asymbol **symbols; | |
e3c01e92 SG |
389 | { |
390 | fprintf (stderr, "hppa_canonicalize_reloc unimplemented\n"); | |
391 | fflush (stderr); | |
392 | abort (); | |
393 | } | |
394 | ||
395 | extern bfd_target hppa_vec; | |
edff0587 SG |
396 | |
397 | static unsigned int | |
398 | hppa_get_symtab (abfd, location) | |
399 | bfd *abfd; | |
400 | asymbol **location; | |
e3c01e92 SG |
401 | { |
402 | fprintf (stderr, "hppa_get_symtab unimplemented\n"); | |
403 | fflush (stderr); | |
404 | abort (); | |
405 | return (0); | |
406 | } | |
407 | ||
edff0587 SG |
408 | static asymbol * |
409 | hppa_make_empty_symbol (abfd) | |
410 | bfd *abfd; | |
e3c01e92 SG |
411 | { |
412 | hppa_symbol_type *new = | |
413 | (hppa_symbol_type *)bfd_zalloc (abfd, sizeof (hppa_symbol_type)); | |
414 | new->symbol.the_bfd = abfd; | |
415 | ||
416 | return &new->symbol; | |
417 | } | |
418 | ||
edff0587 SG |
419 | static void |
420 | hppa_print_symbol (ignore_abfd, afile, symbol, how) | |
421 | bfd *ignore_abfd; | |
422 | PTR afile; | |
423 | asymbol *symbol; | |
424 | bfd_print_symbol_type how; | |
e3c01e92 SG |
425 | { |
426 | fprintf (stderr, "hppa_print_symbol unimplemented\n"); | |
427 | fflush (stderr); | |
428 | abort (); | |
429 | } | |
430 | ||
edff0587 SG |
431 | static boolean |
432 | hppa_new_section_hook (abfd, newsect) | |
433 | bfd *abfd; | |
434 | asection *newsect; | |
e3c01e92 SG |
435 | { |
436 | /* align to double at least */ | |
437 | newsect->alignment_power = 3; | |
438 | ||
439 | if (bfd_get_format (abfd) == bfd_object) { | |
440 | if (obj_textsec(abfd) == NULL && !strcmp(newsect->name, ".text")) { | |
441 | obj_textsec(abfd)= newsect; | |
442 | return true; | |
443 | } | |
444 | ||
445 | if (obj_datasec(abfd) == NULL && !strcmp(newsect->name, ".data")) { | |
446 | obj_datasec(abfd) = newsect; | |
447 | return true; | |
448 | } | |
449 | ||
450 | if (obj_bsssec(abfd) == NULL && !strcmp(newsect->name, ".bss")) { | |
451 | obj_bsssec(abfd) = newsect; | |
452 | return true; | |
453 | } | |
454 | } | |
455 | ||
456 | /* We allow more than three sections internally */ | |
457 | return true; | |
458 | } | |
459 | ||
edff0587 SG |
460 | static boolean |
461 | hppa_set_section_contents (abfd, section, location, offset, count) | |
462 | bfd *abfd; | |
463 | sec_ptr section; | |
464 | PTR location; | |
465 | file_ptr offset; | |
466 | bfd_size_type count; | |
e3c01e92 SG |
467 | { |
468 | fprintf (stderr, "hppa_set_section_contents unimplimented\n"); | |
469 | fflush (stderr); | |
470 | abort(); | |
471 | return false; | |
472 | } | |
473 | ||
edff0587 SG |
474 | static boolean |
475 | hppa_set_arch_mach (abfd, arch, machine) | |
476 | bfd *abfd; | |
477 | enum bfd_architecture arch; | |
478 | unsigned long machine; | |
e3c01e92 SG |
479 | { |
480 | fprintf (stderr, "hppa_set_arch_mach unimplemented\n"); | |
481 | fflush (stderr); | |
482 | /* Allow any architecture to be supported by the hppa backend */ | |
483 | return bfd_default_set_arch_mach(abfd, arch, machine); | |
484 | } | |
485 | ||
e3c01e92 | 486 | static boolean |
edff0587 SG |
487 | hppa_find_nearest_line (abfd, section, symbols, offset, filename_ptr, |
488 | functionname_ptr, line_ptr) | |
489 | bfd *abfd; | |
490 | asection *section; | |
491 | asymbol **symbols; | |
492 | bfd_vma offset; | |
493 | CONST char **filename_ptr; | |
494 | CONST char **functionname_ptr; | |
495 | unsigned int *line_ptr; | |
e3c01e92 SG |
496 | { |
497 | fprintf (stderr, "hppa_find_nearest_line unimplemented\n"); | |
498 | fflush (stderr); | |
499 | abort (); | |
500 | return (false); | |
501 | } | |
502 | ||
503 | static int | |
edff0587 SG |
504 | hppa_sizeof_headers (abfd, reloc) |
505 | bfd *abfd; | |
506 | boolean reloc; | |
e3c01e92 SG |
507 | { |
508 | fprintf (stderr, "hppa_sizeof_headers unimplemented\n"); | |
509 | fflush (stderr); | |
510 | abort (); | |
511 | return (0); | |
512 | } | |
513 | ||
205d660d SG |
514 | static asection * |
515 | make_bfd_asection (abfd, name, flags, _raw_size, vma, alignment_power) | |
e3c01e92 | 516 | bfd *abfd; |
75dd6a3e | 517 | CONST char *name; |
205d660d SG |
518 | flagword flags; |
519 | bfd_size_type _raw_size; | |
520 | bfd_vma vma; | |
521 | unsigned int alignment_power; | |
e3c01e92 | 522 | { |
205d660d | 523 | asection *asect; |
e3c01e92 | 524 | |
edff0587 | 525 | asect = bfd_make_section (abfd, name); |
205d660d | 526 | if (!asect) |
edff0587 | 527 | return NULL; |
e3c01e92 | 528 | |
205d660d SG |
529 | asect->flags = flags; |
530 | asect->_raw_size = _raw_size; | |
531 | asect->vma = vma; | |
532 | asect->filepos = bfd_tell (abfd); | |
533 | asect->alignment_power = alignment_power; | |
e3c01e92 | 534 | |
205d660d SG |
535 | return asect; |
536 | } | |
537 | ||
edff0587 | 538 | static bfd_target * |
205d660d SG |
539 | hppa_core_file_p (abfd) |
540 | bfd *abfd; | |
541 | { | |
542 | core_hdr (abfd) = bfd_zalloc (abfd, sizeof (struct hppa_core_struct)); | |
543 | if (!core_hdr (abfd)) | |
544 | return NULL; | |
e3c01e92 | 545 | |
205d660d SG |
546 | while (1) |
547 | { | |
548 | int val; | |
549 | struct corehead core_header; | |
550 | ||
551 | val = bfd_read ((void *)&core_header, 1, sizeof core_header, abfd); | |
552 | if (val <= 0) | |
553 | break; | |
554 | switch (core_header.type) | |
555 | { | |
556 | case CORE_KERNEL: | |
557 | case CORE_FORMAT: | |
558 | bfd_seek (abfd, core_header.len, SEEK_CUR); /* Just skip this */ | |
559 | break; | |
560 | case CORE_EXEC: | |
561 | { | |
562 | struct proc_exec proc_exec; | |
563 | bfd_read ((void *)&proc_exec, 1, core_header.len, abfd); | |
564 | strncpy (core_command (abfd), proc_exec.cmd, MAXCOMLEN + 1); | |
565 | } | |
566 | break; | |
567 | case CORE_PROC: | |
568 | { | |
569 | struct proc_info proc_info; | |
570 | core_regsec (abfd) = make_bfd_asection (abfd, ".reg", | |
571 | SEC_ALLOC+SEC_HAS_CONTENTS, | |
572 | core_header.len, | |
573 | (int)&proc_info - (int)&proc_info.hw_regs, | |
574 | 2); | |
575 | bfd_read (&proc_info, 1, core_header.len, abfd); | |
576 | core_signal (abfd) = proc_info.sig; | |
577 | } | |
578 | if (!core_regsec (abfd)) | |
579 | return NULL; | |
580 | break; | |
581 | case CORE_DATA: | |
582 | core_datasec (abfd) = make_bfd_asection (abfd, ".data", | |
583 | SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS, | |
584 | core_header.len, | |
585 | core_header.addr, | |
586 | 2); | |
587 | if (!core_datasec (abfd)) | |
588 | return NULL; | |
589 | bfd_seek (abfd, core_header.len, SEEK_CUR); | |
590 | break; | |
591 | case CORE_STACK: | |
edff0587 | 592 | core_stacksec (abfd) = make_bfd_asection (abfd, ".stack", |
205d660d SG |
593 | SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS, |
594 | core_header.len, | |
595 | core_header.addr, | |
596 | 2); | |
597 | if (!core_stacksec (abfd)) | |
598 | return NULL; | |
599 | bfd_seek (abfd, core_header.len, SEEK_CUR); | |
600 | break; | |
601 | default: | |
602 | fprintf (stderr, "Unknown HPPA/HPUX core file section type %d\n", | |
603 | core_header.type); | |
604 | bfd_seek (abfd, core_header.len, SEEK_CUR); | |
605 | break; | |
606 | } | |
607 | } | |
e3c01e92 | 608 | |
205d660d | 609 | /* OK, we believe you. You're a core file (sure, sure). */ |
e3c01e92 SG |
610 | |
611 | return abfd->xvec; | |
612 | } | |
e3c01e92 | 613 | |
edff0587 | 614 | static char * |
e3c01e92 SG |
615 | hppa_core_file_failing_command (abfd) |
616 | bfd *abfd; | |
617 | { | |
205d660d | 618 | return core_command (abfd); |
e3c01e92 | 619 | } |
e3c01e92 SG |
620 | |
621 | /* ARGSUSED */ | |
edff0587 | 622 | static int |
205d660d SG |
623 | hppa_core_file_failing_signal (abfd) |
624 | bfd *abfd; | |
e3c01e92 | 625 | { |
205d660d | 626 | return core_signal (abfd); |
e3c01e92 SG |
627 | } |
628 | ||
629 | /* ARGSUSED */ | |
edff0587 | 630 | static boolean |
e3c01e92 SG |
631 | hppa_core_file_matches_executable_p (core_bfd, exec_bfd) |
632 | bfd *core_bfd, *exec_bfd; | |
633 | { | |
634 | return true; /* FIXME, We have no way of telling at this point */ | |
635 | } | |
636 | ||
637 | #define hppa_bfd_debug_info_start bfd_void | |
638 | #define hppa_bfd_debug_info_end bfd_void | |
639 | #define hppa_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void | |
640 | ||
641 | ||
642 | ||
643 | #define hppa_openr_next_archived_file bfd_generic_openr_next_archived_file | |
644 | #define hppa_generic_stat_arch_elt bfd_generic_stat_arch_elt | |
645 | #define hppa_slurp_armap bfd_false | |
646 | #define hppa_slurp_extended_name_table _bfd_slurp_extended_name_table | |
647 | #define hppa_truncate_arname (void (*)())bfd_nullvoidptr | |
648 | #define hppa_write_armap 0 | |
649 | ||
650 | #define hppa_get_lineno (struct lineno_cache_entry *(*)())bfd_nullvoidptr | |
651 | #define hppa_close_and_cleanup bfd_generic_close_and_cleanup | |
652 | #define hppa_get_section_contents bfd_generic_get_section_contents | |
653 | ||
654 | #define hppa_bfd_get_relocated_section_contents \ | |
655 | bfd_generic_get_relocated_section_contents | |
656 | #define hppa_bfd_relax_section bfd_generic_relax_section | |
657 | ||
e3c01e92 SG |
658 | bfd_target hppa_vec = |
659 | { | |
660 | "hppa", /* name */ | |
661 | bfd_target_hppa_flavour, | |
662 | true, /* target byte order */ | |
663 | true, /* target headers byte order */ | |
664 | (HAS_RELOC | EXEC_P | /* object flags */ | |
665 | HAS_LINENO | HAS_DEBUG | | |
666 | HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), | |
667 | (SEC_CODE|SEC_DATA|SEC_ROM|SEC_HAS_CONTENTS | |
668 | |SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ | |
4e98653c SC |
669 | |
670 | /* leading_symbol_char: is the first char of a user symbol | |
671 | predictable, and if so what is it */ | |
672 | 0, | |
e3c01e92 SG |
673 | ' ', /* ar_pad_char */ |
674 | 16, /* ar_max_namelen */ | |
675 | 3, /* minimum alignment */ | |
676 | _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */ | |
677 | _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */ | |
e3c01e92 SG |
678 | { _bfd_dummy_target, |
679 | hppa_object_p, /* bfd_check_format */ | |
680 | bfd_generic_archive_p, | |
681 | hppa_core_file_p, | |
682 | }, | |
683 | { | |
684 | bfd_false, | |
685 | hppa_mkobject, | |
686 | _bfd_generic_mkarchive, | |
687 | bfd_false | |
688 | }, | |
689 | { | |
690 | bfd_false, | |
691 | hppa_write_object_contents, | |
692 | _bfd_write_archive_contents, | |
693 | bfd_false, | |
694 | }, | |
acc7c493 | 695 | #undef hppa |
e3c01e92 SG |
696 | JUMP_TABLE(hppa) |
697 | }; | |
698 | ||
205d660d | 699 | #endif /* HOST_HPPAHPUX */ |