GDB (xrefs)
Loading...
Searching...
No Matches
coffread.c
Go to the documentation of this file.
1/* Read coff symbol tables and convert to internal format, for GDB.
2 Copyright (C) 1987-2023 Free Software Foundation, Inc.
3 Contributed by David D. Johnson, Brown University (ddj@cs.brown.edu).
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20#include "defs.h"
21#include "symtab.h"
22#include "gdbtypes.h"
23#include "demangle.h"
24#include "breakpoint.h"
25
26#include "bfd.h"
27#include "gdbsupport/gdb_obstack.h"
28#include <ctype.h>
29
30#include "coff/internal.h"
31#include "libcoff.h"
32#include "objfiles.h"
33#include "buildsym-legacy.h"
34#include "stabsread.h"
35#include "complaints.h"
36#include "target.h"
37#include "block.h"
38#include "dictionary.h"
39#include "dwarf2/public.h"
40
41#include "coff-pe-read.h"
42
43#include "build-id.h"
44
45/* The objfile we are currently reading. */
46
48
50 {
51 file_ptr min_lineno_offset = 0; /* Where in file lowest line#s are. */
52 file_ptr max_lineno_offset = 0; /* 1+last byte of line#s in file. */
53
54 CORE_ADDR textaddr = 0; /* Addr of .text section. */
55 unsigned int textsize = 0; /* Size of .text section. */
56 std::vector<asection *> *stabsects; /* .stab sections. */
57 asection *stabstrsect = nullptr; /* Section pointer for .stab section. */
58 char *stabstrdata = nullptr;
59 };
60
61/* Key for COFF-associated data. */
62
64
65/* Translate an external name string into a user-visible name. */
66#define EXTERNAL_NAME(string, abfd) \
67 (*string != '\0' && *string == bfd_get_symbol_leading_char (abfd) \
68 ? string + 1 : string)
69
70/* To be an sdb debug type, type must have at least a basic or primary
71 derived type. Using this rather than checking against T_NULL is
72 said to prevent core dumps if we try to operate on Michael Bloom
73 dbx-in-coff file. */
74
75#define SDB_TYPE(type) (BTYPE(type) | (type & N_TMASK))
76
77/* Core address of start and end of text of current source file.
78 This comes from a ".text" symbol where x_nlinno > 0. */
79
81static CORE_ADDR current_source_end_addr;
82
83/* The addresses of the symbol table stream and number of symbols
84 of the object file we are reading (as copied into core). */
85
86static bfd *nlist_bfd_global;
88
89
90/* Pointers to scratch storage, used for reading raw symbols and
91 auxents. */
92
93static char *temp_sym;
94static char *temp_aux;
95
96/* Local variables that hold the shift and mask values for the
97 COFF file that we are currently reading. These come back to us
98 from BFD, and are referenced by their macro names, as well as
99 internally to the BTYPE, ISPTR, ISFCN, ISARY, ISTAG, and DECREF
100 macros from include/coff/internal.h . */
101
102static unsigned local_n_btmask;
103static unsigned local_n_btshft;
104static unsigned local_n_tmask;
105static unsigned local_n_tshift;
106
107#define N_BTMASK local_n_btmask
108#define N_BTSHFT local_n_btshft
109#define N_TMASK local_n_tmask
110#define N_TSHIFT local_n_tshift
111
112/* Local variables that hold the sizes in the file of various COFF
113 structures. (We only need to know this to read them from the file
114 -- BFD will then translate the data in them, into `internal_xxx'
115 structs in the right byte order, alignment, etc.) */
116
117static unsigned local_linesz;
118static unsigned local_symesz;
119static unsigned local_auxesz;
120
121/* This is set if this is a PE format file. */
122
123static int pe_file;
124
125/* Chain of typedefs of pointers to empty struct/union types.
126 They are chained thru the SYMBOL_VALUE_CHAIN. */
127
129
130/* Simplified internal version of coff symbol table information. */
131
133 {
134 char *c_name;
135 int c_symnum; /* Symbol number of this entry. */
136 int c_naux; /* 0 if syment only, 1 if syment +
137 auxent, etc. */
138 CORE_ADDR c_value;
141 unsigned int c_type;
142 };
143
144/* Vector of types defined so far, indexed by their type numbers. */
145
146static struct type **type_vector;
147
148/* Number of elements allocated for type_vector currently. */
149
151
152/* Initial size of type vector. Is realloc'd larger if needed, and
153 realloc'd down to the size actually used, when completed. */
154
155#define INITIAL_TYPE_VECTOR_LENGTH 160
156
157static char *linetab = NULL;
158static file_ptr linetab_offset;
159static file_ptr linetab_size;
160
161static char *stringtab = NULL;
162static long stringtab_length = 0;
163
164extern void stabsread_clear_cache (void);
165
166static struct type *coff_read_struct_type (int, int, int,
167 struct objfile *);
168
169static struct type *decode_base_type (struct coff_symbol *,
170 unsigned int,
171 union internal_auxent *,
172 struct objfile *);
173
174static struct type *decode_type (struct coff_symbol *, unsigned int,
175 union internal_auxent *,
176 struct objfile *);
177
178static struct type *decode_function_type (struct coff_symbol *,
179 unsigned int,
180 union internal_auxent *,
181 struct objfile *);
182
183static struct type *coff_read_enum_type (int, int, int,
184 struct objfile *);
185
186static struct symbol *process_coff_symbol (struct coff_symbol *,
187 union internal_auxent *,
188 struct objfile *);
189
190static void patch_opaque_types (struct symtab *);
191
192static void enter_linenos (file_ptr, int, int, struct objfile *);
193
194static int init_lineno (bfd *, file_ptr, file_ptr, gdb::unique_xmalloc_ptr<char> *);
195
196static char *getsymname (struct internal_syment *);
197
198static const char *coff_getfilename (union internal_auxent *);
199
200static int init_stringtab (bfd *, file_ptr, gdb::unique_xmalloc_ptr<char> *);
201
202static void read_one_sym (struct coff_symbol *,
203 struct internal_syment *,
204 union internal_auxent *);
205
207 file_ptr, unsigned int, struct objfile *);
208
209/* We are called once per section from coff_symfile_read. We
210 need to examine each section we are passed, check to see
211 if it is something we are interested in processing, and
212 if so, stash away some access information for the section.
213
214 FIXME: The section names should not be hardwired strings (what
215 should they be? I don't think most object file formats have enough
216 section flags to specify what kind of debug section it is
217 -kingdon). */
218
219static void
220coff_locate_sections (bfd *abfd, asection *sectp, void *csip)
221{
222 struct coff_symfile_info *csi;
223 const char *name;
224
225 csi = (struct coff_symfile_info *) csip;
226 name = bfd_section_name (sectp);
227 if (strcmp (name, ".text") == 0)
228 {
229 csi->textaddr = bfd_section_vma (sectp);
230 csi->textsize += bfd_section_size (sectp);
231 }
232 else if (startswith (name, ".text"))
233 {
234 csi->textsize += bfd_section_size (sectp);
235 }
236 else if (strcmp (name, ".stabstr") == 0)
237 {
238 csi->stabstrsect = sectp;
239 }
240 else if (startswith (name, ".stab"))
241 {
242 const char *s;
243
244 /* We can have multiple .stab sections if linked with
245 --split-by-reloc. */
246 for (s = name + sizeof ".stab" - 1; *s != '\0'; s++)
247 if (!isdigit (*s))
248 break;
249 if (*s == '\0')
250 csi->stabsects->push_back (sectp);
251 }
252}
253
254/* Return the section_offsets* that CS points to. */
255static int cs_to_section (struct coff_symbol *, struct objfile *);
256
258 {
260 asection **resultp;
261 };
262
263static void
264find_targ_sec (bfd *abfd, asection *sect, void *obj)
265{
266 struct coff_find_targ_sec_arg *args = (struct coff_find_targ_sec_arg *) obj;
267
268 if (sect->target_index == args->targ_index)
269 *args->resultp = sect;
270}
271
272/* Return the bfd_section that CS points to. */
273static struct bfd_section*
275{
276 asection *sect = NULL;
277 struct coff_find_targ_sec_arg args;
278
279 args.targ_index = cs->c_secnum;
280 args.resultp = &sect;
281 bfd_map_over_sections (objfile->obfd.get (), find_targ_sec, &args);
282 return sect;
283}
284
285/* Return the section number (SECT_OFF_*) that CS points to. */
286static int
288{
289 asection *sect = cs_to_bfd_section (cs, objfile);
290
291 if (sect == NULL)
292 return SECT_OFF_TEXT (objfile);
293 return gdb_bfd_section_index (objfile->obfd.get (), sect);
294}
295
296/* Return the address of the section of a COFF symbol. */
297
298static CORE_ADDR cs_section_address (struct coff_symbol *, bfd *);
299
300static CORE_ADDR
301cs_section_address (struct coff_symbol *cs, bfd *abfd)
302{
303 asection *sect = NULL;
304 struct coff_find_targ_sec_arg args;
305 CORE_ADDR addr = 0;
306
307 args.targ_index = cs->c_secnum;
308 args.resultp = &sect;
309 bfd_map_over_sections (abfd, find_targ_sec, &args);
310 if (sect != NULL)
311 addr = bfd_section_vma (sect);
312 return addr;
313}
314
315/* Look up a coff type-number index. Return the address of the slot
316 where the type for that index is stored.
317 The type-number is in INDEX.
318
319 This can be used for finding the type associated with that index
320 or for associating a new type with the index. */
321
322static struct type **
324{
325 if (index >= type_vector_length)
326 {
327 int old_vector_length = type_vector_length;
328
330 if (index /* is still */ >= type_vector_length)
331 type_vector_length = index * 2;
332
333 type_vector = (struct type **)
334 xrealloc ((char *) type_vector,
335 type_vector_length * sizeof (struct type *));
336 memset (&type_vector[old_vector_length], 0,
337 (type_vector_length - old_vector_length) * sizeof (struct type *));
338 }
339 return &type_vector[index];
340}
341
342/* Make sure there is a type allocated for type number index
343 and return the type object.
344 This can create an empty (zeroed) type object. */
345
346static struct type *
348{
349 struct type **type_addr = coff_lookup_type (index);
350 struct type *type = *type_addr;
351
352 /* If we are referring to a type not known at all yet,
353 allocate an empty type for it.
354 We will fill it in later if we find out how. */
355 if (type == NULL)
356 {
358 *type_addr = type;
359 }
360 return type;
361}
362
363/* Start a new symtab for a new source file.
364 This is called when a COFF ".file" symbol is seen;
365 it indicates the start of data for one original source file. */
366
367static void
369{
370 within_function = 0;
372 name,
373 /* We never know the directory name for COFF. */
374 NULL,
375 /* The start address is irrelevant, since we call
376 set_last_source_start_addr in coff_end_compunit_symtab. */
377 0,
378 /* Let buildsym.c deduce the language for this symtab. */
380 record_debugformat ("COFF");
381}
382
383/* Save the vital information from when starting to read a file,
384 for use when closing off the current file.
385 NAME is the file name the symbols came from, START_ADDR is the
386 first text address for the file, and SIZE is the number of bytes of
387 text. */
388
389static void
390complete_symtab (const char *name, CORE_ADDR start_addr, unsigned int size)
391{
393 current_source_start_addr = start_addr;
394 current_source_end_addr = start_addr + size;
395}
396
397/* Finish the symbol definitions for one main source file, close off
398 all the lexical contexts for that file (creating struct block's for
399 them), then make the struct symtab for that file and put it in the
400 list of all such. */
401
402static void
404{
406
408
409 /* Reinitialize for beginning of new file. */
411}
412
413/* The linker sometimes generates some non-function symbols inside
414 functions referencing variables imported from another DLL.
415 Return nonzero if the given symbol corresponds to one of them. */
416
417static int
420{
421 /* The following is a bit of a heuristic using the characteristics
422 of these fixup symbols, but should work well in practice... */
423 int i;
424
425 /* Must be a non-static text symbol. */
426 if (type != mst_text)
427 return 0;
428
429 /* Must be a non-function symbol. */
430 if (ISFCN (cs->c_type))
431 return 0;
432
433 /* The name must start with "__fu<digits>__". */
434 if (!startswith (cs->c_name, "__fu"))
435 return 0;
436 if (! isdigit (cs->c_name[4]))
437 return 0;
438 for (i = 5; cs->c_name[i] != '\0' && isdigit (cs->c_name[i]); i++)
439 /* Nothing, just incrementing index past all digits. */;
440 if (cs->c_name[i] != '_' || cs->c_name[i + 1] != '_')
441 return 0;
442
443 return 1;
444}
445
446static struct minimal_symbol *
448 struct coff_symbol *cs, unrelocated_addr address,
449 enum minimal_symbol_type type, int section,
450 struct objfile *objfile)
451{
452 /* We don't want TDESC entry points in the minimal symbol table. */
453 if (cs->c_name[0] == '@')
454 return NULL;
455
457 {
458 /* Because the value of these symbols is within a function code
459 range, these symbols interfere with the symbol-from-address
460 reverse lookup; this manifests itself in backtraces, or any
461 other commands that prints symbolic addresses. Just pretend
462 these symbols do not exist. */
463 return NULL;
464 }
465
466 return reader.record_full (cs->c_name, true, address, type, section);
467}
468
469/* coff_symfile_init ()
470 is the coff-specific initialization routine for reading symbols.
471 It is passed a struct objfile which contains, among other things,
472 the BFD for the file whose symbols are being read, and a slot for
473 a pointer to "private data" which we fill with cookies and other
474 treats for coff_symfile_read ().
475
476 We will only be called if this is a COFF or COFF-like file. BFD
477 handles figuring out the format of the file, and code in symtab.c
478 uses BFD's determination to vector to us.
479
480 The ultimate result is a new symtab (or, FIXME, eventually a
481 psymtab). */
482
483static void
485{
486 /* Allocate struct to keep track of the symfile. */
488}
489
490/* This function is called for every section; it finds the outer
491 limits of the line table (minimum and maximum file offset) so that
492 the mainline code can read the whole thing for efficiency. */
493
494static void
495find_linenos (bfd *abfd, struct bfd_section *asect, void *vpinfo)
496{
497 struct coff_symfile_info *info;
498 int size, count;
499 file_ptr offset, maxoff;
500
501 /* WARNING WILL ROBINSON! ACCESSING BFD-PRIVATE DATA HERE! FIXME! */
502 count = asect->lineno_count;
503 /* End of warning. */
504
505 if (count == 0)
506 return;
507 size = count * local_linesz;
508
509 info = (struct coff_symfile_info *) vpinfo;
510 /* WARNING WILL ROBINSON! ACCESSING BFD-PRIVATE DATA HERE! FIXME! */
511 offset = asect->line_filepos;
512 /* End of warning. */
513
514 if (offset < info->min_lineno_offset || info->min_lineno_offset == 0)
515 info->min_lineno_offset = offset;
516
517 maxoff = offset + size;
518 if (maxoff > info->max_lineno_offset)
519 info->max_lineno_offset = maxoff;
520}
521
522
523/* A helper function for coff_symfile_read that reads minimal
524 symbols. It may also read other forms of symbol as well. */
525
526static void
527coff_read_minsyms (file_ptr symtab_offset, unsigned int nsyms,
528 struct objfile *objfile)
529
530{
531 /* If minimal symbols were already read, and if we know we aren't
532 going to read any other kind of symbol here, then we can just
533 return. */
534 if (objfile->per_bfd->minsyms_read && pe_file && nsyms == 0)
535 return;
536
538
539 if (pe_file && nsyms == 0)
540 {
541 /* We've got no debugging symbols, but it's a portable
542 executable, so try to read the export table. */
544 }
545 else
546 {
547 /* Now that the executable file is positioned at symbol table,
548 process it and define symbols accordingly. */
549 coff_symtab_read (reader, symtab_offset, nsyms, objfile);
550 }
551
552 /* Install any minimal symbols that have been collected as the
553 current minimal symbols for this objfile. */
554
555 reader.install ();
556
557 if (pe_file)
558 {
559 for (minimal_symbol *msym : objfile->msymbols ())
560 {
561 const char *name = msym->linkage_name ();
562
563 /* If the minimal symbols whose name are prefixed by "__imp_"
564 or "_imp_", get rid of the prefix, and search the minimal
565 symbol in OBJFILE. Note that 'maintenance print msymbols'
566 shows that type of these "_imp_XXXX" symbols is mst_data. */
567 if (msym->type () == mst_data)
568 {
569 const char *name1 = NULL;
570
571 if (startswith (name, "_imp_"))
572 name1 = name + 5;
573 else if (startswith (name, "__imp_"))
574 name1 = name + 6;
575 if (name1 != NULL)
576 {
577 int lead
578 = bfd_get_symbol_leading_char (objfile->obfd.get ());
579 struct bound_minimal_symbol found;
580
581 if (lead != '\0' && *name1 == lead)
582 name1 += 1;
583
584 found = lookup_minimal_symbol (name1, NULL, objfile);
585
586 /* If found, there are symbols named "_imp_foo" and "foo"
587 respectively in OBJFILE. Set the type of symbol "foo"
588 as 'mst_solib_trampoline'. */
589 if (found.minsym != NULL
590 && found.minsym->type () == mst_text)
592 }
593 }
594 }
595 }
596}
597
598/* The BFD for this file -- only good while we're actively reading
599 symbols into a psymtab or a symtab. */
600
601static bfd *symfile_bfd;
602
603/* Read a symbol file, after initialization by coff_symfile_init. */
604
605static void
606coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
607{
608 struct coff_symfile_info *info;
609 bfd *abfd = objfile->obfd.get ();
610 coff_data_type *cdata = coff_data (abfd);
611 const char *filename = bfd_get_filename (abfd);
612 int val;
613 unsigned int num_symbols;
614 file_ptr symtab_offset;
615 file_ptr stringtab_offset;
616 unsigned int stabstrsize;
617
619 symfile_bfd = abfd; /* Kludge for swap routines. */
620
621 std::vector<asection *> stabsects;
622 scoped_restore restore_stabsects
623 = make_scoped_restore (&info->stabsects, &stabsects);
624
625/* WARNING WILL ROBINSON! ACCESSING BFD-PRIVATE DATA HERE! FIXME! */
626 num_symbols = bfd_get_symcount (abfd); /* How many syms */
627 symtab_offset = cdata->sym_filepos; /* Symbol table file offset */
628 stringtab_offset = symtab_offset + /* String table file offset */
629 num_symbols * cdata->local_symesz;
630
631 /* Set a few file-statics that give us specific information about
632 the particular COFF file format we're reading. */
633 local_n_btmask = cdata->local_n_btmask;
634 local_n_btshft = cdata->local_n_btshft;
635 local_n_tmask = cdata->local_n_tmask;
636 local_n_tshift = cdata->local_n_tshift;
637 local_linesz = cdata->local_linesz;
638 local_symesz = cdata->local_symesz;
639 local_auxesz = cdata->local_auxesz;
640
641 /* Allocate space for raw symbol and aux entries, based on their
642 space requirements as reported by BFD. */
643 gdb::def_vector<char> temp_storage (cdata->local_symesz
644 + cdata->local_auxesz);
645 temp_sym = temp_storage.data ();
646 temp_aux = temp_sym + cdata->local_symesz;
647
648 /* We need to know whether this is a PE file, because in PE files,
649 unlike standard COFF files, symbol values are stored as offsets
650 from the section address, rather than as absolute addresses.
651 FIXME: We should use BFD to read the symbol table, and thus avoid
652 this problem. */
653 pe_file =
654 startswith (bfd_get_target (objfile->obfd.get ()), "pe")
655 || startswith (bfd_get_target (objfile->obfd.get ()), "epoc-pe");
656
657 /* End of warning. */
658
659 info->min_lineno_offset = 0;
660 info->max_lineno_offset = 0;
661
662 /* Only read line number information if we have symbols.
663
664 On Windows NT, some of the system's DLL's have sections with
665 PointerToLinenumbers fields that are non-zero, but point at
666 random places within the image file. (In the case I found,
667 KERNEL32.DLL's .text section has a line number info pointer that
668 points into the middle of the string `lib\\i386\kernel32.dll'.)
669
670 However, these DLL's also have no symbols. The line number
671 tables are meaningless without symbols. And in fact, GDB never
672 uses the line number information unless there are symbols. So we
673 can avoid spurious error messages (and maybe run a little
674 faster!) by not even reading the line number table unless we have
675 symbols. */
676 scoped_restore restore_linetab = make_scoped_restore (&linetab);
677 gdb::unique_xmalloc_ptr<char> linetab_storage;
678 if (num_symbols > 0)
679 {
680 /* Read the line number table, all at once. */
681 bfd_map_over_sections (abfd, find_linenos, (void *) info);
682
683 val = init_lineno (abfd, info->min_lineno_offset,
684 info->max_lineno_offset - info->min_lineno_offset,
685 &linetab_storage);
686 if (val < 0)
687 error (_("\"%s\": error reading line numbers."), filename);
688 }
689
690 /* Now read the string table, all at once. */
691
692 scoped_restore restore_stringtab = make_scoped_restore (&stringtab);
693 gdb::unique_xmalloc_ptr<char> stringtab_storage;
694 val = init_stringtab (abfd, stringtab_offset, &stringtab_storage);
695 if (val < 0)
696 error (_("\"%s\": can't get string table"), filename);
697
698 coff_read_minsyms (symtab_offset, num_symbols, objfile);
699
700 if (!(objfile->flags & OBJF_READNEVER))
701 bfd_map_over_sections (abfd, coff_locate_sections, (void *) info);
702
703 if (!info->stabsects->empty())
704 {
705 if (!info->stabstrsect)
706 {
707 error (_("The debugging information in `%s' is corrupted.\nThe "
708 "file has a `.stabs' section, but no `.stabstr' section."),
709 filename);
710 }
711
712 /* FIXME: dubious. Why can't we use something normal like
713 bfd_get_section_contents? */
714 stabstrsize = bfd_section_size (info->stabstrsect);
715
717 info->textaddr, info->textsize,
718 *info->stabsects,
719 info->stabstrsect->filepos, stabstrsize);
720 }
721 if (dwarf2_has_info (objfile, NULL))
722 {
723 /* DWARF2 sections. */
725 }
726
727 /* Try to add separate debug file if no symbols table found. */
729 {
730 deferred_warnings warnings;
731 std::string debugfile
733
734 if (debugfile.empty ())
735 debugfile
737
738 if (!debugfile.empty ())
739 {
740 gdb_bfd_ref_ptr debug_bfd (symfile_bfd_open (debugfile.c_str ()));
741
742 symbol_file_add_separate (debug_bfd, debugfile.c_str (),
743 symfile_flags, objfile);
744 }
745 /* If all the methods to collect the debuginfo failed, print any
746 warnings that were collected, this is a no-op if there are no
747 warnings. */
748 if (debugfile.empty ())
749 warnings.emit ();
750 }
751}
752
753static void
754coff_new_init (struct objfile *ignore)
755{
756}
757
758/* Perform any local cleanups required when we are done with a
759 particular objfile. I.E, we are in the process of discarding all
760 symbol information for an objfile, freeing up all memory held for
761 it, and unlinking the objfile struct from the global list of known
762 objfiles. */
763
764static void
766{
767 /* Let stabs reader clean up. */
769}
770
771
772/* Given pointers to a symbol table in coff style exec file,
773 analyze them and create struct symtab's describing the symbols.
774 NSYMS is the number of symbols in the symbol table.
775 We read them one at a time using read_one_sym (). */
776
777static void
779 file_ptr symtab_offset, unsigned int nsyms,
780 struct objfile *objfile)
781{
782 struct gdbarch *gdbarch = objfile->arch ();
783 struct context_stack *newobj = nullptr;
785 struct coff_symbol *cs = &coff_symbol;
786 static struct internal_syment main_sym;
787 static union internal_auxent main_aux;
789 static struct internal_syment fcn_sym_saved;
790 static union internal_auxent fcn_aux_saved;
791 /* A .file is open. */
792 int in_source_file = 0;
793 int next_file_symnum = -1;
794 /* Name of the current file. */
795 const char *filestring = "";
796 int depth = 0;
797 int fcn_first_line = 0;
798 CORE_ADDR fcn_first_line_addr = 0;
799 int fcn_last_line = 0;
800 int fcn_start_addr = 0;
801 long fcn_line_ptr = 0;
802 int val;
803 CORE_ADDR tmpaddr;
804 struct minimal_symbol *msym;
805
806 scoped_free_pendings free_pending;
807
808 /* Position to read the symbol table. */
809 val = bfd_seek (objfile->obfd.get (), symtab_offset, 0);
810 if (val < 0)
811 perror_with_name (objfile_name (objfile));
812
814 nlist_bfd_global = objfile->obfd.get ();
815 nlist_nsyms_global = nsyms;
817 memset (opaque_type_chain, 0, sizeof opaque_type_chain);
818
819 if (type_vector) /* Get rid of previous one. */
822 type_vector = XCNEWVEC (struct type *, type_vector_length);
823
825
826 symnum = 0;
827 while (symnum < nsyms)
828 {
829 QUIT; /* Make this command interruptable. */
830
831 read_one_sym (cs, &main_sym, &main_aux);
832
833 if (cs->c_symnum == next_file_symnum && cs->c_sclass != C_FILE)
834 {
837
838 coff_start_compunit_symtab (objfile, "_globals_");
839 /* coff_start_compunit_symtab will set the language of this symtab to
840 language_unknown, since such a ``file name'' is not
841 recognized. Override that with the minimal language to
842 allow printing values in this symtab. */
844 complete_symtab ("_globals_", 0, 0);
845 /* Done with all files, everything from here on out is
846 globals. */
847 }
848
849 /* Special case for file with type declarations only, no
850 text. */
851 if (!get_last_source_file () && SDB_TYPE (cs->c_type)
852 && cs->c_secnum == N_DEBUG)
853 complete_symtab (filestring, 0, 0);
854
855 /* Typedefs should not be treated as symbol definitions. */
856 if (ISFCN (cs->c_type) && cs->c_sclass != C_TPDEF)
857 {
858 /* Record all functions -- external and static -- in
859 minsyms. */
860 int section = cs_to_section (cs, objfile);
861
862 tmpaddr = cs->c_value;
863 /* Don't record unresolved symbols. */
864 if (!(cs->c_secnum <= 0 && cs->c_value == 0))
865 record_minimal_symbol (reader, cs,
866 unrelocated_addr (tmpaddr),
867 mst_text, section, objfile);
868
869 fcn_line_ptr = main_aux.x_sym.x_fcnary.x_fcn.x_lnnoptr;
870 fcn_start_addr = tmpaddr;
871 fcn_cs_saved = *cs;
872 fcn_sym_saved = main_sym;
873 fcn_aux_saved = main_aux;
874 continue;
875 }
876
877 switch (cs->c_sclass)
878 {
879 case C_EFCN:
880 case C_EXTDEF:
881 case C_ULABEL:
882 case C_USTATIC:
883 case C_LINE:
884 case C_ALIAS:
885 case C_HIDDEN:
886 complaint (_("Bad n_sclass for symbol %s"),
887 cs->c_name);
888 break;
889
890 case C_FILE:
891 /* c_value field contains symnum of next .file entry in
892 table or symnum of first global after last .file. */
893 next_file_symnum = cs->c_value;
894 if (cs->c_naux > 0)
895 filestring = coff_getfilename (&main_aux);
896 else
897 filestring = "";
898
899 /* Complete symbol table for last object file
900 containing debugging information. */
902 {
905 }
906 in_source_file = 1;
907 break;
908
909 /* C_LABEL is used for labels and static functions.
910 Including it here allows gdb to see static functions when
911 no debug info is available. */
912 case C_LABEL:
913 /* However, labels within a function can make weird
914 backtraces, so filter them out (from phdm@macqel.be). */
915 if (within_function)
916 break;
917 /* Fall through. */
918 case C_STAT:
919 case C_THUMBLABEL:
920 case C_THUMBSTAT:
921 case C_THUMBSTATFUNC:
922 if (cs->c_name[0] == '.')
923 {
924 if (strcmp (cs->c_name, ".text") == 0)
925 {
926 /* FIXME: don't wire in ".text" as section name or
927 symbol name! */
928 /* Check for in_source_file deals with case of a
929 file with debugging symbols followed by a later
930 file with no symbols. */
931 if (in_source_file)
932 complete_symtab (filestring,
933 (cs->c_value
935 main_aux.x_scn.x_scnlen);
936 in_source_file = 0;
937 }
938 /* Flush rest of '.' symbols. */
939 break;
940 }
941 else if (!SDB_TYPE (cs->c_type)
942 && cs->c_name[0] == 'L'
943 && (startswith (cs->c_name, "LI%")
944 || startswith (cs->c_name, "LF%")
945 || startswith (cs->c_name, "LC%")
946 || startswith (cs->c_name, "LP%")
947 || startswith (cs->c_name, "LPB%")
948 || startswith (cs->c_name, "LBB%")
949 || startswith (cs->c_name, "LBE%")
950 || startswith (cs->c_name, "LPBX%")))
951 /* At least on a 3b1, gcc generates swbeg and string labels
952 that look like this. Ignore them. */
953 break;
954 /* For static symbols that don't start with '.'... */
955 /* Fall through. */
956 case C_THUMBEXT:
957 case C_THUMBEXTFUNC:
958 case C_EXT:
959 {
960 /* Record it in the minimal symbols regardless of
961 SDB_TYPE. This parallels what we do for other debug
962 formats, and probably is needed to make
963 print_address_symbolic work right without the (now
964 gone) "set fast-symbolic-addr off" kludge. */
965
966 enum minimal_symbol_type ms_type;
967 int sec;
968 CORE_ADDR offset = 0;
969
970 if (cs->c_secnum == N_UNDEF)
971 {
972 /* This is a common symbol. We used to rely on
973 the target to tell us whether it knows where
974 the symbol has been relocated to, but none of
975 the target implementations actually provided
976 that operation. So we just ignore the symbol,
977 the same way we would do if we had a target-side
978 symbol lookup which returned no match. */
979 break;
980 }
981 else if (cs->c_secnum == N_ABS)
982 {
983 /* Use the correct minimal symbol type (and don't
984 relocate) for absolute values. */
985 ms_type = mst_abs;
986 sec = cs_to_section (cs, objfile);
987 tmpaddr = cs->c_value;
988 }
989 else
990 {
991 asection *bfd_section = cs_to_bfd_section (cs, objfile);
992
993 sec = cs_to_section (cs, objfile);
994 tmpaddr = cs->c_value;
995 /* Statics in a PE file also get relocated. */
996 if (cs->c_sclass == C_EXT
997 || cs->c_sclass == C_THUMBEXTFUNC
998 || cs->c_sclass == C_THUMBEXT
999 || (pe_file && (cs->c_sclass == C_STAT)))
1000 offset = objfile->section_offsets[sec];
1001
1002 if (bfd_section->flags & SEC_CODE)
1003 {
1004 ms_type =
1005 cs->c_sclass == C_EXT || cs->c_sclass == C_THUMBEXTFUNC
1006 || cs->c_sclass == C_THUMBEXT ?
1008 tmpaddr = gdbarch_addr_bits_remove (gdbarch, tmpaddr);
1009 }
1010 else if (bfd_section->flags & SEC_ALLOC
1011 && bfd_section->flags & SEC_LOAD)
1012 {
1013 ms_type =
1014 cs->c_sclass == C_EXT || cs->c_sclass == C_THUMBEXT
1016 }
1017 else if (bfd_section->flags & SEC_ALLOC)
1018 {
1019 ms_type =
1020 cs->c_sclass == C_EXT || cs->c_sclass == C_THUMBEXT
1022 }
1023 else
1024 ms_type = mst_unknown;
1025 }
1026
1027 msym = record_minimal_symbol (reader, cs,
1028 unrelocated_addr (tmpaddr),
1029 ms_type, sec, objfile);
1030 if (msym)
1032 cs->c_sclass, msym);
1033
1034 if (SDB_TYPE (cs->c_type))
1035 {
1036 struct symbol *sym;
1037
1039 (cs, &main_aux, objfile);
1040 sym->set_value_longest (tmpaddr + offset);
1041 sym->set_section_index (sec);
1042 }
1043 }
1044 break;
1045
1046 case C_FCN:
1047 if (strcmp (cs->c_name, ".bf") == 0)
1048 {
1049 within_function = 1;
1050
1051 /* Value contains address of first non-init type
1052 code. */
1053 /* main_aux.x_sym.x_misc.x_lnsz.x_lnno
1054 contains line number of '{' }. */
1055 if (cs->c_naux != 1)
1056 complaint (_("`.bf' symbol %d has no aux entry"),
1057 cs->c_symnum);
1058 fcn_first_line = main_aux.x_sym.x_misc.x_lnsz.x_lnno;
1059 fcn_first_line_addr = cs->c_value;
1060
1061 /* Might want to check that locals are 0 and
1062 context_stack_depth is zero, and complain if not. */
1063
1064 depth = 0;
1065 newobj = push_context (depth, fcn_start_addr);
1066 fcn_cs_saved.c_name = getsymname (&fcn_sym_saved);
1067 newobj->name =
1069 &fcn_aux_saved, objfile);
1070 }
1071 else if (strcmp (cs->c_name, ".ef") == 0)
1072 {
1073 if (!within_function)
1074 error (_("Bad coff function information."));
1075 /* The value of .ef is the address of epilogue code;
1076 not useful for gdb. */
1077 /* { main_aux.x_sym.x_misc.x_lnsz.x_lnno
1078 contains number of lines to '}' */
1079
1080 if (outermost_context_p ())
1081 { /* We attempted to pop an empty context stack. */
1082 complaint (_("`.ef' symbol without matching `.bf' "
1083 "symbol ignored starting at symnum %d"),
1084 cs->c_symnum);
1085 within_function = 0;
1086 break;
1087 }
1088
1089 struct context_stack cstk = pop_context ();
1090 /* Stack must be empty now. */
1091 if (!outermost_context_p () || newobj == NULL)
1092 {
1093 complaint (_("Unmatched .ef symbol(s) ignored "
1094 "starting at symnum %d"),
1095 cs->c_symnum);
1096 within_function = 0;
1097 break;
1098 }
1099 if (cs->c_naux != 1)
1100 {
1101 complaint (_("`.ef' symbol %d has no aux entry"),
1102 cs->c_symnum);
1103 fcn_last_line = 0x7FFFFFFF;
1104 }
1105 else
1106 {
1107 fcn_last_line = main_aux.x_sym.x_misc.x_lnsz.x_lnno;
1108 }
1109 /* fcn_first_line is the line number of the opening '{'.
1110 Do not record it - because it would affect gdb's idea
1111 of the line number of the first statement of the
1112 function - except for one-line functions, for which
1113 it is also the line number of all the statements and
1114 of the closing '}', and for which we do not have any
1115 other statement-line-number. */
1116 if (fcn_last_line == 1)
1118 (get_current_subfile (), fcn_first_line,
1119 unrelocated_addr (gdbarch_addr_bits_remove (gdbarch,
1120 fcn_first_line_addr)));
1121 else
1122 enter_linenos (fcn_line_ptr, fcn_first_line,
1123 fcn_last_line, objfile);
1124
1125 finish_block (cstk.name, cstk.old_blocks,
1126 NULL, cstk.start_addr,
1128 + fcn_aux_saved.x_sym.x_misc.x_fsize
1130 within_function = 0;
1131 }
1132 break;
1133
1134 case C_BLOCK:
1135 if (strcmp (cs->c_name, ".bb") == 0)
1136 {
1137 tmpaddr = cs->c_value;
1138 tmpaddr += objfile->text_section_offset ();
1139 push_context (++depth, tmpaddr);
1140 }
1141 else if (strcmp (cs->c_name, ".eb") == 0)
1142 {
1143 if (outermost_context_p ())
1144 { /* We attempted to pop an empty context stack. */
1145 complaint (_("`.eb' symbol without matching `.bb' "
1146 "symbol ignored starting at symnum %d"),
1147 cs->c_symnum);
1148 break;
1149 }
1150
1151 struct context_stack cstk = pop_context ();
1152 if (depth-- != cstk.depth)
1153 {
1154 complaint (_("Mismatched .eb symbol ignored "
1155 "starting at symnum %d"),
1156 symnum);
1157 break;
1158 }
1160 {
1161 tmpaddr = cs->c_value + objfile->text_section_offset ();
1162 /* Make a block for the local symbols within. */
1163 finish_block (0, cstk.old_blocks, NULL,
1164 cstk.start_addr, tmpaddr);
1165 }
1166 /* Now pop locals of block just finished. */
1167 *get_local_symbols () = cstk.locals;
1168 }
1169 break;
1170
1171 default:
1172 process_coff_symbol (cs, &main_aux, objfile);
1173 break;
1174 }
1175 }
1176
1177 if (get_last_source_file ())
1179
1180 /* Patch up any opaque types (references to types that are not defined
1181 in the file where they are referenced, e.g. "struct foo *bar"). */
1182 {
1183 for (compunit_symtab *cu : objfile->compunits ())
1184 {
1185 for (symtab *s : cu->filetabs ())
1187 }
1188 }
1189
1190 coffread_objfile = NULL;
1191}
1192
1193/* Routines for reading headers and symbols from executable. */
1194
1195/* Read the next symbol, swap it, and return it in both
1196 internal_syment form, and coff_symbol form. Also return its first
1197 auxent, if any, in internal_auxent form, and skip any other
1198 auxents. */
1199
1200static void
1202 struct internal_syment *sym,
1203 union internal_auxent *aux)
1204{
1205 int i;
1206 bfd_size_type bytes;
1207
1208 cs->c_symnum = symnum;
1209 bytes = bfd_read (temp_sym, local_symesz, nlist_bfd_global);
1210 if (bytes != local_symesz)
1211 error (_("%s: error reading symbols"), objfile_name (coffread_objfile));
1212 bfd_coff_swap_sym_in (symfile_bfd, temp_sym, (char *) sym);
1213 cs->c_naux = sym->n_numaux & 0xff;
1214 if (cs->c_naux >= 1)
1215 {
1216 bytes = bfd_read (temp_aux, local_auxesz, nlist_bfd_global);
1217 if (bytes != local_auxesz)
1218 error (_("%s: error reading symbols"), objfile_name (coffread_objfile));
1219 bfd_coff_swap_aux_in (symfile_bfd, temp_aux,
1220 sym->n_type, sym->n_sclass,
1221 0, cs->c_naux, (char *) aux);
1222 /* If more than one aux entry, read past it (only the first aux
1223 is important). */
1224 for (i = 1; i < cs->c_naux; i++)
1225 {
1226 bytes = bfd_read (temp_aux, local_auxesz, nlist_bfd_global);
1227 if (bytes != local_auxesz)
1228 error (_("%s: error reading symbols"),
1230 }
1231 }
1232 cs->c_name = getsymname (sym);
1233 cs->c_value = sym->n_value;
1234 cs->c_sclass = (sym->n_sclass & 0xff);
1235 cs->c_secnum = sym->n_scnum;
1236 cs->c_type = (unsigned) sym->n_type;
1237 if (!SDB_TYPE (cs->c_type))
1238 cs->c_type = 0;
1239
1240#if 0
1241 if (cs->c_sclass & 128)
1242 printf (_("thumb symbol %s, class 0x%x\n"), cs->c_name, cs->c_sclass);
1243#endif
1244
1245 symnum += 1 + cs->c_naux;
1246
1247 /* The PE file format stores symbol values as offsets within the
1248 section, rather than as absolute addresses. We correct that
1249 here, if the symbol has an appropriate storage class. FIXME: We
1250 should use BFD to read the symbols, rather than duplicating the
1251 work here. */
1252 if (pe_file)
1253 {
1254 switch (cs->c_sclass)
1255 {
1256 case C_EXT:
1257 case C_THUMBEXT:
1258 case C_THUMBEXTFUNC:
1259 case C_SECTION:
1260 case C_NT_WEAK:
1261 case C_STAT:
1262 case C_THUMBSTAT:
1263 case C_THUMBSTATFUNC:
1264 case C_LABEL:
1265 case C_THUMBLABEL:
1266 case C_BLOCK:
1267 case C_FCN:
1268 case C_EFCN:
1269 if (cs->c_secnum != 0)
1271 break;
1272 }
1273 }
1274}
1275
1276/* Support for string table handling. */
1277
1278static int
1279init_stringtab (bfd *abfd, file_ptr offset, gdb::unique_xmalloc_ptr<char> *storage)
1280{
1281 long length;
1282 int val;
1283 unsigned char lengthbuf[4];
1284
1285 /* If the file is stripped, the offset might be zero, indicating no
1286 string table. Just return with `stringtab' set to null. */
1287 if (offset == 0)
1288 return 0;
1289
1290 if (bfd_seek (abfd, offset, 0) < 0)
1291 return -1;
1292
1293 val = bfd_read (lengthbuf, sizeof lengthbuf, abfd);
1294 /* If no string table is needed, then the file may end immediately
1295 after the symbols. Just return with `stringtab' set to null. */
1296 if (val != sizeof lengthbuf)
1297 return 0;
1298 length = bfd_h_get_32 (symfile_bfd, lengthbuf);
1299 if (length < sizeof lengthbuf)
1300 return 0;
1301
1302 storage->reset ((char *) xmalloc (length));
1303 stringtab = storage->get ();
1304 /* This is in target format (probably not very useful, and not
1305 currently used), not host format. */
1306 memcpy (stringtab, lengthbuf, sizeof lengthbuf);
1307 stringtab_length = length;
1308 if (length == sizeof length) /* Empty table -- just the count. */
1309 return 0;
1310
1311 val = bfd_read (stringtab + sizeof lengthbuf,
1312 length - sizeof lengthbuf, abfd);
1313 if (val != length - sizeof lengthbuf || stringtab[length - 1] != '\0')
1314 return -1;
1315
1316 return 0;
1317}
1318
1319static char *
1320getsymname (struct internal_syment *symbol_entry)
1321{
1322 static char buffer[SYMNMLEN + 1];
1323 char *result;
1324
1325 if (symbol_entry->_n._n_n._n_zeroes == 0)
1326 {
1327 if (symbol_entry->_n._n_n._n_offset > stringtab_length)
1328 error (_("COFF Error: string table offset (%s) outside string table (length %ld)"),
1329 hex_string (symbol_entry->_n._n_n._n_offset), stringtab_length);
1330 result = stringtab + symbol_entry->_n._n_n._n_offset;
1331 }
1332 else
1333 {
1334 strncpy (buffer, symbol_entry->_n._n_name, SYMNMLEN);
1335 buffer[SYMNMLEN] = '\0';
1336 result = buffer;
1337 }
1338 return result;
1339}
1340
1341/* Extract the file name from the aux entry of a C_FILE symbol.
1342 Return only the last component of the name. Result is in static
1343 storage and is only good for temporary use. */
1344
1345static const char *
1346coff_getfilename (union internal_auxent *aux_entry)
1347{
1348 static char buffer[BUFSIZ];
1349 const char *result;
1350
1351 if (aux_entry->x_file.x_n.x_n.x_zeroes == 0)
1352 {
1353 if (strlen (stringtab + aux_entry->x_file.x_n.x_n.x_offset) >= BUFSIZ)
1354 internal_error (_("coff file name too long"));
1355 strcpy (buffer, stringtab + aux_entry->x_file.x_n.x_n.x_offset);
1356 }
1357 else
1358 {
1359 size_t x_fname_len = sizeof (aux_entry->x_file.x_n.x_fname);
1360 strncpy (buffer, aux_entry->x_file.x_n.x_fname, x_fname_len);
1361 buffer[x_fname_len] = '\0';
1362 }
1363 result = buffer;
1364
1365 /* FIXME: We should not be throwing away the information about what
1366 directory. It should go into dirname of the symtab, or some such
1367 place. */
1368 result = lbasename (result);
1369 return (result);
1370}
1371
1372/* Support for line number handling. */
1373
1374/* Read in all the line numbers for fast lookups later. Leave them in
1375 external (unswapped) format in memory; we'll swap them as we enter
1376 them into GDB's data structures. */
1377
1378static int
1379init_lineno (bfd *abfd, file_ptr offset, file_ptr size,
1380 gdb::unique_xmalloc_ptr<char> *storage)
1381{
1382 int val;
1383
1384 linetab_offset = offset;
1386
1387 if (size == 0)
1388 return 0;
1389
1390 if (bfd_seek (abfd, offset, 0) < 0)
1391 return -1;
1392
1393 /* Allocate the desired table, plus a sentinel. */
1394 storage->reset ((char *) xmalloc (size + local_linesz));
1395 linetab = storage->get ();
1396
1397 val = bfd_read (storage->get (), size, abfd);
1398 if (val != size)
1399 return -1;
1400
1401 /* Terminate it with an all-zero sentinel record. */
1402 memset (linetab + size, 0, local_linesz);
1403
1404 return 0;
1405}
1406
1407#if !defined (L_LNNO32)
1408#define L_LNNO32(lp) ((lp)->l_lnno)
1409#endif
1410
1411static void
1412enter_linenos (file_ptr file_offset, int first_line,
1413 int last_line, struct objfile *objfile)
1414{
1415 struct gdbarch *gdbarch = objfile->arch ();
1416 char *rawptr;
1417 struct internal_lineno lptr;
1418
1419 if (!linetab)
1420 return;
1421 if (file_offset < linetab_offset)
1422 {
1423 complaint (_("Line number pointer %s lower than start of line numbers"),
1424 plongest (file_offset));
1425 if (file_offset > linetab_size) /* Too big to be an offset? */
1426 return;
1427 file_offset += linetab_offset; /* Try reading at that linetab
1428 offset. */
1429 }
1430
1431 rawptr = &linetab[file_offset - linetab_offset];
1432
1433 /* Skip first line entry for each function. */
1434 rawptr += local_linesz;
1435 /* Line numbers start at one for the first line of the function. */
1436 first_line--;
1437
1438 /* If the line number table is full (e.g. 64K lines in COFF debug
1439 info), the next function's L_LNNO32 might not be zero, so don't
1440 overstep the table's end in any case. */
1441 while (rawptr <= &linetab[0] + linetab_size)
1442 {
1443 bfd_coff_swap_lineno_in (symfile_bfd, rawptr, &lptr);
1444 rawptr += local_linesz;
1445 /* The next function, or the sentinel, will have L_LNNO32 zero;
1446 we exit. */
1447 if (L_LNNO32 (&lptr) && L_LNNO32 (&lptr) <= last_line)
1448 {
1449 CORE_ADDR addr = lptr.l_addr.l_paddr;
1451 first_line + L_LNNO32 (&lptr),
1452 unrelocated_addr (gdbarch_addr_bits_remove (gdbarch,
1453 addr)));
1454 }
1455 else
1456 break;
1457 }
1458}
1459
1460static void
1461patch_type (struct type *type, struct type *real_type)
1462{
1463 struct type *target = type->target_type ();
1464 struct type *real_target = real_type->target_type ();
1465
1466 target->set_length (real_target->length ());
1467 target->copy_fields (real_target);
1468
1469 if (real_target->name ())
1470 {
1471 /* The previous copy of TYPE_NAME is allocated by
1472 process_coff_symbol. */
1473 xfree ((char *) target->name ());
1474 target->set_name (xstrdup (real_target->name ()));
1475 }
1476}
1477
1478/* Patch up all appropriate typedef symbols in the opaque_type_chains
1479 so that they can be used to print out opaque data structures
1480 properly. */
1481
1482static void
1484{
1485 /* Go through the per-file symbols only. */
1486 const struct block *b = s->compunit ()->blockvector ()->static_block ();
1487 for (struct symbol *real_sym : block_iterator_range (b))
1488 {
1489 /* Find completed typedefs to use to fix opaque ones.
1490 Remove syms from the chain when their types are stored,
1491 but search the whole chain, as there may be several syms
1492 from different files with the same name. */
1493 if (real_sym->aclass () == LOC_TYPEDEF
1494 && real_sym->domain () == VAR_DOMAIN
1495 && real_sym->type ()->code () == TYPE_CODE_PTR
1496 && real_sym->type ()->target_type ()->length () != 0)
1497 {
1498 const char *name = real_sym->linkage_name ();
1499 int hash = hashname (name);
1500 struct symbol *sym, *prev;
1501
1502 prev = 0;
1503 for (sym = opaque_type_chain[hash]; sym;)
1504 {
1505 if (name[0] == sym->linkage_name ()[0]
1506 && strcmp (name + 1, sym->linkage_name () + 1) == 0)
1507 {
1508 if (prev)
1509 prev->set_value_chain (sym->value_chain ());
1510 else
1511 opaque_type_chain[hash] = sym->value_chain ();
1512
1513 patch_type (sym->type (), real_sym->type ());
1514
1515 if (prev)
1516 sym = prev->value_chain ();
1517 else
1518 sym = opaque_type_chain[hash];
1519 }
1520 else
1521 {
1522 prev = sym;
1523 sym->set_value_chain (sym);
1524 }
1525 }
1526 }
1527 }
1528}
1529
1530static int
1532{
1534}
1535
1539
1540/* The "aclass" index for computed COFF symbols. */
1541
1543
1544static struct symbol *
1546 union internal_auxent *aux,
1547 struct objfile *objfile)
1548{
1549 struct symbol *sym = new (&objfile->objfile_obstack) symbol;
1550 char *name;
1551
1552 name = cs->c_name;
1553 name = EXTERNAL_NAME (name, objfile->obfd.get ());
1557
1558 /* default assumptions */
1559 sym->set_value_longest (cs->c_value);
1560 sym->set_domain (VAR_DOMAIN);
1562
1563 if (ISFCN (cs->c_type))
1564 {
1567 sym->set_type
1569 aux, objfile)));
1570
1572 if (cs->c_sclass == C_STAT || cs->c_sclass == C_THUMBSTAT
1573 || cs->c_sclass == C_THUMBSTATFUNC)
1575 else if (cs->c_sclass == C_EXT || cs->c_sclass == C_THUMBEXT
1576 || cs->c_sclass == C_THUMBEXTFUNC)
1578 }
1579 else
1580 {
1581 sym->set_type (decode_type (cs, cs->c_type, aux, objfile));
1582 switch (cs->c_sclass)
1583 {
1584 case C_NULL:
1585 break;
1586
1587 case C_AUTO:
1590 break;
1591
1592 case C_THUMBEXT:
1593 case C_THUMBEXTFUNC:
1594 case C_EXT:
1596 sym->set_value_address ((CORE_ADDR) cs->c_value
1599 break;
1600
1601 case C_THUMBSTAT:
1602 case C_THUMBSTATFUNC:
1603 case C_STAT:
1605 sym->set_value_address ((CORE_ADDR) cs->c_value
1607 if (within_function)
1608 {
1609 /* Static symbol of local scope. */
1611 }
1612 else
1613 {
1614 /* Static symbol at top level of file. */
1616 }
1617 break;
1618
1619#ifdef C_GLBLREG /* AMD coff */
1620 case C_GLBLREG:
1621#endif
1622 case C_REG:
1624 sym->set_value_longest (cs->c_value);
1626 break;
1627
1628 case C_THUMBLABEL:
1629 case C_LABEL:
1630 break;
1631
1632 case C_ARG:
1634 sym->set_is_argument (1);
1636 break;
1637
1638 case C_REGPARM:
1640 sym->set_is_argument (1);
1641 sym->set_value_longest (cs->c_value);
1643 break;
1644
1645 case C_TPDEF:
1647 sym->set_domain (VAR_DOMAIN);
1648
1649 /* If type has no name, give it one. */
1650 if (sym->type ()->name () == 0)
1651 {
1652 if (sym->type ()->code () == TYPE_CODE_PTR
1653 || sym->type ()->code () == TYPE_CODE_FUNC)
1654 {
1655 /* If we are giving a name to a type such as
1656 "pointer to foo" or "function returning foo", we
1657 better not set the TYPE_NAME. If the program
1658 contains "typedef char *caddr_t;", we don't want
1659 all variables of type char * to print as caddr_t.
1660 This is not just a consequence of GDB's type
1661 management; CC and GCC (at least through version
1662 2.4) both output variables of either type char *
1663 or caddr_t with the type refering to the C_TPDEF
1664 symbol for caddr_t. If a future compiler cleans
1665 this up it GDB is not ready for it yet, but if it
1666 becomes ready we somehow need to disable this
1667 check (without breaking the PCC/GCC2.4 case).
1668
1669 Sigh.
1670
1671 Fortunately, this check seems not to be necessary
1672 for anything except pointers or functions. */
1673 ;
1674 }
1675 else
1676 sym->type ()->set_name (xstrdup (sym->linkage_name ()));
1677 }
1678
1679 /* Keep track of any type which points to empty structured
1680 type, so it can be filled from a definition from another
1681 file. A simple forward reference (TYPE_CODE_UNDEF) is
1682 not an empty structured type, though; the forward
1683 references work themselves out via the magic of
1684 coff_lookup_type. */
1685 if (sym->type ()->code () == TYPE_CODE_PTR
1686 && sym->type ()->target_type ()->length () == 0
1687 && sym->type ()->target_type ()->code ()
1688 != TYPE_CODE_UNDEF)
1689 {
1690 int i = hashname (sym->linkage_name ());
1691
1693 opaque_type_chain[i] = sym;
1694 }
1696 break;
1697
1698 case C_STRTAG:
1699 case C_UNTAG:
1700 case C_ENTAG:
1703
1704 /* Some compilers try to be helpful by inventing "fake"
1705 names for anonymous enums, structures, and unions, like
1706 "~0fake" or ".0fake". Thanks, but no thanks... */
1707 if (sym->type ()->name () == 0)
1708 if (sym->linkage_name () != NULL
1709 && *sym->linkage_name () != '~'
1710 && *sym->linkage_name () != '.')
1711 sym->type ()->set_name (xstrdup (sym->linkage_name ()));
1712
1714 break;
1715
1716 default:
1717 break;
1718 }
1719 }
1720 return sym;
1721}
1722
1723/* Decode a coff type specifier; return the type that is meant. */
1724
1725static struct type *
1726decode_type (struct coff_symbol *cs, unsigned int c_type,
1727 union internal_auxent *aux, struct objfile *objfile)
1728{
1729 struct type *type = 0;
1730 unsigned int new_c_type;
1731
1732 if (c_type & ~N_BTMASK)
1733 {
1734 new_c_type = DECREF (c_type);
1735 if (ISPTR (c_type))
1736 {
1737 type = decode_type (cs, new_c_type, aux, objfile);
1739 }
1740 else if (ISFCN (c_type))
1741 {
1742 type = decode_type (cs, new_c_type, aux, objfile);
1744 }
1745 else if (ISARY (c_type))
1746 {
1747 int i, n;
1748 unsigned short *dim;
1749 struct type *base_type, *index_type, *range_type;
1750
1751 /* Define an array type. */
1752 /* auxent refers to array, not base type. */
1753 if (aux->x_sym.x_tagndx.u32 == 0)
1754 cs->c_naux = 0;
1755
1756 /* Shift the indices down. */
1757 dim = &aux->x_sym.x_fcnary.x_ary.x_dimen[0];
1758 i = 1;
1759 n = dim[0];
1760 for (i = 0; *dim && i < DIMNUM - 1; i++, dim++)
1761 *dim = *(dim + 1);
1762 *dim = 0;
1763
1764 base_type = decode_type (cs, new_c_type, aux, objfile);
1767 range_type
1768 = create_static_range_type (alloc, index_type, 0, n - 1);
1769 type = create_array_type (alloc, base_type, range_type);
1770 }
1771 return type;
1772 }
1773
1774 /* Reference to existing type. This only occurs with the struct,
1775 union, and enum types. EPI a29k coff fakes us out by producing
1776 aux entries with a nonzero x_tagndx for definitions of structs,
1777 unions, and enums, so we have to check the c_sclass field. SCO
1778 3.2v4 cc gets confused with pointers to pointers to defined
1779 structs, and generates negative x_tagndx fields. */
1780 if (cs->c_naux > 0 && aux->x_sym.x_tagndx.u32 != 0)
1781 {
1782 if (cs->c_sclass != C_STRTAG
1783 && cs->c_sclass != C_UNTAG
1784 && cs->c_sclass != C_ENTAG
1785 && (int32_t) aux->x_sym.x_tagndx.u32 >= 0)
1786 {
1787 type = coff_alloc_type (aux->x_sym.x_tagndx.u32);
1788 return type;
1789 }
1790 else
1791 {
1792 complaint (_("Symbol table entry for %s has bad tagndx value"),
1793 cs->c_name);
1794 /* And fall through to decode_base_type... */
1795 }
1796 }
1797
1798 return decode_base_type (cs, BTYPE (c_type), aux, objfile);
1799}
1800
1801/* Decode a coff type specifier for function definition;
1802 return the type that the function returns. */
1803
1804static struct type *
1806 unsigned int c_type,
1807 union internal_auxent *aux,
1808 struct objfile *objfile)
1809{
1810 if (aux->x_sym.x_tagndx.u32 == 0)
1811 cs->c_naux = 0; /* auxent refers to function, not base
1812 type. */
1813
1814 return decode_type (cs, DECREF (c_type), aux, objfile);
1815}
1816
1817/* Basic C types. */
1818
1819static struct type *
1821 unsigned int c_type,
1822 union internal_auxent *aux,
1823 struct objfile *objfile)
1824{
1825 struct gdbarch *gdbarch = objfile->arch ();
1826 struct type *type;
1827
1828 switch (c_type)
1829 {
1830 case T_NULL:
1831 /* Shows up with "void (*foo)();" structure members. */
1833
1834#ifdef T_VOID
1835 case T_VOID:
1836 /* Intel 960 COFF has this symbol and meaning. */
1838#endif
1839
1840 case T_CHAR:
1842
1843 case T_SHORT:
1845
1846 case T_INT:
1848
1849 case T_LONG:
1850 if (cs->c_sclass == C_FIELD
1851 && aux->x_sym.x_misc.x_lnsz.x_size
1854 else
1856
1857 case T_FLOAT:
1859
1860 case T_DOUBLE:
1862
1863 case T_LNGDBL:
1865
1866 case T_STRUCT:
1867 if (cs->c_naux != 1)
1868 {
1869 /* Anonymous structure type. */
1871 type->set_code (TYPE_CODE_STRUCT);
1872 type->set_name (NULL);
1874 type->set_length (0);
1875 type->set_fields (nullptr);
1876 type->set_num_fields (0);
1877 }
1878 else
1879 {
1881 aux->x_sym.x_misc.x_lnsz.x_size,
1882 aux->x_sym.x_fcnary.x_fcn.x_endndx.u32,
1883 objfile);
1884 }
1885 return type;
1886
1887 case T_UNION:
1888 if (cs->c_naux != 1)
1889 {
1890 /* Anonymous union type. */
1892 type->set_name (NULL);
1894 type->set_length (0);
1895 type->set_fields (nullptr);
1896 type->set_num_fields (0);
1897 }
1898 else
1899 {
1901 aux->x_sym.x_misc.x_lnsz.x_size,
1902 aux->x_sym.x_fcnary.x_fcn.x_endndx.u32,
1903 objfile);
1904 }
1905 type->set_code (TYPE_CODE_UNION);
1906 return type;
1907
1908 case T_ENUM:
1909 if (cs->c_naux != 1)
1910 {
1911 /* Anonymous enum type. */
1913 type->set_code (TYPE_CODE_ENUM);
1914 type->set_name (NULL);
1915 type->set_length (0);
1916 type->set_fields (nullptr);
1917 type->set_num_fields (0);
1918 }
1919 else
1920 {
1922 aux->x_sym.x_misc.x_lnsz.x_size,
1923 aux->x_sym.x_fcnary.x_fcn.x_endndx.u32,
1924 objfile);
1925 }
1926 return type;
1927
1928 case T_MOE:
1929 /* Shouldn't show up here. */
1930 break;
1931
1932 case T_UCHAR:
1934
1935 case T_USHORT:
1937
1938 case T_UINT:
1940
1941 case T_ULONG:
1942 if (cs->c_sclass == C_FIELD
1943 && aux->x_sym.x_misc.x_lnsz.x_size
1946 else
1948 }
1949 complaint (_("Unexpected type for symbol %s"), cs->c_name);
1951}
1952
1953/* This page contains subroutines of read_type. */
1954
1955/* Read the description of a structure (or union type) and return an
1956 object describing the type. */
1957
1958static struct type *
1959coff_read_struct_type (int index, int length, int lastsym,
1960 struct objfile *objfile)
1961{
1962 struct nextfield
1963 {
1964 struct nextfield *next;
1965 struct field field;
1966 };
1967
1968 struct type *type;
1969 struct nextfield *list = 0;
1970 struct nextfield *newobj;
1971 int nfields = 0;
1972 int n;
1973 char *name;
1974 struct coff_symbol member_sym;
1975 struct coff_symbol *ms = &member_sym;
1976 struct internal_syment sub_sym;
1977 union internal_auxent sub_aux;
1978 int done = 0;
1979
1980 type = coff_alloc_type (index);
1981 type->set_code (TYPE_CODE_STRUCT);
1983 type->set_length (length);
1984
1985 while (!done && symnum < lastsym && symnum < nlist_nsyms_global)
1986 {
1987 read_one_sym (ms, &sub_sym, &sub_aux);
1988 name = ms->c_name;
1989 name = EXTERNAL_NAME (name, objfile->obfd.get ());
1990
1991 switch (ms->c_sclass)
1992 {
1993 case C_MOS:
1994 case C_MOU:
1995
1996 /* Get space to record the next field's data. */
1997 newobj = XALLOCA (struct nextfield);
1998 newobj->next = list;
1999 list = newobj;
2000
2001 /* Save the data. */
2002 list->field.set_name (obstack_strdup (&objfile->objfile_obstack,
2003 name));
2004 list->field.set_type (decode_type (ms, ms->c_type, &sub_aux,
2005 objfile));
2006 list->field.set_loc_bitpos (8 * ms->c_value);
2007 list->field.set_bitsize (0);
2008 nfields++;
2009 break;
2010
2011 case C_FIELD:
2012
2013 /* Get space to record the next field's data. */
2014 newobj = XALLOCA (struct nextfield);
2015 newobj->next = list;
2016 list = newobj;
2017
2018 /* Save the data. */
2019 list->field.set_name (obstack_strdup (&objfile->objfile_obstack,
2020 name));
2021 list->field.set_type (decode_type (ms, ms->c_type, &sub_aux,
2022 objfile));
2023 list->field.set_loc_bitpos (ms->c_value);
2024 list->field.set_bitsize (sub_aux.x_sym.x_misc.x_lnsz.x_size);
2025 nfields++;
2026 break;
2027
2028 case C_EOS:
2029 done = 1;
2030 break;
2031 }
2032 }
2033 /* Now create the vector of fields, and record how big it is. */
2034
2035 type->alloc_fields (nfields);
2036
2037 /* Copy the saved-up fields into the field vector. */
2038
2039 for (n = nfields; list; list = list->next)
2040 type->field (--n) = list->field;
2041
2042 return type;
2043}
2044
2045/* Read a definition of an enumeration type,
2046 and create and return a suitable type object.
2047 Also defines the symbols that represent the values of the type. */
2048
2049static struct type *
2050coff_read_enum_type (int index, int length, int lastsym,
2051 struct objfile *objfile)
2052{
2053 struct gdbarch *gdbarch = objfile->arch ();
2054 struct symbol *sym;
2055 struct type *type;
2056 int nsyms = 0;
2057 int done = 0;
2058 struct pending **symlist;
2059 struct coff_symbol member_sym;
2060 struct coff_symbol *ms = &member_sym;
2061 struct internal_syment sub_sym;
2062 union internal_auxent sub_aux;
2063 struct pending *osyms, *syms;
2064 int o_nsyms;
2065 int n;
2066 char *name;
2067 int unsigned_enum = 1;
2068
2069 type = coff_alloc_type (index);
2070 if (within_function)
2071 symlist = get_local_symbols ();
2072 else
2073 symlist = get_file_symbols ();
2074 osyms = *symlist;
2075 o_nsyms = osyms ? osyms->nsyms : 0;
2076
2077 while (!done && symnum < lastsym && symnum < nlist_nsyms_global)
2078 {
2079 read_one_sym (ms, &sub_sym, &sub_aux);
2080 name = ms->c_name;
2081 name = EXTERNAL_NAME (name, objfile->obfd.get ());
2082
2083 switch (ms->c_sclass)
2084 {
2085 case C_MOE:
2086 sym = new (&objfile->objfile_obstack) symbol;
2087
2088 name = obstack_strdup (&objfile->objfile_obstack, name);
2089 sym->set_linkage_name (name);
2091 sym->set_domain (VAR_DOMAIN);
2092 sym->set_value_longest (ms->c_value);
2093 add_symbol_to_list (sym, symlist);
2094 nsyms++;
2095 break;
2096
2097 case C_EOS:
2098 /* Sometimes the linker (on 386/ix 2.0.2 at least) screws
2099 up the count of how many symbols to read. So stop
2100 on .eos. */
2101 done = 1;
2102 break;
2103 }
2104 }
2105
2106 /* Now fill in the fields of the type-structure. */
2107
2108 if (length > 0)
2109 type->set_length (length);
2110 else /* Assume ints. */
2111 type->set_length (gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT);
2112 type->set_code (TYPE_CODE_ENUM);
2114
2115 /* Find the symbols for the values and put them into the type.
2116 The symbols can be found in the symlist that we put them on
2117 to cause them to be defined. osyms contains the old value
2118 of that symlist; everything up to there was defined by us. */
2119 /* Note that we preserve the order of the enum constants, so
2120 that in something like "enum {FOO, LAST_THING=FOO}" we print
2121 FOO, not LAST_THING. */
2122
2123 for (syms = *symlist, n = 0; syms; syms = syms->next)
2124 {
2125 int j = 0;
2126
2127 if (syms == osyms)
2128 j = o_nsyms;
2129 for (; j < syms->nsyms; j++, n++)
2130 {
2131 struct symbol *xsym = syms->symbol[j];
2132
2133 xsym->set_type (type);
2134 type->field (n).set_name (xsym->linkage_name ());
2135 type->field (n).set_loc_enumval (xsym->value_longest ());
2136 if (xsym->value_longest () < 0)
2137 unsigned_enum = 0;
2138 type->field (n).set_bitsize (0);
2139 }
2140 if (syms == osyms)
2141 break;
2142 }
2143
2144 if (unsigned_enum)
2145 type->set_is_unsigned (true);
2146
2147 return type;
2148}
2149
2150/* Register our ability to parse symbols for coff BFD files. */
2151
2152static const struct sym_fns coff_sym_fns =
2153{
2154 coff_new_init, /* sym_new_init: init anything gbl to
2155 entire symtab */
2156 coff_symfile_init, /* sym_init: read initial info, setup
2157 for sym_read() */
2158 coff_symfile_read, /* sym_read: read a symbol file into
2159 symtab */
2160 coff_symfile_finish, /* sym_finish: finished with file,
2161 cleanup */
2162 default_symfile_offsets, /* sym_offsets: xlate external to
2163 internal form */
2164 default_symfile_segments, /* sym_segments: Get segment
2165 information from a file */
2166 NULL, /* sym_read_linetable */
2167
2168 default_symfile_relocate, /* sym_relocate: Relocate a debug
2169 section. */
2170 NULL, /* sym_probe_fns */
2171};
2172
2173void _initialize_coffread ();
2174void
const char *const name
void * xmalloc(YYSIZE_T)
void xfree(void *)
void * xrealloc(void *ptr, size_t size)
Definition alloc.c:65
iterator_range< block_iterator_wrapper > block_iterator_range
Definition block.h:553
std::string find_separate_debug_file_by_buildid(struct objfile *objfile, deferred_warnings *warnings)
Definition build-id.c:212
void set_last_source_start_addr(CORE_ADDR addr)
struct context_stack * push_context(int desc, CORE_ADDR valu)
struct block * finish_block(struct symbol *symbol, struct pending_block *old_blocks, const struct dynamic_prop *static_link, CORE_ADDR start, CORE_ADDR end)
struct compunit_symtab * start_compunit_symtab(struct objfile *objfile, const char *name, const char *comp_dir, CORE_ADDR start_addr, enum language language)
struct context_stack pop_context()
struct pending ** get_file_symbols()
bool outermost_context_p()
struct subfile * get_current_subfile()
void record_debugformat(const char *format)
void set_last_source_file(const char *name)
struct compunit_symtab * end_compunit_symtab(CORE_ADDR end_addr)
struct pending ** get_global_symbols()
void record_line(struct subfile *subfile, int line, unrelocated_addr pc)
const char * get_last_source_file()
struct pending ** get_local_symbols()
void add_symbol_to_list(struct symbol *symbol, struct pending **listhead)
Definition buildsym.c:125
struct minimal_symbol * record_full(gdb::string_view name, bool copy_name, unrelocated_addr address, enum minimal_symbol_type ms_type, int section)
Definition minsyms.c:1173
void * get(unsigned key)
Definition registry.h:211
type * new_type()
Definition gdbtypes.c:208
void read_pe_exported_syms(minimal_symbol_reader &reader, struct objfile *objfile)
static struct objfile * coffread_objfile
Definition coffread.c:47
#define L_LNNO32(lp)
Definition coffread.c:1408
static void find_linenos(bfd *abfd, struct bfd_section *asect, void *vpinfo)
Definition coffread.c:495
static int coff_register_index
Definition coffread.c:1542
static file_ptr linetab_offset
Definition coffread.c:158
static bfd * symfile_bfd
Definition coffread.c:601
static void coff_start_compunit_symtab(struct objfile *objfile, const char *name)
Definition coffread.c:368
static void coff_read_minsyms(file_ptr symtab_offset, unsigned int nsyms, struct objfile *objfile)
Definition coffread.c:527
static const char * coff_getfilename(union internal_auxent *)
Definition coffread.c:1346
static const struct sym_fns coff_sym_fns
Definition coffread.c:2152
static unsigned local_symesz
Definition coffread.c:118
static void coff_end_compunit_symtab(struct objfile *objfile)
Definition coffread.c:403
static char * linetab
Definition coffread.c:157
static int is_import_fixup_symbol(struct coff_symbol *cs, enum minimal_symbol_type type)
Definition coffread.c:418
static int init_stringtab(bfd *, file_ptr, gdb::unique_xmalloc_ptr< char > *)
Definition coffread.c:1279
static CORE_ADDR cs_section_address(struct coff_symbol *, bfd *)
Definition coffread.c:301
static unsigned local_linesz
Definition coffread.c:117
static unsigned local_n_tshift
Definition coffread.c:105
static int init_lineno(bfd *, file_ptr, file_ptr, gdb::unique_xmalloc_ptr< char > *)
Definition coffread.c:1379
static char * stringtab
Definition coffread.c:161
static file_ptr linetab_size
Definition coffread.c:159
#define SDB_TYPE(type)
Definition coffread.c:75
static int type_vector_length
Definition coffread.c:150
static CORE_ADDR current_source_end_addr
Definition coffread.c:81
static void read_one_sym(struct coff_symbol *, struct internal_syment *, union internal_auxent *)
Definition coffread.c:1201
static struct type ** coff_lookup_type(int index)
Definition coffread.c:323
static const registry< objfile >::key< coff_symfile_info > coff_objfile_data_key
Definition coffread.c:63
static int coff_reg_to_regnum(struct symbol *sym, struct gdbarch *gdbarch)
Definition coffread.c:1531
static void coff_new_init(struct objfile *ignore)
Definition coffread.c:754
static struct type * coff_read_struct_type(int, int, int, struct objfile *)
Definition coffread.c:1959
static void coff_symfile_finish(struct objfile *objfile)
Definition coffread.c:765
static void coff_symtab_read(minimal_symbol_reader &, file_ptr, unsigned int, struct objfile *)
Definition coffread.c:778
#define N_BTMASK
Definition coffread.c:107
static long stringtab_length
Definition coffread.c:162
static CORE_ADDR current_source_start_addr
Definition coffread.c:80
#define INITIAL_TYPE_VECTOR_LENGTH
Definition coffread.c:155
static void patch_type(struct type *type, struct type *real_type)
Definition coffread.c:1461
static char * temp_sym
Definition coffread.c:93
static unsigned local_auxesz
Definition coffread.c:119
static struct type * decode_type(struct coff_symbol *, unsigned int, union internal_auxent *, struct objfile *)
Definition coffread.c:1726
static const struct symbol_register_ops coff_register_funcs
Definition coffread.c:1536
static struct symbol * process_coff_symbol(struct coff_symbol *, union internal_auxent *, struct objfile *)
Definition coffread.c:1545
static void enter_linenos(file_ptr, int, int, struct objfile *)
Definition coffread.c:1412
static void coff_symfile_init(struct objfile *objfile)
Definition coffread.c:484
static bfd * nlist_bfd_global
Definition coffread.c:86
void stabsread_clear_cache(void)
Definition stabsread.c:530
static struct type * coff_read_enum_type(int, int, int, struct objfile *)
Definition coffread.c:2050
static struct type * coff_alloc_type(int index)
Definition coffread.c:347
static struct type * decode_function_type(struct coff_symbol *, unsigned int, union internal_auxent *, struct objfile *)
Definition coffread.c:1805
static struct minimal_symbol * record_minimal_symbol(minimal_symbol_reader &reader, struct coff_symbol *cs, unrelocated_addr address, enum minimal_symbol_type type, int section, struct objfile *objfile)
Definition coffread.c:447
static struct type ** type_vector
Definition coffread.c:146
static char * getsymname(struct internal_syment *)
Definition coffread.c:1320
static void coff_symfile_read(struct objfile *objfile, symfile_add_flags symfile_flags)
Definition coffread.c:606
static char * temp_aux
Definition coffread.c:94
void _initialize_coffread()
Definition coffread.c:2175
static struct bfd_section * cs_to_bfd_section(struct coff_symbol *cs, struct objfile *objfile)
Definition coffread.c:274
static unsigned local_n_btmask
Definition coffread.c:102
static unsigned local_n_tmask
Definition coffread.c:104
#define EXTERNAL_NAME(string, abfd)
Definition coffread.c:66
static void find_targ_sec(bfd *abfd, asection *sect, void *obj)
Definition coffread.c:264
static int nlist_nsyms_global
Definition coffread.c:87
static struct type * decode_base_type(struct coff_symbol *, unsigned int, union internal_auxent *, struct objfile *)
Definition coffread.c:1820
static int pe_file
Definition coffread.c:123
static void coff_locate_sections(bfd *abfd, asection *sectp, void *csip)
Definition coffread.c:220
static int cs_to_section(struct coff_symbol *, struct objfile *)
Definition coffread.c:287
static struct symbol * opaque_type_chain[HASHSIZE]
Definition coffread.c:128
static unsigned local_n_btshft
Definition coffread.c:103
static void patch_opaque_types(struct symtab *)
Definition coffread.c:1483
#define complaint(FMT,...)
Definition complaints.h:47
void coffstab_build_psymtabs(struct objfile *objfile, CORE_ADDR textaddr, unsigned int textsize, const std::vector< asection * > &stabsects, file_ptr stabstroffset, unsigned int stabstrsize)
Definition dbxread.c:2989
language
Definition defs.h:211
@ language_unknown
Definition defs.h:212
@ language_minimal
Definition defs.h:224
@ language_c
Definition defs.h:213
#define QUIT
Definition defs.h:187
int gdb_bfd_section_index(bfd *abfd, asection *section)
Definition gdb_bfd.c:984
gdb::ref_ptr< struct bfd, gdb_bfd_ref_policy > gdb_bfd_ref_ptr
Definition gdb_bfd.h:79
void gdbarch_coff_make_msymbol_special(struct gdbarch *gdbarch, int val, struct minimal_symbol *msym)
Definition gdbarch.c:3479
int gdbarch_sdb_reg_to_regnum(struct gdbarch *gdbarch, int sdb_regnr)
Definition gdbarch.c:2139
int gdbarch_int_bit(struct gdbarch *gdbarch)
Definition gdbarch.c:1449
CORE_ADDR gdbarch_addr_bits_remove(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition gdbarch.c:3152
int gdbarch_long_bit(struct gdbarch *gdbarch)
Definition gdbarch.c:1466
struct type * lookup_pointer_type(struct type *type)
Definition gdbtypes.c:430
struct type * create_static_range_type(type_allocator &alloc, struct type *index_type, LONGEST low_bound, LONGEST high_bound)
Definition gdbtypes.c:1019
struct type * lookup_function_type(struct type *type)
Definition gdbtypes.c:567
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
Definition gdbtypes.c:6168
struct type * create_array_type(type_allocator &alloc, struct type *element_type, struct type *range_type)
Definition gdbtypes.c:1388
@ TYPE_CODE_UNDEF
Definition gdbtypes.h:83
#define INIT_CPLUS_SPECIFIC(type)
Definition gdbtypes.h:1819
size_t size
Definition go32-nat.c:239
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
Definition minsyms.c:363
@ OBJF_READNEVER
const char * objfile_name(const struct objfile *objfile)
Definition objfiles.c:1259
#define SECT_OFF_TEXT(objfile)
Definition objfiles.h:139
bool dwarf2_has_info(struct objfile *, const struct dwarf2_debug_sections *, bool=false)
Definition read.c:1360
void dwarf2_initialize_objfile(struct objfile *objfile)
Definition read.c:3383
enum var_types type
Definition scm-param.c:142
int within_function
Definition stabsread.c:56
unsigned int symnum
Definition stabsread.c:53
int hashname(const char *name)
Definition stabsread.c:4748
#define HASHSIZE
Definition stabsread.h:29
Definition block.h:109
struct block * static_block()
Definition block.h:405
struct minimal_symbol * minsym
Definition minsyms.h:49
struct type * builtin_long_long
Definition gdbtypes.h:2096
struct type * builtin_double
Definition gdbtypes.h:2090
struct type * builtin_long
Definition gdbtypes.h:2081
struct type * builtin_unsigned_char
Definition gdbtypes.h:2083
struct type * builtin_long_double
Definition gdbtypes.h:2091
struct type * builtin_unsigned_long_long
Definition gdbtypes.h:2097
struct type * builtin_short
Definition gdbtypes.h:2079
struct type * builtin_char
Definition gdbtypes.h:2078
struct type * builtin_int
Definition gdbtypes.h:2080
struct type * builtin_unsigned_short
Definition gdbtypes.h:2084
struct type * builtin_unsigned_int
Definition gdbtypes.h:2085
struct type * builtin_unsigned_long
Definition gdbtypes.h:2086
struct type * builtin_void
Definition gdbtypes.h:2077
struct type * builtin_float
Definition gdbtypes.h:2089
asection ** resultp
Definition coffread.c:260
unsigned int c_type
Definition coffread.c:141
CORE_ADDR c_value
Definition coffread.c:138
char * c_name
Definition coffread.c:134
std::vector< asection * > * stabsects
Definition coffread.c:56
char * stabstrdata
Definition coffread.c:58
file_ptr max_lineno_offset
Definition coffread.c:52
asection * stabstrsect
Definition coffread.c:57
file_ptr min_lineno_offset
Definition coffread.c:51
CORE_ADDR textaddr
Definition coffread.c:54
unsigned int textsize
Definition coffread.c:55
struct blockvector * blockvector()
Definition symtab.h:1847
struct pending * locals
Definition buildsym.h:91
struct pending_block * old_blocks
Definition buildsym.h:99
CORE_ADDR start_addr
Definition buildsym.h:112
struct symbol * name
Definition buildsym.h:103
void emit() const
Definition utils.h:416
void set_bitsize(unsigned int bitsize)
Definition gdbtypes.h:582
void set_loc_enumval(LONGEST enumval)
Definition gdbtypes.h:629
void set_name(const char *name)
Definition gdbtypes.h:562
void set_section_index(short idx)
Definition symtab.h:614
CORE_ADDR address
Definition symtab.h:561
void compute_and_set_names(gdb::string_view linkage_name, bool copy_name, struct objfile_per_bfd_storage *per_bfd, gdb::optional< hashval_t > hash=gdb::optional< hashval_t >())
Definition symtab.c:943
void set_language(enum language language, struct obstack *obstack)
Definition symtab.c:803
const char * linkage_name() const
Definition symtab.h:460
void set_linkage_name(const char *linkage_name)
Definition symtab.h:494
void set_type(minimal_symbol_type type)
Definition symtab.h:777
minimal_symbol_type type() const
Definition symtab.h:770
struct gdbarch * arch() const
Definition objfiles.h:507
struct objfile_per_bfd_storage * per_bfd
Definition objfiles.h:744
gdb_bfd_ref_ptr obfd
Definition objfiles.h:740
CORE_ADDR text_section_offset() const
Definition objfiles.h:482
compunit_symtab_range compunits()
Definition objfiles.h:451
objfile_flags flags
Definition objfiles.h:724
auto_obstack objfile_obstack
Definition objfiles.h:760
::section_offsets section_offsets
Definition objfiles.h:786
bool has_partial_symbols()
msymbols_range msymbols()
Definition objfiles.h:464
int nsyms
Definition buildsym.h:80
struct symbol * symbol[PENDINGSIZE]
Definition buildsym.h:81
struct pending * next
Definition buildsym.h:79
enum language language
Definition buildsym.h:65
symbol * value_chain() const
Definition symtab.h:1401
struct type * type() const
Definition symtab.h:1331
void set_aclass_index(unsigned int aclass_index)
Definition symtab.h:1264
LONGEST value_longest() const
Definition symtab.h:1351
void set_type(struct type *type)
Definition symtab.h:1336
void set_is_argument(bool is_argument)
Definition symtab.h:1311
void set_value_address(CORE_ADDR address)
Definition symtab.h:1369
void set_value_longest(LONGEST value)
Definition symtab.h:1356
void set_value_chain(symbol *sym)
Definition symtab.h:1406
void set_domain(domain_enum domain)
Definition symtab.h:1291
struct compunit_symtab * compunit() const
Definition symtab.h:1677
struct type * target_type() const
Definition gdbtypes.h:1037
type_code code() const
Definition gdbtypes.h:956
void copy_fields(struct type *src)
Definition gdbtypes.c:5920
void set_code(type_code code)
Definition gdbtypes.h:962
ULONGEST length() const
Definition gdbtypes.h:983
struct field & field(int idx) const
Definition gdbtypes.h:1012
void set_is_unsigned(bool is_unsigned)
Definition gdbtypes.h:1105
void set_num_fields(unsigned int num_fields)
Definition gdbtypes.h:1000
void set_name(const char *name)
Definition gdbtypes.h:974
void alloc_fields(unsigned int nfields, bool init=true)
Definition gdbtypes.c:5898
void set_length(ULONGEST length)
Definition gdbtypes.h:988
const char * name() const
Definition gdbtypes.h:968
type * index_type() const
Definition gdbtypes.h:1032
void set_fields(struct field *fields)
Definition gdbtypes.h:1019
CORE_ADDR c_value
Definition xcoffread.c:94
char * c_name
Definition xcoffread.c:91
gdb_bfd_ref_ptr symfile_bfd_open(const char *name)
Definition symfile.c:1724
void add_symtab_fns(enum bfd_flavour flavour, const struct sym_fns *sf)
Definition symfile.c:1804
std::string find_separate_debug_file_by_debuglink(struct objfile *objfile, deferred_warnings *warnings)
Definition symfile.c:1534
void default_symfile_offsets(struct objfile *objfile, const section_addr_info &addrs)
Definition symfile.c:625
symfile_segment_data_up default_symfile_segments(bfd *abfd)
Definition symfile.c:711
void symbol_file_add_separate(const gdb_bfd_ref_ptr &bfd, const char *name, symfile_add_flags symfile_flags, struct objfile *objfile)
Definition symfile.c:1134
bfd_byte * default_symfile_relocate(struct objfile *objfile, asection *sectp, bfd_byte *buf)
Definition symfile.c:3595
int register_symbol_register_impl(enum address_class aclass, const struct symbol_register_ops *ops)
Definition symtab.c:6452
@ LOC_STATIC
Definition symtab.h:979
@ LOC_BLOCK
Definition symtab.h:1028
@ LOC_REGISTER
Definition symtab.h:993
@ LOC_LOCAL
Definition symtab.h:1013
@ LOC_CONST
Definition symtab.h:975
@ LOC_TYPEDEF
Definition symtab.h:1018
@ LOC_ARG
Definition symtab.h:997
minimal_symbol_type
Definition symtab.h:670
@ mst_abs
Definition symtab.h:696
@ mst_bss
Definition symtab.h:695
@ mst_data
Definition symtab.h:694
@ mst_unknown
Definition symtab.h:671
@ mst_solib_trampoline
Definition symtab.h:705
@ mst_file_text
Definition symtab.h:708
@ mst_file_data
Definition symtab.h:709
@ mst_text
Definition symtab.h:672
@ mst_file_bss
Definition symtab.h:710
@ VAR_DOMAIN
Definition symtab.h:910
@ STRUCT_DOMAIN
Definition symtab.h:916
static struct xcoff_symbol fcn_cs_saved
Definition xcoffread.c:102
#define complete_symtab(name, start_addr)
Definition xcoffread.c:816