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