gdb.mi/mi-nonstop.exp: Replace gdb_test_multiple with mi_gdb_test.
[deliverable/binutils-gdb.git] / gdb / xcoffread.c
CommitLineData
c906108c 1/* Read AIX xcoff symbol tables and convert to internal format, for GDB.
197e01b6 2 Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
4c38e0a4 3 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008, 2009,
7b6bb8da 4 2010, 2011 Free Software Foundation, Inc.
c906108c
SS
5 Derived from coffread.c, dbxread.c, and a lot of hacking.
6 Contributed by IBM Corporation.
7
c5aa993b 8 This file is part of GDB.
c906108c 9
c5aa993b
JM
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
a9762ec7 12 the Free Software Foundation; either version 3 of the License, or
c5aa993b 13 (at your option) any later version.
c906108c 14
c5aa993b
JM
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
c906108c 19
c5aa993b 20 You should have received a copy of the GNU General Public License
a9762ec7 21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c
SS
22
23#include "defs.h"
24#include "bfd.h"
25
26#include <sys/types.h>
27#include <fcntl.h>
28#include <ctype.h>
29#include "gdb_string.h"
30
31#include <sys/param.h>
c0ccb908 32#ifdef HAVE_SYS_FILE_H
c906108c
SS
33#include <sys/file.h>
34#endif
35#include "gdb_stat.h"
36
37#include "coff/internal.h"
38#include "libcoff.h" /* FIXME, internal data from BFD */
11ed25ac
KB
39#include "coff/xcoff.h"
40#include "libxcoff.h"
c906108c 41#include "coff/rs6000.h"
63807e1d 42#include "xcoffread.h"
c906108c
SS
43
44#include "symtab.h"
45#include "gdbtypes.h"
9ab9195f 46/* FIXME: ezannoni/2004-02-13 Verify if the include below is really needed. */
c906108c
SS
47#include "symfile.h"
48#include "objfiles.h"
49#include "buildsym.h"
50#include "stabsread.h"
51#include "expression.h"
c906108c 52#include "complaints.h"
ccefe4c4 53#include "psympriv.h"
c906108c
SS
54
55#include "gdb-stabs.h"
56
57/* For interface with stabsread.c. */
58#include "aout/stab_gnu.h"
59
c906108c
SS
60\f
61/* We put a pointer to this structure in the read_symtab_private field
62 of the psymtab. */
63
c5aa993b
JM
64struct symloc
65 {
c906108c 66
c5aa993b 67 /* First symbol number for this file. */
c906108c 68
c5aa993b 69 int first_symnum;
c906108c 70
c5aa993b
JM
71 /* Number of symbols in the section of the symbol table devoted to
72 this file's symbols (actually, the section bracketed may contain
73 more than just this file's symbols). If numsyms is 0, the only
74 reason for this thing's existence is the dependency list. Nothing
75 else will happen when it is read in. */
c906108c 76
c5aa993b 77 int numsyms;
c906108c 78
3e43a32a
MS
79 /* Position of the start of the line number information for this
80 psymtab. */
c5aa993b
JM
81 unsigned int lineno_off;
82 };
c906108c 83
581e13c1 84/* Remember what we deduced to be the source language of this psymtab. */
c906108c
SS
85
86static enum language psymtab_language = language_unknown;
c906108c 87\f
c5aa993b 88
581e13c1 89/* Simplified internal version of coff symbol table information. */
c906108c 90
c5aa993b
JM
91struct coff_symbol
92 {
93 char *c_name;
581e13c1
MS
94 int c_symnum; /* Symbol number of this entry. */
95 int c_naux; /* 0 if syment only, 1 if syment + auxent. */
c5aa993b
JM
96 long c_value;
97 unsigned char c_sclass;
98 int c_secnum;
99 unsigned int c_type;
100 };
c906108c 101
581e13c1 102/* Last function's saved coff symbol `cs'. */
c906108c
SS
103
104static struct coff_symbol fcn_cs_saved;
105
106static bfd *symfile_bfd;
107
108/* Core address of start and end of text of current source file.
109 This is calculated from the first function seen after a C_FILE
581e13c1 110 symbol. */
c906108c
SS
111
112
113static CORE_ADDR cur_src_end_addr;
114
115/* Core address of the end of the first object file. */
116
117static CORE_ADDR first_object_file_end;
118
581e13c1 119/* Initial symbol-table-debug-string vector length. */
c906108c
SS
120
121#define INITIAL_STABVECTOR_LENGTH 40
122
123/* Nonzero if within a function (so symbols should be local,
124 if nothing says specifically). */
125
126int within_function;
127
128/* Size of a COFF symbol. I think it is always 18, so I'm not sure
129 there is any reason not to just use a #define, but might as well
130 ask BFD for the size and store it here, I guess. */
131
c5aa993b 132static unsigned local_symesz;
c906108c 133
c5aa993b
JM
134struct coff_symfile_info
135 {
581e13c1
MS
136 file_ptr min_lineno_offset; /* Where in file lowest line#s are. */
137 file_ptr max_lineno_offset; /* 1+last byte of line#s in file. */
c906108c 138
c5aa993b
JM
139 /* Pointer to the string table. */
140 char *strtbl;
c906108c 141
c5aa993b
JM
142 /* Pointer to debug section. */
143 char *debugsec;
c906108c 144
c5aa993b
JM
145 /* Pointer to the a.out symbol table. */
146 char *symtbl;
c906108c 147
c5aa993b
JM
148 /* Number of symbols in symtbl. */
149 int symtbl_num_syms;
c906108c 150
c5aa993b
JM
151 /* Offset in data section to TOC anchor. */
152 CORE_ADDR toc_offset;
153 };
c906108c 154
23136709
KB
155static void
156bf_notfound_complaint (void)
157{
3e43a32a
MS
158 complaint (&symfile_complaints,
159 _("line numbers off, `.bf' symbol not found"));
23136709 160}
c906108c 161
23136709
KB
162static void
163ef_complaint (int arg1)
164{
165 complaint (&symfile_complaints,
e2e0b3e5 166 _("Mismatched .ef symbol ignored starting at symnum %d"), arg1);
23136709 167}
c906108c 168
23136709
KB
169static void
170eb_complaint (int arg1)
171{
172 complaint (&symfile_complaints,
e2e0b3e5 173 _("Mismatched .eb symbol ignored starting at symnum %d"), arg1);
23136709 174}
c906108c 175
a14ed312 176static void xcoff_initial_scan (struct objfile *, int);
c906108c 177
a14ed312 178static void scan_xcoff_symtab (struct objfile *);
c906108c 179
a14ed312 180static char *xcoff_next_symbol_text (struct objfile *);
c906108c 181
a14ed312 182static void record_include_begin (struct coff_symbol *);
c906108c
SS
183
184static void
a14ed312
KB
185enter_line_range (struct subfile *, unsigned, unsigned,
186 CORE_ADDR, CORE_ADDR, unsigned *);
c906108c 187
a14ed312 188static void init_stringtab (bfd *, file_ptr, struct objfile *);
c906108c 189
a14ed312 190static void xcoff_symfile_init (struct objfile *);
c906108c 191
a14ed312 192static void xcoff_new_init (struct objfile *);
c906108c 193
a14ed312 194static void xcoff_symfile_finish (struct objfile *);
c906108c 195
570b8f7c
AC
196static void xcoff_symfile_offsets (struct objfile *,
197 struct section_addr_info *addrs);
c906108c 198
a14ed312 199static char *coff_getfilename (union internal_auxent *, struct objfile *);
c906108c 200
a14ed312 201static void read_symbol (struct internal_syment *, int);
c906108c 202
a14ed312 203static int read_symbol_lineno (int);
c906108c 204
470d5666 205static CORE_ADDR read_symbol_nvalue (int);
c906108c 206
a14ed312
KB
207static struct symbol *process_xcoff_symbol (struct coff_symbol *,
208 struct objfile *);
c906108c 209
a14ed312 210static void read_xcoff_symtab (struct partial_symtab *);
c906108c
SS
211
212#if 0
a14ed312 213static void add_stab_to_list (char *, struct pending_stabs **);
c906108c
SS
214#endif
215
a14ed312 216static int compare_lte (const void *, const void *);
c906108c 217
a14ed312 218static struct linetable *arrange_linetable (struct linetable *);
c906108c 219
a14ed312 220static void record_include_end (struct coff_symbol *);
c906108c 221
a14ed312 222static void process_linenos (CORE_ADDR, CORE_ADDR);
c906108c 223\f
c5aa993b 224
c906108c
SS
225/* Translate from a COFF section number (target_index) to a SECT_OFF_*
226 code. */
a14ed312
KB
227static int secnum_to_section (int, struct objfile *);
228static asection *secnum_to_bfd_section (int, struct objfile *);
c906108c 229
c5aa993b
JM
230struct find_targ_sec_arg
231 {
232 int targ_index;
233 int *resultp;
234 asection **bfd_sect;
b8fbeb18 235 struct objfile *objfile;
c5aa993b 236 };
c906108c 237
a14ed312 238static void find_targ_sec (bfd *, asection *, void *);
c906108c 239
c5aa993b 240static void
4efb68b1 241find_targ_sec (bfd *abfd, asection *sect, void *obj)
c906108c 242{
c5aa993b 243 struct find_targ_sec_arg *args = (struct find_targ_sec_arg *) obj;
b8fbeb18 244 struct objfile *objfile = args->objfile;
a109c7c1 245
c906108c
SS
246 if (sect->target_index == args->targ_index)
247 {
248 /* This is the section. Figure out what SECT_OFF_* code it is. */
249 if (bfd_get_section_flags (abfd, sect) & SEC_CODE)
b8fbeb18 250 *args->resultp = SECT_OFF_TEXT (objfile);
c906108c 251 else if (bfd_get_section_flags (abfd, sect) & SEC_LOAD)
b8fbeb18 252 *args->resultp = SECT_OFF_DATA (objfile);
c906108c 253 else
44af9391 254 *args->resultp = sect->index;
c906108c
SS
255 *args->bfd_sect = sect;
256 }
257}
258
259/* Return the section number (SECT_OFF_*) that CS points to. */
260static int
fba45db2 261secnum_to_section (int secnum, struct objfile *objfile)
c906108c 262{
b8fbeb18 263 int off = SECT_OFF_TEXT (objfile);
a109c7c1 264
c906108c
SS
265 asection *sect = NULL;
266 struct find_targ_sec_arg args;
267 args.targ_index = secnum;
268 args.resultp = &off;
269 args.bfd_sect = &sect;
b8fbeb18 270 args.objfile = objfile;
c906108c
SS
271 bfd_map_over_sections (objfile->obfd, find_targ_sec, &args);
272 return off;
273}
274
275/* Return the BFD section that CS points to. */
276static asection *
fba45db2 277secnum_to_bfd_section (int secnum, struct objfile *objfile)
c906108c 278{
b8fbeb18 279 int off = SECT_OFF_TEXT (objfile);
a109c7c1 280
c906108c
SS
281 asection *sect = NULL;
282 struct find_targ_sec_arg args;
283 args.targ_index = secnum;
284 args.resultp = &off;
285 args.bfd_sect = &sect;
7a78ae4e 286 args.objfile = objfile;
c906108c
SS
287 bfd_map_over_sections (objfile->obfd, find_targ_sec, &args);
288 return sect;
289}
290\f
581e13c1 291/* add a given stab string into given stab vector. */
c906108c
SS
292
293#if 0
294
295static void
fba45db2 296add_stab_to_list (char *stabname, struct pending_stabs **stabvector)
c906108c 297{
c5aa993b
JM
298 if (*stabvector == NULL)
299 {
300 *stabvector = (struct pending_stabs *)
301 xmalloc (sizeof (struct pending_stabs) +
302 INITIAL_STABVECTOR_LENGTH * sizeof (char *));
303 (*stabvector)->count = 0;
304 (*stabvector)->length = INITIAL_STABVECTOR_LENGTH;
305 }
306 else if ((*stabvector)->count >= (*stabvector)->length)
307 {
308 (*stabvector)->length += INITIAL_STABVECTOR_LENGTH;
309 *stabvector = (struct pending_stabs *)
310 xrealloc ((char *) *stabvector, sizeof (struct pending_stabs) +
3e43a32a 311 (*stabvector)->length * sizeof (char *));
c5aa993b
JM
312 }
313 (*stabvector)->stab[(*stabvector)->count++] = stabname;
c906108c
SS
314}
315
316#endif
c5aa993b 317\f/* *INDENT-OFF* */
c906108c
SS
318/* Linenos are processed on a file-by-file basis.
319
320 Two reasons:
321
c5aa993b 322 1) xlc (IBM's native c compiler) postpones static function code
581e13c1 323 emission to the end of a compilation unit. This way it can
c5aa993b 324 determine if those functions (statics) are needed or not, and
581e13c1 325 can do some garbage collection (I think). This makes line
c5aa993b
JM
326 numbers and corresponding addresses unordered, and we end up
327 with a line table like:
328
329
330 lineno addr
331 foo() 10 0x100
332 20 0x200
333 30 0x300
334
335 foo3() 70 0x400
336 80 0x500
337 90 0x600
338
339 static foo2()
340 40 0x700
341 50 0x800
342 60 0x900
343
344 and that breaks gdb's binary search on line numbers, if the
581e13c1 345 above table is not sorted on line numbers. And that sort
c5aa993b
JM
346 should be on function based, since gcc can emit line numbers
347 like:
348
349 10 0x100 - for the init/test part of a for stmt.
350 20 0x200
351 30 0x300
352 10 0x400 - for the increment part of a for stmt.
353
581e13c1 354 arrange_linetable() will do this sorting.
c5aa993b
JM
355
356 2) aix symbol table might look like:
357
358 c_file // beginning of a new file
359 .bi // beginning of include file
360 .ei // end of include file
361 .bi
362 .ei
363
364 basically, .bi/.ei pairs do not necessarily encapsulate
581e13c1 365 their scope. They need to be recorded, and processed later
c5aa993b
JM
366 on when we come the end of the compilation unit.
367 Include table (inclTable) and process_linenos() handle
368 that. */
9846de1b 369/* *INDENT-ON* */
c906108c 370
c5aa993b
JM
371
372
581e13c1 373/* compare line table entry addresses. */
c906108c
SS
374
375static int
fba45db2 376compare_lte (const void *lte1p, const void *lte2p)
c906108c
SS
377{
378 struct linetable_entry *lte1 = (struct linetable_entry *) lte1p;
379 struct linetable_entry *lte2 = (struct linetable_entry *) lte2p;
a109c7c1 380
c906108c
SS
381 return lte1->pc - lte2->pc;
382}
383
581e13c1
MS
384/* Given a line table with function entries are marked, arrange its
385 functions in ascending order and strip off function entry markers
386 and return it in a newly created table. If the old one is good
387 enough, return the old one. */
c906108c
SS
388/* FIXME: I think all this stuff can be replaced by just passing
389 sort_linevec = 1 to end_symtab. */
390
391static struct linetable *
b095261a 392arrange_linetable (struct linetable *oldLineTb)
c906108c 393{
c5aa993b
JM
394 int ii, jj, newline, /* new line count */
395 function_count; /* # of functions */
c906108c 396
c5aa993b
JM
397 struct linetable_entry *fentry; /* function entry vector */
398 int fentry_size; /* # of function entries */
399 struct linetable *newLineTb; /* new line table */
c906108c
SS
400
401#define NUM_OF_FUNCTIONS 20
402
403 fentry_size = NUM_OF_FUNCTIONS;
c5aa993b 404 fentry = (struct linetable_entry *)
c906108c
SS
405 xmalloc (fentry_size * sizeof (struct linetable_entry));
406
c5aa993b
JM
407 for (function_count = 0, ii = 0; ii < oldLineTb->nitems; ++ii)
408 {
c5aa993b 409 if (oldLineTb->item[ii].line == 0)
581e13c1 410 { /* Function entry found. */
c5aa993b 411 if (function_count >= fentry_size)
581e13c1 412 { /* Make sure you have room. */
c5aa993b
JM
413 fentry_size *= 2;
414 fentry = (struct linetable_entry *)
3e43a32a
MS
415 xrealloc (fentry,
416 fentry_size * sizeof (struct linetable_entry));
c5aa993b
JM
417 }
418 fentry[function_count].line = ii;
419 fentry[function_count].pc = oldLineTb->item[ii].pc;
420 ++function_count;
421 }
c906108c 422 }
c906108c 423
c5aa993b
JM
424 if (function_count == 0)
425 {
b8c9b27d 426 xfree (fentry);
c5aa993b
JM
427 return oldLineTb;
428 }
c906108c 429 else if (function_count > 1)
3e43a32a
MS
430 qsort (fentry, function_count,
431 sizeof (struct linetable_entry), compare_lte);
c906108c 432
581e13c1 433 /* Allocate a new line table. */
c906108c
SS
434 newLineTb = (struct linetable *)
435 xmalloc
c5aa993b
JM
436 (sizeof (struct linetable) +
437 (oldLineTb->nitems - function_count) * sizeof (struct linetable_entry));
c906108c 438
581e13c1
MS
439 /* If line table does not start with a function beginning, copy up until
440 a function begin. */
c906108c
SS
441
442 newline = 0;
443 if (oldLineTb->item[0].line != 0)
c5aa993b
JM
444 for (newline = 0;
445 newline < oldLineTb->nitems && oldLineTb->item[newline].line; ++newline)
c906108c
SS
446 newLineTb->item[newline] = oldLineTb->item[newline];
447
581e13c1 448 /* Now copy function lines one by one. */
c906108c 449
c5aa993b
JM
450 for (ii = 0; ii < function_count; ++ii)
451 {
452 for (jj = fentry[ii].line + 1;
453 jj < oldLineTb->nitems && oldLineTb->item[jj].line != 0;
454 ++jj, ++newline)
455 newLineTb->item[newline] = oldLineTb->item[jj];
456 }
b8c9b27d 457 xfree (fentry);
c906108c 458 newLineTb->nitems = oldLineTb->nitems - function_count;
c5aa993b
JM
459 return newLineTb;
460}
c906108c
SS
461
462/* include file support: C_BINCL/C_EINCL pairs will be kept in the
581e13c1 463 following `IncludeChain'. At the end of each symtab (end_symtab),
c906108c 464 we will determine if we should create additional symtab's to
581e13c1 465 represent if (the include files. */
c906108c
SS
466
467
c5aa993b
JM
468typedef struct _inclTable
469{
470 char *name; /* include filename */
c906108c
SS
471
472 /* Offsets to the line table. end points to the last entry which is
473 part of this include file. */
c5aa993b
JM
474 int begin, end;
475
c906108c 476 struct subfile *subfile;
581e13c1 477 unsigned funStartLine; /* Start line # of its function. */
c5aa993b
JM
478}
479InclTable;
c906108c
SS
480
481#define INITIAL_INCLUDE_TABLE_LENGTH 20
c5aa993b
JM
482static InclTable *inclTable; /* global include table */
483static int inclIndx; /* last entry to table */
484static int inclLength; /* table length */
485static int inclDepth; /* nested include depth */
c906108c 486
a14ed312 487static void allocate_include_entry (void);
c906108c
SS
488
489static void
fba45db2 490record_include_begin (struct coff_symbol *cs)
c906108c
SS
491{
492 if (inclDepth)
493 {
494 /* In xcoff, we assume include files cannot be nested (not in .c files
c5aa993b 495 of course, but in corresponding .s files.). */
c906108c
SS
496
497 /* This can happen with old versions of GCC.
c5aa993b
JM
498 GCC 2.3.3-930426 does not exhibit this on a test case which
499 a user said produced the message for him. */
e2e0b3e5 500 complaint (&symfile_complaints, _("Nested C_BINCL symbols"));
c906108c
SS
501 }
502 ++inclDepth;
503
504 allocate_include_entry ();
505
c5aa993b
JM
506 inclTable[inclIndx].name = cs->c_name;
507 inclTable[inclIndx].begin = cs->c_value;
c906108c
SS
508}
509
510static void
fba45db2 511record_include_end (struct coff_symbol *cs)
c906108c 512{
c5aa993b 513 InclTable *pTbl;
c906108c
SS
514
515 if (inclDepth == 0)
516 {
e2e0b3e5 517 complaint (&symfile_complaints, _("Mismatched C_BINCL/C_EINCL pair"));
c906108c
SS
518 }
519
520 allocate_include_entry ();
521
c5aa993b 522 pTbl = &inclTable[inclIndx];
c906108c
SS
523 pTbl->end = cs->c_value;
524
525 --inclDepth;
526 ++inclIndx;
527}
528
529static void
fba45db2 530allocate_include_entry (void)
c906108c
SS
531{
532 if (inclTable == NULL)
533 {
c5aa993b 534 inclTable = (InclTable *)
c906108c
SS
535 xmalloc (sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH);
536 memset (inclTable,
537 '\0', sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH);
538 inclLength = INITIAL_INCLUDE_TABLE_LENGTH;
539 inclIndx = 0;
540 }
541 else if (inclIndx >= inclLength)
542 {
543 inclLength += INITIAL_INCLUDE_TABLE_LENGTH;
c5aa993b 544 inclTable = (InclTable *)
c906108c 545 xrealloc (inclTable, sizeof (InclTable) * inclLength);
c5aa993b
JM
546 memset (inclTable + inclLength - INITIAL_INCLUDE_TABLE_LENGTH,
547 '\0', sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH);
c906108c
SS
548 }
549}
550
551/* Global variable to pass the psymtab down to all the routines involved
552 in psymtab to symtab processing. */
553static struct partial_symtab *this_symtab_psymtab;
554
555/* given the start and end addresses of a compilation unit (or a csect,
581e13c1 556 at times) process its lines and create appropriate line vectors. */
c906108c
SS
557
558static void
fba45db2 559process_linenos (CORE_ADDR start, CORE_ADDR end)
c906108c
SS
560{
561 int offset, ii;
562 file_ptr max_offset =
a109c7c1
MS
563 ((struct coff_symfile_info *) this_symtab_psymtab->objfile
564 ->deprecated_sym_private)->max_lineno_offset;
c906108c
SS
565
566 /* subfile structure for the main compilation unit. */
567 struct subfile main_subfile;
568
569 /* In the main source file, any time we see a function entry, we
570 reset this variable to function's absolute starting line number.
571 All the following line numbers in the function are relative to
572 this, and we record absolute line numbers in record_line(). */
573
574 unsigned int main_source_baseline = 0;
575
576 unsigned *firstLine;
577
578 offset =
c5aa993b 579 ((struct symloc *) this_symtab_psymtab->read_symtab_private)->lineno_off;
c906108c
SS
580 if (offset == 0)
581 goto return_after_cleanup;
582
583 memset (&main_subfile, '\0', sizeof (main_subfile));
584
585 if (inclIndx == 0)
581e13c1
MS
586 /* All source lines were in the main source file. None in include
587 files. */
c906108c 588
c5aa993b
JM
589 enter_line_range (&main_subfile, offset, 0, start, end,
590 &main_source_baseline);
c906108c
SS
591
592 else
593 {
594 /* There was source with line numbers in include files. */
7a78ae4e
ND
595
596 int linesz =
597 coff_data (this_symtab_psymtab->objfile->obfd)->local_linesz;
c906108c 598 main_source_baseline = 0;
7a78ae4e 599
c5aa993b 600 for (ii = 0; ii < inclIndx; ++ii)
c906108c
SS
601 {
602 struct subfile *tmpSubfile;
603
604 /* If there is main file source before include file, enter it. */
605 if (offset < inclTable[ii].begin)
606 {
607 enter_line_range
7a78ae4e 608 (&main_subfile, offset, inclTable[ii].begin - linesz,
c906108c
SS
609 start, 0, &main_source_baseline);
610 }
611
c5933f6d
JB
612 if (strcmp (inclTable[ii].name, last_source_file) == 0)
613 {
614 /* The entry in the include table refers to the main source
581e13c1 615 file. Add the lines to the main subfile. */
c5933f6d
JB
616
617 main_source_baseline = inclTable[ii].funStartLine;
618 enter_line_range
619 (&main_subfile, inclTable[ii].begin, inclTable[ii].end,
620 start, 0, &main_source_baseline);
621 inclTable[ii].subfile = &main_subfile;
622 }
623 else
624 {
c5933f6d 625 /* Have a new subfile for the include file. */
c906108c 626
c5933f6d
JB
627 tmpSubfile = inclTable[ii].subfile =
628 (struct subfile *) xmalloc (sizeof (struct subfile));
c906108c 629
c5933f6d
JB
630 memset (tmpSubfile, '\0', sizeof (struct subfile));
631 firstLine = &(inclTable[ii].funStartLine);
632
633 /* Enter include file's lines now. */
634 enter_line_range (tmpSubfile, inclTable[ii].begin,
635 inclTable[ii].end, start, 0, firstLine);
636 }
c906108c
SS
637
638 if (offset <= inclTable[ii].end)
7a78ae4e 639 offset = inclTable[ii].end + linesz;
c906108c
SS
640 }
641
642 /* All the include files' line have been processed at this point. Now,
c5aa993b 643 enter remaining lines of the main file, if any left. */
7a78ae4e 644 if (offset < max_offset + 1 - linesz)
c906108c 645 {
c5aa993b 646 enter_line_range (&main_subfile, offset, 0, start, end,
c906108c
SS
647 &main_source_baseline);
648 }
649 }
650
651 /* Process main file's line numbers. */
652 if (main_subfile.line_vector)
653 {
654 struct linetable *lineTb, *lv;
655
656 lv = main_subfile.line_vector;
657
581e13c1
MS
658 /* Line numbers are not necessarily ordered. xlc compilation will
659 put static function to the end. */
c906108c
SS
660
661 lineTb = arrange_linetable (lv);
662 if (lv == lineTb)
663 {
664 current_subfile->line_vector = (struct linetable *)
665 xrealloc (lv, (sizeof (struct linetable)
666 + lv->nitems * sizeof (struct linetable_entry)));
667 }
668 else
669 {
b8c9b27d 670 xfree (lv);
c906108c
SS
671 current_subfile->line_vector = lineTb;
672 }
673
c5aa993b 674 current_subfile->line_vector_length =
c906108c
SS
675 current_subfile->line_vector->nitems;
676 }
677
678 /* Now, process included files' line numbers. */
679
c5aa993b 680 for (ii = 0; ii < inclIndx; ++ii)
c906108c 681 {
c5933f6d 682 if (inclTable[ii].subfile != ((struct subfile *) &main_subfile)
3e43a32a
MS
683 && (inclTable[ii].subfile)->line_vector) /* Useless if!!!
684 FIXMEmgo */
c906108c
SS
685 {
686 struct linetable *lineTb, *lv;
687
688 lv = (inclTable[ii].subfile)->line_vector;
689
581e13c1
MS
690 /* Line numbers are not necessarily ordered. xlc compilation will
691 put static function to the end. */
c906108c
SS
692
693 lineTb = arrange_linetable (lv);
694
695 push_subfile ();
696
697 /* For the same include file, we might want to have more than one
698 subfile. This happens if we have something like:
699
c5aa993b
JM
700 ......
701 #include "foo.h"
702 ......
703 #include "foo.h"
704 ......
c906108c 705
581e13c1 706 while foo.h including code in it. (stupid but possible)
c906108c
SS
707 Since start_subfile() looks at the name and uses an
708 existing one if finds, we need to provide a fake name and
709 fool it. */
710
711#if 0
c5aa993b 712 start_subfile (inclTable[ii].name, (char *) 0);
c906108c
SS
713#else
714 {
715 /* Pick a fake name that will produce the same results as this
716 one when passed to deduce_language_from_filename. Kludge on
717 top of kludge. */
718 char *fakename = strrchr (inclTable[ii].name, '.');
a109c7c1 719
c906108c
SS
720 if (fakename == NULL)
721 fakename = " ?";
c5aa993b 722 start_subfile (fakename, (char *) 0);
b8c9b27d 723 xfree (current_subfile->name);
c906108c 724 }
c2d11a7d 725 current_subfile->name = xstrdup (inclTable[ii].name);
c906108c
SS
726#endif
727
728 if (lv == lineTb)
729 {
730 current_subfile->line_vector =
731 (struct linetable *) xrealloc
c5aa993b
JM
732 (lv, (sizeof (struct linetable)
733 + lv->nitems * sizeof (struct linetable_entry)));
c906108c
SS
734
735 }
736 else
737 {
b8c9b27d 738 xfree (lv);
c906108c
SS
739 current_subfile->line_vector = lineTb;
740 }
741
c5aa993b 742 current_subfile->line_vector_length =
c906108c 743 current_subfile->line_vector->nitems;
c5aa993b 744 start_subfile (pop_subfile (), (char *) 0);
c906108c
SS
745 }
746 }
747
c5aa993b 748return_after_cleanup:
c906108c
SS
749
750 /* We don't want to keep alloc/free'ing the global include file table. */
751 inclIndx = 0;
752
753 /* Start with a fresh subfile structure for the next file. */
754 memset (&main_subfile, '\0', sizeof (struct subfile));
755}
756
c295b2e5 757static void
fba45db2 758aix_process_linenos (void)
c906108c 759{
581e13c1 760 /* Process line numbers and enter them into line vector. */
c906108c
SS
761 process_linenos (last_source_start_addr, cur_src_end_addr);
762}
763
764
765/* Enter a given range of lines into the line vector.
766 can be called in the following two ways:
3e43a32a
MS
767 enter_line_range (subfile, beginoffset, endoffset,
768 startaddr, 0, firstLine) or
769 enter_line_range (subfile, beginoffset, 0,
770 startaddr, endaddr, firstLine)
c906108c
SS
771
772 endoffset points to the last line table entry that we should pay
773 attention to. */
774
775static void
3e43a32a
MS
776enter_line_range (struct subfile *subfile, unsigned beginoffset,
777 unsigned endoffset, /* offsets to line table */
fba45db2
KB
778 CORE_ADDR startaddr, /* offsets to line table */
779 CORE_ADDR endaddr, unsigned *firstLine)
c906108c 780{
fbf65064
UW
781 struct objfile *objfile = this_symtab_psymtab->objfile;
782 struct gdbarch *gdbarch = get_objfile_arch (objfile);
c906108c
SS
783 unsigned int curoffset;
784 CORE_ADDR addr;
7a78ae4e 785 void *ext_lnno;
c906108c
SS
786 struct internal_lineno int_lnno;
787 unsigned int limit_offset;
788 bfd *abfd;
7a78ae4e 789 int linesz;
c906108c
SS
790
791 if (endoffset == 0 && startaddr == 0 && endaddr == 0)
792 return;
793 curoffset = beginoffset;
794 limit_offset =
fbf65064 795 ((struct coff_symfile_info *) objfile->deprecated_sym_private)
c5aa993b 796 ->max_lineno_offset;
c906108c
SS
797
798 if (endoffset != 0)
799 {
800 if (endoffset >= limit_offset)
801 {
23136709 802 complaint (&symfile_complaints,
e2e0b3e5 803 _("Bad line table offset in C_EINCL directive"));
c906108c
SS
804 return;
805 }
806 limit_offset = endoffset;
807 }
808 else
809 limit_offset -= 1;
7a78ae4e 810
fbf65064 811 abfd = objfile->obfd;
7a78ae4e
ND
812 linesz = coff_data (abfd)->local_linesz;
813 ext_lnno = alloca (linesz);
c906108c
SS
814
815 while (curoffset <= limit_offset)
816 {
817 bfd_seek (abfd, curoffset, SEEK_SET);
3a42e9d0 818 bfd_bread (ext_lnno, linesz, abfd);
7a78ae4e 819 bfd_coff_swap_lineno_in (abfd, ext_lnno, &int_lnno);
c906108c
SS
820
821 /* Find the address this line represents. */
822 addr = (int_lnno.l_lnno
823 ? int_lnno.l_addr.l_paddr
824 : read_symbol_nvalue (int_lnno.l_addr.l_symndx));
fbf65064 825 addr += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
c906108c
SS
826
827 if (addr < startaddr || (endaddr && addr >= endaddr))
828 return;
829
830 if (int_lnno.l_lnno == 0)
831 {
832 *firstLine = read_symbol_lineno (int_lnno.l_addr.l_symndx);
fbf65064 833 record_line (subfile, 0, gdbarch_addr_bits_remove (gdbarch, addr));
c906108c
SS
834 --(*firstLine);
835 }
836 else
fbf65064
UW
837 record_line (subfile, *firstLine + int_lnno.l_lnno,
838 gdbarch_addr_bits_remove (gdbarch, addr));
7a78ae4e 839 curoffset += linesz;
c906108c
SS
840 }
841}
842
843
844/* Save the vital information for use when closing off the current file.
845 NAME is the file name the symbols came from, START_ADDR is the first
846 text address for the file, and SIZE is the number of bytes of text. */
847
848#define complete_symtab(name, start_addr) { \
1b36a34b
JK
849 last_source_file = xstrdup (name); \
850 last_source_start_addr = start_addr; \
c906108c
SS
851}
852
853
854/* Refill the symbol table input buffer
855 and set the variables that control fetching entries from it.
856 Reports an error if no data available.
857 This function can read past the end of the symbol table
858 (into the string table) but this does no harm. */
859
860/* Reading symbol table has to be fast! Keep the followings as macros, rather
581e13c1 861 than functions. */
c906108c
SS
862
863#define RECORD_MINIMAL_SYMBOL(NAME, ADDR, TYPE, SECTION, OBJFILE) \
864{ \
865 char *namestr; \
a109c7c1
MS
866 \
867 namestr = (NAME); \
868 if (namestr[0] == '.') ++namestr; \
869 prim_record_minimal_symbol_and_info (namestr, (ADDR), (TYPE), \
870 (SECTION), (asection *)NULL, \
871 (OBJFILE)); \
872 misc_func_recorded = 1; \
c906108c
SS
873}
874
875
581e13c1
MS
876/* xcoff has static blocks marked in `.bs', `.es' pairs. They cannot be
877 nested. At any given time, a symbol can only be in one static block.
878 This is the base address of current static block, zero if non exists. */
c5aa993b 879
c906108c
SS
880static int static_block_base = 0;
881
882/* Section number for the current static block. */
883
884static int static_block_section = -1;
885
581e13c1 886/* true if space for symbol name has been allocated. */
c906108c
SS
887
888static int symname_alloced = 0;
889
890/* Next symbol to read. Pointer into raw seething symbol table. */
891
892static char *raw_symbol;
893
894/* This is the function which stabsread.c calls to get symbol
895 continuations. */
896
897static char *
fba45db2 898xcoff_next_symbol_text (struct objfile *objfile)
c906108c
SS
899{
900 struct internal_syment symbol;
c906108c 901 char *retval;
a109c7c1 902
581e13c1 903 /* FIXME: is this the same as the passed arg? */
13c763f4
JB
904 if (this_symtab_psymtab)
905 objfile = this_symtab_psymtab->objfile;
c906108c
SS
906
907 bfd_coff_swap_sym_in (objfile->obfd, raw_symbol, &symbol);
908 if (symbol.n_zeroes)
909 {
e2e0b3e5 910 complaint (&symfile_complaints, _("Unexpected symbol continuation"));
c906108c
SS
911
912 /* Return something which points to '\0' and hope the symbol reading
c5aa993b 913 code does something reasonable. */
c906108c
SS
914 retval = "";
915 }
916 else if (symbol.n_sclass & 0x80)
917 {
3e43a32a
MS
918 retval = ((struct coff_symfile_info *)
919 objfile->deprecated_sym_private)->debugsec
c5aa993b 920 + symbol.n_offset;
3e43a32a 921 raw_symbol += coff_data (objfile->obfd)->local_symesz;
c906108c
SS
922 ++symnum;
923 }
924 else
925 {
e2e0b3e5 926 complaint (&symfile_complaints, _("Unexpected symbol continuation"));
c906108c
SS
927
928 /* Return something which points to '\0' and hope the symbol reading
c5aa993b 929 code does something reasonable. */
c906108c
SS
930 retval = "";
931 }
932 return retval;
933}
934
935/* Read symbols for a given partial symbol table. */
936
937static void
fba45db2 938read_xcoff_symtab (struct partial_symtab *pst)
c906108c
SS
939{
940 struct objfile *objfile = pst->objfile;
941 bfd *abfd = objfile->obfd;
581e13c1 942 char *raw_auxptr; /* Pointer to first raw aux entry for sym. */
a109c7c1
MS
943 char *strtbl =
944 ((struct coff_symfile_info *) objfile->deprecated_sym_private)->strtbl;
c906108c 945 char *debugsec =
a109c7c1 946 ((struct coff_symfile_info *) objfile->deprecated_sym_private)->debugsec;
554d387d 947 const char *debugfmt = bfd_xcoff_is_xcoff64 (abfd) ? "XCOFF64" : "XCOFF";
c906108c
SS
948
949 struct internal_syment symbol[1];
950 union internal_auxent main_aux;
951 struct coff_symbol cs[1];
952 CORE_ADDR file_start_addr = 0;
953 CORE_ADDR file_end_addr = 0;
954
955 int next_file_symnum = -1;
956 unsigned int max_symnum;
957 int just_started = 1;
958 int depth = 0;
959 int fcn_start_addr = 0;
960
238ae9af 961 struct coff_symbol fcn_stab_saved = { 0 };
c906108c 962
581e13c1 963 /* fcn_cs_saved is global because process_xcoff_symbol needs it. */
3672b1be 964 union internal_auxent fcn_aux_saved = main_aux;
c906108c
SS
965 struct context_stack *new;
966
581e13c1 967 char *filestring = " _start_ "; /* Name of the current file. */
c906108c 968
581e13c1 969 char *last_csect_name; /* Last seen csect's name and value. */
c906108c
SS
970 CORE_ADDR last_csect_val;
971 int last_csect_sec;
972
973 this_symtab_psymtab = pst;
974
975 /* Get the appropriate COFF "constants" related to the file we're
581e13c1 976 handling. */
c906108c
SS
977 local_symesz = coff_data (abfd)->local_symesz;
978
979 last_source_file = NULL;
980 last_csect_name = 0;
981 last_csect_val = 0;
982
983 start_stabs ();
c5aa993b 984 start_symtab (filestring, (char *) NULL, file_start_addr);
7a78ae4e 985 record_debugformat (debugfmt);
c5aa993b 986 symnum = ((struct symloc *) pst->read_symtab_private)->first_symnum;
c906108c 987 max_symnum =
c5aa993b 988 symnum + ((struct symloc *) pst->read_symtab_private)->numsyms;
c906108c
SS
989 first_object_file_end = 0;
990
991 raw_symbol =
0a6ddd08 992 ((struct coff_symfile_info *) objfile->deprecated_sym_private)->symtbl
c5aa993b 993 + symnum * local_symesz;
c906108c
SS
994
995 while (symnum < max_symnum)
996 {
c906108c
SS
997 QUIT; /* make this command interruptable. */
998
999 /* READ_ONE_SYMBOL (symbol, cs, symname_alloced); */
581e13c1 1000 /* read one symbol into `cs' structure. After processing the
c5aa993b 1001 whole symbol table, only string table will be kept in memory,
581e13c1 1002 symbol table and debug section of xcoff will be freed. Thus
c5aa993b 1003 we can mark symbols with names in string table as
581e13c1 1004 `alloced'. */
c906108c
SS
1005 {
1006 int ii;
1007
1008 /* Swap and align the symbol into a reasonable C structure. */
1009 bfd_coff_swap_sym_in (abfd, raw_symbol, symbol);
1010
1011 cs->c_symnum = symnum;
1012 cs->c_naux = symbol->n_numaux;
1013 if (symbol->n_zeroes)
1014 {
1015 symname_alloced = 0;
1016 /* We must use the original, unswapped, name here so the name field
1017 pointed to by cs->c_name will persist throughout xcoffread. If
1018 we use the new field, it gets overwritten for each symbol. */
c5aa993b 1019 cs->c_name = ((struct external_syment *) raw_symbol)->e.e_name;
c906108c
SS
1020 /* If it's exactly E_SYMNMLEN characters long it isn't
1021 '\0'-terminated. */
1022 if (cs->c_name[E_SYMNMLEN - 1] != '\0')
1023 {
1024 char *p;
a109c7c1 1025
4a146b47 1026 p = obstack_alloc (&objfile->objfile_obstack, E_SYMNMLEN + 1);
c906108c
SS
1027 strncpy (p, cs->c_name, E_SYMNMLEN);
1028 p[E_SYMNMLEN] = '\0';
1029 cs->c_name = p;
1030 symname_alloced = 1;
1031 }
1032 }
1033 else if (symbol->n_sclass & 0x80)
1034 {
1035 cs->c_name = debugsec + symbol->n_offset;
1036 symname_alloced = 0;
1037 }
1038 else
1039 {
1040 /* in string table */
c5aa993b 1041 cs->c_name = strtbl + (int) symbol->n_offset;
c906108c
SS
1042 symname_alloced = 1;
1043 }
1044 cs->c_value = symbol->n_value;
1045 cs->c_sclass = symbol->n_sclass;
1046 cs->c_secnum = symbol->n_scnum;
c5aa993b 1047 cs->c_type = (unsigned) symbol->n_type;
c906108c 1048
7a78ae4e 1049 raw_symbol += local_symesz;
c906108c
SS
1050 ++symnum;
1051
1052 /* Save addr of first aux entry. */
1053 raw_auxptr = raw_symbol;
1054
1055 /* Skip all the auxents associated with this symbol. */
1056 for (ii = symbol->n_numaux; ii; --ii)
1057 {
1058 raw_symbol += coff_data (abfd)->local_auxesz;
1059 ++symnum;
1060 }
1061 }
1062
581e13c1 1063 /* if symbol name starts with ".$" or "$", ignore it. */
c906108c
SS
1064 if (cs->c_name[0] == '$'
1065 || (cs->c_name[1] == '$' && cs->c_name[0] == '.'))
1066 continue;
1067
1068 if (cs->c_symnum == next_file_symnum && cs->c_sclass != C_FILE)
1069 {
1070 if (last_source_file)
1071 {
3e43a32a
MS
1072 pst->symtab = end_symtab (cur_src_end_addr, objfile,
1073 SECT_OFF_TEXT (objfile));
c906108c
SS
1074 end_stabs ();
1075 }
1076
1077 start_stabs ();
c5aa993b 1078 start_symtab ("_globals_", (char *) NULL, (CORE_ADDR) 0);
7a78ae4e 1079 record_debugformat (debugfmt);
c906108c 1080 cur_src_end_addr = first_object_file_end;
581e13c1 1081 /* Done with all files, everything from here on is globals. */
c906108c
SS
1082 }
1083
c906108c
SS
1084 if ((cs->c_sclass == C_EXT || cs->c_sclass == C_HIDEXT)
1085 && cs->c_naux == 1)
1086 {
1087 /* Dealing with a symbol with a csect entry. */
1088
1089#define CSECT(PP) ((PP)->x_csect)
1090#define CSECT_LEN(PP) (CSECT(PP).x_scnlen.l)
1091#define CSECT_ALIGN(PP) (SMTYP_ALIGN(CSECT(PP).x_smtyp))
1092#define CSECT_SMTYP(PP) (SMTYP_SMTYP(CSECT(PP).x_smtyp))
1093#define CSECT_SCLAS(PP) (CSECT(PP).x_smclas)
1094
1095 /* Convert the auxent to something we can access. */
1096 bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass,
1097 0, cs->c_naux, &main_aux);
1098
1099 switch (CSECT_SMTYP (&main_aux))
1100 {
1101
1102 case XTY_ER:
1103 /* Ignore all external references. */
1104 continue;
1105
1106 case XTY_SD:
1107 /* A section description. */
1108 {
1109 switch (CSECT_SCLAS (&main_aux))
1110 {
1111
1112 case XMC_PR:
1113 {
1114
1115 /* A program csect is seen. We have to allocate one
c5aa993b
JM
1116 symbol table for each program csect. Normally gdb
1117 prefers one symtab for each source file. In case
1118 of AIX, one source file might include more than one
1119 [PR] csect, and they don't have to be adjacent in
581e13c1 1120 terms of the space they occupy in memory. Thus, one
c5aa993b
JM
1121 single source file might get fragmented in the
1122 memory and gdb's file start and end address
1123 approach does not work! GCC (and I think xlc) seem
1124 to put all the code in the unnamed program csect. */
c906108c
SS
1125
1126 if (last_csect_name)
1127 {
1128 complete_symtab (filestring, file_start_addr);
1129 cur_src_end_addr = file_end_addr;
3e43a32a
MS
1130 end_symtab (file_end_addr, objfile,
1131 SECT_OFF_TEXT (objfile));
c906108c
SS
1132 end_stabs ();
1133 start_stabs ();
1134 /* Give all csects for this source file the same
1135 name. */
c5aa993b 1136 start_symtab (filestring, NULL, (CORE_ADDR) 0);
7a78ae4e 1137 record_debugformat (debugfmt);
c906108c
SS
1138 }
1139
1140 /* If this is the very first csect seen,
581e13c1 1141 basically `__start'. */
c906108c
SS
1142 if (just_started)
1143 {
1144 first_object_file_end
1145 = cs->c_value + CSECT_LEN (&main_aux);
1146 just_started = 0;
1147 }
1148
1149 file_start_addr =
1150 cs->c_value + ANOFFSET (objfile->section_offsets,
b8fbeb18 1151 SECT_OFF_TEXT (objfile));
c906108c
SS
1152 file_end_addr = file_start_addr + CSECT_LEN (&main_aux);
1153
977adac5
ND
1154 if (cs->c_name && (cs->c_name[0] == '.'
1155 || cs->c_name[0] == '@'))
c906108c
SS
1156 {
1157 last_csect_name = cs->c_name;
1158 last_csect_val = cs->c_value;
3e43a32a
MS
1159 last_csect_sec = secnum_to_section (cs->c_secnum,
1160 objfile);
c906108c
SS
1161 }
1162 }
1163 continue;
1164
1165 /* All other symbols are put into the minimal symbol
1166 table only. */
1167
1168 case XMC_RW:
1169 continue;
1170
1171 case XMC_TC0:
1172 continue;
1173
1174 case XMC_TC:
1175 continue;
1176
1177 default:
1178 /* Ignore the symbol. */
1179 continue;
1180 }
1181 }
1182 break;
1183
1184 case XTY_LD:
1185
1186 switch (CSECT_SCLAS (&main_aux))
1187 {
1188 case XMC_PR:
581e13c1 1189 /* a function entry point. */
c906108c
SS
1190 function_entry_point:
1191
1192 fcn_start_addr = cs->c_value;
1193
1194 /* save the function header info, which will be used
581e13c1 1195 when `.bf' is seen. */
c906108c
SS
1196 fcn_cs_saved = *cs;
1197 fcn_aux_saved = main_aux;
1198 continue;
1199
1200 case XMC_GL:
581e13c1 1201 /* shared library function trampoline code entry point. */
c906108c
SS
1202 continue;
1203
1204 case XMC_DS:
1205 /* The symbols often have the same names as debug symbols for
1206 functions, and confuse lookup_symbol. */
1207 continue;
1208
1209 default:
1210 /* xlc puts each variable in a separate csect, so we get
1211 an XTY_SD for each variable. But gcc puts several
1212 variables in a csect, so that each variable only gets
581e13c1 1213 an XTY_LD. This will typically be XMC_RW; I suspect
c906108c
SS
1214 XMC_RO and XMC_BS might be possible too.
1215 These variables are put in the minimal symbol table
1216 only. */
1217 continue;
1218 }
1219 break;
1220
1221 case XTY_CM:
1222 /* Common symbols are put into the minimal symbol table only. */
1223 continue;
1224
1225 default:
1226 break;
1227 }
1228 }
1229
977adac5
ND
1230 /* If explicitly specified as a function, treat is as one. This check
1231 evaluates to true for @FIX* bigtoc CSECT symbols, so it must occur
1232 after the above CSECT check. */
1233 if (ISFCN (cs->c_type) && cs->c_sclass != C_TPDEF)
1234 {
1235 bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass,
1236 0, cs->c_naux, &main_aux);
1237 goto function_entry_point;
1238 }
1239
c906108c
SS
1240 switch (cs->c_sclass)
1241 {
c906108c
SS
1242 case C_FILE:
1243
1244 /* c_value field contains symnum of next .file entry in table
581e13c1 1245 or symnum of first global after last .file. */
c906108c
SS
1246
1247 next_file_symnum = cs->c_value;
1248
1249 /* Complete symbol table for last object file containing
581e13c1 1250 debugging information. */
c906108c
SS
1251
1252 /* Whether or not there was a csect in the previous file, we
1253 have to call `end_stabs' and `start_stabs' to reset
1254 type_vector, line_vector, etc. structures. */
1255
1256 complete_symtab (filestring, file_start_addr);
1257 cur_src_end_addr = file_end_addr;
b8fbeb18 1258 end_symtab (file_end_addr, objfile, SECT_OFF_TEXT (objfile));
c906108c
SS
1259 end_stabs ();
1260
3e43a32a
MS
1261 /* XCOFF, according to the AIX 3.2 documentation, puts the
1262 filename in cs->c_name. But xlc 1.3.0.2 has decided to
1263 do things the standard COFF way and put it in the auxent.
1264 We use the auxent if the symbol is ".file" and an auxent
1265 exists, otherwise use the symbol itself. Simple
1266 enough. */
c906108c
SS
1267 if (!strcmp (cs->c_name, ".file") && cs->c_naux > 0)
1268 {
1269 bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass,
1270 0, cs->c_naux, &main_aux);
1271 filestring = coff_getfilename (&main_aux, objfile);
1272 }
1273 else
1274 filestring = cs->c_name;
1275
1276 start_stabs ();
c5aa993b 1277 start_symtab (filestring, (char *) NULL, (CORE_ADDR) 0);
7a78ae4e 1278 record_debugformat (debugfmt);
c906108c
SS
1279 last_csect_name = 0;
1280
581e13c1 1281 /* reset file start and end addresses. A compilation unit
3e43a32a 1282 with no text (only data) should have zero file
581e13c1 1283 boundaries. */
c906108c
SS
1284 file_start_addr = file_end_addr = 0;
1285 break;
1286
1287 case C_FUN:
1288 fcn_stab_saved = *cs;
1289 break;
1290
1291 case C_FCN:
7ecb6532 1292 if (strcmp (cs->c_name, ".bf") == 0)
c906108c
SS
1293 {
1294 CORE_ADDR off = ANOFFSET (objfile->section_offsets,
b8fbeb18 1295 SECT_OFF_TEXT (objfile));
a109c7c1 1296
c906108c
SS
1297 bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass,
1298 0, cs->c_naux, &main_aux);
1299
1300 within_function = 1;
1301
1302 new = push_context (0, fcn_start_addr + off);
1303
c5aa993b 1304 new->name = define_symbol
c906108c
SS
1305 (fcn_cs_saved.c_value + off,
1306 fcn_stab_saved.c_name, 0, 0, objfile);
1307 if (new->name != NULL)
b8fbeb18 1308 SYMBOL_SECTION (new->name) = SECT_OFF_TEXT (objfile);
c906108c 1309 }
7ecb6532 1310 else if (strcmp (cs->c_name, ".ef") == 0)
c906108c 1311 {
c906108c
SS
1312 bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass,
1313 0, cs->c_naux, &main_aux);
1314
1315 /* The value of .ef is the address of epilogue code;
c5aa993b 1316 not useful for gdb. */
c906108c 1317 /* { main_aux.x_sym.x_misc.x_lnsz.x_lnno
c5aa993b 1318 contains number of lines to '}' */
c906108c
SS
1319
1320 if (context_stack_depth <= 0)
581e13c1 1321 { /* We attempted to pop an empty context stack. */
23136709 1322 ef_complaint (cs->c_symnum);
c906108c
SS
1323 within_function = 0;
1324 break;
1325 }
1326 new = pop_context ();
1327 /* Stack must be empty now. */
1328 if (context_stack_depth > 0 || new == NULL)
1329 {
23136709 1330 ef_complaint (cs->c_symnum);
c906108c
SS
1331 within_function = 0;
1332 break;
1333 }
1334
1335 finish_block (new->name, &local_symbols, new->old_blocks,
1336 new->start_addr,
1337 (fcn_cs_saved.c_value
1338 + fcn_aux_saved.x_sym.x_misc.x_fsize
1339 + ANOFFSET (objfile->section_offsets,
b8fbeb18 1340 SECT_OFF_TEXT (objfile))),
c906108c
SS
1341 objfile);
1342 within_function = 0;
1343 }
1344 break;
1345
1346 case C_BSTAT:
1347 /* Begin static block. */
1348 {
1349 struct internal_syment symbol;
1350
1351 read_symbol (&symbol, cs->c_value);
1352 static_block_base = symbol.n_value;
1353 static_block_section =
1354 secnum_to_section (symbol.n_scnum, objfile);
1355 }
1356 break;
1357
1358 case C_ESTAT:
1359 /* End of static block. */
1360 static_block_base = 0;
1361 static_block_section = -1;
1362 break;
1363
1364 case C_ARG:
1365 case C_REGPARM:
1366 case C_REG:
1367 case C_TPDEF:
1368 case C_STRTAG:
1369 case C_UNTAG:
1370 case C_ENTAG:
1371 {
3e43a32a
MS
1372 complaint (&symfile_complaints,
1373 _("Unrecognized storage class %d."),
23136709 1374 cs->c_sclass);
c906108c
SS
1375 }
1376 break;
1377
1378 case C_LABEL:
1379 case C_NULL:
1380 /* Ignore these. */
1381 break;
1382
1383 case C_HIDEXT:
1384 case C_STAT:
1385 break;
1386
1387 case C_BINCL:
1388 /* beginning of include file */
1389 /* In xlc output, C_BINCL/C_EINCL pair doesn't show up in sorted
581e13c1
MS
1390 order. Thus, when wee see them, we might not know enough info
1391 to process them. Thus, we'll be saving them into a table
1392 (inclTable) and postpone their processing. */
c906108c
SS
1393
1394 record_include_begin (cs);
1395 break;
1396
1397 case C_EINCL:
1398 /* End of include file. */
1399 /* See the comment after case C_BINCL. */
1400 record_include_end (cs);
1401 break;
1402
1403 case C_BLOCK:
7ecb6532 1404 if (strcmp (cs->c_name, ".bb") == 0)
c906108c
SS
1405 {
1406 depth++;
1407 new = push_context (depth,
1408 (cs->c_value
1409 + ANOFFSET (objfile->section_offsets,
b8fbeb18 1410 SECT_OFF_TEXT (objfile))));
c906108c 1411 }
7ecb6532 1412 else if (strcmp (cs->c_name, ".eb") == 0)
c906108c
SS
1413 {
1414 if (context_stack_depth <= 0)
581e13c1 1415 { /* We attempted to pop an empty context stack. */
23136709 1416 eb_complaint (cs->c_symnum);
c906108c
SS
1417 break;
1418 }
1419 new = pop_context ();
1420 if (depth-- != new->depth)
1421 {
23136709 1422 eb_complaint (cs->c_symnum);
c906108c
SS
1423 break;
1424 }
1425 if (local_symbols && context_stack_depth > 0)
1426 {
1427 /* Make a block for the local symbols within. */
1428 finish_block (new->name, &local_symbols, new->old_blocks,
1429 new->start_addr,
1430 (cs->c_value
1431 + ANOFFSET (objfile->section_offsets,
b8fbeb18 1432 SECT_OFF_TEXT (objfile))),
c906108c
SS
1433 objfile);
1434 }
1435 local_symbols = new->locals;
1436 }
1437 break;
1438
1439 default:
1440 process_xcoff_symbol (cs, objfile);
1441 break;
1442 }
1443 }
1444
1445 if (last_source_file)
1446 {
1447 struct symtab *s;
1448
1449 complete_symtab (filestring, file_start_addr);
1450 cur_src_end_addr = file_end_addr;
b8fbeb18 1451 s = end_symtab (file_end_addr, objfile, SECT_OFF_TEXT (objfile));
c906108c
SS
1452 /* When reading symbols for the last C_FILE of the objfile, try
1453 to make sure that we set pst->symtab to the symtab for the
1454 file, not to the _globals_ symtab. I'm not sure whether this
1455 actually works right or when/if it comes up. */
1456 if (pst->symtab == NULL)
1457 pst->symtab = s;
1458 end_stabs ();
1459 }
1460}
1461
1462#define SYMBOL_DUP(SYMBOL1, SYMBOL2) \
1463 (SYMBOL2) = (struct symbol *) \
4a146b47 1464 obstack_alloc (&objfile->objfile_obstack, sizeof (struct symbol)); \
c906108c 1465 *(SYMBOL2) = *(SYMBOL1);
c5aa993b
JM
1466
1467
c906108c 1468#define SYMNAME_ALLOC(NAME, ALLOCED) \
3e43a32a
MS
1469 ((ALLOCED) ? (NAME) : obsavestring ((NAME), strlen (NAME), \
1470 &objfile->objfile_obstack))
c906108c
SS
1471
1472
581e13c1 1473/* process one xcoff symbol. */
c906108c
SS
1474
1475static struct symbol *
aa1ee363 1476process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
c906108c
SS
1477{
1478 struct symbol onesymbol;
52f0bd74 1479 struct symbol *sym = &onesymbol;
c906108c
SS
1480 struct symbol *sym2 = NULL;
1481 char *name, *pp;
1482
1483 int sec;
1484 CORE_ADDR off;
1485
1486 if (cs->c_secnum < 0)
1487 {
1488 /* The value is a register number, offset within a frame, etc.,
c5aa993b 1489 and does not get relocated. */
c906108c
SS
1490 off = 0;
1491 sec = -1;
1492 }
1493 else
1494 {
1495 sec = secnum_to_section (cs->c_secnum, objfile);
1496 off = ANOFFSET (objfile->section_offsets, sec);
1497 }
1498
1499 name = cs->c_name;
1500 if (name[0] == '.')
1501 ++name;
1502
1503 memset (sym, '\0', sizeof (struct symbol));
1504
1505 /* default assumptions */
7a78ae4e 1506 SYMBOL_VALUE_ADDRESS (sym) = cs->c_value + off;
176620f1 1507 SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
c906108c
SS
1508 SYMBOL_SECTION (sym) = secnum_to_section (cs->c_secnum, objfile);
1509
1510 if (ISFCN (cs->c_type))
1511 {
1512 /* At this point, we don't know the type of the function. This
c5aa993b
JM
1513 will be patched with the type from its stab entry later on in
1514 patch_block_stabs (), unless the file was compiled without -g. */
c906108c 1515
3567439c 1516 SYMBOL_SET_LINKAGE_NAME (sym, SYMNAME_ALLOC (name, symname_alloced));
46bf5051 1517 SYMBOL_TYPE (sym) = objfile_type (objfile)->nodebug_text_symbol;
c906108c
SS
1518
1519 SYMBOL_CLASS (sym) = LOC_BLOCK;
1520 SYMBOL_DUP (sym, sym2);
1521
1522 if (cs->c_sclass == C_EXT)
1523 add_symbol_to_list (sym2, &global_symbols);
1524 else if (cs->c_sclass == C_HIDEXT || cs->c_sclass == C_STAT)
1525 add_symbol_to_list (sym2, &file_symbols);
1526 }
1527 else
1528 {
581e13c1 1529 /* In case we can't figure out the type, provide default. */
46bf5051 1530 SYMBOL_TYPE (sym) = objfile_type (objfile)->nodebug_data_symbol;
c906108c
SS
1531
1532 switch (cs->c_sclass)
1533 {
1534#if 0
c5aa993b
JM
1535 /* The values of functions and global symbols are now resolved
1536 via the global_sym_chain in stabsread.c. */
c906108c
SS
1537 case C_FUN:
1538 if (fcn_cs_saved.c_sclass == C_EXT)
1539 add_stab_to_list (name, &global_stabs);
1540 else
1541 add_stab_to_list (name, &file_stabs);
1542 break;
1543
1544 case C_GSYM:
1545 add_stab_to_list (name, &global_stabs);
1546 break;
1547#endif
1548
1549 case C_BCOMM:
1550 common_block_start (cs->c_name, objfile);
1551 break;
1552
1553 case C_ECOMM:
1554 common_block_end (objfile);
1555 break;
1556
1557 default:
e2e0b3e5 1558 complaint (&symfile_complaints, _("Unexpected storage class: %d"),
23136709 1559 cs->c_sclass);
c906108c
SS
1560 /* FALLTHROUGH */
1561
1562 case C_DECL:
1563 case C_PSYM:
1564 case C_RPSYM:
1565 case C_ECOML:
1566 case C_LSYM:
1567 case C_RSYM:
1568 case C_GSYM:
1569
1570 {
1571 sym = define_symbol (cs->c_value + off, cs->c_name, 0, 0, objfile);
1572 if (sym != NULL)
1573 {
1574 SYMBOL_SECTION (sym) = sec;
1575 }
1576 return sym;
1577 }
1578
1579 case C_STSYM:
1580
1581 /* For xlc (not GCC), the 'V' symbol descriptor is used for
1582 all statics and we need to distinguish file-scope versus
1583 function-scope using within_function. We do this by
1584 changing the string we pass to define_symbol to use 'S'
1585 where we need to, which is not necessarily super-clean,
1586 but seems workable enough. */
1587
9b13a2db
PM
1588 if (*name == ':')
1589 return NULL;
1590
ed4b0e6a 1591 pp = strchr (name, ':');
9b13a2db 1592 if (pp == NULL)
c906108c
SS
1593 return NULL;
1594
1595 ++pp;
1596 if (*pp == 'V' && !within_function)
1597 *pp = 'S';
1598 sym = define_symbol ((cs->c_value
1599 + ANOFFSET (objfile->section_offsets,
1600 static_block_section)),
1601 cs->c_name, 0, 0, objfile);
1602 if (sym != NULL)
1603 {
7a78ae4e 1604 SYMBOL_VALUE_ADDRESS (sym) += static_block_base;
c906108c
SS
1605 SYMBOL_SECTION (sym) = static_block_section;
1606 }
1607 return sym;
1608
1609 }
1610 }
1611 return sym2;
1612}
1613
1614/* Extract the file name from the aux entry of a C_FILE symbol.
1615 Result is in static storage and is only good for temporary use. */
1616
1617static char *
fba45db2 1618coff_getfilename (union internal_auxent *aux_entry, struct objfile *objfile)
c906108c
SS
1619{
1620 static char buffer[BUFSIZ];
1621
1622 if (aux_entry->x_file.x_n.x_zeroes == 0)
3e43a32a
MS
1623 strcpy (buffer, ((struct coff_symfile_info *)
1624 objfile->deprecated_sym_private)->strtbl
c906108c
SS
1625 + aux_entry->x_file.x_n.x_offset);
1626 else
1627 {
1628 strncpy (buffer, aux_entry->x_file.x_fname, FILNMLEN);
1629 buffer[FILNMLEN] = '\0';
1630 }
1631 return (buffer);
1632}
1633
1634/* Set *SYMBOL to symbol number symno in symtbl. */
1635static void
fba45db2 1636read_symbol (struct internal_syment *symbol, int symno)
c906108c 1637{
3e43a32a
MS
1638 int nsyms
1639 = ((struct coff_symfile_info *)
1640 this_symtab_psymtab->objfile->deprecated_sym_private)->symtbl_num_syms;
1641 char *stbl = ((struct coff_symfile_info *)
1642 this_symtab_psymtab->objfile->deprecated_sym_private)->symtbl;
a109c7c1 1643
c906108c
SS
1644 if (symno < 0 || symno >= nsyms)
1645 {
e2e0b3e5 1646 complaint (&symfile_complaints, _("Invalid symbol offset"));
c906108c
SS
1647 symbol->n_value = 0;
1648 symbol->n_scnum = -1;
1649 return;
1650 }
1651 bfd_coff_swap_sym_in (this_symtab_psymtab->objfile->obfd,
c5aa993b 1652 stbl + (symno * local_symesz),
c906108c
SS
1653 symbol);
1654}
c5aa993b 1655
c906108c
SS
1656/* Get value corresponding to symbol number symno in symtbl. */
1657
470d5666 1658static CORE_ADDR
fba45db2 1659read_symbol_nvalue (int symno)
c906108c
SS
1660{
1661 struct internal_syment symbol[1];
1662
1663 read_symbol (symbol, symno);
c5aa993b 1664 return symbol->n_value;
c906108c
SS
1665}
1666
1667
1668/* Find the address of the function corresponding to symno, where
1669 symno is the symbol pointed to by the linetable. */
1670
1671static int
fba45db2 1672read_symbol_lineno (int symno)
c906108c 1673{
7a78ae4e 1674 struct objfile *objfile = this_symtab_psymtab->objfile;
7af35dad 1675 int xcoff64 = bfd_xcoff_is_xcoff64 (objfile->obfd);
7a78ae4e
ND
1676
1677 struct coff_symfile_info *info =
0a6ddd08 1678 (struct coff_symfile_info *)objfile->deprecated_sym_private;
7a78ae4e
ND
1679 int nsyms = info->symtbl_num_syms;
1680 char *stbl = info->symtbl;
1681 char *strtbl = info->strtbl;
1682
c906108c
SS
1683 struct internal_syment symbol[1];
1684 union internal_auxent main_aux[1];
1685
1686 if (symno < 0)
1687 {
23136709 1688 bf_notfound_complaint ();
c906108c
SS
1689 return 0;
1690 }
1691
1692 /* Note that just searching for a short distance (e.g. 50 symbols)
1693 is not enough, at least in the following case.
1694
1695 .extern foo
1696 [many .stabx entries]
1697 [a few functions, referring to foo]
1698 .globl foo
1699 .bf
1700
1701 What happens here is that the assembler moves the .stabx entries
1702 to right before the ".bf" for foo, but the symbol for "foo" is before
1703 all the stabx entries. See PR gdb/2222. */
1704
1705 /* Maintaining a table of .bf entries might be preferable to this search.
1706 If I understand things correctly it would need to be done only for
1707 the duration of a single psymtab to symtab conversion. */
1708 while (symno < nsyms)
1709 {
1710 bfd_coff_swap_sym_in (symfile_bfd,
1711 stbl + (symno * local_symesz), symbol);
7a78ae4e
ND
1712 if (symbol->n_sclass == C_FCN)
1713 {
1714 char *name = xcoff64 ? strtbl + symbol->n_offset : symbol->n_name;
a109c7c1 1715
7ecb6532 1716 if (strcmp (name, ".bf") == 0)
7a78ae4e
ND
1717 goto gotit;
1718 }
c906108c
SS
1719 symno += symbol->n_numaux + 1;
1720 }
1721
23136709 1722 bf_notfound_complaint ();
c906108c
SS
1723 return 0;
1724
1725gotit:
581e13c1 1726 /* Take aux entry and return its lineno. */
c906108c 1727 symno++;
7a78ae4e 1728 bfd_coff_swap_aux_in (objfile->obfd, stbl + symno * local_symesz,
c906108c
SS
1729 symbol->n_type, symbol->n_sclass,
1730 0, symbol->n_numaux, main_aux);
1731
1732 return main_aux->x_sym.x_misc.x_lnsz.x_lnno;
1733}
1734
581e13c1 1735/* Support for line number handling. */
c906108c
SS
1736
1737/* This function is called for every section; it finds the outer limits
1738 * of the line table (minimum and maximum file offset) so that the
1739 * mainline code can read the whole thing for efficiency.
1740 */
1741static void
7be0c536 1742find_linenos (struct bfd *abfd, struct bfd_section *asect, void *vpinfo)
c906108c
SS
1743{
1744 struct coff_symfile_info *info;
1745 int size, count;
1746 file_ptr offset, maxoff;
1747
1748 count = asect->lineno_count;
1749
7ecb6532 1750 if (strcmp (asect->name, ".text") != 0 || count == 0)
c906108c
SS
1751 return;
1752
1753 size = count * coff_data (abfd)->local_linesz;
c5aa993b 1754 info = (struct coff_symfile_info *) vpinfo;
c906108c
SS
1755 offset = asect->line_filepos;
1756 maxoff = offset + size;
1757
1758 if (offset < info->min_lineno_offset || info->min_lineno_offset == 0)
1759 info->min_lineno_offset = offset;
1760
1761 if (maxoff > info->max_lineno_offset)
1762 info->max_lineno_offset = maxoff;
1763}
1764\f
a14ed312 1765static void xcoff_psymtab_to_symtab_1 (struct partial_symtab *);
c906108c
SS
1766
1767static void
fba45db2 1768xcoff_psymtab_to_symtab_1 (struct partial_symtab *pst)
c906108c
SS
1769{
1770 struct cleanup *old_chain;
1771 int i;
c5aa993b 1772
c906108c
SS
1773 if (!pst)
1774 return;
1775
1776 if (pst->readin)
1777 {
1778 fprintf_unfiltered
1779 (gdb_stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
1780 pst->filename);
1781 return;
1782 }
1783
581e13c1 1784 /* Read in all partial symtabs on which this one is dependent. */
c906108c
SS
1785 for (i = 0; i < pst->number_of_dependencies; i++)
1786 if (!pst->dependencies[i]->readin)
1787 {
1788 /* Inform about additional files that need to be read in. */
1789 if (info_verbose)
1790 {
1791 fputs_filtered (" ", gdb_stdout);
1792 wrap_here ("");
1793 fputs_filtered ("and ", gdb_stdout);
1794 wrap_here ("");
1795 printf_filtered ("%s...", pst->dependencies[i]->filename);
c5aa993b 1796 wrap_here (""); /* Flush output */
c906108c
SS
1797 gdb_flush (gdb_stdout);
1798 }
1799 xcoff_psymtab_to_symtab_1 (pst->dependencies[i]);
1800 }
1801
c5aa993b 1802 if (((struct symloc *) pst->read_symtab_private)->numsyms != 0)
c906108c
SS
1803 {
1804 /* Init stuff necessary for reading in symbols. */
1805 stabsread_init ();
1806 buildsym_init ();
a0b3c4fd 1807 old_chain = make_cleanup (really_free_pendings, 0);
c906108c
SS
1808
1809 read_xcoff_symtab (pst);
c906108c
SS
1810
1811 do_cleanups (old_chain);
1812 }
1813
1814 pst->readin = 1;
1815}
1816
a14ed312 1817static void xcoff_psymtab_to_symtab (struct partial_symtab *);
c906108c
SS
1818
1819/* Read in all of the symbols for a given psymtab for real.
1820 Be verbose about it if the user wants that. */
1821
1822static void
fba45db2 1823xcoff_psymtab_to_symtab (struct partial_symtab *pst)
c906108c
SS
1824{
1825 bfd *sym_bfd;
1826
1827 if (!pst)
1828 return;
1829
1830 if (pst->readin)
1831 {
1832 fprintf_unfiltered
1833 (gdb_stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
1834 pst->filename);
1835 return;
1836 }
1837
c5aa993b 1838 if (((struct symloc *) pst->read_symtab_private)->numsyms != 0
c906108c
SS
1839 || pst->number_of_dependencies)
1840 {
1841 /* Print the message now, before reading the string table,
c5aa993b 1842 to avoid disconcerting pauses. */
c906108c
SS
1843 if (info_verbose)
1844 {
1845 printf_filtered ("Reading in symbols for %s...", pst->filename);
1846 gdb_flush (gdb_stdout);
1847 }
1848
1849 sym_bfd = pst->objfile->obfd;
1850
1851 next_symbol_text_func = xcoff_next_symbol_text;
1852
1853 xcoff_psymtab_to_symtab_1 (pst);
1854
1855 /* Match with global symbols. This only needs to be done once,
1856 after all of the symtabs and dependencies have been read in. */
1857 scan_file_globals (pst->objfile);
1858
1859 /* Finish up the debug error message. */
1860 if (info_verbose)
1861 printf_filtered ("done.\n");
1862 }
1863}
1864\f
1865static void
fba45db2 1866xcoff_new_init (struct objfile *objfile)
c906108c
SS
1867{
1868 stabsread_new_init ();
1869 buildsym_new_init ();
1870}
1871
1872/* Do initialization in preparation for reading symbols from OBJFILE.
c5aa993b 1873
c906108c
SS
1874 We will only be called if this is an XCOFF or XCOFF-like file.
1875 BFD handles figuring out the format of the file, and code in symfile.c
1876 uses BFD's determination to vector to us. */
1877
1878static void
fba45db2 1879xcoff_symfile_init (struct objfile *objfile)
c906108c 1880{
581e13c1 1881 /* Allocate struct to keep track of the symfile. */
3e43a32a
MS
1882 objfile->deprecated_sym_private
1883 = xmalloc (sizeof (struct coff_symfile_info));
c906108c
SS
1884
1885 /* XCOFF objects may be reordered, so set OBJF_REORDERED. If we
1886 find this causes a significant slowdown in gdb then we could
1887 set it in the debug symbol readers only when necessary. */
1888 objfile->flags |= OBJF_REORDERED;
1889
1890 init_entry_point_info (objfile);
1891}
1892
1893/* Perform any local cleanups required when we are done with a particular
1894 objfile. I.E, we are in the process of discarding all symbol information
1895 for an objfile, freeing up all memory held for it, and unlinking the
581e13c1 1896 objfile struct from the global list of known objfiles. */
c906108c
SS
1897
1898static void
fba45db2 1899xcoff_symfile_finish (struct objfile *objfile)
c906108c 1900{
0a6ddd08 1901 if (objfile->deprecated_sym_private != NULL)
c906108c 1902 {
0a6ddd08 1903 xfree (objfile->deprecated_sym_private);
c906108c
SS
1904 }
1905
1906 /* Start with a fresh include table for the next objfile. */
1907 if (inclTable)
1908 {
b8c9b27d 1909 xfree (inclTable);
c906108c
SS
1910 inclTable = NULL;
1911 }
1912 inclIndx = inclLength = inclDepth = 0;
1913}
1914
1915
1916static void
fba45db2 1917init_stringtab (bfd *abfd, file_ptr offset, struct objfile *objfile)
c906108c
SS
1918{
1919 long length;
1920 int val;
1921 unsigned char lengthbuf[4];
1922 char *strtbl;
1923
3e43a32a
MS
1924 ((struct coff_symfile_info *) objfile->deprecated_sym_private)->strtbl
1925 = NULL;
c906108c
SS
1926
1927 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
8a3fe4f8 1928 error (_("cannot seek to string table in %s: %s"),
c906108c
SS
1929 bfd_get_filename (abfd), bfd_errmsg (bfd_get_error ()));
1930
3a42e9d0 1931 val = bfd_bread ((char *) lengthbuf, sizeof lengthbuf, abfd);
c906108c
SS
1932 length = bfd_h_get_32 (abfd, lengthbuf);
1933
1934 /* If no string table is needed, then the file may end immediately
1935 after the symbols. Just return with `strtbl' set to NULL. */
1936
1937 if (val != sizeof lengthbuf || length < sizeof lengthbuf)
1938 return;
1939
581e13c1
MS
1940 /* Allocate string table from objfile_obstack. We will need this table
1941 as long as we have its symbol table around. */
c906108c 1942
4a146b47 1943 strtbl = (char *) obstack_alloc (&objfile->objfile_obstack, length);
3e43a32a
MS
1944 ((struct coff_symfile_info *) objfile->deprecated_sym_private)->strtbl
1945 = strtbl;
c906108c
SS
1946
1947 /* Copy length buffer, the first byte is usually zero and is
1948 used for stabs with a name length of zero. */
1949 memcpy (strtbl, lengthbuf, sizeof lengthbuf);
1950 if (length == sizeof lengthbuf)
1951 return;
1952
3a42e9d0 1953 val = bfd_bread (strtbl + sizeof lengthbuf, length - sizeof lengthbuf, abfd);
c906108c
SS
1954
1955 if (val != length - sizeof lengthbuf)
8a3fe4f8 1956 error (_("cannot read string table from %s: %s"),
c906108c
SS
1957 bfd_get_filename (abfd), bfd_errmsg (bfd_get_error ()));
1958 if (strtbl[length - 1] != '\0')
3e43a32a
MS
1959 error (_("bad symbol file: string table "
1960 "does not end with null character"));
c906108c
SS
1961
1962 return;
1963}
1964\f
1965/* If we have not yet seen a function for this psymtab, this is 0. If we
1966 have seen one, it is the offset in the line numbers of the line numbers
1967 for the psymtab. */
1968static unsigned int first_fun_line_offset;
1969
1970static struct partial_symtab *xcoff_start_psymtab
a14ed312
KB
1971 (struct objfile *, char *, int,
1972 struct partial_symbol **, struct partial_symbol **);
c906108c
SS
1973
1974/* Allocate and partially fill a partial symtab. It will be
1975 completely filled at the end of the symbol list.
1976
1977 SYMFILE_NAME is the name of the symbol-file we are reading from, and ADDR
1978 is the address relative to which its symbols are (incremental) or 0
581e13c1 1979 (normal). */
c906108c
SS
1980
1981static struct partial_symtab *
fba45db2
KB
1982xcoff_start_psymtab (struct objfile *objfile, char *filename, int first_symnum,
1983 struct partial_symbol **global_syms,
1984 struct partial_symbol **static_syms)
c906108c
SS
1985{
1986 struct partial_symtab *result =
a109c7c1
MS
1987 start_psymtab_common (objfile, objfile->section_offsets,
1988 filename,
1989 /* We fill in textlow later. */
1990 0,
1991 global_syms, static_syms);
c906108c 1992
e38df1d0
TT
1993 result->read_symtab_private = obstack_alloc (&objfile->objfile_obstack,
1994 sizeof (struct symloc));
c5aa993b 1995 ((struct symloc *) result->read_symtab_private)->first_symnum = first_symnum;
c906108c
SS
1996 result->read_symtab = xcoff_psymtab_to_symtab;
1997
581e13c1 1998 /* Deduce the source language from the filename for this psymtab. */
c906108c
SS
1999 psymtab_language = deduce_language_from_filename (filename);
2000
2001 return result;
2002}
2003
2004static struct partial_symtab *xcoff_end_psymtab
a14ed312
KB
2005 (struct partial_symtab *, char **, int, int,
2006 struct partial_symtab **, int, int);
c906108c 2007
581e13c1 2008/* Close off the current usage of PST.
c906108c
SS
2009 Returns PST, or NULL if the partial symtab was empty and thrown away.
2010
2011 CAPPING_SYMBOL_NUMBER is the end of pst (exclusive).
2012
2013 INCLUDE_LIST, NUM_INCLUDES, DEPENDENCY_LIST, and NUMBER_DEPENDENCIES
2014 are the information for includes and dependencies. */
2015
2016static struct partial_symtab *
fba45db2
KB
2017xcoff_end_psymtab (struct partial_symtab *pst, char **include_list,
2018 int num_includes, int capping_symbol_number,
2019 struct partial_symtab **dependency_list,
2020 int number_dependencies, int textlow_not_set)
c906108c
SS
2021{
2022 int i;
c5aa993b 2023 struct objfile *objfile = pst->objfile;
c906108c
SS
2024
2025 if (capping_symbol_number != -1)
c5aa993b 2026 ((struct symloc *) pst->read_symtab_private)->numsyms =
c906108c 2027 capping_symbol_number
c5aa993b
JM
2028 - ((struct symloc *) pst->read_symtab_private)->first_symnum;
2029 ((struct symloc *) pst->read_symtab_private)->lineno_off =
c906108c
SS
2030 first_fun_line_offset;
2031 first_fun_line_offset = 0;
3e43a32a
MS
2032 pst->n_global_syms = objfile->global_psymbols.next
2033 - (objfile->global_psymbols.list + pst->globals_offset);
2034 pst->n_static_syms = objfile->static_psymbols.next
2035 - (objfile->static_psymbols.list + pst->statics_offset);
c906108c
SS
2036
2037 pst->number_of_dependencies = number_dependencies;
2038 if (number_dependencies)
2039 {
2040 pst->dependencies = (struct partial_symtab **)
8b92e4d5 2041 obstack_alloc (&objfile->objfile_obstack,
c5aa993b 2042 number_dependencies * sizeof (struct partial_symtab *));
c906108c 2043 memcpy (pst->dependencies, dependency_list,
c5aa993b 2044 number_dependencies * sizeof (struct partial_symtab *));
c906108c
SS
2045 }
2046 else
2047 pst->dependencies = 0;
2048
2049 for (i = 0; i < num_includes; i++)
2050 {
2051 struct partial_symtab *subpst =
a109c7c1 2052 allocate_psymtab (include_list[i], objfile);
c906108c
SS
2053
2054 subpst->section_offsets = pst->section_offsets;
e38df1d0
TT
2055 subpst->read_symtab_private = obstack_alloc (&objfile->objfile_obstack,
2056 sizeof (struct symloc));
c5aa993b
JM
2057 ((struct symloc *) subpst->read_symtab_private)->first_symnum = 0;
2058 ((struct symloc *) subpst->read_symtab_private)->numsyms = 0;
c906108c
SS
2059 subpst->textlow = 0;
2060 subpst->texthigh = 0;
2061
2062 /* We could save slight bits of space by only making one of these,
c5aa993b 2063 shared by the entire set of include files. FIXME-someday. */
c906108c 2064 subpst->dependencies = (struct partial_symtab **)
8b92e4d5 2065 obstack_alloc (&objfile->objfile_obstack,
c906108c
SS
2066 sizeof (struct partial_symtab *));
2067 subpst->dependencies[0] = pst;
2068 subpst->number_of_dependencies = 1;
2069
2070 subpst->globals_offset =
2071 subpst->n_global_syms =
c5aa993b
JM
2072 subpst->statics_offset =
2073 subpst->n_static_syms = 0;
c906108c
SS
2074
2075 subpst->readin = 0;
2076 subpst->symtab = 0;
2077 subpst->read_symtab = pst->read_symtab;
2078 }
2079
2080 sort_pst_symbols (pst);
2081
c906108c
SS
2082 if (num_includes == 0
2083 && number_dependencies == 0
2084 && pst->n_global_syms == 0
2085 && pst->n_static_syms == 0)
2086 {
2087 /* Throw away this psymtab, it's empty. We can't deallocate it, since
c5aa993b 2088 it is on the obstack, but we can forget to chain it on the list. */
c906108c 2089 /* Empty psymtabs happen as a result of header files which don't have
c5aa993b 2090 any symbols in them. There can be a lot of them. */
c906108c
SS
2091
2092 discard_psymtab (pst);
2093
2094 /* Indicate that psymtab was thrown away. */
c5aa993b 2095 pst = (struct partial_symtab *) NULL;
c906108c
SS
2096 }
2097 return pst;
2098}
2099
a14ed312
KB
2100static void swap_sym (struct internal_syment *,
2101 union internal_auxent *, char **, char **,
2102 unsigned int *, struct objfile *);
c906108c
SS
2103
2104/* Swap raw symbol at *RAW and put the name in *NAME, the symbol in
2105 *SYMBOL, the first auxent in *AUX. Advance *RAW and *SYMNUMP over
2106 the symbol and its auxents. */
2107
2108static void
fba45db2
KB
2109swap_sym (struct internal_syment *symbol, union internal_auxent *aux,
2110 char **name, char **raw, unsigned int *symnump,
2111 struct objfile *objfile)
c906108c
SS
2112{
2113 bfd_coff_swap_sym_in (objfile->obfd, *raw, symbol);
2114 if (symbol->n_zeroes)
2115 {
2116 /* If it's exactly E_SYMNMLEN characters long it isn't
c5aa993b 2117 '\0'-terminated. */
c906108c
SS
2118 if (symbol->n_name[E_SYMNMLEN - 1] != '\0')
2119 {
2120 /* FIXME: wastes memory for symbols which we don't end up putting
2121 into the minimal symbols. */
2122 char *p;
a109c7c1 2123
8b92e4d5 2124 p = obstack_alloc (&objfile->objfile_obstack, E_SYMNMLEN + 1);
c906108c
SS
2125 strncpy (p, symbol->n_name, E_SYMNMLEN);
2126 p[E_SYMNMLEN] = '\0';
2127 *name = p;
2128 }
2129 else
2130 /* Point to the unswapped name as that persists as long as the
2131 objfile does. */
c5aa993b 2132 *name = ((struct external_syment *) *raw)->e.e_name;
c906108c
SS
2133 }
2134 else if (symbol->n_sclass & 0x80)
2135 {
3e43a32a
MS
2136 *name = ((struct coff_symfile_info *)
2137 objfile->deprecated_sym_private)->debugsec + symbol->n_offset;
c906108c
SS
2138 }
2139 else
2140 {
3e43a32a
MS
2141 *name = ((struct coff_symfile_info *)
2142 objfile->deprecated_sym_private)->strtbl + symbol->n_offset;
c906108c
SS
2143 }
2144 ++*symnump;
2145 *raw += coff_data (objfile->obfd)->local_symesz;
2146 if (symbol->n_numaux > 0)
2147 {
2148 bfd_coff_swap_aux_in (objfile->obfd, *raw, symbol->n_type,
2149 symbol->n_sclass, 0, symbol->n_numaux, aux);
2150
2151 *symnump += symbol->n_numaux;
2152 *raw += coff_data (objfile->obfd)->local_symesz * symbol->n_numaux;
2153 }
2154}
2155
23136709
KB
2156static void
2157function_outside_compilation_unit_complaint (const char *arg1)
2158{
2159 complaint (&symfile_complaints,
3e43a32a
MS
2160 _("function `%s' appears to be defined "
2161 "outside of all compilation units"),
23136709
KB
2162 arg1);
2163}
2164
c906108c 2165static void
fba45db2 2166scan_xcoff_symtab (struct objfile *objfile)
c906108c 2167{
40c58d95 2168 struct gdbarch *gdbarch = get_objfile_arch (objfile);
581e13c1 2169 CORE_ADDR toc_offset = 0; /* toc offset value in data section. */
c906108c
SS
2170 char *filestring = NULL;
2171
2172 char *namestring;
2173 int past_first_source_file = 0;
2174 bfd *abfd;
2175 asection *bfd_sect;
2176 unsigned int nsyms;
2177
2178 /* Current partial symtab */
2179 struct partial_symtab *pst;
2180
581e13c1 2181 /* List of current psymtab's include files. */
c906108c
SS
2182 char **psymtab_include_list;
2183 int includes_allocated;
2184 int includes_used;
2185
581e13c1 2186 /* Index within current psymtab dependency list. */
c906108c
SS
2187 struct partial_symtab **dependency_list;
2188 int dependencies_used, dependencies_allocated;
2189
2190 char *sraw_symbol;
2191 struct internal_syment symbol;
96baa820 2192 union internal_auxent main_aux[5];
c906108c
SS
2193 unsigned int ssymnum;
2194
581e13c1 2195 char *last_csect_name = NULL; /* Last seen csect's name and value. */
c906108c
SS
2196 CORE_ADDR last_csect_val = 0;
2197 int last_csect_sec = 0;
581e13c1 2198 int misc_func_recorded = 0; /* true if any misc. function. */
c906108c
SS
2199 int textlow_not_set = 1;
2200
2201 pst = (struct partial_symtab *) 0;
2202
2203 includes_allocated = 30;
2204 includes_used = 0;
2205 psymtab_include_list = (char **) alloca (includes_allocated *
2206 sizeof (char *));
2207
2208 dependencies_allocated = 30;
2209 dependencies_used = 0;
2210 dependency_list =
2211 (struct partial_symtab **) alloca (dependencies_allocated *
2212 sizeof (struct partial_symtab *));
2213
2214 last_source_file = NULL;
2215
2216 abfd = objfile->obfd;
13c763f4 2217 next_symbol_text_func = xcoff_next_symbol_text;
c906108c 2218
3e43a32a
MS
2219 sraw_symbol = ((struct coff_symfile_info *)
2220 objfile->deprecated_sym_private)->symtbl;
2221 nsyms = ((struct coff_symfile_info *)
2222 objfile->deprecated_sym_private)->symtbl_num_syms;
c906108c
SS
2223 ssymnum = 0;
2224 while (ssymnum < nsyms)
2225 {
7a78ae4e 2226 int sclass;
c906108c
SS
2227
2228 QUIT;
2229
7a78ae4e
ND
2230 bfd_coff_swap_sym_in (abfd, sraw_symbol, &symbol);
2231 sclass = symbol.n_sclass;
2232
c906108c
SS
2233 switch (sclass)
2234 {
2235 case C_EXT:
2236 case C_HIDEXT:
2237 {
2238 /* The CSECT auxent--always the last auxent. */
2239 union internal_auxent csect_aux;
2240 unsigned int symnum_before = ssymnum;
2241
96baa820 2242 swap_sym (&symbol, &main_aux[0], &namestring, &sraw_symbol,
c906108c
SS
2243 &ssymnum, objfile);
2244 if (symbol.n_numaux > 1)
2245 {
2246 bfd_coff_swap_aux_in
2247 (objfile->obfd,
c5aa993b 2248 sraw_symbol - coff_data (abfd)->local_symesz,
c906108c
SS
2249 symbol.n_type,
2250 symbol.n_sclass,
2251 symbol.n_numaux - 1,
2252 symbol.n_numaux,
2253 &csect_aux);
2254 }
2255 else
96baa820 2256 csect_aux = main_aux[0];
c906108c 2257
977adac5
ND
2258 /* If symbol name starts with ".$" or "$", ignore it. */
2259 if (namestring[0] == '$'
c906108c
SS
2260 || (namestring[0] == '.' && namestring[1] == '$'))
2261 break;
2262
2263 switch (csect_aux.x_csect.x_smtyp & 0x7)
2264 {
2265 case XTY_SD:
2266 switch (csect_aux.x_csect.x_smclas)
2267 {
2268 case XMC_PR:
2269 if (last_csect_name)
2270 {
2271 /* If no misc. function recorded in the last
581e13c1 2272 seen csect, enter it as a function. This
c906108c
SS
2273 will take care of functions like strcmp()
2274 compiled by xlc. */
2275
2276 if (!misc_func_recorded)
2277 {
2278 RECORD_MINIMAL_SYMBOL
2279 (last_csect_name, last_csect_val,
2280 mst_text, last_csect_sec,
2281 objfile);
2282 }
2283
2284 if (pst != NULL)
2285 {
2286 /* We have to allocate one psymtab for
2287 each program csect, because their text
2288 sections need not be adjacent. */
2289 xcoff_end_psymtab
2290 (pst, psymtab_include_list, includes_used,
2291 symnum_before, dependency_list,
2292 dependencies_used, textlow_not_set);
2293 includes_used = 0;
2294 dependencies_used = 0;
2295 /* Give all psymtabs for this source file the same
2296 name. */
2297 pst = xcoff_start_psymtab
d4f3574e 2298 (objfile,
c906108c
SS
2299 filestring,
2300 symnum_before,
2301 objfile->global_psymbols.next,
2302 objfile->static_psymbols.next);
2303 }
2304 }
977adac5
ND
2305 /* Activate the misc_func_recorded mechanism for
2306 compiler- and linker-generated CSECTs like ".strcmp"
2307 and "@FIX1". */
2308 if (namestring && (namestring[0] == '.'
2309 || namestring[0] == '@'))
c906108c
SS
2310 {
2311 last_csect_name = namestring;
2312 last_csect_val = symbol.n_value;
2313 last_csect_sec =
2314 secnum_to_section (symbol.n_scnum, objfile);
2315 }
2316 if (pst != NULL)
2317 {
2318 CORE_ADDR highval =
a109c7c1
MS
2319 symbol.n_value + csect_aux.x_csect.x_scnlen.l;
2320
c906108c
SS
2321 if (highval > pst->texthigh)
2322 pst->texthigh = highval;
2323 if (pst->textlow == 0 || symbol.n_value < pst->textlow)
2324 pst->textlow = symbol.n_value;
2325 }
2326 misc_func_recorded = 0;
2327 break;
2328
2329 case XMC_RW:
6904b546 2330 case XMC_TD:
c906108c
SS
2331 /* Data variables are recorded in the minimal symbol
2332 table, except for section symbols. */
2333 if (*namestring != '.')
2334 prim_record_minimal_symbol_and_info
2335 (namestring, symbol.n_value,
2336 sclass == C_HIDEXT ? mst_file_data : mst_data,
b887350f 2337 secnum_to_section (symbol.n_scnum, objfile),
c906108c
SS
2338 NULL, objfile);
2339 break;
2340
2341 case XMC_TC0:
2342 if (toc_offset)
8a3fe4f8 2343 warning (_("More than one XMC_TC0 symbol found."));
c906108c
SS
2344 toc_offset = symbol.n_value;
2345
3e43a32a
MS
2346 /* Make TOC offset relative to start address of
2347 section. */
c906108c
SS
2348 bfd_sect = secnum_to_bfd_section (symbol.n_scnum, objfile);
2349 if (bfd_sect)
2350 toc_offset -= bfd_section_vma (objfile->obfd, bfd_sect);
2351 break;
2352
2353 case XMC_TC:
2354 /* These symbols tell us where the TOC entry for a
2355 variable is, not the variable itself. */
2356 break;
2357
2358 default:
2359 break;
2360 }
2361 break;
2362
2363 case XTY_LD:
2364 switch (csect_aux.x_csect.x_smclas)
2365 {
2366 case XMC_PR:
2367 /* A function entry point. */
2368
2369 if (first_fun_line_offset == 0 && symbol.n_numaux > 1)
2370 first_fun_line_offset =
96baa820 2371 main_aux[0].x_sym.x_fcnary.x_fcn.x_lnnoptr;
c906108c
SS
2372 RECORD_MINIMAL_SYMBOL
2373 (namestring, symbol.n_value,
2374 sclass == C_HIDEXT ? mst_file_text : mst_text,
2375 secnum_to_section (symbol.n_scnum, objfile),
2376 objfile);
2377 break;
2378
2379 case XMC_GL:
2380 /* shared library function trampoline code entry
581e13c1 2381 point. */
c906108c
SS
2382
2383 /* record trampoline code entries as
2384 mst_solib_trampoline symbol. When we lookup mst
2385 symbols, we will choose mst_text over
581e13c1 2386 mst_solib_trampoline. */
c906108c
SS
2387 RECORD_MINIMAL_SYMBOL
2388 (namestring, symbol.n_value,
2389 mst_solib_trampoline,
2390 secnum_to_section (symbol.n_scnum, objfile),
2391 objfile);
2392 break;
2393
2394 case XMC_DS:
2395 /* The symbols often have the same names as
2396 debug symbols for functions, and confuse
2397 lookup_symbol. */
2398 break;
2399
2400 default:
2401
2402 /* xlc puts each variable in a separate csect,
2403 so we get an XTY_SD for each variable. But
2404 gcc puts several variables in a csect, so
2405 that each variable only gets an XTY_LD. We
2406 still need to record them. This will
2407 typically be XMC_RW; I suspect XMC_RO and
2408 XMC_BS might be possible too. */
2409 if (*namestring != '.')
2410 prim_record_minimal_symbol_and_info
2411 (namestring, symbol.n_value,
2412 sclass == C_HIDEXT ? mst_file_data : mst_data,
b887350f 2413 secnum_to_section (symbol.n_scnum, objfile),
c906108c
SS
2414 NULL, objfile);
2415 break;
2416 }
2417 break;
2418
2419 case XTY_CM:
2420 switch (csect_aux.x_csect.x_smclas)
2421 {
2422 case XMC_RW:
2423 case XMC_BS:
2424 /* Common variables are recorded in the minimal symbol
2425 table, except for section symbols. */
2426 if (*namestring != '.')
2427 prim_record_minimal_symbol_and_info
2428 (namestring, symbol.n_value,
2429 sclass == C_HIDEXT ? mst_file_bss : mst_bss,
b887350f 2430 secnum_to_section (symbol.n_scnum, objfile),
c906108c
SS
2431 NULL, objfile);
2432 break;
2433 }
2434 break;
2435
2436 default:
2437 break;
2438 }
2439 }
2440 break;
2441 case C_FILE:
2442 {
2443 unsigned int symnum_before;
2444
2445 symnum_before = ssymnum;
96baa820 2446 swap_sym (&symbol, &main_aux[0], &namestring, &sraw_symbol,
c906108c
SS
2447 &ssymnum, objfile);
2448
2449 /* See if the last csect needs to be recorded. */
2450
2451 if (last_csect_name && !misc_func_recorded)
2452 {
c906108c
SS
2453 /* If no misc. function recorded in the last seen csect, enter
2454 it as a function. This will take care of functions like
2455 strcmp() compiled by xlc. */
2456
2457 RECORD_MINIMAL_SYMBOL
2458 (last_csect_name, last_csect_val,
2459 mst_text, last_csect_sec, objfile);
2460 }
2461
2462 if (pst)
2463 {
2464 xcoff_end_psymtab (pst, psymtab_include_list, includes_used,
2465 symnum_before, dependency_list,
2466 dependencies_used, textlow_not_set);
2467 includes_used = 0;
2468 dependencies_used = 0;
2469 }
2470 first_fun_line_offset = 0;
2471
2472 /* XCOFF, according to the AIX 3.2 documentation, puts the
2473 filename in cs->c_name. But xlc 1.3.0.2 has decided to
2474 do things the standard COFF way and put it in the auxent.
2475 We use the auxent if the symbol is ".file" and an auxent
2476 exists, otherwise use the symbol itself. */
2477 if (!strcmp (namestring, ".file") && symbol.n_numaux > 0)
2478 {
96baa820 2479 filestring = coff_getfilename (&main_aux[0], objfile);
c906108c
SS
2480 }
2481 else
2482 filestring = namestring;
2483
d4f3574e 2484 pst = xcoff_start_psymtab (objfile,
c906108c
SS
2485 filestring,
2486 symnum_before,
2487 objfile->global_psymbols.next,
2488 objfile->static_psymbols.next);
2489 last_csect_name = NULL;
2490 }
2491 break;
2492
2493 default:
2494 {
23136709 2495 complaint (&symfile_complaints,
3e43a32a
MS
2496 _("Storage class %d not recognized during scan"),
2497 sclass);
c906108c
SS
2498 }
2499 /* FALLTHROUGH */
2500
2501 /* C_FCN is .bf and .ef symbols. I think it is sufficient
2502 to handle only the C_FUN and C_EXT. */
2503 case C_FCN:
2504
2505 case C_BSTAT:
2506 case C_ESTAT:
2507 case C_ARG:
2508 case C_REGPARM:
2509 case C_REG:
2510 case C_TPDEF:
2511 case C_STRTAG:
2512 case C_UNTAG:
2513 case C_ENTAG:
2514 case C_LABEL:
2515 case C_NULL:
2516
2517 /* C_EINCL means we are switching back to the main file. But there
2518 is no reason to care; the only thing we want to know about
2519 includes is the names of all the included (.h) files. */
2520 case C_EINCL:
2521
2522 case C_BLOCK:
2523
2524 /* I don't think C_STAT is used in xcoff; C_HIDEXT appears to be
2525 used instead. */
2526 case C_STAT:
2527
2528 /* I don't think the name of the common block (as opposed to the
2529 variables within it) is something which is user visible
2530 currently. */
2531 case C_BCOMM:
2532 case C_ECOMM:
2533
2534 case C_PSYM:
2535 case C_RPSYM:
2536
2537 /* I think we can ignore C_LSYM; types on xcoff seem to use C_DECL
2538 so C_LSYM would appear to be only for locals. */
2539 case C_LSYM:
2540
2541 case C_AUTO:
2542 case C_RSYM:
2543 {
2544 /* We probably could save a few instructions by assuming that
2545 C_LSYM, C_PSYM, etc., never have auxents. */
7a78ae4e 2546 int naux1 = symbol.n_numaux + 1;
a109c7c1 2547
c906108c 2548 ssymnum += naux1;
7a78ae4e 2549 sraw_symbol += bfd_coff_symesz (abfd) * naux1;
c906108c
SS
2550 }
2551 break;
2552
2553 case C_BINCL:
d5d0a62f 2554 {
581e13c1 2555 /* Mark down an include file in the current psymtab. */
d5d0a62f 2556 enum language tmp_language;
a109c7c1 2557
d5d0a62f
EZ
2558 swap_sym (&symbol, &main_aux[0], &namestring, &sraw_symbol,
2559 &ssymnum, objfile);
2560
2561 tmp_language = deduce_language_from_filename (namestring);
2562
2563 /* Only change the psymtab's language if we've learned
2564 something useful (eg. tmp_language is not language_unknown).
2565 In addition, to match what start_subfile does, never change
2566 from C++ to C. */
2567 if (tmp_language != language_unknown
2568 && (tmp_language != language_c
2569 || psymtab_language != language_cplus))
2570 psymtab_language = tmp_language;
2571
2572 /* In C++, one may expect the same filename to come round many
2573 times, when code is coming alternately from the main file
581e13c1 2574 and from inline functions in other files. So I check to see
d5d0a62f
EZ
2575 if this is a file we've seen before -- either the main
2576 source file, or a previously included file.
2577
2578 This seems to be a lot of time to be spending on N_SOL, but
2579 things like "break c-exp.y:435" need to work (I
2580 suppose the psymtab_include_list could be hashed or put
2581 in a binary tree, if profiling shows this is a major hog). */
7ecb6532 2582 if (pst && strcmp (namestring, pst->filename) == 0)
d5d0a62f 2583 continue;
a109c7c1 2584
d5d0a62f 2585 {
aa1ee363 2586 int i;
a109c7c1 2587
d5d0a62f 2588 for (i = 0; i < includes_used; i++)
7ecb6532 2589 if (strcmp (namestring, psymtab_include_list[i]) == 0)
d5d0a62f
EZ
2590 {
2591 i = -1;
2592 break;
2593 }
2594 if (i == -1)
2595 continue;
2596 }
2597 psymtab_include_list[includes_used++] = namestring;
2598 if (includes_used >= includes_allocated)
2599 {
2600 char **orig = psymtab_include_list;
c906108c 2601
d5d0a62f
EZ
2602 psymtab_include_list = (char **)
2603 alloca ((includes_allocated *= 2) *
2604 sizeof (char *));
4efb68b1 2605 memcpy (psymtab_include_list, orig,
d5d0a62f
EZ
2606 includes_used * sizeof (char *));
2607 }
2608 continue;
2609 }
c906108c
SS
2610 case C_FUN:
2611 /* The value of the C_FUN is not the address of the function (it
2612 appears to be the address before linking), but as long as it
2613 is smaller than the actual address, then find_pc_partial_function
2614 will use the minimal symbols instead. I hope. */
2615
2616 case C_GSYM:
2617 case C_ECOML:
2618 case C_DECL:
2619 case C_STSYM:
d5d0a62f 2620 {
d5d0a62f 2621 char *p;
a109c7c1 2622
d5d0a62f
EZ
2623 swap_sym (&symbol, &main_aux[0], &namestring, &sraw_symbol,
2624 &ssymnum, objfile);
2625
ed4b0e6a 2626 p = strchr (namestring, ':');
d5d0a62f
EZ
2627 if (!p)
2628 continue; /* Not a debugging symbol. */
2629
2630 /* Main processing section for debugging symbols which
2631 the initial read through the symbol tables needs to worry
2632 about. If we reach this point, the symbol which we are
2633 considering is definitely one we are interested in.
2634 p must also contain the (valid) index into the namestring
2635 which indicates the debugging type symbol. */
2636
2637 switch (p[1])
2638 {
2639 case 'S':
3e43a32a
MS
2640 symbol.n_value += ANOFFSET (objfile->section_offsets,
2641 SECT_OFF_DATA (objfile));
149ad273 2642
5e2b427d 2643 if (gdbarch_static_transform_name_p (gdbarch))
149ad273 2644 namestring = gdbarch_static_transform_name
5e2b427d 2645 (gdbarch, namestring);
149ad273 2646
04a679b8 2647 add_psymbol_to_list (namestring, p - namestring, 1,
176620f1 2648 VAR_DOMAIN, LOC_STATIC,
d5d0a62f
EZ
2649 &objfile->static_psymbols,
2650 0, symbol.n_value,
2651 psymtab_language, objfile);
2652 continue;
2653
2654 case 'G':
3e43a32a
MS
2655 symbol.n_value += ANOFFSET (objfile->section_offsets,
2656 SECT_OFF_DATA (objfile));
d5d0a62f 2657 /* The addresses in these entries are reported to be
581e13c1 2658 wrong. See the code that reads 'G's for symtabs. */
04a679b8 2659 add_psymbol_to_list (namestring, p - namestring, 1,
176620f1 2660 VAR_DOMAIN, LOC_STATIC,
d5d0a62f
EZ
2661 &objfile->global_psymbols,
2662 0, symbol.n_value,
2663 psymtab_language, objfile);
2664 continue;
2665
2666 case 'T':
2667 /* When a 'T' entry is defining an anonymous enum, it
2668 may have a name which is the empty string, or a
2669 single space. Since they're not really defining a
2670 symbol, those shouldn't go in the partial symbol
2671 table. We do pick up the elements of such enums at
2672 'check_enum:', below. */
2673 if (p >= namestring + 2
2674 || (p == namestring + 1
2675 && namestring[0] != ' '))
2676 {
04a679b8 2677 add_psymbol_to_list (namestring, p - namestring, 1,
176620f1 2678 STRUCT_DOMAIN, LOC_TYPEDEF,
d5d0a62f
EZ
2679 &objfile->static_psymbols,
2680 symbol.n_value, 0,
2681 psymtab_language, objfile);
2682 if (p[2] == 't')
2683 {
2684 /* Also a typedef with the same name. */
04a679b8 2685 add_psymbol_to_list (namestring, p - namestring, 1,
176620f1 2686 VAR_DOMAIN, LOC_TYPEDEF,
d5d0a62f
EZ
2687 &objfile->static_psymbols,
2688 symbol.n_value, 0,
2689 psymtab_language, objfile);
2690 p += 1;
2691 }
d5d0a62f
EZ
2692 }
2693 goto check_enum;
2694
2695 case 't':
581e13c1 2696 if (p != namestring) /* a name is there, not just :T... */
d5d0a62f 2697 {
04a679b8 2698 add_psymbol_to_list (namestring, p - namestring, 1,
176620f1 2699 VAR_DOMAIN, LOC_TYPEDEF,
d5d0a62f
EZ
2700 &objfile->static_psymbols,
2701 symbol.n_value, 0,
2702 psymtab_language, objfile);
2703 }
2704 check_enum:
2705 /* If this is an enumerated type, we need to
2706 add all the enum constants to the partial symbol
2707 table. This does not cover enums without names, e.g.
2708 "enum {a, b} c;" in C, but fortunately those are
2709 rare. There is no way for GDB to find those from the
2710 enum type without spending too much time on it. Thus
2711 to solve this problem, the compiler needs to put out the
2712 enum in a nameless type. GCC2 does this. */
2713
2714 /* We are looking for something of the form
2715 <name> ":" ("t" | "T") [<number> "="] "e"
2716 {<constant> ":" <value> ","} ";". */
2717
2718 /* Skip over the colon and the 't' or 'T'. */
2719 p += 2;
2720 /* This type may be given a number. Also, numbers can come
2721 in pairs like (0,26). Skip over it. */
2722 while ((*p >= '0' && *p <= '9')
2723 || *p == '(' || *p == ',' || *p == ')'
2724 || *p == '=')
2725 p++;
2726
2727 if (*p++ == 'e')
2728 {
3e43a32a
MS
2729 /* The aix4 compiler emits extra crud before the
2730 members. */
d5d0a62f
EZ
2731 if (*p == '-')
2732 {
2733 /* Skip over the type (?). */
2734 while (*p != ':')
2735 p++;
2736
2737 /* Skip over the colon. */
2738 p++;
2739 }
2740
2741 /* We have found an enumerated type. */
2742 /* According to comments in read_enum_type
2743 a comma could end it instead of a semicolon.
2744 I don't know where that happens.
2745 Accept either. */
2746 while (*p && *p != ';' && *p != ',')
2747 {
2748 char *q;
2749
2750 /* Check for and handle cretinous dbx symbol name
2751 continuation! */
2752 if (*p == '\\' || (*p == '?' && p[1] == '\0'))
2753 p = next_symbol_text (objfile);
2754
2755 /* Point to the character after the name
2756 of the enum constant. */
2757 for (q = p; *q && *q != ':'; q++)
2758 ;
2759 /* Note that the value doesn't matter for
2760 enum constants in psymtabs, just in symtabs. */
04a679b8 2761 add_psymbol_to_list (p, q - p, 1,
176620f1 2762 VAR_DOMAIN, LOC_CONST,
d5d0a62f
EZ
2763 &objfile->static_psymbols, 0,
2764 0, psymtab_language, objfile);
2765 /* Point past the name. */
2766 p = q;
2767 /* Skip over the value. */
2768 while (*p && *p != ',')
2769 p++;
2770 /* Advance past the comma. */
2771 if (*p)
2772 p++;
2773 }
2774 }
2775 continue;
2776
2777 case 'c':
2778 /* Constant, e.g. from "const" in Pascal. */
04a679b8 2779 add_psymbol_to_list (namestring, p - namestring, 1,
176620f1 2780 VAR_DOMAIN, LOC_CONST,
d5d0a62f
EZ
2781 &objfile->static_psymbols, symbol.n_value,
2782 0, psymtab_language, objfile);
2783 continue;
2784
2785 case 'f':
2786 if (! pst)
2787 {
2788 int name_len = p - namestring;
2789 char *name = xmalloc (name_len + 1);
a109c7c1 2790
d5d0a62f
EZ
2791 memcpy (name, namestring, name_len);
2792 name[name_len] = '\0';
23136709 2793 function_outside_compilation_unit_complaint (name);
d5d0a62f
EZ
2794 xfree (name);
2795 }
3e43a32a
MS
2796 symbol.n_value += ANOFFSET (objfile->section_offsets,
2797 SECT_OFF_TEXT (objfile));
04a679b8 2798 add_psymbol_to_list (namestring, p - namestring, 1,
176620f1 2799 VAR_DOMAIN, LOC_BLOCK,
d5d0a62f
EZ
2800 &objfile->static_psymbols,
2801 0, symbol.n_value,
2802 psymtab_language, objfile);
2803 continue;
2804
2805 /* Global functions were ignored here, but now they
2806 are put into the global psymtab like one would expect.
2807 They're also in the minimal symbol table. */
2808 case 'F':
2809 if (! pst)
2810 {
2811 int name_len = p - namestring;
2812 char *name = xmalloc (name_len + 1);
a109c7c1 2813
d5d0a62f
EZ
2814 memcpy (name, namestring, name_len);
2815 name[name_len] = '\0';
23136709 2816 function_outside_compilation_unit_complaint (name);
d5d0a62f
EZ
2817 xfree (name);
2818 }
9f1d5432
PH
2819
2820 /* We need only the minimal symbols for these
581e13c1 2821 loader-generated definitions. Keeping the global
9f1d5432 2822 symbols leads to "in psymbols but not in symbols"
581e13c1 2823 errors. */
9f1d5432
PH
2824 if (strncmp (namestring, "@FIX", 4) == 0)
2825 continue;
2826
3e43a32a
MS
2827 symbol.n_value += ANOFFSET (objfile->section_offsets,
2828 SECT_OFF_TEXT (objfile));
04a679b8 2829 add_psymbol_to_list (namestring, p - namestring, 1,
176620f1 2830 VAR_DOMAIN, LOC_BLOCK,
d5d0a62f
EZ
2831 &objfile->global_psymbols,
2832 0, symbol.n_value,
2833 psymtab_language, objfile);
2834 continue;
2835
2836 /* Two things show up here (hopefully); static symbols of
2837 local scope (static used inside braces) or extensions
2838 of structure symbols. We can ignore both. */
2839 case 'V':
2840 case '(':
2841 case '0':
2842 case '1':
2843 case '2':
2844 case '3':
2845 case '4':
2846 case '5':
2847 case '6':
2848 case '7':
2849 case '8':
2850 case '9':
2851 case '-':
3e43a32a
MS
2852 case '#': /* For symbol identification (used in
2853 live ranges). */
d5d0a62f
EZ
2854 continue;
2855
2856 case ':':
2857 /* It is a C++ nested symbol. We don't need to record it
2858 (I don't think); if we try to look up foo::bar::baz,
2859 then symbols for the symtab containing foo should get
2860 read in, I think. */
2861 /* Someone says sun cc puts out symbols like
2862 /foo/baz/maclib::/usr/local/bin/maclib,
2863 which would get here with a symbol type of ':'. */
2864 continue;
2865
2866 default:
3e43a32a
MS
2867 /* Unexpected symbol descriptor. The second and
2868 subsequent stabs of a continued stab can show up
2869 here. The question is whether they ever can mimic
2870 a normal stab--it would be nice if not, since we
2871 certainly don't want to spend the time searching to
2872 the end of every string looking for a
2873 backslash. */
d5d0a62f 2874
23136709 2875 complaint (&symfile_complaints,
e2e0b3e5 2876 _("unknown symbol descriptor `%c'"), p[1]);
d5d0a62f
EZ
2877
2878 /* Ignore it; perhaps it is an extension that we don't
2879 know about. */
2880 continue;
2881 }
2882 }
c906108c
SS
2883 }
2884 }
2885
2886 if (pst)
2887 {
2888 xcoff_end_psymtab (pst, psymtab_include_list, includes_used,
2889 ssymnum, dependency_list,
2890 dependencies_used, textlow_not_set);
2891 }
2892
581e13c1
MS
2893 /* Record the toc offset value of this symbol table into objfile
2894 structure. If no XMC_TC0 is found, toc_offset should be zero.
2895 Another place to obtain this information would be file auxiliary
2896 header. */
c906108c 2897
3e43a32a
MS
2898 ((struct coff_symfile_info *) objfile->deprecated_sym_private)->toc_offset
2899 = toc_offset;
c906108c
SS
2900}
2901
2902/* Return the toc offset value for a given objfile. */
2903
2904CORE_ADDR
63807e1d 2905xcoff_get_toc_offset (struct objfile *objfile)
c906108c
SS
2906{
2907 if (objfile)
3e43a32a
MS
2908 return ((struct coff_symfile_info *)
2909 objfile->deprecated_sym_private)->toc_offset;
c906108c
SS
2910 return 0;
2911}
2912
2913/* Scan and build partial symbols for a symbol file.
2914 We have been initialized by a call to dbx_symfile_init, which
2915 put all the relevant info into a "struct dbx_symfile_info",
2916 hung off the objfile structure.
2917
2918 SECTION_OFFSETS contains offsets relative to which the symbols in the
581e13c1
MS
2919 various sections are (depending where the sections were actually
2920 loaded). */
c906108c
SS
2921
2922static void
f4352531 2923xcoff_initial_scan (struct objfile *objfile, int symfile_flags)
c906108c
SS
2924{
2925 bfd *abfd;
2926 int val;
2927 struct cleanup *back_to;
c5aa993b
JM
2928 int num_symbols; /* # of symbols */
2929 file_ptr symtab_offset; /* symbol table and */
2930 file_ptr stringtab_offset; /* string table file offsets */
c906108c
SS
2931 struct coff_symfile_info *info;
2932 char *name;
2933 unsigned int size;
2934
0a6ddd08 2935 info = (struct coff_symfile_info *) objfile->deprecated_sym_private;
c906108c
SS
2936 symfile_bfd = abfd = objfile->obfd;
2937 name = objfile->name;
2938
2939 num_symbols = bfd_get_symcount (abfd); /* # of symbols */
2940 symtab_offset = obj_sym_filepos (abfd); /* symbol table file offset */
2941 stringtab_offset = symtab_offset +
c5aa993b 2942 num_symbols * coff_data (abfd)->local_symesz;
c906108c
SS
2943
2944 info->min_lineno_offset = 0;
2945 info->max_lineno_offset = 0;
2946 bfd_map_over_sections (abfd, find_linenos, info);
2947
2948 if (num_symbols > 0)
2949 {
2950 /* Read the string table. */
2951 init_stringtab (abfd, stringtab_offset, objfile);
2952
2953 /* Read the .debug section, if present. */
2954 {
7be0c536 2955 struct bfd_section *secp;
c906108c
SS
2956 bfd_size_type length;
2957 char *debugsec = NULL;
2958
2959 secp = bfd_get_section_by_name (abfd, ".debug");
2960 if (secp)
2961 {
2962 length = bfd_section_size (abfd, secp);
2963 if (length)
2964 {
2965 debugsec =
4a146b47 2966 (char *) obstack_alloc (&objfile->objfile_obstack, length);
c906108c
SS
2967
2968 if (!bfd_get_section_contents (abfd, secp, debugsec,
2969 (file_ptr) 0, length))
2970 {
8a3fe4f8 2971 error (_("Error reading .debug section of `%s': %s"),
c906108c
SS
2972 name, bfd_errmsg (bfd_get_error ()));
2973 }
2974 }
2975 }
3e43a32a
MS
2976 ((struct coff_symfile_info *)
2977 objfile->deprecated_sym_private)->debugsec
2978 = debugsec;
c906108c
SS
2979 }
2980 }
2981
2982 /* Read the symbols. We keep them in core because we will want to
2983 access them randomly in read_symbol*. */
2984 val = bfd_seek (abfd, symtab_offset, SEEK_SET);
2985 if (val < 0)
8a3fe4f8 2986 error (_("Error reading symbols from %s: %s"),
c906108c
SS
2987 name, bfd_errmsg (bfd_get_error ()));
2988 size = coff_data (abfd)->local_symesz * num_symbols;
0a6ddd08 2989 ((struct coff_symfile_info *) objfile->deprecated_sym_private)->symtbl =
4a146b47 2990 obstack_alloc (&objfile->objfile_obstack, size);
3e43a32a
MS
2991 ((struct coff_symfile_info *)
2992 objfile->deprecated_sym_private)->symtbl_num_syms
2993 = num_symbols;
c906108c 2994
3e43a32a
MS
2995 val = bfd_bread (((struct coff_symfile_info *)
2996 objfile->deprecated_sym_private)->symtbl,
3a42e9d0 2997 size, abfd);
c906108c 2998 if (val != size)
e2e0b3e5 2999 perror_with_name (_("reading symbol table"));
c906108c 3000
581e13c1 3001 /* If we are reinitializing, or if we have never loaded syms yet, init. */
de1d8fb9 3002 if (objfile->global_psymbols.size == 0 && objfile->static_psymbols.size == 0)
c906108c
SS
3003 /* I'm not sure how how good num_symbols is; the rule of thumb in
3004 init_psymbol_list was developed for a.out. On the one hand,
3005 num_symbols includes auxents. On the other hand, it doesn't
3006 include N_SLINE. */
3007 init_psymbol_list (objfile, num_symbols);
3008
3009 free_pending_blocks ();
a0b3c4fd 3010 back_to = make_cleanup (really_free_pendings, 0);
c906108c
SS
3011
3012 init_minimal_symbol_collection ();
56e290f4 3013 make_cleanup_discard_minimal_symbols ();
c906108c
SS
3014
3015 /* Now that the symbol table data of the executable file are all in core,
3016 process them and define symbols accordingly. */
3017
d4f3574e 3018 scan_xcoff_symtab (objfile);
c906108c
SS
3019
3020 /* Install any minimal symbols that have been collected as the current
581e13c1 3021 minimal symbols for this objfile. */
c906108c
SS
3022
3023 install_minimal_symbols (objfile);
3024
3025 do_cleanups (back_to);
3026}
3027\f
d4f3574e 3028static void
3e43a32a
MS
3029xcoff_symfile_offsets (struct objfile *objfile,
3030 struct section_addr_info *addrs)
c906108c 3031{
b8fbeb18 3032 asection *sect = NULL;
c906108c
SS
3033 int i;
3034
a39a16c4 3035 objfile->num_sections = bfd_count_sections (objfile->obfd);
d4f3574e 3036 objfile->section_offsets = (struct section_offsets *)
8b92e4d5 3037 obstack_alloc (&objfile->objfile_obstack,
a39a16c4 3038 SIZEOF_N_SECTION_OFFSETS (objfile->num_sections));
c906108c 3039
581e13c1 3040 /* Initialize the section indexes for future use. */
b8fbeb18
EZ
3041 sect = bfd_get_section_by_name (objfile->obfd, ".text");
3042 if (sect)
3043 objfile->sect_index_text = sect->index;
3044
3045 sect = bfd_get_section_by_name (objfile->obfd, ".data");
3046 if (sect)
3047 objfile->sect_index_data = sect->index;
3048
3049 sect = bfd_get_section_by_name (objfile->obfd, ".bss");
3050 if (sect)
3051 objfile->sect_index_bss = sect->index;
3052
3053 sect = bfd_get_section_by_name (objfile->obfd, ".rodata");
3054 if (sect)
3055 objfile->sect_index_rodata = sect->index;
3056
c906108c 3057 for (i = 0; i < objfile->num_sections; ++i)
b8fbeb18
EZ
3058 {
3059 /* syms_from_objfile kindly subtracts from addr the
3060 bfd_section_vma of the .text section. This strikes me as
3061 wrong--whether the offset to be applied to symbol reading is
3062 relative to the start address of the section depends on the
3063 symbol format. In any event, this whole "addr" concept is
3064 pretty broken (it doesn't handle any section but .text
3065 sensibly), so just ignore the addr parameter and use 0.
3066 rs6000-nat.c will set the correct section offsets via
3067 objfile_relocate. */
f0a58b0b 3068 (objfile->section_offsets)->offsets[i] = 0;
b8fbeb18 3069 }
c906108c
SS
3070}
3071
3072/* Register our ability to parse symbols for xcoff BFD files. */
3073
00b5771c 3074static const struct sym_fns xcoff_sym_fns =
c906108c
SS
3075{
3076
7a78ae4e 3077 /* It is possible that coff and xcoff should be merged as
c906108c
SS
3078 they do have fundamental similarities (for example, the extra storage
3079 classes used for stabs could presumably be recognized in any COFF file).
3080 However, in addition to obvious things like all the csect hair, there are
3081 some subtler differences between xcoffread.c and coffread.c, notably
3082 the fact that coffread.c has no need to read in all the symbols, but
3083 xcoffread.c reads all the symbols and does in fact randomly access them
3084 (in C_BSTAT and line number processing). */
3085
7a78ae4e 3086 bfd_target_xcoff_flavour,
c906108c 3087
3e43a32a
MS
3088 xcoff_new_init, /* init anything gbl to entire symtab */
3089 xcoff_symfile_init, /* read initial info, setup for sym_read() */
3090 xcoff_initial_scan, /* read a symbol file into symtab */
b11896a5 3091 NULL, /* sym_read_psymbols */
3e43a32a
MS
3092 xcoff_symfile_finish, /* finished with file, cleanup */
3093 xcoff_symfile_offsets, /* xlate offsets ext->int form */
3094 default_symfile_segments, /* Get segment information from a file. */
3095 aix_process_linenos,
3096 default_symfile_relocate, /* Relocate a debug section. */
00b5771c 3097 &psym_functions
c906108c
SS
3098};
3099
63807e1d
PA
3100/* Provide a prototype to silence -Wmissing-prototypes. */
3101extern initialize_file_ftype _initialize_xcoffread;
3102
c906108c 3103void
fba45db2 3104_initialize_xcoffread (void)
c906108c 3105{
c5aa993b 3106 add_symtab_fns (&xcoff_sym_fns);
c906108c 3107}
This page took 1.356105 seconds and 4 git commands to generate.