30 #include "coff/internal.h"
69 #define EXTERNAL_NAME(string, abfd) \
70 (string[0] == bfd_get_symbol_leading_char (abfd) \
71 ? string + 1 : string)
78 #define SDB_TYPE(type) (BTYPE(type) | (type & N_TMASK))
110 #define N_BTMASK local_n_btmask
111 #define N_BTSHFT local_n_btshft
112 #define N_TMASK local_n_tmask
113 #define N_TSHIFT local_n_tshift
158 #define INITIAL_TYPE_VECTOR_LENGTH 160
167 union internal_auxent *,
171 union internal_auxent *,
176 union internal_auxent *,
183 union internal_auxent *,
196 static char *
getsymname (
struct internal_syment *);
207 struct internal_syment *,
208 union internal_auxent *);
229 name = bfd_get_section_name (abfd, sectp);
230 if (strcmp (name,
".text") == 0)
232 csi->
textaddr = bfd_section_vma (abfd, sectp);
233 csi->
textsize += bfd_section_size (abfd, sectp);
237 csi->
textsize += bfd_section_size (abfd, sectp);
239 else if (strcmp (name,
".stabstr") == 0)
249 for (s = name +
sizeof ".stab" - 1; *s !=
'\0'; s++)
291 static struct bfd_section*
294 asection *sect = NULL;
321 asection *sect = NULL;
329 addr = bfd_get_section_vma (abfd, sect);
340 static struct type **
351 type_vector = (
struct type **)
354 memset (&type_vector[old_vector_length], 0,
357 return &type_vector[index];
454 if (! isdigit (cs->
c_name[4]))
456 for (i = 5; cs->
c_name[i] !=
'\0' && isdigit (cs->
c_name[i]); i++)
484 type, section, objfile);
533 count = asect->lineno_count;
542 offset = asect->line_filepos;
548 maxoff = offset +
size;
566 bfd *abfd = objfile->
obfd;
567 coff_data_type *cdata = coff_data (abfd);
568 char *
name = bfd_get_filename (abfd);
570 unsigned int num_symbols;
572 int stringtab_offset;
573 struct cleanup *back_to, *cleanup_minimal_symbols;
581 num_symbols = bfd_get_symcount (abfd);
582 symtab_offset = cdata->sym_filepos;
583 stringtab_offset = symtab_offset +
584 num_symbols * cdata->local_symesz;
599 (cdata->local_symesz + cdata->local_auxesz);
634 bfd_map_over_sections (abfd,
find_linenos, (
void *) info);
640 error (
_(
"\"%s\": error reading line numbers."), name);
648 error (
_(
"\"%s\": can't get string table"), name);
677 const char *name1 = NULL;
685 int lead = bfd_get_symbol_leading_char (objfile->
obfd);
688 if (lead !=
'\0' && *name1 == lead)
713 error (
_(
"The debugging information in `%s' is corrupted.\nThe "
714 "file has a `.stabs' section, but no `.stabstr' section."),
720 bfd_seek (abfd, abfd->where, 0);
722 stabstrsize = bfd_section_size (abfd, info->
stabstrsect);
744 if (debugfile == NULL)
793 struct coff_symbol *cs = &coff_symbol;
794 static struct internal_syment main_sym;
795 static union internal_auxent main_aux;
796 struct coff_symbol fcn_cs_saved;
797 static struct internal_syment fcn_sym_saved;
798 static union internal_auxent fcn_aux_saved;
800 int in_source_file = 0;
801 int next_file_symnum = -1;
803 const char *filestring =
"";
805 int fcn_first_line = 0;
807 int fcn_last_line = 0;
808 int fcn_start_addr = 0;
809 long fcn_line_ptr = 0;
828 bfd_seek (objfile->
obfd, 0, 0);
831 val = bfd_seek (objfile->
obfd, (
long) symtab_offset, 0);
835 coffread_objfile = objfile;
839 memset (opaque_type_chain, 0,
sizeof opaque_type_chain);
844 type_vector = (
struct type **)
890 fcn_line_ptr = main_aux.x_sym.x_fcnary.x_fcn.x_lnnoptr;
891 fcn_start_addr = tmpaddr;
893 fcn_sym_saved = main_sym;
894 fcn_aux_saved = main_aux;
908 _(
"Bad n_sclass for symbol %s"),
915 next_file_symnum = cs->
c_value;
942 case C_THUMBSTATFUNC:
945 if (strcmp (cs->
c_name,
".text") == 0)
956 main_aux.x_scn.x_scnlen);
1022 if (bfd_section->flags & SEC_CODE)
1030 else if (bfd_section->flags & SEC_ALLOC
1031 && bfd_section->flags & SEC_LOAD)
1037 else if (bfd_section->flags & SEC_ALLOC)
1058 (cs, &main_aux, objfile);
1066 if (strcmp (cs->
c_name,
".bf") == 0)
1076 _(
"`.bf' symbol %d has no aux entry"),
1078 fcn_first_line = main_aux.x_sym.x_misc.x_lnsz.x_lnno;
1079 fcn_first_line_addr = cs->
c_value;
1089 &fcn_aux_saved, objfile);
1091 else if (strcmp (cs->
c_name,
".ef") == 0)
1094 error (
_(
"Bad coff function information."));
1103 _(
"`.ef' symbol without matching `.bf' "
1104 "symbol ignored starting at symnum %d"),
1115 _(
"Unmatched .ef symbol(s) ignored "
1116 "starting at symnum %d"),
1124 _(
"`.ef' symbol %d has no aux entry"),
1126 fcn_last_line = 0x7FFFFFFF;
1130 fcn_last_line = main_aux.x_sym.x_misc.x_lnsz.x_lnno;
1139 if (fcn_last_line == 1)
1142 fcn_first_line_addr));
1145 fcn_last_line, objfile);
1150 + fcn_aux_saved.x_sym.x_misc.x_fsize
1158 if (strcmp (cs->
c_name,
".bb") == 0)
1165 else if (strcmp (cs->
c_name,
".eb") == 0)
1170 _(
"`.eb' symbol without matching `.bb' "
1171 "symbol ignored starting at symnum %d"),
1177 if (depth-- != newobj->
depth)
1180 _(
"Mismatched .eb symbol ignored "
1181 "starting at symnum %d"),
1205 if ((nsyms == 0) && (
pe_file))
1225 coffread_objfile = NULL;
1237 struct internal_syment *sym,
1238 union internal_auxent *aux)
1241 bfd_size_type bytes;
1248 cs->
c_naux = sym->n_numaux & 0xff;
1255 sym->n_type, sym->n_sclass,
1256 0, cs->
c_naux, (
char *) aux);
1259 for (i = 1; i < cs->
c_naux; i++)
1263 error (
_(
"%s: error reading symbols"),
1269 cs->
c_sclass = (sym->n_sclass & 0xff);
1271 cs->
c_type = (unsigned) sym->n_type;
1277 printf (
_(
"thumb symbol %s, class 0x%x\n"), cs->
c_name, cs->
c_sclass);
1293 case C_THUMBEXTFUNC:
1298 case C_THUMBSTATFUNC:
1320 unsigned char lengthbuf[4];
1329 if (bfd_seek (abfd, offset, 0) < 0)
1332 val = bfd_bread ((
char *) lengthbuf,
sizeof lengthbuf, abfd);
1337 if (val !=
sizeof lengthbuf || length <
sizeof lengthbuf)
1343 memcpy (
stringtab, lengthbuf,
sizeof lengthbuf);
1344 if (length ==
sizeof length)
1347 val = bfd_bread (
stringtab +
sizeof lengthbuf,
1348 length -
sizeof lengthbuf, abfd);
1349 if (val != length -
sizeof lengthbuf ||
stringtab[length - 1] !=
'\0')
1372 static char buffer[SYMNMLEN + 1];
1375 if (symbol_entry->_n._n_n._n_zeroes == 0)
1379 result =
stringtab + symbol_entry->_n._n_n._n_offset;
1383 strncpy (buffer, symbol_entry->_n._n_name, SYMNMLEN);
1384 buffer[SYMNMLEN] =
'\0';
1397 static char buffer[BUFSIZ];
1400 if (aux_entry->x_file.x_n.x_zeroes == 0)
1402 if (strlen (
stringtab + aux_entry->x_file.x_n.x_offset) >= BUFSIZ)
1404 strcpy (buffer,
stringtab + aux_entry->x_file.x_n.x_offset);
1408 strncpy (buffer, aux_entry->x_file.x_fname, FILNMLEN);
1409 buffer[FILNMLEN] =
'\0';
1416 result = lbasename (result);
1443 if (bfd_seek (abfd, offset, 0) < 0)
1449 val = bfd_bread (
linetab, size, abfd);
1473 #if !defined (L_LNNO32)
1474 #define L_LNNO32(lp) ((lp)->l_lnno)
1483 struct internal_lineno lptr;
1490 _(
"Line number pointer %ld lower than start of line numbers"),
1510 bfd_coff_swap_lineno_in (
symfile_bfd, rawptr, &lptr);
1580 struct symbol *sym, *prev;
1583 for (sym = opaque_type_chain[hash]; sym;)
1605 sym = opaque_type_chain[
hash];
1634 union internal_auxent *aux,
1661 || cs->
c_sclass == C_THUMBSTATFUNC)
1681 case C_THUMBEXTFUNC:
1691 case C_THUMBSTATFUNC:
1784 opaque_type_chain[i] = sym;
1817 static struct type *
1822 unsigned int new_c_type;
1826 new_c_type = DECREF (c_type);
1829 type =
decode_type (cs, new_c_type, aux, objfile);
1832 else if (ISFCN (c_type))
1834 type =
decode_type (cs, new_c_type, aux, objfile);
1837 else if (ISARY (c_type))
1840 unsigned short *dim;
1841 struct type *base_type, *index_type, *range_type;
1845 if (aux->x_sym.x_tagndx.l == 0)
1849 dim = &aux->x_sym.x_fcnary.x_ary.x_dimen[0];
1852 for (i = 0; *dim && i < DIMNUM - 1; i++, dim++)
1856 base_type =
decode_type (cs, new_c_type, aux, objfile);
1860 index_type, 0, n - 1);
1863 base_type, range_type);
1874 if (cs->
c_naux > 0 && aux->x_sym.x_tagndx.l != 0)
1879 && aux->x_sym.x_tagndx.l >= 0)
1887 _(
"Symbol table entry for %s has bad tagndx value"),
1899 static struct type *
1901 unsigned int c_type,
1902 union internal_auxent *aux,
1905 if (aux->x_sym.x_tagndx.l == 0)
1909 return decode_type (cs, DECREF (c_type), aux, objfile);
1914 static struct type *
1916 unsigned int c_type,
1917 union internal_auxent *aux,
1946 && aux->x_sym.x_misc.x_lnsz.x_size
1980 aux->x_sym.x_misc.x_lnsz.x_size,
1981 aux->x_sym.x_fcnary.x_fcn.x_endndx.l,
2004 aux->x_sym.x_misc.x_lnsz.x_size,
2005 aux->x_sym.x_fcnary.x_fcn.x_endndx.l,
2029 aux->x_sym.x_misc.x_lnsz.x_size,
2030 aux->x_sym.x_fcnary.x_fcn.x_endndx.l,
2050 && aux->x_sym.x_misc.x_lnsz.x_size
2057 _(
"Unexpected type for symbol %s"), cs->
c_name);
2066 static struct type *
2084 struct internal_syment sub_sym;
2085 union internal_auxent sub_aux;
2106 newobj->
next = list;
2111 name, strlen (name));
2123 newobj->
next = list;
2128 name, strlen (name));
2149 for (n = nfields; list; list = list->
next)
2159 static struct type *
2171 struct internal_syment sub_sym;
2172 union internal_auxent sub_aux;
2177 int unsigned_enum = 1;
2185 o_nsyms = osyms ? osyms->
nsyms : 0;
2200 name, strlen (name)));
2236 for (syms = *symlist, n = 0; syms; syms = syms->
next)
2242 for (; j < syms->
nsyms; j++, n++)
static unsigned local_n_tmask
int dwarf2_has_info(struct objfile *objfile, const struct dwarf2_debug_sections *names)
static struct minimal_symbol * record_minimal_symbol(struct coff_symbol *cs, CORE_ADDR address, enum minimal_symbol_type type, int section, struct objfile *objfile)
#define SECT_OFF_TEXT(objfile)
#define ALL_OBJFILE_FILETABS(objfile, cu, s)
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)
#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 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)
void dwarf2_build_psymtabs(struct objfile *objfile)
#define BLOCKVECTOR_BLOCK(blocklist, n)
static struct type * coff_read_enum_type(int, int, int, struct objfile *)
struct type * builtin_short
struct minimal_symbol * prim_record_minimal_symbol_and_info(const char *name, CORE_ADDR address, enum minimal_symbol_type ms_type, int section, struct objfile *objfile)
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
struct obstack objfile_obstack
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
void symbol_file_add_separate(bfd *bfd, const char *name, int symfile_flags, struct objfile *objfile)
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
void complaint(struct complaints **complaints, const char *fmt,...)
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)
static int startswith(const char *string, const char *pattern)
struct cleanup * make_cleanup_discard_minimal_symbols(void)
#define SET_FIELD_ENUMVAL(thisfld, enumval)
static CORE_ADDR cs_section_address(struct coff_symbol *, bfd *)
#define TYPE_FIELDS(thistype)
static void coff_symfile_read(struct objfile *objfile, int symfile_flags)
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)
struct cleanup * make_cleanup_bfd_unref(bfd *abfd)
struct compunit_symtab * start_symtab(struct objfile *objfile, const char *name, const char *comp_dir, CORE_ADDR start_addr)
static struct symbol * process_coff_symbol(struct coff_symbol *, union internal_auxent *, struct objfile *)
#define TYPE_FIELD_BITSIZE(thistype, n)
bfd * symfile_bfd_open(const char *name)
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)
void init_minimal_symbol_collection(void)
file_ptr max_lineno_offset
struct type * builtin_int
unsigned long hash(const void *addr, int length)
void read_pe_exported_syms(struct objfile *objfile)
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 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
#define DBX_SYMFILE_INFO(o)
#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)
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
EXTERN int within_function
void install_minimal_symbols(struct objfile *objfile)
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 void coff_symtab_read(long, unsigned int, struct objfile *)
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)
struct block * finish_block(struct symbol *symbol, struct pending **listhead, struct pending_block *old_blocks, CORE_ADDR start, CORE_ADDR end)
void stabsread_clear_cache(void)