X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gdb%2Fcoffread.c;h=4723662f14088d80a313e85cb12c6032f0303123;hb=578c64a45a0e47fd0af53c77339ec0c26ef4874a;hp=a43d9e2679ee7f3faa14737c55af25a58ce21e10;hpb=653223d3561b5976d12ade101113af9d08348b8c;p=binutils-gdb.git diff --git a/gdb/coffread.c b/gdb/coffread.c index a43d9e2679e..4723662f140 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1,5 +1,5 @@ /* Read coff symbol tables and convert to internal format, for GDB. - Copyright (C) 1987-2020 Free Software Foundation, Inc. + Copyright (C) 1987-2021 Free Software Foundation, Inc. Contributed by David D. Johnson, Brown University (ddj@cs.brown.edu). This file is part of GDB. @@ -36,6 +36,7 @@ #include "target.h" #include "block.h" #include "dictionary.h" +#include "dwarf2/public.h" #include "coff-pe-read.h" @@ -155,8 +156,8 @@ static int type_vector_length; #define INITIAL_TYPE_VECTOR_LENGTH 160 static char *linetab = NULL; -static long linetab_offset; -static unsigned long linetab_size; +static file_ptr linetab_offset; +static file_ptr linetab_size; static char *stringtab = NULL; @@ -188,23 +189,23 @@ static struct symbol *process_coff_symbol (struct coff_symbol *, static void patch_opaque_types (struct symtab *); -static void enter_linenos (long, int, int, struct objfile *); +static void enter_linenos (file_ptr, int, int, struct objfile *); -static int init_lineno (bfd *, long, int, gdb::unique_xmalloc_ptr *); +static int init_lineno (bfd *, file_ptr, file_ptr, gdb::unique_xmalloc_ptr *); static char *getsymname (struct internal_syment *); static const char *coff_getfilename (union internal_auxent *); -static int init_stringtab (bfd *, long, gdb::unique_xmalloc_ptr *); +static int init_stringtab (bfd *, file_ptr, gdb::unique_xmalloc_ptr *); static void read_one_sym (struct coff_symbol *, struct internal_syment *, union internal_auxent *); static void coff_symtab_read (minimal_symbol_reader &, - long, unsigned int, struct objfile *); - + file_ptr, unsigned int, struct objfile *); + /* We are called once per section from coff_symfile_read. We need to examine each section we are passed, check to see if it is something we are interested in processing, and @@ -241,7 +242,7 @@ coff_locate_sections (bfd *abfd, asection *sectp, void *csip) const char *s; /* We can have multiple .stab sections if linked with - --split-by-reloc. */ + --split-by-reloc. */ for (s = name + sizeof ".stab" - 1; *s != '\0'; s++) if (!isdigit (*s)) break; @@ -540,9 +541,9 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) const char *filename = bfd_get_filename (abfd); int val; unsigned int num_symbols; - int symtab_offset; - int stringtab_offset; - int stabstrsize; + file_ptr symtab_offset; + file_ptr stringtab_offset; + unsigned int stabstrsize; info = coff_objfile_data_key.get (objfile); symfile_bfd = abfd; /* Kludge for swap routines. */ @@ -610,10 +611,10 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) bfd_map_over_sections (abfd, find_linenos, (void *) info); val = init_lineno (abfd, info->min_lineno_offset, - info->max_lineno_offset - info->min_lineno_offset, + info->max_lineno_offset - info->min_lineno_offset, &linetab_storage); if (val < 0) - error (_("\"%s\": error reading line numbers."), filename); + error (_("\"%s\": error reading line numbers."), filename); } /* Now read the string table, all at once. */ @@ -659,7 +660,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) int lead = bfd_get_symbol_leading_char (objfile->obfd); struct bound_minimal_symbol found; - if (lead != '\0' && *name1 == lead) + if (lead != '\0' && *name1 == lead) name1 += 1; found = lookup_minimal_symbol (name1, NULL, objfile); @@ -688,7 +689,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) } /* FIXME: dubious. Why can't we use something normal like - bfd_get_section_contents? */ + bfd_get_section_contents? */ bfd_seek (abfd, abfd->where, 0); stabstrsize = bfd_section_size (info->stabstrsect); @@ -707,7 +708,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) dwarf2_build_frame_info (objfile); /* Try to add separate debug file if no symbols table found. */ - if (!objfile_has_partial_symbols (objfile)) + if (!objfile->has_partial_symbols ()) { std::string debugfile = find_separate_debug_file_by_buildid (objfile); @@ -750,7 +751,7 @@ coff_symfile_finish (struct objfile *objfile) static void coff_symtab_read (minimal_symbol_reader &reader, - long symtab_offset, unsigned int nsyms, + file_ptr symtab_offset, unsigned int nsyms, struct objfile *objfile) { struct gdbarch *gdbarch = objfile->arch (); @@ -796,7 +797,7 @@ coff_symtab_read (minimal_symbol_reader &reader, bfd_seek (objfile->obfd, 0, 0); /* Position to read the symbol table. */ - val = bfd_seek (objfile->obfd, (long) symtab_offset, 0); + val = bfd_seek (objfile->obfd, symtab_offset, 0); if (val < 0) perror_with_name (objfile_name (objfile)); @@ -967,25 +968,25 @@ coff_symtab_read (minimal_symbol_reader &reader, symbol lookup which returned no match. */ break; } - else if (cs->c_secnum == N_ABS) - { - /* Use the correct minimal symbol type (and don't - relocate) for absolute values. */ - ms_type = mst_abs; - sec = cs_to_section (cs, objfile); - tmpaddr = cs->c_value; - } + else if (cs->c_secnum == N_ABS) + { + /* Use the correct minimal symbol type (and don't + relocate) for absolute values. */ + ms_type = mst_abs; + sec = cs_to_section (cs, objfile); + tmpaddr = cs->c_value; + } else { asection *bfd_section = cs_to_bfd_section (cs, objfile); sec = cs_to_section (cs, objfile); tmpaddr = cs->c_value; - /* Statics in a PE file also get relocated. */ - if (cs->c_sclass == C_EXT - || cs->c_sclass == C_THUMBEXTFUNC - || cs->c_sclass == C_THUMBEXT - || (pe_file && (cs->c_sclass == C_STAT))) + /* Statics in a PE file also get relocated. */ + if (cs->c_sclass == C_EXT + || cs->c_sclass == C_THUMBEXTFUNC + || cs->c_sclass == C_THUMBEXT + || (pe_file && (cs->c_sclass == C_STAT))) offset = objfile->section_offsets[sec]; if (bfd_section->flags & SEC_CODE) @@ -1026,7 +1027,7 @@ coff_symtab_read (minimal_symbol_reader &reader, sym = process_coff_symbol (cs, &main_aux, objfile); SYMBOL_VALUE (sym) = tmpaddr + offset; - SYMBOL_SECTION (sym) = sec; + sym->set_section_index (sec); } } break; @@ -1039,7 +1040,7 @@ coff_symtab_read (minimal_symbol_reader &reader, /* Value contains address of first non-init type code. */ /* main_aux.x_sym.x_misc.x_lnsz.x_lnno - contains line number of '{' }. */ + contains line number of '{' }. */ if (cs->c_naux != 1) complaint (_("`.bf' symbol %d has no aux entry"), cs->c_symnum); @@ -1047,7 +1048,7 @@ coff_symtab_read (minimal_symbol_reader &reader, fcn_first_line_addr = cs->c_value; /* Might want to check that locals are 0 and - context_stack_depth is zero, and complain if not. */ + context_stack_depth is zero, and complain if not. */ depth = 0; newobj = push_context (depth, fcn_start_addr); @@ -1061,9 +1062,9 @@ coff_symtab_read (minimal_symbol_reader &reader, if (!within_function) error (_("Bad coff function information.")); /* The value of .ef is the address of epilogue code; - not useful for gdb. */ + not useful for gdb. */ /* { main_aux.x_sym.x_misc.x_lnsz.x_lnno - contains number of lines to '}' */ + contains number of lines to '}' */ if (outermost_context_p ()) { /* We attempted to pop an empty context stack. */ @@ -1095,12 +1096,12 @@ coff_symtab_read (minimal_symbol_reader &reader, fcn_last_line = main_aux.x_sym.x_misc.x_lnsz.x_lnno; } /* fcn_first_line is the line number of the opening '{'. - Do not record it - because it would affect gdb's idea - of the line number of the first statement of the - function - except for one-line functions, for which - it is also the line number of all the statements and - of the closing '}', and for which we do not have any - other statement-line-number. */ + Do not record it - because it would affect gdb's idea + of the line number of the first statement of the + function - except for one-line functions, for which + it is also the line number of all the statements and + of the closing '}', and for which we do not have any + other statement-line-number. */ if (fcn_last_line == 1) record_line (get_current_subfile (), fcn_first_line, gdbarch_addr_bits_remove (gdbarch, @@ -1214,7 +1215,7 @@ read_one_sym (struct coff_symbol *cs, sym->n_type, sym->n_sclass, 0, cs->c_naux, (char *) aux); /* If more than one aux entry, read past it (only the first aux - is important). */ + is important). */ for (i = 1; i < cs->c_naux; i++) { bytes = bfd_bread (temp_aux, local_auxesz, nlist_bfd_global); @@ -1270,7 +1271,7 @@ read_one_sym (struct coff_symbol *cs, /* Support for string table handling. */ static int -init_stringtab (bfd *abfd, long offset, gdb::unique_xmalloc_ptr *storage) +init_stringtab (bfd *abfd, file_ptr offset, gdb::unique_xmalloc_ptr *storage) { long length; int val; @@ -1317,7 +1318,7 @@ getsymname (struct internal_syment *symbol_entry) if (symbol_entry->_n._n_n._n_zeroes == 0) { /* FIXME: Probably should be detecting corrupt symbol files by - seeing whether offset points to within the stringtab. */ + seeing whether offset points to within the stringtab. */ result = stringtab + symbol_entry->_n._n_n._n_offset; } else @@ -1339,15 +1340,15 @@ coff_getfilename (union internal_auxent *aux_entry) static char buffer[BUFSIZ]; const char *result; - if (aux_entry->x_file.x_n.x_zeroes == 0) + if (aux_entry->x_file.x_n.x_n.x_zeroes == 0) { - if (strlen (stringtab + aux_entry->x_file.x_n.x_offset) >= BUFSIZ) + if (strlen (stringtab + aux_entry->x_file.x_n.x_n.x_offset) >= BUFSIZ) internal_error (__FILE__, __LINE__, _("coff file name too long")); - strcpy (buffer, stringtab + aux_entry->x_file.x_n.x_offset); + strcpy (buffer, stringtab + aux_entry->x_file.x_n.x_n.x_offset); } else { - strncpy (buffer, aux_entry->x_file.x_fname, FILNMLEN); + strncpy (buffer, aux_entry->x_file.x_n.x_fname, FILNMLEN); buffer[FILNMLEN] = '\0'; } result = buffer; @@ -1366,7 +1367,7 @@ coff_getfilename (union internal_auxent *aux_entry) them into GDB's data structures. */ static int -init_lineno (bfd *abfd, long offset, int size, +init_lineno (bfd *abfd, file_ptr offset, file_ptr size, gdb::unique_xmalloc_ptr *storage) { int val; @@ -1399,7 +1400,7 @@ init_lineno (bfd *abfd, long offset, int size, #endif static void -enter_linenos (long file_offset, int first_line, +enter_linenos (file_ptr file_offset, int first_line, int last_line, struct objfile *objfile) { struct gdbarch *gdbarch = objfile->arch (); @@ -1410,8 +1411,8 @@ enter_linenos (long file_offset, int first_line, return; if (file_offset < linetab_offset) { - complaint (_("Line number pointer %ld lower than start of line numbers"), - file_offset); + complaint (_("Line number pointer %s lower than start of line numbers"), + plongest (file_offset)); if (file_offset > linetab_size) /* Too big to be an offset? */ return; file_offset += linetab_offset; /* Try reading at that linetab @@ -1486,9 +1487,9 @@ patch_opaque_types (struct symtab *s) ALL_BLOCK_SYMBOLS (b, iter, real_sym) { /* Find completed typedefs to use to fix opaque ones. - Remove syms from the chain when their types are stored, - but search the whole chain, as there may be several syms - from different files with the same name. */ + Remove syms from the chain when their types are stored, + but search the whole chain, as there may be several syms + from different files with the same name. */ if (SYMBOL_CLASS (real_sym) == LOC_TYPEDEF && SYMBOL_DOMAIN (real_sym) == VAR_DOMAIN && SYMBOL_TYPE (real_sym)->code () == TYPE_CODE_PTR @@ -1565,7 +1566,7 @@ process_coff_symbol (struct coff_symbol *cs, /* default assumptions */ SYMBOL_VALUE (sym) = cs->c_value; SYMBOL_DOMAIN (sym) = VAR_DOMAIN; - SYMBOL_SECTION (sym) = cs_to_section (cs, objfile); + sym->set_section_index (cs_to_section (cs, objfile)); if (ISFCN (cs->c_type)) { @@ -2007,10 +2008,11 @@ coff_read_struct_type (int index, int length, int lastsym, list = newobj; /* Save the data. */ - list->field.name = obstack_strdup (&objfile->objfile_obstack, name); + list->field.set_name (obstack_strdup (&objfile->objfile_obstack, + name)); list->field.set_type (decode_type (ms, ms->c_type, &sub_aux, objfile)); - SET_FIELD_BITPOS (list->field, 8 * ms->c_value); + list->field.set_loc_bitpos (8 * ms->c_value); FIELD_BITSIZE (list->field) = 0; nfields++; break; @@ -2023,10 +2025,11 @@ coff_read_struct_type (int index, int length, int lastsym, list = newobj; /* Save the data. */ - list->field.name = obstack_strdup (&objfile->objfile_obstack, name); + list->field.set_name (obstack_strdup (&objfile->objfile_obstack, + name)); list->field.set_type (decode_type (ms, ms->c_type, &sub_aux, objfile)); - SET_FIELD_BITPOS (list->field, ms->c_value); + list->field.set_loc_bitpos (ms->c_value); FIELD_BITSIZE (list->field) = sub_aux.x_sym.x_misc.x_lnsz.x_size; nfields++; break; @@ -2141,8 +2144,8 @@ coff_read_enum_type (int index, int length, int lastsym, struct symbol *xsym = syms->symbol[j]; SYMBOL_TYPE (xsym) = type; - TYPE_FIELD_NAME (type, n) = xsym->linkage_name (); - SET_FIELD_ENUMVAL (type->field (n), SYMBOL_VALUE (xsym)); + type->field (n).set_name (xsym->linkage_name ()); + type->field (n).set_loc_enumval (SYMBOL_VALUE (xsym)); if (SYMBOL_VALUE (xsym) < 0) unsigned_enum = 0; TYPE_FIELD_BITSIZE (type, n) = 0; @@ -2167,7 +2170,6 @@ static const struct sym_fns coff_sym_fns = for sym_read() */ coff_symfile_read, /* sym_read: read a symbol file into symtab */ - NULL, /* sym_read_psymbols */ coff_symfile_finish, /* sym_finish: finished with file, cleanup */ default_symfile_offsets, /* sym_offsets: xlate external to @@ -2179,7 +2181,6 @@ static const struct sym_fns coff_sym_fns = default_symfile_relocate, /* sym_relocate: Relocate a debug section. */ NULL, /* sym_probe_fns */ - &psym_functions }; void _initialize_coffread ();