27#include "gdbsupport/gdb_obstack.h"
30#include "coff/internal.h"
67#define EXTERNAL_NAME(string, abfd) \
68 (string[0] == bfd_get_symbol_leading_char (abfd) \
69 ? string + 1 : string)
76#define SDB_TYPE(type) (BTYPE(type) | (type & N_TMASK))
108#define N_BTMASK local_n_btmask
109#define N_BTSHFT local_n_btshft
110#define N_TMASK local_n_tmask
111#define N_TSHIFT local_n_tshift
156#define INITIAL_TYPE_VECTOR_LENGTH 160
171 union internal_auxent *,
175 union internal_auxent *,
180 union internal_auxent *,
187 union internal_auxent *,
194static int init_lineno (bfd *, file_ptr, file_ptr, gdb::unique_xmalloc_ptr<char> *);
196static char *
getsymname (
struct internal_syment *);
200static int init_stringtab (bfd *, file_ptr, gdb::unique_xmalloc_ptr<char> *);
203 struct internal_syment *,
204 union internal_auxent *);
207 file_ptr,
unsigned int,
struct objfile *);
226 name = bfd_section_name (sectp);
227 if (strcmp (
name,
".text") == 0)
229 csi->
textaddr = bfd_section_vma (sectp);
230 csi->
textsize += bfd_section_size (sectp);
232 else if (startswith (
name,
".text"))
234 csi->
textsize += bfd_section_size (sectp);
236 else if (strcmp (
name,
".stabstr") == 0)
240 else if (startswith (
name,
".stab"))
246 for (s =
name +
sizeof ".stab" - 1; *s !=
'\0'; s++)
268 if (sect->target_index == args->targ_index)
269 *args->resultp = sect;
273static struct bfd_section*
276 asection *sect = NULL;
280 args.resultp = §
303 asection *sect = NULL;
308 args.resultp = §
311 addr = bfd_section_vma (sect);
434 if (!startswith (cs->
c_name,
"__fu"))
436 if (! isdigit (cs->
c_name[4]))
438 for (i = 5; cs->
c_name[i] !=
'\0' && isdigit (cs->
c_name[i]); i++)
504 file_ptr offset, maxoff;
507 count = asect->lineno_count;
516 offset = asect->line_filepos;
520 info->min_lineno_offset = offset;
522 maxoff = offset +
size;
523 if (maxoff > info->max_lineno_offset)
524 info->max_lineno_offset = maxoff;
566 const char *
name = msym->linkage_name ();
574 const char *name1 = NULL;
576 if (startswith (
name,
"_imp_"))
578 else if (startswith (
name,
"__imp_"))
583 = bfd_get_symbol_leading_char (
objfile->
obfd.get ());
586 if (lead !=
'\0' && *name1 == lead)
615 coff_data_type *cdata = coff_data (abfd);
616 const char *filename = bfd_get_filename (abfd);
618 unsigned int num_symbols;
619 file_ptr symtab_offset;
620 file_ptr stringtab_offset;
621 unsigned int stabstrsize;
627 scoped_restore restore_stabsects
628 = make_scoped_restore (&info->stabsects, &
stabsects);
631 num_symbols = bfd_get_symcount (abfd);
632 symtab_offset = cdata->sym_filepos;
633 stringtab_offset = symtab_offset +
634 num_symbols * cdata->local_symesz;
648 gdb::def_vector<char> temp_storage (cdata->local_symesz
649 + cdata->local_auxesz);
659 startswith (bfd_get_target (
objfile->
obfd.get ()),
"pe")
660 || startswith (bfd_get_target (
objfile->
obfd.get ()),
"epoc-pe");
664 info->min_lineno_offset = 0;
665 info->max_lineno_offset = 0;
681 scoped_restore restore_linetab = make_scoped_restore (&
linetab);
682 gdb::unique_xmalloc_ptr<char> linetab_storage;
686 bfd_map_over_sections (abfd,
find_linenos, (
void *) info);
689 info->max_lineno_offset - info->min_lineno_offset,
692 error (_(
"\"%s\": error reading line numbers."), filename);
697 scoped_restore restore_stringtab = make_scoped_restore (&
stringtab);
698 gdb::unique_xmalloc_ptr<char> stringtab_storage;
699 val =
init_stringtab (abfd, stringtab_offset, &stringtab_storage);
701 error (_(
"\"%s\": can't get string table"), filename);
708 if (!info->stabsects->empty())
710 if (!info->stabstrsect)
712 error (_(
"The debugging information in `%s' is corrupted.\nThe "
713 "file has a `.stabs' section, but no `.stabstr' section."),
719 bfd_seek (abfd, abfd->where, 0);
721 stabstrsize = bfd_section_size (info->stabstrsect);
724 info->textaddr, info->textsize,
726 info->stabstrsect->filepos, stabstrsize);
739 if (debugfile.empty ())
742 if (!debugfile.empty ())
778 file_ptr symtab_offset,
unsigned int nsyms,
785 static struct internal_syment main_sym;
786 static union internal_auxent main_aux;
788 static struct internal_syment fcn_sym_saved;
789 static union internal_auxent fcn_aux_saved;
791 int in_source_file = 0;
792 int next_file_symnum = -1;
794 const char *filestring =
"";
796 int fcn_first_line = 0;
797 CORE_ADDR fcn_first_line_addr = 0;
798 int fcn_last_line = 0;
799 int fcn_start_addr = 0;
800 long fcn_line_ptr = 0;
824 val = bfd_seek (
objfile->
obfd.get (), symtab_offset, 0);
883 fcn_line_ptr = main_aux.x_sym.x_fcnary.x_fcn.x_lnnoptr;
884 fcn_start_addr = tmpaddr;
886 fcn_sym_saved = main_sym;
887 fcn_aux_saved = main_aux;
900 complaint (_(
"Bad n_sclass for symbol %s"),
907 next_file_symnum = cs->
c_value;
935 case C_THUMBSTATFUNC:
938 if (strcmp (cs->
c_name,
".text") == 0)
949 main_aux.x_scn.x_scnlen);
957 && (startswith (cs->
c_name,
"LI%")
958 || startswith (cs->
c_name,
"LF%")
959 || startswith (cs->
c_name,
"LC%")
960 || startswith (cs->
c_name,
"LP%")
961 || startswith (cs->
c_name,
"LPB%")
962 || startswith (cs->
c_name,
"LBB%")
963 || startswith (cs->
c_name,
"LBE%")
964 || startswith (cs->
c_name,
"LPBX%")))
982 CORE_ADDR offset = 0;
1016 if (bfd_section->flags & SEC_CODE)
1024 else if (bfd_section->flags & SEC_ALLOC
1025 && bfd_section->flags & SEC_LOAD)
1031 else if (bfd_section->flags & SEC_ALLOC)
1060 if (strcmp (cs->
c_name,
".bf") == 0)
1069 complaint (_(
"`.bf' symbol %d has no aux entry"),
1071 fcn_first_line = main_aux.x_sym.x_misc.x_lnsz.x_lnno;
1072 fcn_first_line_addr = cs->
c_value;
1084 else if (strcmp (cs->
c_name,
".ef") == 0)
1087 error (_(
"Bad coff function information."));
1095 complaint (_(
"`.ef' symbol without matching `.bf' "
1096 "symbol ignored starting at symnum %d"),
1106 complaint (_(
"Unmatched .ef symbol(s) ignored "
1107 "starting at symnum %d"),
1114 complaint (_(
"`.ef' symbol %d has no aux entry"),
1116 fcn_last_line = 0x7FFFFFFF;
1120 fcn_last_line = main_aux.x_sym.x_misc.x_lnsz.x_lnno;
1129 if (fcn_last_line == 1)
1132 fcn_first_line_addr));
1140 + fcn_aux_saved.x_sym.x_misc.x_fsize
1147 if (strcmp (cs->
c_name,
".bb") == 0)
1153 else if (strcmp (cs->
c_name,
".eb") == 0)
1157 complaint (_(
"`.eb' symbol without matching `.bb' "
1158 "symbol ignored starting at symnum %d"),
1166 complaint (_(
"Mismatched .eb symbol ignored "
1167 "starting at symnum %d"),
1197 for (
symtab *s : cu->filetabs ())
1214 struct internal_syment *sym,
1215 union internal_auxent *aux)
1218 bfd_size_type bytes;
1225 cs->
c_naux = sym->n_numaux & 0xff;
1232 sym->n_type, sym->n_sclass,
1233 0, cs->
c_naux, (
char *) aux);
1236 for (i = 1; i < cs->
c_naux; i++)
1240 error (_(
"%s: error reading symbols"),
1246 cs->
c_sclass = (sym->n_sclass & 0xff);
1248 cs->
c_type = (unsigned) sym->n_type;
1254 printf (_(
"thumb symbol %s, class 0x%x\n"), cs->
c_name, cs->
c_sclass);
1270 case C_THUMBEXTFUNC:
1275 case C_THUMBSTATFUNC:
1295 unsigned char lengthbuf[4];
1302 if (bfd_seek (abfd, offset, 0) < 0)
1305 val = bfd_bread ((
char *) lengthbuf,
sizeof lengthbuf, abfd);
1310 if (val !=
sizeof lengthbuf || length <
sizeof lengthbuf)
1313 storage->reset ((
char *)
xmalloc (length));
1317 memcpy (
stringtab, lengthbuf,
sizeof lengthbuf);
1318 if (length ==
sizeof length)
1321 val = bfd_bread (
stringtab +
sizeof lengthbuf,
1322 length -
sizeof lengthbuf, abfd);
1323 if (val != length -
sizeof lengthbuf ||
stringtab[length - 1] !=
'\0')
1332 static char buffer[SYMNMLEN + 1];
1335 if (symbol_entry->_n._n_n._n_zeroes == 0)
1339 result =
stringtab + symbol_entry->_n._n_n._n_offset;
1343 strncpy (buffer, symbol_entry->_n._n_name, SYMNMLEN);
1344 buffer[SYMNMLEN] =
'\0';
1357 static char buffer[BUFSIZ];
1360 if (aux_entry->x_file.x_n.x_n.x_zeroes == 0)
1362 if (strlen (
stringtab + aux_entry->x_file.x_n.x_n.x_offset) >= BUFSIZ)
1363 internal_error (_(
"coff file name too long"));
1364 strcpy (buffer,
stringtab + aux_entry->x_file.x_n.x_n.x_offset);
1368 strncpy (buffer, aux_entry->x_file.x_n.x_fname, FILNMLEN);
1369 buffer[FILNMLEN] =
'\0';
1376 result = lbasename (result);
1388 gdb::unique_xmalloc_ptr<char> *storage)
1398 if (bfd_seek (abfd, offset, 0) < 0)
1405 val = bfd_bread (storage->get (),
size, abfd);
1415#if !defined (L_LNNO32)
1416#define L_LNNO32(lp) ((lp)->l_lnno)
1425 struct internal_lineno lptr;
1431 complaint (_(
"Line number pointer %s lower than start of line numbers"),
1432 plongest (file_offset));
1451 bfd_coff_swap_lineno_in (
symfile_bfd, rawptr, &lptr);
1457 CORE_ADDR addr = lptr.l_addr.l_paddr;
1479 memcpy (fields, real_target->
fields (), field_size);
1482 if (real_target->
name ())
1511 && real_sym->
type ()->
code () == TYPE_CODE_PTR
1516 struct symbol *sym, *prev;
1562 union internal_auxent *aux,
1589 || cs->
c_sclass == C_THUMBSTATFUNC)
1609 case C_THUMBEXTFUNC:
1618 case C_THUMBSTATFUNC:
1668 if (sym->
type ()->
code () == TYPE_CODE_PTR
1669 || sym->
type ()->
code () == TYPE_CODE_FUNC)
1701 if (sym->
type ()->
code () == TYPE_CODE_PTR
1746 unsigned int new_c_type;
1750 new_c_type = DECREF (c_type);
1756 else if (ISFCN (c_type))
1761 else if (ISARY (c_type))
1764 unsigned short *dim;
1769 if (aux->x_sym.x_tagndx.l == 0)
1773 dim = &aux->x_sym.x_fcnary.x_ary.x_dimen[0];
1776 for (i = 0; *dim && i < DIMNUM - 1; i++, dim++)
1796 if (cs->
c_naux > 0 && aux->x_sym.x_tagndx.l != 0)
1801 && aux->x_sym.x_tagndx.l >= 0)
1808 complaint (_(
"Symbol table entry for %s has bad tagndx value"),
1822 unsigned int c_type,
1823 union internal_auxent *aux,
1826 if (aux->x_sym.x_tagndx.l == 0)
1837 unsigned int c_type,
1838 union internal_auxent *aux,
1867 && aux->x_sym.x_misc.x_lnsz.x_size
1897 aux->x_sym.x_misc.x_lnsz.x_size,
1898 aux->x_sym.x_fcnary.x_fcn.x_endndx.l,
1917 aux->x_sym.x_misc.x_lnsz.x_size,
1918 aux->x_sym.x_fcnary.x_fcn.x_endndx.l,
1938 aux->x_sym.x_misc.x_lnsz.x_size,
1939 aux->x_sym.x_fcnary.x_fcn.x_endndx.l,
1959 && aux->x_sym.x_misc.x_lnsz.x_size
1992 struct internal_syment sub_sym;
1993 union internal_auxent sub_aux;
2014 newobj->next = list;
2031 newobj->next = list;
2057 for (n = nfields; list; list = list->next)
2079 struct internal_syment sub_sym;
2080 union internal_auxent sub_aux;
2085 int unsigned_enum = 1;
2093 o_nsyms = osyms ? osyms->
nsyms : 0;
2143 for (syms = *symlist, n = 0; syms; syms = syms->
next)
2149 for (; j < syms->
nsyms; j++, n++)
void * xrealloc(void *ptr, size_t size)
#define ALL_BLOCK_SYMBOLS(block, iter, sym)
std::string find_separate_debug_file_by_buildid(struct objfile *objfile)
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 compunit_symtab * end_compunit_symtab(CORE_ADDR end_addr, int section)
struct subfile * get_current_subfile()
void record_debugformat(const char *format)
void set_last_source_file(const char *name)
void record_line(struct subfile *subfile, int line, CORE_ADDR pc)
struct pending ** get_global_symbols()
const char * get_last_source_file()
struct pending ** get_local_symbols()
void add_symbol_to_list(struct symbol *symbol, struct pending **listhead)
struct minimal_symbol * record_full(gdb::string_view name, bool copy_name, CORE_ADDR address, enum minimal_symbol_type ms_type, int section)
void read_pe_exported_syms(minimal_symbol_reader &reader, struct objfile *objfile)
static struct objfile * coffread_objfile
static void find_linenos(bfd *abfd, struct bfd_section *asect, void *vpinfo)
static int coff_register_index
static file_ptr linetab_offset
static void coff_start_compunit_symtab(struct objfile *objfile, const char *name)
static void coff_read_minsyms(file_ptr symtab_offset, unsigned int nsyms, struct objfile *objfile)
static const char * coff_getfilename(union internal_auxent *)
static const struct sym_fns coff_sym_fns
static unsigned local_symesz
static void coff_end_compunit_symtab(struct objfile *objfile)
static int is_import_fixup_symbol(struct coff_symbol *cs, enum minimal_symbol_type type)
static int init_stringtab(bfd *, file_ptr, gdb::unique_xmalloc_ptr< char > *)
static CORE_ADDR cs_section_address(struct coff_symbol *, bfd *)
static unsigned local_linesz
static unsigned local_n_tshift
static int init_lineno(bfd *, file_ptr, file_ptr, gdb::unique_xmalloc_ptr< char > *)
static file_ptr linetab_size
static int type_vector_length
static CORE_ADDR current_source_end_addr
static void read_one_sym(struct coff_symbol *, struct internal_syment *, union internal_auxent *)
static struct type ** coff_lookup_type(int index)
static const registry< objfile >::key< coff_symfile_info > coff_objfile_data_key
static int coff_reg_to_regnum(struct symbol *sym, struct gdbarch *gdbarch)
static void coff_new_init(struct objfile *ignore)
static struct type * coff_read_struct_type(int, int, int, struct objfile *)
static void coff_symfile_finish(struct objfile *objfile)
static void coff_symtab_read(minimal_symbol_reader &, file_ptr, unsigned int, struct objfile *)
static CORE_ADDR current_source_start_addr
#define INITIAL_TYPE_VECTOR_LENGTH
static void patch_type(struct type *type, struct type *real_type)
static unsigned local_auxesz
static struct type * decode_type(struct coff_symbol *, unsigned int, union internal_auxent *, struct objfile *)
static const struct symbol_register_ops coff_register_funcs
static struct symbol * process_coff_symbol(struct coff_symbol *, union internal_auxent *, struct objfile *)
static void enter_linenos(file_ptr, int, int, struct objfile *)
static void coff_symfile_init(struct objfile *objfile)
static bfd * nlist_bfd_global
void stabsread_clear_cache(void)
static struct type * coff_read_enum_type(int, int, int, struct objfile *)
static struct type * coff_alloc_type(int index)
static struct type * decode_function_type(struct coff_symbol *, unsigned int, union internal_auxent *, struct objfile *)
static struct type ** type_vector
static char * getsymname(struct internal_syment *)
static void coff_symfile_read(struct objfile *objfile, symfile_add_flags symfile_flags)
void _initialize_coffread()
static struct bfd_section * cs_to_bfd_section(struct coff_symbol *cs, struct objfile *objfile)
static unsigned local_n_btmask
static unsigned local_n_tmask
static struct minimal_symbol * record_minimal_symbol(minimal_symbol_reader &reader, struct coff_symbol *cs, CORE_ADDR address, enum minimal_symbol_type type, int section, struct objfile *objfile)
#define EXTERNAL_NAME(string, abfd)
static void find_targ_sec(bfd *abfd, asection *sect, void *obj)
static int nlist_nsyms_global
static struct type * decode_base_type(struct coff_symbol *, unsigned int, union internal_auxent *, struct objfile *)
static void coff_locate_sections(bfd *abfd, asection *sectp, void *csip)
static int cs_to_section(struct coff_symbol *, struct objfile *)
static struct symbol * opaque_type_chain[HASHSIZE]
static unsigned local_n_btshft
static void patch_opaque_types(struct symtab *)
#define complaint(FMT,...)
void coffstab_build_psymtabs(struct objfile *objfile, CORE_ADDR textaddr, unsigned int textsize, const std::vector< asection * > &stabsects, file_ptr stabstroffset, unsigned int stabstrsize)
int gdb_bfd_section_index(bfd *abfd, asection *section)
gdb::ref_ptr< struct bfd, gdb_bfd_ref_policy > gdb_bfd_ref_ptr
void gdbarch_coff_make_msymbol_special(struct gdbarch *gdbarch, int val, struct minimal_symbol *msym)
int gdbarch_sdb_reg_to_regnum(struct gdbarch *gdbarch, int sdb_regnr)
int gdbarch_int_bit(struct gdbarch *gdbarch)
CORE_ADDR gdbarch_addr_bits_remove(struct gdbarch *gdbarch, CORE_ADDR addr)
int gdbarch_long_bit(struct gdbarch *gdbarch)
struct type * lookup_pointer_type(struct type *type)
struct type * lookup_function_type(struct type *type)
struct type * create_array_type(struct type *result_type, struct type *element_type, struct type *range_type)
struct type * alloc_type(struct objfile *objfile)
struct type * create_static_range_type(struct type *result_type, struct type *index_type, LONGEST low_bound, LONGEST high_bound)
#define TYPE_FIELD_BITSIZE(thistype, n)
#define INIT_CPLUS_SPECIFIC(type)
#define TYPE_ALLOC(t, size)
#define FIELD_BITSIZE(thisfld)
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
const char * objfile_name(const struct objfile *objfile)
#define SECT_OFF_TEXT(objfile)
void dwarf2_initialize_objfile(struct objfile *objfile)
int dwarf2_has_info(struct objfile *, const struct dwarf2_debug_sections *, bool=false)
int hashname(const char *name)
struct block * static_block()
struct minimal_symbol * minsym
std::vector< asection * > * stabsects
file_ptr max_lineno_offset
file_ptr min_lineno_offset
struct blockvector * blockvector()
struct pending_block * old_blocks
void set_loc_enumval(LONGEST enumval)
void set_name(const char *name)
void set_section_index(short idx)
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 >())
void set_language(enum language language, struct obstack *obstack)
const char * linkage_name() const
void set_linkage_name(const char *linkage_name)
void set_type(minimal_symbol_type type)
minimal_symbol_type type() const
struct type * builtin_unsigned_int
struct type * builtin_int
struct type * builtin_long
struct type * builtin_unsigned_long
struct type * builtin_void
struct type * builtin_char
struct type * builtin_long_long
struct type * builtin_long_double
struct type * builtin_float
struct type * builtin_short
struct type * builtin_unsigned_char
struct type * builtin_unsigned_short
struct type * builtin_double
struct type * builtin_unsigned_long_long
struct gdbarch * arch() const
struct objfile_per_bfd_storage * per_bfd
CORE_ADDR text_section_offset() const
compunit_symtab_range compunits()
auto_obstack objfile_obstack
::section_offsets section_offsets
bool has_partial_symbols()
msymbols_range msymbols()
struct symbol * symbol[PENDINGSIZE]
symbol * value_chain() const
address_class aclass() const
struct type * type() const
domain_enum domain() const
void set_aclass_index(unsigned int aclass_index)
LONGEST value_longest() const
void set_type(struct type *type)
void set_is_argument(bool is_argument)
void set_value_address(CORE_ADDR address)
void set_value_longest(LONGEST value)
void set_value_chain(symbol *sym)
void set_domain(domain_enum domain)
struct compunit_symtab * compunit() const
struct type * target_type() const
void set_code(type_code code)
struct field & field(int idx) const
void set_is_unsigned(bool is_unsigned)
void set_num_fields(int num_fields)
void set_name(const char *name)
void set_length(ULONGEST length)
struct field * fields() const
const char * name() const
type * index_type() const
void set_fields(struct field *fields)
gdb_bfd_ref_ptr symfile_bfd_open(const char *name)
void add_symtab_fns(enum bfd_flavour flavour, const struct sym_fns *sf)
void default_symfile_offsets(struct objfile *objfile, const section_addr_info &addrs)
symfile_segment_data_up default_symfile_segments(bfd *abfd)
void symbol_file_add_separate(const gdb_bfd_ref_ptr &bfd, const char *name, symfile_add_flags symfile_flags, struct objfile *objfile)
std::string find_separate_debug_file_by_debuglink(struct objfile *objfile)
bfd_byte * default_symfile_relocate(struct objfile *objfile, asection *sectp, bfd_byte *buf)
int register_symbol_register_impl(enum address_class aclass, const struct symbol_register_ops *ops)
void perror_with_name(const char *string)
static struct xcoff_symbol fcn_cs_saved
#define complete_symtab(name, start_addr)