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 165 union internal_auxent *,
169 union internal_auxent *,
174 union internal_auxent *,
181 union internal_auxent *,
194 static char *
getsymname (
struct internal_syment *);
205 struct internal_syment *,
206 union internal_auxent *);
209 long,
unsigned int,
struct objfile *);
228 name = bfd_get_section_name (abfd, sectp);
229 if (strcmp (
name,
".text") == 0)
231 csi->
textaddr = bfd_section_vma (abfd, sectp);
232 csi->
textsize += bfd_section_size (abfd, sectp);
236 csi->
textsize += bfd_section_size (abfd, sectp);
238 else if (strcmp (
name,
".stabstr") == 0)
248 for (s =
name +
sizeof ".stab" - 1; *s !=
'\0'; s++)
289 static struct bfd_section*
292 asection *sect = NULL;
319 asection *sect = NULL;
327 addr = bfd_get_section_vma (abfd, sect);
338 static struct type **
454 if (! isdigit (cs->
c_name[4]))
456 for (i = 5; cs->
c_name[i] !=
'\0' && isdigit (cs->
c_name[i]); i++)
533 count = asect->lineno_count;
542 offset = asect->line_filepos;
566 coff_data_type *cdata = coff_data (abfd);
567 char *
name = bfd_get_filename (abfd);
569 unsigned int num_symbols;
571 int stringtab_offset;
580 num_symbols = bfd_get_symcount (abfd);
581 symtab_offset = cdata->sym_filepos;
582 stringtab_offset = symtab_offset +
583 num_symbols * cdata->local_symesz;
598 (cdata->local_symesz + cdata->local_auxesz);
633 bfd_map_over_sections (abfd,
find_linenos, (
void *) info);
637 info->max_lineno_offset - info->min_lineno_offset);
639 error (
_(
"\"%s\": error reading line numbers."),
name);
647 error (
_(
"\"%s\": can't get string table"),
name);
675 const char *name1 = NULL;
683 int lead = bfd_get_symbol_leading_char (
objfile->
obfd);
686 if (lead !=
'\0' && *name1 == lead)
707 if (!info->stabstrsect)
709 error (
_(
"The debugging information in `%s' is corrupted.\nThe " 710 "file has a `.stabs' section, but no `.stabstr' section."),
716 bfd_seek (abfd, abfd->where, 0);
718 stabstrsize = bfd_section_size (abfd, info->stabstrsect);
721 info->textaddr, info->textsize,
723 info->stabstrsect->filepos, stabstrsize);
740 if (debugfile == NULL)
784 long symtab_offset,
unsigned int nsyms,
791 static struct internal_syment main_sym;
792 static union internal_auxent main_aux;
794 static struct internal_syment fcn_sym_saved;
795 static union internal_auxent fcn_aux_saved;
797 int in_source_file = 0;
798 int next_file_symnum = -1;
800 const char *filestring =
"";
802 int fcn_first_line = 0;
804 int fcn_last_line = 0;
805 int fcn_start_addr = 0;
806 long fcn_line_ptr = 0;
828 val = bfd_seek (
objfile->
obfd, (
long) symtab_offset, 0);
885 fcn_line_ptr = main_aux.x_sym.x_fcnary.x_fcn.x_lnnoptr;
886 fcn_start_addr = tmpaddr;
888 fcn_sym_saved = main_sym;
889 fcn_aux_saved = main_aux;
903 _(
"Bad n_sclass for symbol %s"),
910 next_file_symnum = cs->
c_value;
937 case C_THUMBSTATFUNC:
940 if (strcmp (cs->
c_name,
".text") == 0)
951 main_aux.x_scn.x_scnlen);
1017 if (bfd_section->flags & SEC_CODE)
1025 else if (bfd_section->flags & SEC_ALLOC
1026 && bfd_section->flags & SEC_LOAD)
1032 else if (bfd_section->flags & SEC_ALLOC)
1061 if (strcmp (cs->
c_name,
".bf") == 0)
1071 _(
"`.bf' symbol %d has no aux entry"),
1073 fcn_first_line = main_aux.x_sym.x_misc.x_lnsz.x_lnno;
1074 fcn_first_line_addr = cs->
c_value;
1086 else if (strcmp (cs->
c_name,
".ef") == 0)
1089 error (
_(
"Bad coff function information."));
1098 _(
"`.ef' symbol without matching `.bf' " 1099 "symbol ignored starting at symnum %d"),
1110 _(
"Unmatched .ef symbol(s) ignored " 1111 "starting at symnum %d"),
1119 _(
"`.ef' symbol %d has no aux entry"),
1121 fcn_last_line = 0x7FFFFFFF;
1125 fcn_last_line = main_aux.x_sym.x_misc.x_lnsz.x_lnno;
1134 if (fcn_last_line == 1)
1137 fcn_first_line_addr));
1145 + fcn_aux_saved.x_sym.x_misc.x_fsize
1153 if (strcmp (cs->
c_name,
".bb") == 0)
1160 else if (strcmp (cs->
c_name,
".eb") == 0)
1165 _(
"`.eb' symbol without matching `.bb' " 1166 "symbol ignored starting at symnum %d"),
1172 if (depth-- != newobj->
depth)
1175 _(
"Mismatched .eb symbol ignored " 1176 "starting at symnum %d"),
1200 if ((nsyms == 0) && (
pe_file))
1232 struct internal_syment *sym,
1233 union internal_auxent *aux)
1236 bfd_size_type bytes;
1243 cs->
c_naux = sym->n_numaux & 0xff;
1250 sym->n_type, sym->n_sclass,
1251 0, cs->
c_naux, (
char *) aux);
1254 for (i = 1; i < cs->
c_naux; i++)
1258 error (
_(
"%s: error reading symbols"),
1264 cs->
c_sclass = (sym->n_sclass & 0xff);
1266 cs->
c_type = (unsigned) sym->n_type;
1272 printf (
_(
"thumb symbol %s, class 0x%x\n"), cs->
c_name, cs->
c_sclass);
1288 case C_THUMBEXTFUNC:
1293 case C_THUMBSTATFUNC:
1315 unsigned char lengthbuf[4];
1324 if (bfd_seek (abfd,
offset, 0) < 0)
1327 val = bfd_bread ((
char *) lengthbuf,
sizeof lengthbuf, abfd);
1332 if (val !=
sizeof lengthbuf || length <
sizeof lengthbuf)
1338 memcpy (
stringtab, lengthbuf,
sizeof lengthbuf);
1339 if (length ==
sizeof length)
1342 val = bfd_bread (
stringtab +
sizeof lengthbuf,
1343 length -
sizeof lengthbuf, abfd);
1344 if (val != length -
sizeof lengthbuf ||
stringtab[length - 1] !=
'\0')
1367 static char buffer[SYMNMLEN + 1];
1370 if (symbol_entry->_n._n_n._n_zeroes == 0)
1374 result =
stringtab + symbol_entry->_n._n_n._n_offset;
1378 strncpy (
buffer, symbol_entry->_n._n_name, SYMNMLEN);
1392 static char buffer[BUFSIZ];
1395 if (aux_entry->x_file.x_n.x_zeroes == 0)
1397 if (strlen (
stringtab + aux_entry->x_file.x_n.x_offset) >= BUFSIZ)
1403 strncpy (
buffer, aux_entry->x_file.x_fname, FILNMLEN);
1411 result = lbasename (result);
1438 if (bfd_seek (abfd,
offset, 0) < 0)
1468 #if !defined (L_LNNO32) 1469 #define L_LNNO32(lp) ((lp)->l_lnno) 1478 struct internal_lineno lptr;
1485 _(
"Line number pointer %ld lower than start of line numbers"),
1505 bfd_coff_swap_lineno_in (
symfile_bfd, rawptr, &lptr);
1575 struct symbol *sym, *prev;
1629 union internal_auxent *aux,
1656 || cs->
c_sclass == C_THUMBSTATFUNC)
1676 case C_THUMBEXTFUNC:
1686 case C_THUMBSTATFUNC:
1812 static struct type *
1817 unsigned int new_c_type;
1821 new_c_type = DECREF (c_type);
1827 else if (ISFCN (c_type))
1832 else if (ISARY (c_type))
1835 unsigned short *dim;
1840 if (aux->x_sym.x_tagndx.l == 0)
1844 dim = &aux->x_sym.x_fcnary.x_ary.x_dimen[0];
1847 for (i = 0; *dim && i < DIMNUM - 1; i++, dim++)
1855 index_type, 0, n - 1);
1869 if (cs->
c_naux > 0 && aux->x_sym.x_tagndx.l != 0)
1874 && aux->x_sym.x_tagndx.l >= 0)
1882 _(
"Symbol table entry for %s has bad tagndx value"),
1894 static struct type *
1896 unsigned int c_type,
1897 union internal_auxent *aux,
1900 if (aux->x_sym.x_tagndx.l == 0)
1909 static struct type *
1911 unsigned int c_type,
1912 union internal_auxent *aux,
1941 && aux->x_sym.x_misc.x_lnsz.x_size
1975 aux->x_sym.x_misc.x_lnsz.x_size,
1976 aux->x_sym.x_fcnary.x_fcn.x_endndx.l,
1999 aux->x_sym.x_misc.x_lnsz.x_size,
2000 aux->x_sym.x_fcnary.x_fcn.x_endndx.l,
2024 aux->x_sym.x_misc.x_lnsz.x_size,
2025 aux->x_sym.x_fcnary.x_fcn.x_endndx.l,
2045 && aux->x_sym.x_misc.x_lnsz.x_size
2052 _(
"Unexpected type for symbol %s"), cs->
c_name);
2061 static struct type *
2079 struct internal_syment sub_sym;
2080 union internal_auxent sub_aux;
2101 newobj->
next = list;
2119 newobj->
next = list;
2146 for (n = nfields; list; list = list->
next)
2156 static struct type *
2168 struct internal_syment sub_sym;
2169 union internal_auxent sub_aux;
2174 int unsigned_enum = 1;
2182 o_nsyms = osyms ? osyms->
nsyms : 0;
2233 for (syms = *symlist, n = 0; syms; syms = syms->
next)
2239 for (; j < syms->
nsyms; j++, n++)
static unsigned local_n_tmask
int dwarf2_has_info(struct objfile *objfile, const struct dwarf2_debug_sections *names)
#define SECT_OFF_TEXT(objfile)
#define ALL_OBJFILE_FILETABS(objfile, cu, s)
struct block * finish_block(struct symbol *symbol, struct pending **listhead, struct pending_block *old_blocks, const struct dynamic_prop *static_link, CORE_ADDR start, CORE_ADDR end)
static CORE_ADDR current_source_start_addr
struct type * create_static_range_type(struct type *result_type, struct type *index_type, LONGEST low_bound, LONGEST high_bound)
static struct type * decode_type(struct coff_symbol *, unsigned int, union internal_auxent *, struct objfile *)
static void enter_linenos(long, int, int, struct objfile *)
void dwarf2_build_frame_info(struct objfile *objfile)
#define MSYMBOL_LINKAGE_NAME(symbol)
struct type * builtin_void
#define TYPE_FIELD_NAME(thistype, n)
static void free_stringtab_cleanup(void *ignore)
char * find_separate_debug_file_by_buildid(struct objfile *objfile)
int gdb_bfd_section_index(bfd *abfd, asection *section)
static void coff_symfile_finish(struct objfile *objfile)
int hashname(const char *name)
void coffstab_build_psymtabs(struct objfile *objfile, CORE_ADDR textaddr, unsigned int textsize, struct stab_section_list *stabsects, file_ptr stabstroffset, unsigned int stabstrsize)
void add_symbol_to_list(struct symbol *symbol, struct pending **listhead)
int gdbarch_int_bit(struct gdbarch *gdbarch)
struct type * builtin_double
struct type * create_array_type(struct type *result_type, struct type *element_type, struct type *range_type)
struct type * builtin_long_double
static void coff_start_symtab(struct objfile *objfile, const char *name)
#define TYPE_NAME(thistype)
static struct type ** coff_lookup_type(int index)
#define INIT_CPLUS_SPECIFIC(type)
static char * getsymname(struct internal_syment *)
static int init_stringtab(bfd *, long)
void _initialize_coffread(void)
void set_last_source_file(const char *name)
static void coff_symfile_read(struct objfile *objfile, symfile_add_flags symfile_flags)
#define SYMBOL_SET_LINKAGE_NAME(symbol, linkage_name)
static void patch_opaque_types(struct symtab *)
const struct objfile_type * objfile_type(struct objfile *objfile)
struct compunit_symtab * end_symtab(CORE_ADDR end_addr, int section)
static unsigned local_n_btmask
#define SYMBOL_CLASS(symbol)
void * memset(T *s, int c, size_t n)=delete
void internal_error(const char *file, int line, const char *fmt,...)
void add_symtab_fns(enum bfd_flavour flavour, const struct sym_fns *sf)
EXTERN struct pending * file_symbols
struct type * builtin_float
static CORE_ADDR current_source_end_addr
struct symfile_segment_data * default_symfile_segments(bfd *abfd)
struct symbol * symbol[PENDINGSIZE]
int gdbarch_long_bit(struct gdbarch *gdbarch)
gdb_bfd_ref_ptr symfile_bfd_open(const char *name)
void dwarf2_build_psymtabs(struct objfile *objfile)
#define BLOCKVECTOR_BLOCK(blocklist, n)
static struct type * coff_read_enum_type(int, int, int, struct objfile *)
static struct symbol * opaque_type_chain[HASHSIZE]
struct type * builtin_short
static void coff_free_info(struct objfile *objfile, void *arg)
struct type * builtin_long_long
EXTERN int context_stack_depth
static int type_vector_length
#define SET_FIELD_BITPOS(thisfld, bitpos)
struct type * builtin_long
#define TYPE_FIELD(thistype, n)
static struct type * decode_function_type(struct coff_symbol *, unsigned int, union internal_auxent *, struct objfile *)
static const char * coff_getfilename(union internal_auxent *)
#define INITIAL_TYPE_VECTOR_LENGTH
EXTERN struct subfile * current_subfile
void read_pe_exported_syms(minimal_symbol_reader &reader, struct objfile *objfile)
static void free_stringtab(void)
int objfile_has_partial_symbols(struct objfile *objfile)
static void free_linetab(void)
#define SYMTAB_BLOCKVECTOR(symtab)
bfd_byte * default_symfile_relocate(struct objfile *objfile, asection *sectp, bfd_byte *buf)
EXTERN unsigned int symnum
#define SYMBOL_ACLASS_INDEX(symbol)
#define SYMBOL_VALUE_ADDRESS(symbol)
struct type * builtin_unsigned_long_long
static void coff_locate_sections(bfd *abfd, asection *sectp, void *csip)
void dwarf2_free_objfile(struct objfile *objfile)
CORE_ADDR gdbarch_addr_bits_remove(struct gdbarch *gdbarch, CORE_ADDR addr)
#define SYMBOL_DOMAIN(symbol)
EXTERN struct pending * global_symbols
struct pending_block * old_blocks
static unsigned local_linesz
struct stab_section_list * next
#define SYMBOL_SET_LANGUAGE(symbol, language, obstack)
struct type * builtin_char
static void coff_end_symtab(struct objfile *objfile)
static int nlist_nsyms_global
void free_current_contents(void *ptr)
static unsigned local_n_tshift
struct type * builtin_unsigned_long
static long linetab_offset
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
#define ANOFFSET(secoff, whichone)
struct gdbarch * get_objfile_arch(const struct objfile *objfile)
EXTERN struct pending * local_symbols
struct context_stack * pop_context(void)
struct type * alloc_type(struct objfile *objfile)
const char * get_last_source_file(void)
char * find_separate_debug_file_by_debuglink(struct objfile *objfile)
static struct bfd_section * cs_to_bfd_section(struct coff_symbol *cs, struct objfile *objfile)
#define SYMBOL_LINKAGE_NAME(symbol)
#define complaint(COMPLAINTS, FMT,...)
static int startswith(const char *string, const char *pattern)
#define SET_FIELD_ENUMVAL(thisfld, enumval)
static const struct symbol_register_ops coff_register_funcs
static CORE_ADDR cs_section_address(struct coff_symbol *, bfd *)
#define TYPE_FIELDS(thistype)
void gdbarch_coff_make_msymbol_special(struct gdbarch *gdbarch, int val, struct minimal_symbol *msym)
static void complete_symtab(const char *name, CORE_ADDR start_addr, unsigned int size)
const char * objfile_name(const struct objfile *objfile)
#define FIELD_BITSIZE(thisfld)
static struct symbol * process_coff_symbol(struct coff_symbol *, union internal_auxent *, struct objfile *)
#define TYPE_FIELD_BITSIZE(thistype, n)
static struct type * coff_read_struct_type(int, int, int, struct objfile *)
struct type * builtin_unsigned_short
#define EXTERNAL_NAME(string, abfd)
static int coff_register_index
#define SYMBOL_VALUE(symbol)
static unsigned long linetab_size
#define SYMBOL_VALUE_CHAIN(symbol)
file_ptr max_lineno_offset
struct type * builtin_int
unsigned long hash(const void *addr, int length)
static unsigned local_symesz
PTR xrealloc(PTR ptr, size_t size)
static void find_linenos(bfd *abfd, struct bfd_section *asect, void *vpinfo)
static struct coff_symbol fcn_cs_saved
static struct objfile * coffread_objfile
#define SYMBOL_SET_NAMES(symbol, linkage_name, len, copy_name, objfile)
struct stab_section_list * stabsects
#define MSYMBOL_TYPE(msymbol)
static void read_one_sym(struct coff_symbol *, struct internal_syment *, union internal_auxent *)
#define TYPE_TARGET_TYPE(thistype)
void void void void void void void void void perror_with_name(const char *string) ATTRIBUTE_NORETURN
struct symbol * allocate_symbol(struct objfile *objfile)
static void free_linetab_cleanup(void *ignore)
static const struct objfile_data * coff_objfile_data_key
struct minimal_symbol * record_with_info(const char *name, CORE_ADDR address, enum minimal_symbol_type ms_type, int section)
#define TYPE_CODE(thistype)
void record_debugformat(const char *format)
struct complaints * symfile_complaints
struct minimal_symbol * minsym
file_ptr min_lineno_offset
static void patch_type(struct type *type, struct type *real_type)
const struct quick_symbol_functions psym_functions
static bfd * nlist_bfd_global
static void find_targ_sec(bfd *abfd, asection *sect, void *obj)
static const struct sym_fns coff_sym_fns
int register_symbol_register_impl(enum address_class aclass, const struct symbol_register_ops *ops)
#define TYPE_NFIELDS(thistype)
record_line_ftype record_line
EXTERN CORE_ADDR last_source_start_addr
void default_symfile_offsets(struct objfile *objfile, const struct section_addr_info *addrs)
static struct type ** type_vector
int gdbarch_sdb_reg_to_regnum(struct gdbarch *gdbarch, int sdb_regnr)
static void coff_symfile_init(struct objfile *objfile)
#define TYPE_TAG_NAME(type)
static void coff_new_init(struct objfile *ignore)
static int init_lineno(bfd *, long, int)
#define ALL_OBJFILE_MSYMBOLS(objfile, m)
static int ignore(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
struct type * builtin_unsigned_int
#define TYPE_ALLOC(t, size)
#define SYMBOL_TYPE(symbol)
const struct objfile_data * dbx_objfile_data_key
static struct type * coff_alloc_type(int index)
struct context_stack * push_context(int desc, CORE_ADDR valu)
static unsigned local_auxesz
#define TYPE_LENGTH(thistype)
#define SYMBOL_SECTION(symbol)
struct section_offsets * section_offsets
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)
struct compunit_symtab * start_symtab(struct objfile *objfile, const char *name, const char *comp_dir, CORE_ADDR start_addr, enum language language)
EXTERN int within_function
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
static int is_import_fixup_symbol(struct coff_symbol *cs, enum minimal_symbol_type type)
static int coff_reg_to_regnum(struct symbol *sym, struct gdbarch *gdbarch)
void error(const char *fmt,...)
static unsigned local_n_btshft
static int cs_to_section(struct coff_symbol *, struct objfile *)
struct type * lookup_pointer_type(struct type *type)
#define ALL_BLOCK_SYMBOLS(block, iter, sym)
static struct type * decode_base_type(struct coff_symbol *, unsigned int, union internal_auxent *, struct objfile *)
void do_cleanups(struct cleanup *old_chain)
#define FIELD_TYPE(thisfld)
struct type * builtin_unsigned_char
struct type * lookup_function_type(struct type *type)
#define SYMBOL_IS_ARGUMENT(symbol)
static void coff_symtab_read(minimal_symbol_reader &, long, unsigned int, struct objfile *)
void stabsread_clear_cache(void)
void symbol_file_add_separate(bfd *bfd, const char *name, symfile_add_flags symfile_flags, struct objfile *objfile)