* serial.h (SERIAL_SET_TTY_STATE): Comment return value.
[deliverable/binutils-gdb.git] / gdb / paread.c
CommitLineData
684a832f
SG
1/* Read HP PA/Risc object files for GDB.
2 Copyright 1991, 1992 Free Software Foundation, Inc.
3 Written by Fred Fish at Cygnus Support.
4
5This file is part of GDB.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20
684a832f
SG
21#include "defs.h"
22#include "bfd.h"
1225fcbd 23#include <time.h> /* For time_t in libbfd.h. */
ddf5d7e8 24#include <sys/types.h> /* For time_t, if not in time.h. */
684a832f 25#include "libbfd.h"
61a29659 26#include "som.h"
003ccb90 27#include "libhppa.h"
684a832f
SG
28#include <syms.h>
29#include "symtab.h"
30#include "symfile.h"
31#include "objfiles.h"
32#include "buildsym.h"
2731625a 33#include "stabsread.h"
684a832f
SG
34#include "gdb-stabs.h"
35#include "complaints.h"
36#include <string.h>
37#include "demangle.h"
38#include <sys/file.h>
1225fcbd
JK
39
40/* Size of n_value and n_strx fields in a stab symbol. */
41#define BYTES_IN_WORD 4
42
0213d96f 43#include "aout/aout64.h"
684a832f
SG
44
45/* Various things we might complain about... */
46
47static void
48pa_symfile_init PARAMS ((struct objfile *));
49
c7f3b703
JL
50static int
51compare_unwind_entries PARAMS ((struct unwind_table_entry *,
52 struct unwind_table_entry *));
53
684a832f
SG
54static void
55pa_new_init PARAMS ((struct objfile *));
56
fa9265e5
SG
57static void
58read_unwind_info PARAMS ((struct objfile *));
59
684a832f
SG
60static void
61pa_symfile_read PARAMS ((struct objfile *, struct section_offsets *, int));
62
63static void
64pa_symfile_finish PARAMS ((struct objfile *));
65
66static void
67pa_symtab_read PARAMS ((bfd *, CORE_ADDR, struct objfile *));
68
69static void
70free_painfo PARAMS ((PTR));
71
72static struct section_offsets *
73pa_symfile_offsets PARAMS ((struct objfile *, CORE_ADDR));
74
75static void
76record_minimal_symbol PARAMS ((char *, CORE_ADDR,
77 enum minimal_symbol_type,
78 struct objfile *));
79
80static void
81record_minimal_symbol (name, address, ms_type, objfile)
82 char *name;
83 CORE_ADDR address;
84 enum minimal_symbol_type ms_type;
85 struct objfile *objfile;
86{
87 name = obsavestring (name, strlen (name), &objfile -> symbol_obstack);
8d60affd 88 prim_record_minimal_symbol (name, address, ms_type, objfile);
684a832f
SG
89}
90
91/*
92
93LOCAL FUNCTION
94
95 pa_symtab_read -- read the symbol table of a PA file
96
97SYNOPSIS
98
99 void pa_symtab_read (bfd *abfd, CORE_ADDR addr,
100 struct objfile *objfile)
101
102DESCRIPTION
103
104 Given an open bfd, a base address to relocate symbols to, and a
105 flag that specifies whether or not this bfd is for an executable
106 or not (may be shared library for example), add all the global
107 function and data symbols to the minimal symbol table.
108*/
109
110static void
111pa_symtab_read (abfd, addr, objfile)
112 bfd *abfd;
113 CORE_ADDR addr;
114 struct objfile *objfile;
115{
116 unsigned int number_of_symbols;
117 unsigned int i;
118 int val;
119 char *stringtab;
3cde1ffa
JK
120 struct symbol_dictionary_record *buf, *bufp, *endbufp;
121 char *symname;
0213d96f 122 CONST int symsize = sizeof (struct symbol_dictionary_record);
684a832f 123
0213d96f 124 number_of_symbols = bfd_get_symcount (abfd);
684a832f 125
0213d96f 126 buf = alloca (symsize * number_of_symbols);
003ccb90 127 bfd_seek (abfd, obj_som_sym_filepos (abfd), L_SET);
0213d96f
SG
128 val = bfd_read (buf, symsize * number_of_symbols, 1, abfd);
129 if (val != symsize * number_of_symbols)
684a832f
SG
130 error ("Couldn't read symbol dictionary!");
131
003ccb90
KR
132 stringtab = alloca (obj_som_stringtab_size (abfd));
133 bfd_seek (abfd, obj_som_str_filepos (abfd), L_SET);
134 val = bfd_read (stringtab, obj_som_stringtab_size (abfd), 1, abfd);
135 if (val != obj_som_stringtab_size (abfd))
684a832f 136 error ("Can't read in HP string table.");
3cde1ffa
JK
137
138 endbufp = buf + number_of_symbols;
139 for (bufp = buf; bufp < endbufp; ++bufp)
684a832f
SG
140 {
141 enum minimal_symbol_type ms_type;
142
143 QUIT;
144
3cde1ffa
JK
145 switch (bufp->symbol_scope)
146 {
147 case SS_UNIVERSAL:
148 switch (bufp->symbol_type)
149 {
150 case ST_SYM_EXT:
151 case ST_ARG_EXT:
152 continue;
153
154 case ST_CODE:
155 case ST_PRI_PROG:
156 case ST_SEC_PROG:
157 case ST_ENTRY:
158 case ST_MILLICODE:
159 symname = bufp->name.n_strx + stringtab;
160 ms_type = mst_text;
9fdb3f7a
JK
161#ifdef SMASH_TEXT_ADDRESS
162 SMASH_TEXT_ADDRESS (bufp->symbol_value);
163#endif
3cde1ffa
JK
164 break;
165 case ST_DATA:
166 symname = bufp->name.n_strx + stringtab;
167 ms_type = mst_data;
168 break;
169 default:
170 continue;
171 }
172 break;
173
247145e6
JK
174#if 0
175 /* SS_GLOBAL and SS_LOCAL are two names for the same thing (!). */
3cde1ffa 176 case SS_GLOBAL:
247145e6 177#endif
3cde1ffa
JK
178 case SS_LOCAL:
179 switch (bufp->symbol_type)
180 {
181 case ST_SYM_EXT:
182 case ST_ARG_EXT:
183 continue;
184
185 case ST_CODE:
186 symname = bufp->name.n_strx + stringtab;
247145e6 187 ms_type = mst_file_text;
9fdb3f7a
JK
188#ifdef SMASH_TEXT_ADDRESS
189 SMASH_TEXT_ADDRESS (bufp->symbol_value);
190#endif
247145e6
JK
191
192 check_strange_names:
3fd4045f
JK
193 /* GAS leaves labels in .o files after assembling. At
194 least labels starting with "LS$", "LBB$", "LBE$",
195 "LC$", and "L$" can happen. This should be fixed in
196 the assembler and/or compiler, to save space in the
197 executable (and because having GDB make gross
198 distinctions based on the name is kind of ugly), but
e1164c83
JK
199 until then, just ignore them. ("L$" at least, has something
200 to do with getting relocation correct, so that one might
201 be hard to fix). */
3cde1ffa 202 if (*symname == 'L'
ffb4ea6a
JL
203 && (symname[1] == '$' || symname[2] == '$'
204 || symname[3] == '$'))
3cde1ffa 205 continue;
3cde1ffa
JK
206 break;
207
208 case ST_PRI_PROG:
209 case ST_SEC_PROG:
210 case ST_ENTRY:
211 case ST_MILLICODE:
212 symname = bufp->name.n_strx + stringtab;
213 ms_type = mst_file_text;
9fdb3f7a
JK
214#ifdef SMASH_TEXT_ADDRESS
215 SMASH_TEXT_ADDRESS (bufp->symbol_value);
216#endif
3cde1ffa 217 break;
247145e6 218
3cde1ffa
JK
219 case ST_DATA:
220 symname = bufp->name.n_strx + stringtab;
221 ms_type = mst_file_data;
247145e6
JK
222 goto check_strange_names;
223
3cde1ffa
JK
224 default:
225 continue;
226 }
247145e6
JK
227 break;
228
3cde1ffa
JK
229 default:
230 continue;
231 }
684a832f 232
003ccb90 233 if (bufp->name.n_strx > obj_som_stringtab_size (abfd))
684a832f
SG
234 error ("Invalid symbol data; bad HP string table offset: %d",
235 bufp->name.n_strx);
236
3cde1ffa 237 record_minimal_symbol (symname,
684a832f
SG
238 bufp->symbol_value, ms_type,
239 objfile);
240 }
241
242 install_minimal_symbols (objfile);
243}
244
c7f3b703
JL
245/* Compare the start address for two unwind entries returning 1 if
246 the first address is larger than the second, -1 if the second is
247 larger than the first, and zero if they are equal. */
248
249static int
250compare_unwind_entries (a, b)
251 struct unwind_table_entry *a;
252 struct unwind_table_entry *b;
253{
254 if (a->region_start > b->region_start)
255 return 1;
256 else if (a->region_start < b->region_start)
257 return -1;
258 else
259 return 0;
260}
261
fa9265e5
SG
262/* Read in the backtrace information stored in the `$UNWIND_START$' section of
263 the object file. This info is used mainly by find_unwind_entry() to find
264 out the stack frame size and frame pointer used by procedures. We put
265 everything on the psymbol obstack in the objfile so that it automatically
266 gets freed when the objfile is destroyed. */
267
268static void
269read_unwind_info (objfile)
270 struct objfile *objfile;
271{
c7f3b703
JL
272 asection *unwind_sec, *stub_unwind_sec;
273 unsigned unwind_size, stub_unwind_size, total_size;
274 unsigned index, unwind_entries, stub_entries, total_entries;
fa9265e5
SG
275 struct obj_unwind_info *ui;
276
277 ui = obstack_alloc (&objfile->psymbol_obstack,
278 sizeof (struct obj_unwind_info));
279
280 ui->table = NULL;
281 ui->cache = NULL;
282 ui->last = -1;
283
c7f3b703
JL
284 /* Get hooks to both unwind sections. */
285 unwind_sec = bfd_get_section_by_name (objfile->obfd, "$UNWIND_START$");
286 stub_unwind_sec = bfd_get_section_by_name (objfile->obfd, "$UNWIND_END$");
287
288 /* Get sizes and unwind counts for both sections. */
fa9265e5
SG
289 if (unwind_sec)
290 {
c7f3b703
JL
291 unwind_size = bfd_section_size (objfile->obfd, unwind_sec);
292 unwind_entries = unwind_size / UNWIND_ENTRY_SIZE;
293 }
294 else
295 {
296 unwind_size = 0;
297 unwind_entries = 0;
298 }
299
300 if (stub_unwind_sec)
301 {
302 stub_unwind_size = bfd_section_size (objfile->obfd, stub_unwind_sec);
303 stub_entries = stub_unwind_size / STUB_UNWIND_ENTRY_SIZE;
304 }
305 else
306 {
307 stub_unwind_size = 0;
308 stub_entries = 0;
309 }
310
311 /* Compute total number of stubs. */
312 total_entries = unwind_entries + stub_entries;
313 total_size = total_entries * sizeof (struct unwind_table_entry);
314
315 /* Allocate memory for the unwind table. */
316 ui->table = obstack_alloc (&objfile->psymbol_obstack, total_size);
317 ui->last = total_entries + 1;
318
319 /* We will read the unwind entries into temporary memory, then
320 fill in the actual unwind table. */
321 if (unwind_size > 0)
322 {
323 unsigned long tmp;
324 unsigned i;
325 char *buf = alloca (unwind_size);
326
327 bfd_get_section_contents (objfile->obfd, unwind_sec, buf, 0, unwind_size);
328
329 /* Now internalize the information being careful to handle host/target
330 endian issues. */
331 for (i = 0; i < unwind_entries; i++)
332 {
333 ui->table[i].region_start = bfd_get_32 (objfile->obfd,
334 (bfd_byte *)buf);
335 buf += 4;
336 ui->table[i].region_end = bfd_get_32 (objfile->obfd, (bfd_byte *)buf);
337 buf += 4;
338 tmp = bfd_get_32 (objfile->obfd, (bfd_byte *)buf);
339 buf += 4;
340 ui->table[i].Cannot_unwind = (tmp >> 31) & 0x1;;
341 ui->table[i].Millicode = (tmp >> 30) & 0x1;
342 ui->table[i].Millicode_save_sr0 = (tmp >> 29) & 0x1;
343 ui->table[i].Region_description = (tmp >> 27) & 0x3;
344 ui->table[i].reserved1 = (tmp >> 26) & 0x1;
345 ui->table[i].Entry_SR = (tmp >> 25) & 0x1;
346 ui->table[i].Entry_FR = (tmp >> 21) & 0xf;
347 ui->table[i].Entry_GR = (tmp >> 16) & 0x1f;
348 ui->table[i].Args_stored = (tmp >> 15) & 0x1;
349 ui->table[i].Variable_Frame = (tmp >> 14) & 0x1;
350 ui->table[i].Separate_Package_Body = (tmp >> 13) & 0x1;
351 ui->table[i].Frame_Extension_Millicode = (tmp >> 12 ) & 0x1;
352 ui->table[i].Stack_Overflow_Check = (tmp >> 11) & 0x1;
353 ui->table[i].Two_Instruction_SP_Increment = (tmp >> 10) & 0x1;
354 ui->table[i].Ada_Region = (tmp >> 9) & 0x1;
355 ui->table[i].reserved2 = (tmp >> 5) & 0xf;
356 ui->table[i].Save_SP = (tmp >> 4) & 0x1;
357 ui->table[i].Save_RP = (tmp >> 3) & 0x1;
358 ui->table[i].Save_MRP_in_frame = (tmp >> 2) & 0x1;
359 ui->table[i].extn_ptr_defined = (tmp >> 1) & 0x1;
360 ui->table[i].Cleanup_defined = tmp & 0x1;
361 tmp = bfd_get_32 (objfile->obfd, (bfd_byte *)buf);
362 buf += 4;
363 ui->table[i].MPE_XL_interrupt_marker = (tmp >> 31) & 0x1;
364 ui->table[i].HP_UX_interrupt_marker = (tmp >> 30) & 0x1;
365 ui->table[i].Large_frame = (tmp >> 29) & 0x1;
366 ui->table[i].reserved4 = (tmp >> 27) & 0x3;
367 ui->table[i].Total_frame_size = tmp & 0x7ffffff;
368 }
369
370 }
371
372 if (stub_unwind_size > 0)
373 {
374 unsigned int i;
375 char *buf = alloca (stub_unwind_size);
fa9265e5 376
c7f3b703
JL
377 /* Read in the stub unwind entries. */
378 bfd_get_section_contents (objfile->obfd, stub_unwind_sec, buf,
379 0, stub_unwind_size);
fa9265e5 380
c7f3b703
JL
381 /* Now convert them into regular unwind entries. */
382 index = unwind_entries;
383 for (i = 0; i < stub_entries; i++, index++)
384 {
385 /* Clear out the next unwind entry. */
386 memset (&ui->table[index], 0, sizeof (struct unwind_table_entry));
387
388 /* Convert offset & size into region_start and region_end.
389 Stuff away the stub type into "reserved" fields. */
390 ui->table[index].region_start = bfd_get_32 (objfile->obfd,
391 (bfd_byte *) buf);
392 buf += 4;
393 ui->table[index].stub_type = bfd_get_8 (objfile->obfd,
394 (bfd_byte *) buf);
395 buf += 2;
396 ui->table[index].region_end
397 = ui->table[index].region_start + 4 * bfd_get_16 (objfile->obfd,
398 (bfd_byte *) buf);
399 buf += 2;
400 }
fa9265e5 401
fa9265e5 402 }
c7f3b703
JL
403
404 /* Unwind table needs to be kept sorted. */
405 qsort (ui->table, total_entries, sizeof (struct unwind_table_entry),
406 compare_unwind_entries);
407
408 /* Keep a pointer to the unwind information. */
36464897 409 objfile->obj_private = (PTR) ui;
fa9265e5
SG
410}
411
684a832f
SG
412/* Scan and build partial symbols for a symbol file.
413 We have been initialized by a call to pa_symfile_init, which
414 currently does nothing.
415
416 SECTION_OFFSETS is a set of offsets to apply to relocate the symbols
417 in each section. This is ignored, as it isn't needed for the PA.
418
419 MAINLINE is true if we are reading the main symbol
420 table (as opposed to a shared lib or dynamically loaded file).
421
422 This function only does the minimum work necessary for letting the
423 user "name" things symbolically; it does not read the entire symtab.
424 Instead, it reads the external and static symbols and puts them in partial
425 symbol tables. When more extensive information is requested of a
426 file, the corresponding partial symbol table is mutated into a full
427 fledged symbol table by going back and reading the symbols
428 for real.
429
430 We look for sections with specific names, to tell us what debug
431 format to look for: FIXME!!!
432
433 pastab_build_psymtabs() handles STABS symbols.
434
435 Note that PA files have a "minimal" symbol table, which is vaguely
436 reminiscent of a COFF symbol table, but has only the minimal information
437 necessary for linking. We process this also, and use the information to
438 build gdb's minimal symbol table. This gives us some minimal debugging
439 capability even for files compiled without -g. */
440
441static void
442pa_symfile_read (objfile, section_offsets, mainline)
443 struct objfile *objfile;
444 struct section_offsets *section_offsets;
445 int mainline;
446{
447 bfd *abfd = objfile->obfd;
448 struct cleanup *back_to;
449 CORE_ADDR offset;
450
451 init_minimal_symbol_collection ();
452 back_to = make_cleanup (discard_minimal_symbols, 0);
453
454 make_cleanup (free_painfo, (PTR) objfile);
455
456 /* Process the normal PA symbol table first. */
457
458 /* FIXME, should take a section_offsets param, not just an offset. */
459
460 offset = ANOFFSET (section_offsets, 0);
461 pa_symtab_read (abfd, offset, objfile);
462
463 /* Now process debugging information, which is contained in
464 special PA sections. */
465
466 pastab_build_psymtabs (objfile, section_offsets, mainline);
467
fa9265e5
SG
468 read_unwind_info(objfile);
469
684a832f
SG
470 do_cleanups (back_to);
471}
472
965a5c32 473/* This cleans up the objfile's sym_stab_info pointer, and the chain of
684a832f
SG
474 stab_section_info's, that might be dangling from it. */
475
476static void
477free_painfo (objp)
478 PTR objp;
479{
480 struct objfile *objfile = (struct objfile *)objp;
481 struct dbx_symfile_info *dbxinfo = (struct dbx_symfile_info *)
965a5c32 482 objfile->sym_stab_info;
684a832f
SG
483 struct stab_section_info *ssi, *nssi;
484
485 ssi = dbxinfo->stab_section_info;
486 while (ssi)
487 {
488 nssi = ssi->next;
489 mfree (objfile->md, ssi);
490 ssi = nssi;
491 }
492
493 dbxinfo->stab_section_info = 0; /* Just say No mo info about this. */
494}
495
496/* Initialize anything that needs initializing when a completely new symbol
497 file is specified (not just adding some symbols from another file, e.g. a
498 shared library).
499
500 We reinitialize buildsym, since we may be reading stabs from a PA file. */
501
502static void
503pa_new_init (ignore)
504 struct objfile *ignore;
505{
506 stabsread_new_init ();
507 buildsym_new_init ();
508}
509
510/* Perform any local cleanups required when we are done with a particular
511 objfile. I.E, we are in the process of discarding all symbol information
512 for an objfile, freeing up all memory held for it, and unlinking the
513 objfile struct from the global list of known objfiles. */
514
515static void
516pa_symfile_finish (objfile)
517 struct objfile *objfile;
518{
965a5c32 519 if (objfile -> sym_stab_info != NULL)
684a832f 520 {
965a5c32 521 mfree (objfile -> md, objfile -> sym_stab_info);
684a832f
SG
522 }
523}
524
684a832f
SG
525/* PA specific initialization routine for reading symbols.
526
527 It is passed a pointer to a struct sym_fns which contains, among other
528 things, the BFD for the file whose symbols are being read, and a slot for
529 a pointer to "private data" which we can fill with goodies.
530
531 This routine is almost a complete ripoff of dbx_symfile_init. The
532 common parts of these routines should be extracted and used instead of
533 duplicating this code. FIXME. */
534
535static void
536pa_symfile_init (objfile)
537 struct objfile *objfile;
538{
539 int val;
540 bfd *sym_bfd = objfile->obfd;
541 char *name = bfd_get_filename (sym_bfd);
0213d96f
SG
542 asection *stabsect; /* Section containing symbol table entries */
543 asection *stringsect; /* Section containing symbol name strings */
544
545 stabsect = bfd_get_section_by_name (sym_bfd, "$GDB_SYMBOLS$");
546 stringsect = bfd_get_section_by_name (sym_bfd, "$GDB_STRINGS$");
684a832f
SG
547
548 /* Allocate struct to keep track of the symfile */
965a5c32 549 objfile->sym_stab_info = (PTR)
684a832f
SG
550 xmmalloc (objfile -> md, sizeof (struct dbx_symfile_info));
551
965a5c32 552 memset ((PTR) objfile->sym_stab_info, 0, sizeof (struct dbx_symfile_info));
0213d96f 553
0213d96f 554
684a832f 555 /* FIXME POKING INSIDE BFD DATA STRUCTURES */
0213d96f
SG
556#define STRING_TABLE_OFFSET (stringsect->filepos)
557#define SYMBOL_TABLE_OFFSET (stabsect->filepos)
684a832f
SG
558
559 /* FIXME POKING INSIDE BFD DATA STRUCTURES */
560
561 DBX_SYMFILE_INFO (objfile)->stab_section_info = NULL;
db98e4d8 562 DBX_TEXT_SECT (objfile) = bfd_get_section_by_name (sym_bfd, "$TEXT$");
684a832f 563 if (!DBX_TEXT_SECT (objfile))
db98e4d8 564 error ("Can't find $TEXT$ section in symbol file");
684a832f 565
f3628b39
FF
566 if (!stabsect)
567 return;
568
569 if (!stringsect)
570 error ("Found stabs, but not string section");
571
1225fcbd
JK
572 /* FIXME: I suspect this should be external_nlist. The size of host
573 types like long and bfd_vma should not affect how we read the
574 file. */
0213d96f
SG
575 DBX_SYMBOL_SIZE (objfile) = sizeof (struct internal_nlist);
576 DBX_SYMCOUNT (objfile) = bfd_section_size (sym_bfd, stabsect)
577 / DBX_SYMBOL_SIZE (objfile);
684a832f
SG
578 DBX_SYMTAB_OFFSET (objfile) = SYMBOL_TABLE_OFFSET;
579
580 /* Read the string table and stash it away in the psymbol_obstack. It is
581 only needed as long as we need to expand psymbols into full symbols,
582 so when we blow away the psymbol the string table goes away as well.
583 Note that gdb used to use the results of attempting to malloc the
584 string table, based on the size it read, as a form of sanity check
585 for botched byte swapping, on the theory that a byte swapped string
586 table size would be so totally bogus that the malloc would fail. Now
587 that we put in on the psymbol_obstack, we can't do this since gdb gets
588 a fatal error (out of virtual memory) if the size is bogus. We can
589 however at least check to see if the size is zero or some negative
590 value. */
591
0213d96f 592 DBX_STRINGTAB_SIZE (objfile) = bfd_section_size (sym_bfd, stringsect);
684a832f
SG
593
594 if (DBX_SYMCOUNT (objfile) == 0
595 || DBX_STRINGTAB_SIZE (objfile) == 0)
596 return;
597
598 if (DBX_STRINGTAB_SIZE (objfile) <= 0
599 || DBX_STRINGTAB_SIZE (objfile) > bfd_get_size (sym_bfd))
600 error ("ridiculous string table size (%d bytes).",
601 DBX_STRINGTAB_SIZE (objfile));
602
603 DBX_STRINGTAB (objfile) =
604 (char *) obstack_alloc (&objfile -> psymbol_obstack,
605 DBX_STRINGTAB_SIZE (objfile));
606
607 /* Now read in the string table in one big gulp. */
608
609 val = bfd_seek (sym_bfd, STRING_TABLE_OFFSET, L_SET);
610 if (val < 0)
611 perror_with_name (name);
612 val = bfd_read (DBX_STRINGTAB (objfile), DBX_STRINGTAB_SIZE (objfile), 1,
613 sym_bfd);
93af329a
JK
614 if (val == 0)
615 error ("End of file reading string table");
616 else if (val < 0)
617 /* It's possible bfd_read should be setting bfd_error, and we should be
618 checking that. But currently it doesn't set bfd_error. */
684a832f 619 perror_with_name (name);
93af329a
JK
620 else if (val != DBX_STRINGTAB_SIZE (objfile))
621 error ("Short read reading string table");
684a832f
SG
622}
623
624/* PA specific parsing routine for section offsets.
625
626 Plain and simple for now. */
627
628static struct section_offsets *
629pa_symfile_offsets (objfile, addr)
630 struct objfile *objfile;
631 CORE_ADDR addr;
632{
633 struct section_offsets *section_offsets;
634 int i;
4d57c599
JK
635
636 objfile->num_sections = SECT_OFF_MAX;
684a832f
SG
637 section_offsets = (struct section_offsets *)
638 obstack_alloc (&objfile -> psymbol_obstack,
4d57c599
JK
639 sizeof (struct section_offsets)
640 + sizeof (section_offsets->offsets) * (SECT_OFF_MAX-1));
684a832f
SG
641
642 for (i = 0; i < SECT_OFF_MAX; i++)
643 ANOFFSET (section_offsets, i) = addr;
4d57c599 644
684a832f
SG
645 return section_offsets;
646}
647\f
00b02f17 648/* Register that we are able to handle SOM object file formats. */
684a832f 649
684a832f
SG
650static struct sym_fns pa_sym_fns =
651{
55449edd 652 bfd_target_som_flavour,
684a832f
SG
653 pa_new_init, /* sym_new_init: init anything gbl to entire symtab */
654 pa_symfile_init, /* sym_init: read initial info, setup for sym_read() */
655 pa_symfile_read, /* sym_read: read a symbol file into symtab */
656 pa_symfile_finish, /* sym_finish: finished with file, cleanup */
657 pa_symfile_offsets, /* sym_offsets: Translate ext. to int. relocation */
658 NULL /* next: pointer to next struct sym_fns */
659};
660
661void
662_initialize_paread ()
663{
664 add_symtab_fns (&pa_sym_fns);
665}
This page took 0.155289 seconds and 4 git commands to generate.