From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 682463858C39; Wed, 3 Aug 2022 19:42:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 682463858C39 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Use gdb_bfd_ref_ptr in objfile X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 4d44946794e68cf79cfba467fa414a958dba2185 X-Git-Newrev: 98badbfdc222d1d7f346046f23a64522b88d22a0 Message-Id: <20220803194215.682463858C39@sourceware.org> Date: Wed, 3 Aug 2022 19:42:15 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Aug 2022 19:42:15 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D98badbfdc222= d1d7f346046f23a64522b88d22a0 commit 98badbfdc222d1d7f346046f23a64522b88d22a0 Author: Tom Tromey Date: Tue Aug 2 09:55:32 2022 -0600 Use gdb_bfd_ref_ptr in objfile =20 This changes struct objfile to use a gdb_bfd_ref_ptr. In addition to removing some manual memory management, this fixes a use-after-free that was introduced by the registry rewrite series. The issue there was that, in some cases, registry shutdown could refer to memory that had already been freed. This help fix the bug by delaying the destruction of the BFD reference (and thus the per-bfd object) until after the registry has been shut down. Diff: --- gdb/arm-tdep.c | 21 ++++++----- gdb/auto-load.c | 4 +- gdb/build-id.c | 2 +- gdb/coff-pe-read.c | 4 +- gdb/coffread.c | 27 ++++++------- gdb/compile/compile-object-load.c | 2 +- gdb/ctfread.c | 6 +-- gdb/dbxread.c | 22 +++++------ gdb/dtrace-probe.c | 2 +- gdb/dwarf2/frame.c | 6 +-- gdb/dwarf2/index-cache.c | 2 +- gdb/dwarf2/index-write.c | 2 +- gdb/dwarf2/loc.c | 4 +- gdb/dwarf2/read.c | 70 ++++++++++++++++++---------------- gdb/elfread.c | 43 ++++++++++----------- gdb/gcore.c | 2 +- gdb/hppa-tdep.c | 9 +++-- gdb/i386-tdep.c | 7 ++-- gdb/jit.c | 2 +- gdb/machoread.c | 24 ++++++------ gdb/maint.c | 6 ++- gdb/mdebugread.c | 6 +-- gdb/minidebug.c | 6 +-- gdb/minsyms.c | 4 +- gdb/mipsread.c | 4 +- gdb/objfiles.c | 55 ++++++++++++++------------- gdb/objfiles.h | 12 +++--- gdb/python/py-objfile.c | 6 +-- gdb/remote.c | 4 +- gdb/solib-aix.c | 2 +- gdb/solib-frv.c | 2 +- gdb/solib-svr4.c | 4 +- gdb/solib.c | 4 +- gdb/source.c | 3 +- gdb/stap-probe.c | 4 +- gdb/symfile-mem.c | 4 +- gdb/symfile.c | 79 +++++++++++++++++++----------------= ---- gdb/symfile.h | 7 ++-- gdb/symmisc.c | 2 +- gdb/xcoffread.c | 22 +++++------ 40 files changed, 256 insertions(+), 241 deletions(-) diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index d4c5beb5e06..cf8b610a381 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -608,7 +608,7 @@ arm_find_mapping_symbol (CORE_ADDR memaddr, CORE_ADDR *= start) sec =3D find_pc_section (memaddr); if (sec !=3D NULL) { - arm_per_bfd *data =3D arm_bfd_data_key.get (sec->objfile->obfd); + arm_per_bfd *data =3D arm_bfd_data_key.get (sec->objfile->obfd.get (= )); if (data !=3D NULL) { unsigned int section_idx =3D sec->the_bfd_section->index; @@ -2451,38 +2451,39 @@ arm_exidx_new_objfile (struct objfile *objfile) LONGEST i; =20 /* If we've already touched this file, do nothing. */ - if (!objfile || arm_exidx_data_key.get (objfile->obfd) !=3D NULL) + if (!objfile || arm_exidx_data_key.get (objfile->obfd.get ()) !=3D NULL) return; =20 /* Read contents of exception table and index. */ - exidx =3D bfd_get_section_by_name (objfile->obfd, ELF_STRING_ARM_unwind); + exidx =3D bfd_get_section_by_name (objfile->obfd.get (), + ELF_STRING_ARM_unwind); gdb::byte_vector exidx_data; if (exidx) { exidx_vma =3D bfd_section_vma (exidx); exidx_data.resize (bfd_section_size (exidx)); =20 - if (!bfd_get_section_contents (objfile->obfd, exidx, + if (!bfd_get_section_contents (objfile->obfd.get (), exidx, exidx_data.data (), 0, exidx_data.size ())) return; } =20 - extab =3D bfd_get_section_by_name (objfile->obfd, ".ARM.extab"); + extab =3D bfd_get_section_by_name (objfile->obfd.get (), ".ARM.extab"); gdb::byte_vector extab_data; if (extab) { extab_vma =3D bfd_section_vma (extab); extab_data.resize (bfd_section_size (extab)); =20 - if (!bfd_get_section_contents (objfile->obfd, extab, + if (!bfd_get_section_contents (objfile->obfd.get (), extab, extab_data.data (), 0, extab_data.size ())) return; } =20 /* Allocate exception table data structure. */ - data =3D arm_exidx_data_key.emplace (objfile->obfd); + data =3D arm_exidx_data_key.emplace (objfile->obfd.get ()); data->section_maps.resize (objfile->obfd->section_count); =20 /* Fill in exception table. */ @@ -2654,7 +2655,7 @@ arm_find_exidx_entry (CORE_ADDR memaddr, CORE_ADDR *s= tart) struct arm_exidx_data *data; struct arm_exidx_entry map_key =3D { memaddr - sec->addr (), 0 }; =20 - data =3D arm_exidx_data_key.get (sec->objfile->obfd); + data =3D arm_exidx_data_key.get (sec->objfile->obfd.get ()); if (data !=3D NULL) { std::vector &map @@ -9453,9 +9454,9 @@ arm_record_special_symbol (struct gdbarch *gdbarch, s= truct objfile *objfile, if (name[1] !=3D 'a' && name[1] !=3D 't' && name[1] !=3D 'd') return; =20 - data =3D arm_bfd_data_key.get (objfile->obfd); + data =3D arm_bfd_data_key.get (objfile->obfd.get ()); if (data =3D=3D NULL) - data =3D arm_bfd_data_key.emplace (objfile->obfd, + data =3D arm_bfd_data_key.emplace (objfile->obfd.get (), objfile->obfd->section_count); arm_mapping_symbol_vec &map =3D data->section_maps[bfd_asymbol_section (sym)->index]; diff --git a/gdb/auto-load.c b/gdb/auto-load.c index 54ed73d1bf3..198bb073a1b 100644 --- a/gdb/auto-load.c +++ b/gdb/auto-load.c @@ -858,7 +858,7 @@ auto_load_objfile_script (struct objfile *objfile, { unsigned long crc32; gdb::unique_xmalloc_ptr debuglink - (bfd_get_debug_link_info (parent->obfd, &crc32)); + (bfd_get_debug_link_info (parent->obfd.get (), &crc32)); =20 if (debuglink.get () !=3D nullptr && strcmp (debuglink.get (), lbasename (realname.get ())) !=3D 0) @@ -1119,7 +1119,7 @@ source_section_scripts (struct objfile *objfile, cons= t char *section_name, static void auto_load_section_scripts (struct objfile *objfile, const char *section_na= me) { - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); asection *scripts_sect; bfd_byte *data =3D NULL; =20 diff --git a/gdb/build-id.c b/gdb/build-id.c index 345ed0e196e..0c5d65d02ac 100644 --- a/gdb/build-id.c +++ b/gdb/build-id.c @@ -206,7 +206,7 @@ find_separate_debug_file_by_buildid (struct objfile *ob= jfile) { const struct bfd_build_id *build_id; =20 - build_id =3D build_id_bfd_get (objfile->obfd); + build_id =3D build_id_bfd_get (objfile->obfd.get ()); if (build_id !=3D NULL) { if (separate_debug_file_debug) diff --git a/gdb/coff-pe-read.c b/gdb/coff-pe-read.c index 72bd43b23d8..2f3b80815b5 100644 --- a/gdb/coff-pe-read.c +++ b/gdb/coff-pe-read.c @@ -300,7 +300,7 @@ void read_pe_exported_syms (minimal_symbol_reader &reader, struct objfile *objfile) { - bfd *dll =3D objfile->obfd; + bfd *dll =3D objfile->obfd.get (); unsigned long nbnormal, nbforward; unsigned long pe_header_offset, opthdr_ofs, num_entries, i; unsigned long export_opthdrrva, export_opthdrsize; @@ -312,7 +312,7 @@ read_pe_exported_syms (minimal_symbol_reader &reader, int is_pe64 =3D 0; int is_pe32 =3D 0; =20 - char const *target =3D bfd_get_target (objfile->obfd); + char const *target =3D bfd_get_target (objfile->obfd.get ()); =20 std::vector section_data (PE_SECTION_TABLE_SIZE); diff --git a/gdb/coffread.c b/gdb/coffread.c index f7f5bb007ca..45d41d08449 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -278,7 +278,7 @@ cs_to_bfd_section (struct coff_symbol *cs, struct objfi= le *objfile) =20 args.targ_index =3D cs->c_secnum; args.resultp =3D § - bfd_map_over_sections (objfile->obfd, find_targ_sec, &args); + bfd_map_over_sections (objfile->obfd.get (), find_targ_sec, &args); return sect; } =20 @@ -290,7 +290,7 @@ cs_to_section (struct coff_symbol *cs, struct objfile *= objfile) =20 if (sect =3D=3D NULL) return SECT_OFF_TEXT (objfile); - return gdb_bfd_section_index (objfile->obfd, sect); + return gdb_bfd_section_index (objfile->obfd.get (), sect); } =20 /* Return the address of the section of a COFF symbol. */ @@ -579,7 +579,8 @@ coff_read_minsyms (file_ptr symtab_offset, unsigned int= nsyms, name1 =3D name + 6; if (name1 !=3D NULL) { - int lead =3D bfd_get_symbol_leading_char (objfile->obfd); + int lead + =3D bfd_get_symbol_leading_char (objfile->obfd.get ()); struct bound_minimal_symbol found; =20 if (lead !=3D '\0' && *name1 =3D=3D lead) @@ -610,7 +611,7 @@ static void coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flag= s) { struct coff_symfile_info *info; - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); coff_data_type *cdata =3D coff_data (abfd); const char *filename =3D bfd_get_filename (abfd); int val; @@ -655,8 +656,8 @@ coff_symfile_read (struct objfile *objfile, symfile_add= _flags symfile_flags) FIXME: We should use BFD to read the symbol table, and thus avoid this problem. */ pe_file =3D - startswith (bfd_get_target (objfile->obfd), "pe") - || startswith (bfd_get_target (objfile->obfd), "epoc-pe"); + startswith (bfd_get_target (objfile->obfd.get ()), "pe") + || startswith (bfd_get_target (objfile->obfd.get ()), "epoc-pe"); =20 /* End of warning. */ =20 @@ -742,7 +743,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add= _flags symfile_flags) { gdb_bfd_ref_ptr debug_bfd (symfile_bfd_open (debugfile.c_str ())); =20 - symbol_file_add_separate (debug_bfd.get (), debugfile.c_str (), + symbol_file_add_separate (debug_bfd, debugfile.c_str (), symfile_flags, objfile); } } @@ -817,15 +818,15 @@ coff_symtab_read (minimal_symbol_reader &reader, FIXME: Find out if this has been reported to Sun, whether it has been fixed in a later release, etc. */ =20 - bfd_seek (objfile->obfd, 0, 0); + bfd_seek (objfile->obfd.get (), 0, 0); =20 /* Position to read the symbol table. */ - val =3D bfd_seek (objfile->obfd, symtab_offset, 0); + val =3D bfd_seek (objfile->obfd.get (), symtab_offset, 0); if (val < 0) perror_with_name (objfile_name (objfile)); =20 coffread_objfile =3D objfile; - nlist_bfd_global =3D objfile->obfd; + nlist_bfd_global =3D objfile->obfd.get (); nlist_nsyms_global =3D nsyms; set_last_source_file (NULL); memset (opaque_type_chain, 0, sizeof opaque_type_chain); @@ -1565,7 +1566,7 @@ process_coff_symbol (struct coff_symbol *cs, char *name; =20 name =3D cs->c_name; - name =3D EXTERNAL_NAME (name, objfile->obfd); + name =3D EXTERNAL_NAME (name, objfile->obfd.get ()); sym->set_language (get_current_subfile ()->language, &objfile->objfile_obstack); sym->compute_and_set_names (name, true, objfile->per_bfd); @@ -2001,7 +2002,7 @@ coff_read_struct_type (int index, int length, int las= tsym, { read_one_sym (ms, &sub_sym, &sub_aux); name =3D ms->c_name; - name =3D EXTERNAL_NAME (name, objfile->obfd); + name =3D EXTERNAL_NAME (name, objfile->obfd.get ()); =20 switch (ms->c_sclass) { @@ -2095,7 +2096,7 @@ coff_read_enum_type (int index, int length, int lasts= ym, { read_one_sym (ms, &sub_sym, &sub_aux); name =3D ms->c_name; - name =3D EXTERNAL_NAME (name, objfile->obfd); + name =3D EXTERNAL_NAME (name, objfile->obfd.get ()); =20 switch (ms->c_sclass) { diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object= -load.c index d393091966c..06e8c850d5e 100644 --- a/gdb/compile/compile-object-load.c +++ b/gdb/compile/compile-object-load.c @@ -643,7 +643,7 @@ compile_object_load (const compile_file_names &file_nam= es, =20 /* SYMFILE_VERBOSE is not passed even if FROM_TTY, user is not intereste= d in "Reading symbols from ..." message for automatically generated file. = */ - objfile_up objfile_holder (symbol_file_add_from_bfd (abfd.get (), + objfile_up objfile_holder (symbol_file_add_from_bfd (abfd, filename.get (), 0, NULL, 0, NULL)); objfile =3D objfile_holder.get (); diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 0da4f0d0720..9436ce55fc7 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -1235,7 +1235,7 @@ add_stt_func (struct ctf_context *ccp) static CORE_ADDR get_objfile_text_range (struct objfile *of, int *tsize) { - bfd *abfd =3D of->obfd; + bfd *abfd =3D of->obfd.get (); const asection *codes; =20 codes =3D bfd_get_section_by_name (abfd, ".text"); @@ -1543,7 +1543,7 @@ scan_partial_symbols (ctf_dict_t *cfp, psymtab_storag= e *partial_symtabs, =20 if (strcmp (fname, ".ctf") =3D=3D 0) { - fname =3D bfd_get_filename (of->obfd); + fname =3D bfd_get_filename (of->obfd.get ()); isparent =3D true; } =20 @@ -1602,7 +1602,7 @@ void elfctf_build_psymtabs (struct objfile *of) { struct ctf_per_tu_data pcu; - bfd *abfd =3D of->obfd; + bfd *abfd =3D of->obfd.get (); int err; =20 ctf_archive_t *arc =3D ctf_bfdopen (abfd, &err); diff --git a/gdb/dbxread.c b/gdb/dbxread.c index e1bf9a01e30..1f93eb5aafd 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -485,7 +485,7 @@ record_minimal_symbol (minimal_symbol_reader &reader, { const char *tempstring =3D name; =20 - if (tempstring[0] =3D=3D bfd_get_symbol_leading_char (objfile->obfd)) + if (tempstring[0] =3D=3D bfd_get_symbol_leading_char (objfile->obfd.get (= ))) ++tempstring; if (is_vtable_name (tempstring)) ms_type =3D mst_data; @@ -520,7 +520,7 @@ dbx_symfile_read (struct objfile *objfile, symfile_add_= flags symfile_flags) bfd *sym_bfd; int val; =20 - sym_bfd =3D objfile->obfd; + sym_bfd =3D objfile->obfd.get (); =20 /* .o and .nlm files are relocatables with text, data and bss segs based= at 0. This flag disables special (Solaris stabs-in-elf only) fixups for @@ -583,7 +583,7 @@ static void dbx_symfile_init (struct objfile *objfile) { int val; - bfd *sym_bfd =3D objfile->obfd; + bfd *sym_bfd =3D objfile->obfd.get (); const char *name =3D bfd_get_filename (sym_bfd); asection *text_sect; unsigned char size_temp[DBX_STRINGTAB_SIZE_SIZE]; @@ -1010,8 +1010,8 @@ read_dbx_symtab (minimal_symbol_reader &reader, =20 lowest_text_address =3D (CORE_ADDR) -1; =20 - symfile_bfd =3D objfile->obfd; /* For next_text_symbol. */ - abfd =3D objfile->obfd; + symfile_bfd =3D objfile->obfd.get (); /* For next_text_symbol. */ + abfd =3D objfile->obfd.get (); symbuf_end =3D symbuf_idx =3D 0; next_symbol_text_func =3D dbx_next_symbol_text; textlow_not_set =3D 1; @@ -2120,7 +2120,7 @@ dbx_expand_psymtab (legacy_psymtab *pst, struct objfi= le *objfile) symbol_size =3D SYMBOL_SIZE (pst); =20 /* Read in this file's symbols. */ - bfd_seek (objfile->obfd, SYMBOL_OFFSET (pst), SEEK_SET); + bfd_seek (objfile->obfd.get (), SYMBOL_OFFSET (pst), SEEK_SET); read_ofile_symtab (objfile, pst); } =20 @@ -2187,8 +2187,8 @@ read_ofile_symtab (struct objfile *objfile, legacy_ps= ymtab *pst) stringtab_global =3D DBX_STRINGTAB (objfile); set_last_source_file (NULL); =20 - abfd =3D objfile->obfd; - symfile_bfd =3D objfile->obfd; /* Implicit param to next_text_symbol. */ + abfd =3D objfile->obfd.get (); + symfile_bfd =3D objfile->obfd.get (); /* Implicit param to next_text_sym= bol. */ symbuf_end =3D symbuf_idx =3D 0; symbuf_read =3D 0; symbuf_left =3D sym_offset + sym_size; @@ -2932,7 +2932,7 @@ coffstab_build_psymtabs (struct objfile *objfile, file_ptr stabstroffset, unsigned int stabstrsize) { int val; - bfd *sym_bfd =3D objfile->obfd; + bfd *sym_bfd =3D objfile->obfd.get (); const char *name =3D bfd_get_filename (sym_bfd); unsigned int stabsize; =20 @@ -3019,7 +3019,7 @@ elfstab_build_psymtabs (struct objfile *objfile, asec= tion *stabsect, file_ptr stabstroffset, unsigned int stabstrsize) { int val; - bfd *sym_bfd =3D objfile->obfd; + bfd *sym_bfd =3D objfile->obfd.get (); const char *name =3D bfd_get_filename (sym_bfd); =20 stabsread_new_init (); @@ -3100,7 +3100,7 @@ stabsect_build_psymtabs (struct objfile *objfile, cha= r *stab_name, char *stabstr_name, char *text_name) { int val; - bfd *sym_bfd =3D objfile->obfd; + bfd *sym_bfd =3D objfile->obfd.get (); const char *name =3D bfd_get_filename (sym_bfd); asection *stabsect; asection *stabstrsect; diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c index 6f01edf3924..b1f6ce5039c 100644 --- a/gdb/dtrace-probe.c +++ b/gdb/dtrace-probe.c @@ -830,7 +830,7 @@ dtrace_static_probe_ops::get_probes (std::vector> *probesp, struct objfile *objfile) const { - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); asection *sect =3D NULL; =20 /* Do nothing in case this is a .debug file, instead of the objfile diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c index d7a06395acb..387a2bc7515 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -138,7 +138,7 @@ typedef std::vector dwarf2_fde_table; struct comp_unit { comp_unit (struct objfile *objf) - : abfd (objf->obfd) + : abfd (objf->obfd.get ()) { } =20 @@ -1534,7 +1534,7 @@ bsearch_fde_cmp (const dwarf2_fde *fde, CORE_ADDR see= k_pc) static comp_unit * find_comp_unit (struct objfile *objfile) { - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); if (gdb_bfd_requires_relocations (abfd)) return dwarf2_frame_objfile_data.get (objfile); =20 @@ -1547,7 +1547,7 @@ find_comp_unit (struct objfile *objfile) static void set_comp_unit (struct objfile *objfile, struct comp_unit *unit) { - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); if (gdb_bfd_requires_relocations (abfd)) return dwarf2_frame_objfile_data.set (objfile, unit); =20 diff --git a/gdb/dwarf2/index-cache.c b/gdb/dwarf2/index-cache.c index a1f6ff59634..6de58592050 100644 --- a/gdb/dwarf2/index-cache.c +++ b/gdb/dwarf2/index-cache.c @@ -101,7 +101,7 @@ index_cache::store (dwarf2_per_objfile *per_objfile) return; =20 /* Get build id of objfile. */ - const bfd_build_id *build_id =3D build_id_bfd_get (obj->obfd); + const bfd_build_id *build_id =3D build_id_bfd_get (obj->obfd.get ()); if (build_id =3D=3D nullptr) { index_cache_debug ("objfile %s has no build id", diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index efd154d41df..b6d8dddafd3 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -765,7 +765,7 @@ private: /* Object constructor to be called for current DWARF2_PER_OBJFILE. All .debug_str section strings are automatically stored. */ debug_str_lookup (dwarf2_per_objfile *per_objfile) - : m_abfd (per_objfile->objfile->obfd), + : m_abfd (per_objfile->objfile->obfd.get ()), m_per_objfile (per_objfile) { per_objfile->per_bfd->str.read (per_objfile->objfile); diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index f490b68adc3..bf0df613f24 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -355,7 +355,7 @@ dwarf2_find_location_expression (struct dwarf2_loclist_= baton *baton, struct gdbarch *gdbarch =3D objfile->arch (); enum bfd_endian byte_order =3D gdbarch_byte_order (gdbarch); unsigned int addr_size =3D baton->per_cu->addr_size (); - int signed_addr_p =3D bfd_get_sign_extend_vma (objfile->obfd); + int signed_addr_p =3D bfd_get_sign_extend_vma (objfile->obfd.get ()); /* Adjustment for relocatable objects. */ CORE_ADDR text_offset =3D baton->per_objfile->objfile->text_section_offs= et (); CORE_ADDR base_address =3D baton->base_address; @@ -3952,7 +3952,7 @@ loclist_describe_location (struct symbol *symbol, COR= E_ADDR addr, enum bfd_endian byte_order =3D gdbarch_byte_order (gdbarch); unsigned int addr_size =3D dlbaton->per_cu->addr_size (); int offset_size =3D dlbaton->per_cu->offset_size (); - int signed_addr_p =3D bfd_get_sign_extend_vma (objfile->obfd); + int signed_addr_p =3D bfd_get_sign_extend_vma (objfile->obfd.get ()); /* Adjustment for relocatable objects. */ CORE_ADDR text_offset =3D objfile->text_section_offset (); CORE_ADDR base_address =3D dlbaton->base_address; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 8c66cb89162..f03151983dc 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1569,23 +1569,24 @@ dwarf2_has_info (struct objfile *objfile, We don't share with objfiles for which -readnow was requested, because it would complicate things when loading the same BFD with -readnow and then without -readnow. */ - if (!gdb_bfd_requires_relocations (objfile->obfd) + if (!gdb_bfd_requires_relocations (objfile->obfd.get ()) && (objfile->flags & OBJF_READNOW) =3D=3D 0) { /* See if one has been created for this BFD yet. */ - per_bfd =3D dwarf2_per_bfd_bfd_data_key.get (objfile->obfd); + per_bfd =3D dwarf2_per_bfd_bfd_data_key.get (objfile->obfd.get ()); =20 if (per_bfd =3D=3D nullptr) { /* No, create it now. */ - per_bfd =3D new dwarf2_per_bfd (objfile->obfd, names, can_copy); - dwarf2_per_bfd_bfd_data_key.set (objfile->obfd, per_bfd); + per_bfd =3D new dwarf2_per_bfd (objfile->obfd.get (), names, + can_copy); + dwarf2_per_bfd_bfd_data_key.set (objfile->obfd.get (), per_bfd); } } else { /* No sharing possible, create one specifically for this objfile. */ - per_bfd =3D new dwarf2_per_bfd (objfile->obfd, names, can_copy); + per_bfd =3D new dwarf2_per_bfd (objfile->obfd.get (), names, can_copy); dwarf2_per_bfd_objfile_data_key.set (objfile, per_bfd); } =20 @@ -2326,7 +2327,7 @@ read_addrmap_from_aranges (dwarf2_per_objfile *per_ob= jfile, addrmap *mutable_map) { struct objfile *objfile =3D per_objfile->objfile; - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); struct gdbarch *gdbarch =3D objfile->arch (); const CORE_ADDR baseaddr =3D objfile->text_section_offset (); dwarf2_per_bfd *per_bfd =3D per_objfile->per_bfd; @@ -4926,7 +4927,7 @@ dw2_debug_names_iterator::next () =20 dwarf2_per_bfd *per_bfd =3D m_per_objfile->per_bfd; struct objfile *objfile =3D m_per_objfile->objfile; - bfd *const abfd =3D objfile->obfd; + bfd *const abfd =3D objfile->obfd.get (); =20 again: =20 @@ -5297,7 +5298,7 @@ get_gdb_index_contents_from_section (objfile *obj, T = *section_owner) static gdb::array_view get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_bfd *dwarf2_pe= r_bfd) { - const bfd_build_id *build_id =3D build_id_bfd_get (obj->obfd); + const bfd_build_id *build_id =3D build_id_bfd_get (obj->obfd.get ()); if (build_id =3D=3D nullptr) return {}; =20 @@ -11118,7 +11119,7 @@ try_open_dwop_file (dwarf2_per_objfile *per_objfile, This is important because things like demangled_names_hash lives in t= he objfile's per_bfd space and may have references to things like symbol names that live in the DWO/DWP file's per_bfd space. PR 16426. */ - gdb_bfd_record_inclusion (per_objfile->objfile->obfd, sym_bfd.get ()); + gdb_bfd_record_inclusion (per_objfile->objfile->obfd.get (), sym_bfd.get= ()); =20 return sym_bfd; } @@ -12645,7 +12646,7 @@ dwarf2_rnglists_process (unsigned offset, struct dw= arf2_cu *cu, { dwarf2_per_objfile *per_objfile =3D cu->per_objfile; struct objfile *objfile =3D per_objfile->objfile; - bfd *obfd =3D objfile->obfd; + bfd *obfd =3D objfile->obfd.get (); /* Base address selection entry. */ gdb::optional base; const gdb_byte *buffer; @@ -12841,7 +12842,7 @@ dwarf2_ranges_process (unsigned offset, struct dwar= f2_cu *cu, dwarf_tag tag, dwarf2_per_objfile *per_objfile =3D cu->per_objfile; struct objfile *objfile =3D per_objfile->objfile; struct comp_unit_head *cu_header =3D &cu->header; - bfd *obfd =3D objfile->obfd; + bfd *obfd =3D objfile->obfd.get (); unsigned int addr_size =3D cu_header->addr_size; CORE_ADDR mask =3D ~(~(CORE_ADDR)1 << (addr_size * 8 - 1)); /* Base address selection entry. */ @@ -16683,7 +16684,8 @@ get_mpz (struct dwarf2_cu *cu, gdb_mpz *value, stru= ct attribute *attr) if (ptr - blk->data + len <=3D blk->size) { mpz_import (value->val, len, - bfd_big_endian (cu->per_objfile->objfile->obfd) ? 1 : -1, + bfd_big_endian (cu->per_objfile->objfile->obfd.get ()) + ? 1 : -1, 1, 0, 0, ptr); return; } @@ -16696,7 +16698,8 @@ get_mpz (struct dwarf2_cu *cu, gdb_mpz *value, stru= ct attribute *attr) { dwarf_block *blk =3D attr->as_block (); mpz_import (value->val, blk->size, - bfd_big_endian (cu->per_objfile->objfile->obfd) ? 1 : -1, + bfd_big_endian (cu->per_objfile->objfile->obfd.get ()) + ? 1 : -1, 1, 0, 0, blk->data); } else @@ -18791,7 +18794,7 @@ read_loclist_index (struct dwarf2_cu *cu, ULONGEST = loclist_index) { dwarf2_per_objfile *per_objfile =3D cu->per_objfile; struct objfile *objfile =3D per_objfile->objfile; - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); ULONGEST loclist_header_size =3D (cu->header.initial_length_size =3D=3D 4 ? LOCLIST_HEADER_SIZE32 : LOCLIST_HEADER_SIZE64); @@ -18850,7 +18853,7 @@ read_rnglist_index (struct dwarf2_cu *cu, ULONGEST = rnglist_index, { struct dwarf2_per_objfile *dwarf2_per_objfile =3D cu->per_objfile; struct objfile *objfile =3D dwarf2_per_objfile->objfile; - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); ULONGEST rnglist_header_size =3D (cu->header.initial_length_size =3D=3D 4 ? RNGLIST_HEADER_SIZE32 : RNGLIST_HEADER_SIZE64); @@ -19285,7 +19288,7 @@ const char * dwarf2_per_objfile::read_line_string (const gdb_byte *buf, unsigned int offset_size) { - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); ULONGEST str_offset =3D read_offset (abfd, buf, offset_size); =20 return per_bfd->line_str.read_string (objfile, str_offset, "DW_FORM_line= _strp"); @@ -19298,7 +19301,7 @@ dwarf2_per_objfile::read_line_string (const gdb_byt= e *buf, const struct comp_unit_head *cu_header, unsigned int *bytes_read_ptr) { - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); LONGEST str_offset =3D cu_header->read_offset (abfd, buf, bytes_read_ptr= ); =20 return per_bfd->line_str.read_string (objfile, str_offset, "DW_FORM_line= _strp"); @@ -19313,7 +19316,7 @@ read_addr_index_1 (dwarf2_per_objfile *per_objfile,= unsigned int addr_index, gdb::optional addr_base, int addr_size) { struct objfile *objfile =3D per_objfile->objfile; - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); const gdb_byte *info_ptr; ULONGEST addr_base_or_zero =3D addr_base.has_value () ? *addr_base : 0; =20 @@ -19349,7 +19352,7 @@ static CORE_ADDR read_addr_index_from_leb128 (struct dwarf2_cu *cu, const gdb_byte *info_pt= r, unsigned int *bytes_read) { - bfd *abfd =3D cu->per_objfile->objfile->obfd; + bfd *abfd =3D cu->per_objfile->objfile->obfd.get (); unsigned int addr_index =3D read_unsigned_leb128 (abfd, info_ptr, bytes_= read); =20 return read_addr_index (cu, addr_index); @@ -19411,7 +19414,7 @@ read_str_index (struct dwarf2_cu *cu, dwarf2_per_objfile *per_objfile =3D cu->per_objfile; struct objfile *objfile =3D per_objfile->objfile; const char *objf_name =3D objfile_name (objfile); - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); const gdb_byte *info_ptr; ULONGEST str_offset; static const char form_name[] =3D "DW_FORM_GNU_str_index or DW_FORM_strx= "; @@ -20298,7 +20301,7 @@ dwarf_decode_lines_1 (struct line_header *lh, struc= t dwarf2_cu *cu, unsigned char op_code, extended_op; CORE_ADDR baseaddr; struct objfile *objfile =3D cu->per_objfile->objfile; - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); struct gdbarch *gdbarch =3D objfile->arch (); =20 baseaddr =3D objfile->text_section_offset (); @@ -20635,7 +20638,7 @@ var_decode_location (struct attribute *attr, struct= symbol *sym, =20 if (block->data[0] =3D=3D DW_OP_addr) sym->set_value_address - (cu->header.read_address (objfile->obfd, block->data + 1, + (cu->header.read_address (objfile->obfd.get (), block->data + 1, &dummy)); else sym->set_value_address @@ -21107,7 +21110,7 @@ dwarf2_const_value_data (const struct attribute *at= tr, struct obstack *obstack, struct dwarf2_cu *cu, LONGEST *value, int bits) { struct objfile *objfile =3D cu->per_objfile->objfile; - enum bfd_endian byte_order =3D bfd_big_endian (objfile->obfd) ? + enum bfd_endian byte_order =3D bfd_big_endian (objfile->obfd.get ()) ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE; LONGEST l =3D attr->constant_value (0); =20 @@ -21145,7 +21148,7 @@ dwarf2_const_value_attr (const struct attribute *at= tr, struct type *type, struct objfile *objfile =3D per_objfile->objfile; struct comp_unit_head *cu_header =3D &cu->header; struct dwarf_block *blk; - enum bfd_endian byte_order =3D (bfd_big_endian (objfile->obfd) ? + enum bfd_endian byte_order =3D (bfd_big_endian (objfile->obfd.get ()) ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE); =20 *value =3D 0; @@ -22497,7 +22500,7 @@ dwarf2_fetch_constant_bytes (sect_offset sect_off, if (attr =3D=3D NULL) return NULL; =20 - byte_order =3D (bfd_big_endian (objfile->obfd) + byte_order =3D (bfd_big_endian (objfile->obfd.get ()) ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE); =20 switch (attr->form) @@ -23009,43 +23012,44 @@ decode_locdesc (struct dwarf_block *blk, struct d= warf2_cu *cu, bool *computed) break; =20 case DW_OP_addr: - stack[++stacki] =3D cu->header.read_address (objfile->obfd, &data[i], + stack[++stacki] =3D cu->header.read_address (objfile->obfd.get (), + &data[i], &bytes_read); i +=3D bytes_read; break; =20 case DW_OP_const1u: - stack[++stacki] =3D read_1_byte (objfile->obfd, &data[i]); + stack[++stacki] =3D read_1_byte (objfile->obfd.get (), &data[i]); i +=3D 1; break; =20 case DW_OP_const1s: - stack[++stacki] =3D read_1_signed_byte (objfile->obfd, &data[i]); + stack[++stacki] =3D read_1_signed_byte (objfile->obfd.get (), &data[i]); i +=3D 1; break; =20 case DW_OP_const2u: - stack[++stacki] =3D read_2_bytes (objfile->obfd, &data[i]); + stack[++stacki] =3D read_2_bytes (objfile->obfd.get (), &data[i]); i +=3D 2; break; =20 case DW_OP_const2s: - stack[++stacki] =3D read_2_signed_bytes (objfile->obfd, &data[i]); + stack[++stacki] =3D read_2_signed_bytes (objfile->obfd.get (), &data[i]= ); i +=3D 2; break; =20 case DW_OP_const4u: - stack[++stacki] =3D read_4_bytes (objfile->obfd, &data[i]); + stack[++stacki] =3D read_4_bytes (objfile->obfd.get (), &data[i]); i +=3D 4; break; =20 case DW_OP_const4s: - stack[++stacki] =3D read_4_signed_bytes (objfile->obfd, &data[i]); + stack[++stacki] =3D read_4_signed_bytes (objfile->obfd.get (), &data[i]= ); i +=3D 4; break; =20 case DW_OP_const8u: - stack[++stacki] =3D read_8_bytes (objfile->obfd, &data[i]); + stack[++stacki] =3D read_8_bytes (objfile->obfd.get (), &data[i]); i +=3D 8; break; =20 diff --git a/gdb/elfread.c b/gdb/elfread.c index e0de52cd1b9..08db208ebbb 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -211,7 +211,7 @@ record_minimal_symbol (minimal_symbol_reader &reader, create an msymbol that references an uninitialised section object. */ int section_index =3D 0; if ((bfd_section_flags (bfd_section) & SEC_ALLOC) =3D=3D SEC_ALLOC) - section_index =3D gdb_bfd_section_index (objfile->obfd, bfd_section); + section_index =3D gdb_bfd_section_index (objfile->obfd.get (), bfd_sec= tion); =20 struct minimal_symbol *result =3D reader.record_full (name, copy_name, address, ms_type, section_ind= ex); @@ -252,7 +252,7 @@ elf_symtab_read (minimal_symbol_reader &reader, /* Name of the last file symbol. This is either a constant string or is saved on the objfile's filename cache. */ const char *filesymname =3D ""; - int stripped =3D (bfd_get_symcount (objfile->obfd) =3D=3D 0); + int stripped =3D (bfd_get_symcount (objfile->obfd.get ()) =3D=3D 0); int elf_make_msymbol_special_p =3D gdbarch_elf_make_msymbol_special_p (gdbarch); =20 @@ -271,7 +271,7 @@ elf_symtab_read (minimal_symbol_reader &reader, /* Skip "special" symbols, e.g. ARM mapping symbols. These are symbols which do not correspond to objects in the symbol table, but have some other target-specific meaning. */ - if (bfd_is_target_special_symbol (objfile->obfd, sym)) + if (bfd_is_target_special_symbol (objfile->obfd.get (), sym)) { if (gdbarch_record_special_symbol_p (gdbarch)) gdbarch_record_special_symbol (gdbarch, objfile, sym); @@ -283,7 +283,7 @@ elf_symtab_read (minimal_symbol_reader &reader, && (sym->flags & BSF_FUNCTION)) { struct minimal_symbol *msym; - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); asection *sect; =20 /* Symbol is a reference to a function defined in @@ -547,7 +547,7 @@ static void elf_rel_plt_read (minimal_symbol_reader &reader, struct objfile *objfile, asymbol **dyn_symbol_table) { - bfd *obfd =3D objfile->obfd; + bfd *obfd =3D objfile->obfd.get (); const struct elf_backend_data *bed =3D get_elf_backend_data (obfd); asection *relplt, *got_plt; bfd_size_type reloc_count, reloc; @@ -816,7 +816,7 @@ elf_gnu_ifunc_resolve_by_got (const char *name, CORE_AD= DR *addr_p) =20 for (objfile *objfile : current_program_space->objfiles ()) { - bfd *obfd =3D objfile->obfd; + bfd *obfd =3D objfile->obfd.get (); struct gdbarch *gdbarch =3D objfile->arch (); struct type *ptr_type =3D builtin_type (gdbarch)->builtin_data_ptr; size_t ptr_size =3D TYPE_LENGTH (ptr_type); @@ -1041,7 +1041,7 @@ static void elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags, const struct elfinfo *ei) { - bfd *synth_abfd, *abfd =3D objfile->obfd; + bfd *synth_abfd, *abfd =3D objfile->obfd.get (); long symcount =3D 0, dynsymcount =3D 0, synthcount, storage_needed; asymbol **symbol_table =3D NULL, **dyn_symbol_table =3D NULL; asymbol *synthsyms; @@ -1067,10 +1067,10 @@ elf_read_minimal_symbols (struct objfile *objfile, = int symfile_flags, =20 /* Process the normal ELF symbol table first. */ =20 - storage_needed =3D bfd_get_symtab_upper_bound (objfile->obfd); + storage_needed =3D bfd_get_symtab_upper_bound (objfile->obfd.get ()); if (storage_needed < 0) error (_("Can't read symbols from %s: %s"), - bfd_get_filename (objfile->obfd), + bfd_get_filename (objfile->obfd.get ()), bfd_errmsg (bfd_get_error ())); =20 if (storage_needed > 0) @@ -1079,11 +1079,11 @@ elf_read_minimal_symbols (struct objfile *objfile, = int symfile_flags, bfd_canonicalize_symtab so it must not get freed before ABFD gets. */ =20 symbol_table =3D (asymbol **) bfd_alloc (abfd, storage_needed); - symcount =3D bfd_canonicalize_symtab (objfile->obfd, symbol_table); + symcount =3D bfd_canonicalize_symtab (objfile->obfd.get (), symbol_t= able); =20 if (symcount < 0) error (_("Can't read symbols from %s: %s"), - bfd_get_filename (objfile->obfd), + bfd_get_filename (objfile->obfd.get ()), bfd_errmsg (bfd_get_error ())); =20 elf_symtab_read (reader, objfile, ST_REGULAR, symcount, symbol_table, @@ -1092,7 +1092,7 @@ elf_read_minimal_symbols (struct objfile *objfile, in= t symfile_flags, =20 /* Add the dynamic symbols. */ =20 - storage_needed =3D bfd_get_dynamic_symtab_upper_bound (objfile->obfd); + storage_needed =3D bfd_get_dynamic_symtab_upper_bound (objfile->obfd.get= ()); =20 if (storage_needed > 0) { @@ -1104,12 +1104,12 @@ elf_read_minimal_symbols (struct objfile *objfile, = int symfile_flags, implementation detail, though. */ =20 dyn_symbol_table =3D (asymbol **) bfd_alloc (abfd, storage_needed); - dynsymcount =3D bfd_canonicalize_dynamic_symtab (objfile->obfd, + dynsymcount =3D bfd_canonicalize_dynamic_symtab (objfile->obfd.get (= ), dyn_symbol_table); =20 if (dynsymcount < 0) error (_("Can't read symbols from %s: %s"), - bfd_get_filename (objfile->obfd), + bfd_get_filename (objfile->obfd.get ()), bfd_errmsg (bfd_get_error ())); =20 elf_symtab_read (reader, objfile, ST_DYNAMIC, dynsymcount, @@ -1131,7 +1131,7 @@ elf_read_minimal_symbols (struct objfile *objfile, in= t symfile_flags, backlinked binary where it is valid. */ =20 if (objfile->separate_debug_objfile_backlink) - synth_abfd =3D objfile->separate_debug_objfile_backlink->obfd; + synth_abfd =3D objfile->separate_debug_objfile_backlink->obfd.get (); else synth_abfd =3D abfd; =20 @@ -1193,7 +1193,7 @@ elf_read_minimal_symbols (struct objfile *objfile, in= t symfile_flags, static void elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) { - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); struct elfinfo ei; bool has_dwarf2 =3D true; =20 @@ -1271,13 +1271,14 @@ elf_symfile_read (struct objfile *objfile, symfile_= add_flags symfile_flags) { gdb_bfd_ref_ptr debug_bfd (symfile_bfd_open (debugfile.c_str ())); =20 - symbol_file_add_separate (debug_bfd.get (), debugfile.c_str (), + symbol_file_add_separate (debug_bfd, debugfile.c_str (), symfile_flags, objfile); } else { has_dwarf2 =3D false; - const struct bfd_build_id *build_id =3D build_id_bfd_get (objfile->obfd= ); + const struct bfd_build_id *build_id + =3D build_id_bfd_get (objfile->obfd.get ()); =20 if (build_id !=3D nullptr) { @@ -1297,7 +1298,7 @@ elf_symfile_read (struct objfile *objfile, symfile_ad= d_flags symfile_flags) objfile->original_name); else if (build_id_verify (debug_bfd.get (), build_id->size, build_id->= data)) { - symbol_file_add_separate (debug_bfd.get (), symfile_path.get (), + symbol_file_add_separate (debug_bfd, symfile_path.get (), symfile_flags, objfile); has_dwarf2 =3D true; } @@ -1348,11 +1349,11 @@ elf_symfile_init (struct objfile *objfile) static const elfread_data & elf_get_probes (struct objfile *objfile) { - elfread_data *probes_per_bfd =3D probe_key.get (objfile->obfd); + elfread_data *probes_per_bfd =3D probe_key.get (objfile->obfd.get ()); =20 if (probes_per_bfd =3D=3D NULL) { - probes_per_bfd =3D probe_key.emplace (objfile->obfd); + probes_per_bfd =3D probe_key.emplace (objfile->obfd.get ()); =20 /* Here we try to gather information about all types of probes from = the objfile. */ diff --git a/gdb/gcore.c b/gdb/gcore.c index b81ef81ab84..519007714e5 100644 --- a/gdb/gcore.c +++ b/gdb/gcore.c @@ -407,7 +407,7 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long s= ize, int read, for (objfile *objfile : current_program_space->objfiles ()) ALL_OBJFILE_OSECTIONS (objfile, objsec) { - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); asection *asec =3D objsec->the_bfd_section; bfd_vma align =3D (bfd_vma) 1 << bfd_section_alignment (asec); bfd_vma start =3D objsec->addr () & -align; diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index 54b3d22a2d0..91f9cecdcbc 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -264,7 +264,7 @@ internalize_unwinds (struct objfile *objfile, struct un= wind_table_entry *table, { low_text_segment_address =3D -1; =20 - bfd_map_over_sections (objfile->obfd, + bfd_map_over_sections (objfile->obfd.get (), record_text_segment_lowaddr,=20 &low_text_segment_address); =20 @@ -275,7 +275,7 @@ internalize_unwinds (struct objfile *objfile, struct un= wind_table_entry *table, text_offset =3D tdep->solib_get_text_base (objfile); } =20 - bfd_get_section_contents (objfile->obfd, section, buf, 0, size); + bfd_get_section_contents (objfile->obfd.get (), section, buf, 0, siz= e); =20 /* Now internalize the information being careful to handle host/targ= et endian issues. */ @@ -379,7 +379,8 @@ read_unwind_info (struct objfile *objfile) =20 /* Now compute the size of the stub unwinds. Note the ELF tools do not use stub unwinds at the current time. */ - stub_unwind_sec =3D bfd_get_section_by_name (objfile->obfd, "$UNWIND_END= $"); + stub_unwind_sec =3D bfd_get_section_by_name (objfile->obfd.get (), + "$UNWIND_END$"); =20 if (stub_unwind_sec) { @@ -427,7 +428,7 @@ read_unwind_info (struct objfile *objfile) char *buf =3D (char *) alloca (stub_unwind_size); =20 /* Read in the stub unwind entries. */ - bfd_get_section_contents (objfile->obfd, stub_unwind_sec, buf, + bfd_get_section_contents (objfile->obfd.get (), stub_unwind_sec, buf, 0, stub_unwind_size); =20 /* Now convert them into regular unwind entries. */ diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index d500f6998c5..d8e910bb407 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -2799,14 +2799,15 @@ i386_thiscall_push_dummy_call (struct gdbarch *gdba= rch, struct value *function, if (objf !=3D nullptr) { /* Get corresponding .got.plt or .got section. */ - asect =3D bfd_get_section_by_name (objf->obfd, ".got.plt"); + asect =3D bfd_get_section_by_name (objf->obfd.get (), ".got.plt"); if (asect =3D=3D nullptr) - asect =3D bfd_get_section_by_name (objf->obfd, ".got"); + asect =3D bfd_get_section_by_name (objf->obfd.get (), ".got"); } =20 if (asect !=3D nullptr) /* Translate asection to obj_section. */ - osect =3D maint_obj_section_from_bfd_section (objf->obfd, asect, objf); + osect =3D maint_obj_section_from_bfd_section (objf->obfd.get (), + asect, objf); =20 if (osect !=3D nullptr) { diff --git a/gdb/jit.c b/gdb/jit.c index b4a070bb879..167ea8cad81 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -798,7 +798,7 @@ JITed symbol file is not an object file, ignoring it.\n= ")); } =20 /* This call does not take ownership of SAI. */ - objfile =3D symbol_file_add_from_bfd (nbfd.get (), + objfile =3D symbol_file_add_from_bfd (nbfd, bfd_get_filename (nbfd.get ()), 0, &sai, OBJF_SHARED | OBJF_NOT_FILENAME, NULL); diff --git a/gdb/machoread.c b/gdb/machoread.c index 8c4b08f8cea..15ce4effcd6 100644 --- a/gdb/machoread.c +++ b/gdb/machoread.c @@ -139,7 +139,7 @@ macho_symtab_add_minsym (minimal_symbol_reader &reader, return; /* Skip this symbol. */ =20 reader.record_with_info (sym->name, symaddr, ms_type, - gdb_bfd_section_index (objfile->obfd, + gdb_bfd_section_index (objfile->obfd.get (), sym->section)); } } @@ -395,7 +395,7 @@ macho_resolve_oso_sym_with_minsym (struct objfile *main= _objfile, asymbol *sym) struct bound_minimal_symbol msym; const char *name =3D sym->name; =20 - if (name[0] =3D=3D bfd_get_symbol_leading_char (main_objfile->obfd)) + if (name[0] =3D=3D bfd_get_symbol_leading_char (main_objfile->obfd.get (= ))) ++name; msym =3D lookup_minimal_symbol (name, NULL, main_objfile); if (msym.minsym =3D=3D NULL) @@ -584,7 +584,7 @@ macho_add_oso_symfile (oso_el *oso, const gdb_bfd_ref_p= tr &abfd, /* We need to clear SYMFILE_MAINLINE to avoid interactive question from symfile.c:symbol_file_add_with_addrs_or_offsets. */ symbol_file_add_from_bfd - (abfd.get (), name, symfile_flags & ~(SYMFILE_MAINLINE | SYMFILE_VERBO= SE), + (abfd, name, symfile_flags & ~(SYMFILE_MAINLINE | SYMFILE_VERBOSE), NULL, main_objfile->flags & (OBJF_REORDERED | OBJF_SHARED | OBJF_READNOW | OBJF_USERLOADED), @@ -742,7 +742,7 @@ macho_check_dsym (struct objfile *objfile, std::string = *filenamep) if (access (dsym_filename, R_OK) !=3D 0) return NULL; =20 - if (bfd_mach_o_lookup_command (objfile->obfd, + if (bfd_mach_o_lookup_command (objfile->obfd.get (), BFD_MACH_O_LC_UUID, &main_uuid) =3D=3D 0) { warning (_("can't find UUID in %s"), objfile_name (objfile)); @@ -781,7 +781,7 @@ macho_check_dsym (struct objfile *objfile, std::string = *filenamep) static void macho_symfile_read (struct objfile *objfile, symfile_add_flags symfile_fla= gs) { - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); long storage_needed; std::vector oso_vector; /* We have to hold on to the symbol table until the call to @@ -796,10 +796,10 @@ macho_symfile_read (struct objfile *objfile, symfile_= add_flags symfile_flags) std::string dsym_filename; =20 /* Process the normal symbol table first. */ - storage_needed =3D bfd_get_symtab_upper_bound (objfile->obfd); + storage_needed =3D bfd_get_symtab_upper_bound (objfile->obfd.get ()); if (storage_needed < 0) error (_("Can't read symbols from %s: %s"), - bfd_get_filename (objfile->obfd), + bfd_get_filename (objfile->obfd.get ()), bfd_errmsg (bfd_get_error ())); =20 if (storage_needed > 0) @@ -810,12 +810,12 @@ macho_symfile_read (struct objfile *objfile, symfile_= add_flags symfile_flags) =20 minimal_symbol_reader reader (objfile); =20 - symcount =3D bfd_canonicalize_symtab (objfile->obfd, + symcount =3D bfd_canonicalize_symtab (objfile->obfd.get (), symbol_table.data ()); =20 if (symcount < 0) error (_("Can't read symbols from %s: %s"), - bfd_get_filename (objfile->obfd), + bfd_get_filename (objfile->obfd.get ()), bfd_errmsg (bfd_get_error ())); =20 macho_symtab_read (reader, objfile, symcount, symbol_table.data (), @@ -849,7 +849,7 @@ macho_symfile_read (struct objfile *objfile, symfile_ad= d_flags symfile_flags) } =20 /* Add the dsym file as a separate file. */ - symbol_file_add_separate (dsym_bfd.get (), dsym_filename.c_str (), + symbol_file_add_separate (dsym_bfd, dsym_filename.c_str (), symfile_flags, objfile); =20 /* Don't try to read dwarf2 from main file or shared libraries. */ @@ -872,7 +872,7 @@ static bfd_byte * macho_symfile_relocate (struct objfile *objfile, asection *sectp, bfd_byte *buf) { - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); =20 /* We're only interested in sections with relocation information. */ @@ -898,7 +898,7 @@ macho_symfile_offsets (struct objfile *objfile, struct obj_section *osect; =20 /* Allocate section_offsets. */ - objfile->section_offsets.assign (gdb_bfd_count_sections (objfile->obfd),= 0); + objfile->section_offsets.assign (gdb_bfd_count_sections (objfile->obfd.g= et ()), 0); =20 /* This code is run when we first add the objfile with symfile_add_with_addrs_or_offsets, when "addrs" not "offsets" are diff --git a/gdb/maint.c b/gdb/maint.c index 289560957f2..76ac7bece38 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -452,9 +452,11 @@ maintenance_info_sections (const char *arg, int from_t= ty) for (objfile *ofile : current_program_space->objfiles ()) { if (ofile->obfd =3D=3D current_program_space->exec_bfd ()) - maint_print_all_sections (_("Exec file: "), ofile->obfd, ofile, arg); + maint_print_all_sections (_("Exec file: "), ofile->obfd.get (), + ofile, arg); else if (opts.all_objects) - maint_print_all_sections (_("Object file: "), ofile->obfd, ofile, arg); + maint_print_all_sections (_("Object file: "), ofile->obfd.get (), + ofile, arg); } =20 if (core_bfd) diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 001042b9cf5..bfd5a6f4680 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -335,7 +335,7 @@ mdebug_build_psymtabs (minimal_symbol_reader &reader, const struct ecoff_debug_swap *swap, struct ecoff_debug_info *info) { - cur_bfd =3D objfile->obfd; + cur_bfd =3D objfile->obfd.get (); debug_swap =3D swap; debug_info =3D info; =20 @@ -357,7 +357,7 @@ mdebug_build_psymtabs (minimal_symbol_reader &reader, + info->symbolic_header.ifdMax * swap->external_fdr_size); fdr_ptr =3D info->fdr; for (; fdr_src < fdr_end; fdr_src +=3D swap->external_fdr_size, fdr_= ptr++) - (*swap->swap_fdr_in) (objfile->obfd, fdr_src, fdr_ptr); + (*swap->swap_fdr_in) (objfile->obfd.get (), fdr_src, fdr_ptr); } =20 psymbol_functions *psf =3D new psymbol_functions (); @@ -4764,7 +4764,7 @@ void elfmdebug_build_psymtabs (struct objfile *objfile, const struct ecoff_debug_swap *swap, asection *sec) { - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); struct ecoff_debug_info *info; =20 /* FIXME: It's not clear whether we should be getting minimal symbol diff --git a/gdb/minidebug.c b/gdb/minidebug.c index dbbdf85e08c..47928fa141f 100644 --- a/gdb/minidebug.c +++ b/gdb/minidebug.c @@ -268,12 +268,12 @@ find_separate_debug_file_in_section (struct objfile *= objfile) if (objfile->obfd =3D=3D NULL) return NULL; =20 - section =3D bfd_get_section_by_name (objfile->obfd, ".gnu_debugdata"); + section =3D bfd_get_section_by_name (objfile->obfd.get (), ".gnu_debugda= ta"); if (section =3D=3D NULL) return NULL; =20 #ifdef HAVE_LIBLZMA - gdb_bfd_ref_ptr *shared =3D gnu_debug_key.get (objfile->obfd); + gdb_bfd_ref_ptr *shared =3D gnu_debug_key.get (objfile->obfd.get ()); if (shared !=3D nullptr) return *shared; =20 @@ -291,7 +291,7 @@ find_separate_debug_file_in_section (struct objfile *ob= jfile) return NULL; } =20 - gnu_debug_key.emplace (objfile->obfd, abfd); + gnu_debug_key.emplace (objfile->obfd.get (), abfd); =20 #else warning (_("Cannot parse .gnu_debugdata section; LZMA support was " diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 3f4ad90dbd3..c6abec81ce2 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -1062,7 +1062,7 @@ get_symbol_leading_char (bfd *abfd) { objfile *objf =3D current_program_space->symfile_object_file; if (objf->obfd !=3D NULL) - return bfd_get_symbol_leading_char (objf->obfd); + return bfd_get_symbol_leading_char (objf->obfd.get ()); } return 0; } @@ -1178,7 +1178,7 @@ minimal_symbol_reader::record_full (gdb::string_view = name, =20 /* It's safe to strip the leading char here once, since the name is also stored stripped in the minimal symbol table. */ - if (name[0] =3D=3D get_symbol_leading_char (m_objfile->obfd)) + if (name[0] =3D=3D get_symbol_leading_char (m_objfile->obfd.get ())) name =3D name.substr (1); =20 if (ms_type =3D=3D mst_file_text && startswith (name, "__gnu_compiled")) diff --git a/gdb/mipsread.c b/gdb/mipsread.c index 868b13f6433..def7f5ae33c 100644 --- a/gdb/mipsread.c +++ b/gdb/mipsread.c @@ -67,7 +67,7 @@ mipscoff_symfile_init (struct objfile *objfile) static void mipscoff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_= flags) { - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); =20 minimal_symbol_reader reader (objfile); =20 @@ -175,7 +175,7 @@ static void read_alphacoff_dynamic_symtab (minimal_symbol_reader &reader, struct objfile *objfile) { - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); struct alphacoff_dynsecinfo si; int sym_count; int i; diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 7759311afca..3db9135a64b 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -147,7 +147,7 @@ get_objfile_bfd_data (bfd *abfd) void set_objfile_per_bfd (struct objfile *objfile) { - objfile->per_bfd =3D get_objfile_bfd_data (objfile->obfd); + objfile->per_bfd =3D get_objfile_bfd_data (objfile->obfd.get ()); } =20 /* Set the objfile's per-BFD notion of the "main" name and @@ -284,20 +284,24 @@ add_to_objfile_sections (struct bfd *abfd, struct bfd= _section *asect, void build_objfile_section_table (struct objfile *objfile) { - int count =3D gdb_bfd_count_sections (objfile->obfd); + int count =3D gdb_bfd_count_sections (objfile->obfd.get ()); =20 objfile->sections =3D OBSTACK_CALLOC (&objfile->objfile_obstack, count, struct obj_section); objfile->sections_end =3D (objfile->sections + count); for (asection *sect : gdb_bfd_sections (objfile->obfd)) - add_to_objfile_sections (objfile->obfd, sect, objfile, 0); + add_to_objfile_sections (objfile->obfd.get (), sect, objfile, 0); =20 /* See gdb_bfd_section_index. */ - add_to_objfile_sections (objfile->obfd, bfd_com_section_ptr, objfile, 1); - add_to_objfile_sections (objfile->obfd, bfd_und_section_ptr, objfile, 1); - add_to_objfile_sections (objfile->obfd, bfd_abs_section_ptr, objfile, 1); - add_to_objfile_sections (objfile->obfd, bfd_ind_section_ptr, objfile, 1); + add_to_objfile_sections (objfile->obfd.get (), bfd_com_section_ptr, + objfile, 1); + add_to_objfile_sections (objfile->obfd.get (), bfd_und_section_ptr, + objfile, 1); + add_to_objfile_sections (objfile->obfd.get (), bfd_abs_section_ptr, + objfile, 1); + add_to_objfile_sections (objfile->obfd.get (), bfd_ind_section_ptr, + objfile, 1); } =20 /* Given a pointer to an initialized bfd (ABFD) and some flag bits, @@ -313,10 +317,10 @@ build_objfile_section_table (struct objfile *objfile) requests for specific operations. Other bits like OBJF_SHARED are simply copied through to the new objfile flags member. */ =20 -objfile::objfile (bfd *abfd, const char *name, objfile_flags flags_) +objfile::objfile (gdb_bfd_ref_ptr bfd_, const char *name, objfile_flags fl= ags_) : flags (flags_), pspace (current_program_space), - obfd (abfd) + obfd (std::move (bfd_)) { const char *expanded_name; =20 @@ -327,7 +331,7 @@ objfile::objfile (bfd *abfd, const char *name, objfile_= flags flags_) std::string name_holder; if (name =3D=3D NULL) { - gdb_assert (abfd =3D=3D NULL); + gdb_assert (obfd =3D=3D nullptr); gdb_assert ((flags & OBJF_NOT_FILENAME) !=3D 0); expanded_name =3D "<>"; } @@ -345,16 +349,15 @@ objfile::objfile (bfd *abfd, const char *name, objfil= e_flags flags_) that any data that is reference is saved in the per-objfile data region. */ =20 - gdb_bfd_ref (abfd); - if (abfd !=3D NULL) + if (obfd !=3D nullptr) { - mtime =3D bfd_get_mtime (abfd); + mtime =3D bfd_get_mtime (obfd.get ()); =20 /* Build section table. */ build_objfile_section_table (this); } =20 - per_bfd =3D get_objfile_bfd_data (abfd); + per_bfd =3D get_objfile_bfd_data (obfd.get ()); } =20 /* If there is a valid and known entry point, function fills *ENTRY_P with= it @@ -454,10 +457,10 @@ add_separate_debug_objfile (struct objfile *objfile, = struct objfile *parent) /* See objfiles.h. */ =20 objfile * -objfile::make (bfd *bfd_, const char *name_, objfile_flags flags_, +objfile::make (gdb_bfd_ref_ptr bfd_, const char *name_, objfile_flags flag= s_, objfile *parent) { - objfile *result =3D new objfile (bfd_, name_, flags_); + objfile *result =3D new objfile (std::move (bfd_), name_, flags_); if (parent !=3D nullptr) add_separate_debug_objfile (result, parent); =20 @@ -556,9 +559,7 @@ objfile::~objfile () if (sf !=3D NULL) (*sf->sym_finish) (this); =20 - if (obfd) - gdb_bfd_unref (obfd); - else + if (obfd =3D=3D nullptr) delete per_bfd; =20 /* Before the symbol table code was redone to make it easier to @@ -709,7 +710,7 @@ objfile_relocate1 (struct objfile *objfile, { int idx =3D s - objfile->sections; =20 - exec_set_section_address (bfd_get_filename (objfile->obfd), idx, + exec_set_section_address (bfd_get_filename (objfile->obfd.get ()), i= dx, s->addr ()); } =20 @@ -745,10 +746,10 @@ objfile_relocate (struct objfile *objfile, /* Here OBJFILE_ADDRS contain the correct absolute addresses, the relative ones must be already created according to debug_objfile. */ =20 - addr_info_make_relative (&objfile_addrs, debug_objfile->obfd); + addr_info_make_relative (&objfile_addrs, debug_objfile->obfd.get ()); =20 gdb_assert (debug_objfile->section_offsets.size () - =3D=3D gdb_bfd_count_sections (debug_objfile->obfd)); + =3D=3D gdb_bfd_count_sections (debug_objfile->obfd.get ())); section_offsets new_debug_offsets (debug_objfile->section_offsets.size ()); relative_addr_info_to_section_offsets (new_debug_offsets, objfile_ad= drs); @@ -1130,7 +1131,7 @@ update_section_map (struct program_space *pspace, alloc_size =3D 0; for (objfile *objfile : pspace->objfiles ()) ALL_OBJFILE_OSECTIONS (objfile, s) - if (insert_section_p (objfile->obfd, s->the_bfd_section)) + if (insert_section_p (objfile->obfd.get (), s->the_bfd_section)) alloc_size +=3D 1; =20 /* This happens on detach/attach (e.g. in gdb.base/attach.exp). */ @@ -1146,7 +1147,7 @@ update_section_map (struct program_space *pspace, i =3D 0; for (objfile *objfile : pspace->objfiles ()) ALL_OBJFILE_OSECTIONS (objfile, s) - if (insert_section_p (objfile->obfd, s->the_bfd_section)) + if (insert_section_p (objfile->obfd.get (), s->the_bfd_section)) map[i++] =3D s; =20 std::sort (map, map + alloc_size, sort_cmp); @@ -1322,7 +1323,7 @@ const char * objfile_name (const struct objfile *objfile) { if (objfile->obfd !=3D NULL) - return bfd_get_filename (objfile->obfd); + return bfd_get_filename (objfile->obfd.get ()); =20 return objfile->original_name; } @@ -1333,7 +1334,7 @@ const char * objfile_filename (const struct objfile *objfile) { if (objfile->obfd !=3D NULL) - return bfd_get_filename (objfile->obfd); + return bfd_get_filename (objfile->obfd.get ()); =20 return NULL; } @@ -1352,7 +1353,7 @@ const char * objfile_flavour_name (struct objfile *objfile) { if (objfile->obfd !=3D NULL) - return bfd_flavour_name (bfd_get_flavour (objfile->obfd)); + return bfd_flavour_name (bfd_get_flavour (objfile->obfd.get ())); return NULL; } =20 diff --git a/gdb/objfiles.h b/gdb/objfiles.h index e724a4e8764..eb85ed478c6 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -401,7 +401,7 @@ struct objfile private: =20 /* The only way to create an objfile is to call objfile::make. */ - objfile (bfd *, const char *, objfile_flags); + objfile (gdb_bfd_ref_ptr, const char *, objfile_flags); =20 public: =20 @@ -414,8 +414,8 @@ public: ~objfile (); =20 /* Create an objfile. */ - static objfile *make (bfd *bfd_, const char *name_, objfile_flags flags_, - objfile *parent =3D nullptr); + static objfile *make (gdb_bfd_ref_ptr bfd_, const char *name_, + objfile_flags flags_, objfile *parent =3D nullptr); =20 /* Remove an objfile from the current program space, and free it. */ @@ -597,7 +597,7 @@ public: section. */ gdb_assert (section->owner =3D=3D nullptr || section->owner =3D=3D thi= s->obfd); =20 - int idx =3D gdb_bfd_section_index (this->obfd, section); + int idx =3D gdb_bfd_section_index (this->obfd.get (), section); return this->section_offsets[idx]; } =20 @@ -608,7 +608,7 @@ public: section. */ gdb_assert (section->owner =3D=3D nullptr || section->owner =3D=3D thi= s->obfd); =20 - int idx =3D gdb_bfd_section_index (this->obfd, section); + int idx =3D gdb_bfd_section_index (this->obfd.get (), section); this->section_offsets[idx] =3D offset; } =20 @@ -651,7 +651,7 @@ public: /* The object file's BFD. Can be null if the objfile contains only minimal symbols, e.g. the run time common symbols for SunOS4. */ =20 - bfd *obfd; + gdb_bfd_ref_ptr obfd; =20 /* The per-BFD data. Note that this is treated specially if OBFD is NULL. */ diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c index 4cc570286dc..757f9aac4fc 100644 --- a/gdb/python/py-objfile.c +++ b/gdb/python/py-objfile.c @@ -157,7 +157,7 @@ objfpy_get_build_id (PyObject *self, void *closure) =20 try { - build_id =3D build_id_bfd_get (objfile->obfd); + build_id =3D build_id_bfd_get (objfile->obfd.get ()); } catch (const gdb_exception &except) { @@ -448,7 +448,7 @@ objfpy_add_separate_debug_file (PyObject *self, PyObjec= t *args, PyObject *kw) { gdb_bfd_ref_ptr abfd (symfile_bfd_open (file_name)); =20 - symbol_file_add_separate (abfd.get (), file_name, 0, obj->objfile); + symbol_file_add_separate (abfd, file_name, 0, obj->objfile); } catch (const gdb_exception &except) { @@ -625,7 +625,7 @@ objfpy_lookup_objfile_by_build_id (const char *build_id) /* Don't return separate debug files. */ if (objfile->separate_debug_objfile_backlink !=3D NULL) continue; - obfd_build_id =3D build_id_bfd_get (objfile->obfd); + obfd_build_id =3D build_id_bfd_get (objfile->obfd.get ()); if (obfd_build_id =3D=3D NULL) continue; if (objfpy_build_id_matches (obfd_build_id, build_id)) diff --git a/gdb/remote.c b/gdb/remote.c index 49d26c2039e..04b283fba52 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -4321,7 +4321,7 @@ remote_target::get_offsets () objfile *objf =3D current_program_space->symfile_object_file; section_offsets offs =3D objf->section_offsets; =20 - symfile_segment_data_up data =3D get_symfile_segment_data (objf->obfd); + symfile_segment_data_up data =3D get_symfile_segment_data (objf->obfd.ge= t ()); do_segments =3D (data !=3D NULL); do_sections =3D num_segments =3D=3D 0; =20 @@ -4356,7 +4356,7 @@ remote_target::get_offsets () =20 if (do_segments) { - int ret =3D symfile_map_offsets_to_segments (objf->obfd, + int ret =3D symfile_map_offsets_to_segments (objf->obfd.get (), data.get (), offs, num_segments, segments); =20 diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c index 33b15a9d8ad..948bd0f2463 100644 --- a/gdb/solib-aix.c +++ b/gdb/solib-aix.c @@ -399,7 +399,7 @@ static section_offsets solib_aix_get_section_offsets (struct objfile *objfile, lm_info_aix *info) { - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); =20 section_offsets offsets (objfile->section_offsets.size ()); =20 diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index a6d6fe07088..df86b147f47 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -958,7 +958,7 @@ frv_fdpic_find_canonical_descriptor (CORE_ADDR entry_po= int) /* Check the main executable. */ objfile *objf =3D current_program_space->symfile_object_file; addr =3D find_canonical_descriptor_in_load_object - (entry_point, got_value, name, objf->obfd, + (entry_point, got_value, name, objf->obfd.get (), main_executable_lm_info); =20 /* If descriptor not found via main executable, check each load object diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index f9a43e23969..6f8680f75b8 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -2170,7 +2170,7 @@ enable_break (struct svr4_info *info, int from_tty) bfd *tmp_bfd; CORE_ADDR load_addr; =20 - tmp_bfd =3D os->objfile->obfd; + tmp_bfd =3D os->objfile->obfd.get (); load_addr =3D os->objfile->text_section_offset (); =20 interp_sect =3D bfd_get_section_by_name (tmp_bfd, ".text"); @@ -3149,7 +3149,7 @@ svr4_iterate_over_objfiles_in_search_order if (current_objfile =3D=3D current_program_space->symfile_object_fil= e) abfd =3D current_program_space->exec_bfd (); else - abfd =3D current_objfile->obfd; + abfd =3D current_objfile->obfd.get (); =20 if (abfd !=3D nullptr && gdb_bfd_scan_elf_dyntag (DT_SYMBOLIC, abfd, nullptr, nullptr) =3D=3D= 1) diff --git a/gdb/solib.c b/gdb/solib.c index b9ddd049b00..fc07f60a6d5 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -764,7 +764,9 @@ solib_read_symbols (struct so_list *so, symfile_add_fla= gs flags) { section_addr_info sap =3D build_section_addr_info_from_section_table (*so->sections); - so->objfile =3D symbol_file_add_from_bfd (so->abfd, so->so_name, + gdb_bfd_ref_ptr tmp_bfd + (gdb_bfd_ref_ptr::new_reference (so->abfd)); + so->objfile =3D symbol_file_add_from_bfd (tmp_bfd, so->so_name, flags, &sap, OBJF_SHARED, NULL); so->objfile->addr_low =3D so->addr_low; diff --git a/gdb/source.c b/gdb/source.c index 425b02fc3a0..3f498d552c4 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1203,7 +1203,8 @@ open_source_file (struct symtab *s) srcpath +=3D s->filename; } =20 - const struct bfd_build_id *build_id =3D build_id_bfd_get (ofp->obfd); + const struct bfd_build_id *build_id + =3D build_id_bfd_get (ofp->obfd.get ()); =20 /* Query debuginfod for the source file. */ if (build_id !=3D nullptr && !srcpath.empty ()) diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c index 8488ddb9c31..2b3eb37b39a 100644 --- a/gdb/stap-probe.c +++ b/gdb/stap-probe.c @@ -1566,7 +1566,7 @@ handle_stap_probe (struct objfile *objfile, struct sd= t_note *el, std::vector> *probesp, CORE_ADDR base) { - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); int size =3D bfd_get_arch_size (abfd) / 8; struct gdbarch *gdbarch =3D objfile->arch (); struct type *ptr_type =3D builtin_type (gdbarch)->builtin_data_ptr; @@ -1678,7 +1678,7 @@ stap_static_probe_ops::get_probes SystemTap probe's information. We basically have to count how many probes the objfile has, and then fill in the necessary information for each one. */ - bfd *obfd =3D objfile->obfd; + bfd *obfd =3D objfile->obfd.get (); bfd_vma base; struct sdt_note *iter; unsigned save_probesp_len =3D probesp->size (); diff --git a/gdb/symfile-mem.c b/gdb/symfile-mem.c index 73c5ee378b8..78c0e091a6e 100644 --- a/gdb/symfile-mem.c +++ b/gdb/symfile-mem.c @@ -119,7 +119,7 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_AD= DR addr, if (from_tty) add_flags |=3D SYMFILE_VERBOSE; =20 - objf =3D symbol_file_add_from_bfd (nbfd, bfd_get_filename (nbfd), + objf =3D symbol_file_add_from_bfd (nbfd_holder, bfd_get_filename (nbfd), add_flags, &sai, OBJF_SHARED, NULL); =20 current_program_space->add_target_sections (objf); @@ -144,7 +144,7 @@ add_symbol_file_from_memory_command (const char *args, = int from_tty) =20 /* We need some representative bfd to know the target we are looking at.= */ if (current_program_space->symfile_object_file !=3D NULL) - templ =3D current_program_space->symfile_object_file->obfd; + templ =3D current_program_space->symfile_object_file->obfd.get (); else templ =3D current_program_space->exec_bfd (); if (templ =3D=3D NULL) diff --git a/gdb/symfile.c b/gdb/symfile.c index aea8c762ee6..361274eea45 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -263,7 +263,8 @@ build_section_addr_info_from_objfile (const struct objf= ile *objfile) /* Before reread_symbols gets rewritten it is not safe to call: gdb_assert (objfile->num_sections =3D=3D bfd_count_sections (objfile-= >obfd)); */ - section_addr_info sap =3D build_section_addr_info_from_bfd (objfile->obf= d); + section_addr_info sap + =3D build_section_addr_info_from_bfd (objfile->obfd.get ()); for (i =3D 0; i < sap.size (); i++) { int sectindex =3D sap[i].sectindex; @@ -281,19 +282,19 @@ init_objfile_sect_indices (struct objfile *objfile) asection *sect; int i; =20 - sect =3D bfd_get_section_by_name (objfile->obfd, ".text"); + sect =3D bfd_get_section_by_name (objfile->obfd.get (), ".text"); if (sect) objfile->sect_index_text =3D sect->index; =20 - sect =3D bfd_get_section_by_name (objfile->obfd, ".data"); + sect =3D bfd_get_section_by_name (objfile->obfd.get (), ".data"); if (sect) objfile->sect_index_data =3D sect->index; =20 - sect =3D bfd_get_section_by_name (objfile->obfd, ".bss"); + sect =3D bfd_get_section_by_name (objfile->obfd.get (), ".bss"); if (sect) objfile->sect_index_bss =3D sect->index; =20 - sect =3D bfd_get_section_by_name (objfile->obfd, ".rodata"); + sect =3D bfd_get_section_by_name (objfile->obfd.get (), ".rodata"); if (sect) objfile->sect_index_rodata =3D sect->index; =20 @@ -626,7 +627,7 @@ void default_symfile_offsets (struct objfile *objfile, const section_addr_info &addrs) { - objfile->section_offsets.resize (gdb_bfd_count_sections (objfile->obfd)); + objfile->section_offsets.resize (gdb_bfd_count_sections (objfile->obfd.g= et ())); relative_addr_info_to_section_offsets (objfile->section_offsets, addrs); =20 /* For relocatable files, all loadable sections will start at zero. @@ -634,9 +635,9 @@ default_symfile_offsets (struct objfile *objfile, that no loadable sections overlap. This algorithm is quadratic, but the number of sections in a single object file is generally small. */ - if ((bfd_get_file_flags (objfile->obfd) & (EXEC_P | DYNAMIC)) =3D=3D 0) + if ((bfd_get_file_flags (objfile->obfd.get ()) & (EXEC_P | DYNAMIC)) =3D= =3D 0) { - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); asection *cur_sec; =20 for (cur_sec =3D abfd->sections; cur_sec !=3D NULL; cur_sec =3D cur_= sec->next) @@ -652,8 +653,8 @@ default_symfile_offsets (struct objfile *objfile, /* Pick non-overlapping offsets for sections the user did not place explicitly. */ CORE_ADDR lowest =3D 0; - for (asection *sect : gdb_bfd_sections (objfile->obfd)) - place_section (objfile->obfd, sect, objfile->section_offsets, + for (asection *sect : gdb_bfd_sections (objfile->obfd.get ())) + place_section (objfile->obfd.get (), sect, objfile->section_offsets, lowest); =20 /* Correctly filling in the section offsets is not quite @@ -786,8 +787,7 @@ read_symbols (struct objfile *objfile, symfile_add_flag= s add_flags) virtual section-as-bfd like the bfd filename containing the section. Therefore use also non-canonical name form for the same file containing the section. */ - symbol_file_add_separate (abfd.get (), - bfd_get_filename (abfd.get ()), + symbol_file_add_separate (abfd, bfd_get_filename (abfd.get ()), add_flags | SYMFILE_NOT_FILENAME, objfile); } } @@ -809,20 +809,20 @@ init_entry_point_info (struct objfile *objfile) /* Save startup file's range of PC addresses to help blockframe.c decide where the bottom of the stack is. */ =20 - if (bfd_get_file_flags (objfile->obfd) & EXEC_P) + if (bfd_get_file_flags (objfile->obfd.get ()) & EXEC_P) { /* Executable file -- record its entry point so we'll recognize the startup file because it contains the entry point. */ - ei->entry_point =3D bfd_get_start_address (objfile->obfd); + ei->entry_point =3D bfd_get_start_address (objfile->obfd.get ()); ei->entry_point_p =3D 1; } - else if (bfd_get_file_flags (objfile->obfd) & DYNAMIC - && bfd_get_start_address (objfile->obfd) !=3D 0) + else if (bfd_get_file_flags (objfile->obfd.get ()) & DYNAMIC + && bfd_get_start_address (objfile->obfd.get ()) !=3D 0) { /* Some shared libraries may have entry points set and be runnable. There's no clear way to indicate this, so just check for values other than zero. */ - ei->entry_point =3D bfd_get_start_address (objfile->obfd); + ei->entry_point =3D bfd_get_start_address (objfile->obfd.get ()); ei->entry_point_p =3D 1; } else @@ -857,7 +857,7 @@ init_entry_point_info (struct objfile *objfile) + bfd_section_size (sect))) { ei->the_bfd_section_index - =3D gdb_bfd_section_index (objfile->obfd, sect); + =3D gdb_bfd_section_index (objfile->obfd.get (), sect); found =3D 1; break; } @@ -900,14 +900,14 @@ syms_from_objfile_1 (struct objfile *objfile, section_addr_info local_addr; const int mainline =3D add_flags & SYMFILE_MAINLINE; =20 - objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd)); + objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd.get ())); objfile->qf.clear (); =20 if (objfile->sf =3D=3D NULL) { /* No symbols to load, but we still need to make sure that the section_offsets table is allocated. */ - int num_sections =3D gdb_bfd_count_sections (objfile->obfd); + int num_sections =3D gdb_bfd_count_sections (objfile->obfd.get ()); =20 objfile->section_offsets.assign (num_sections, 0); return; @@ -954,7 +954,7 @@ syms_from_objfile_1 (struct objfile *objfile, We no longer warn if the lowest section is not a text segment (as happens for the PA64 port. */ if (addrs->size () > 0) - addr_info_make_relative (addrs, objfile->obfd); + addr_info_make_relative (addrs, objfile->obfd.get ()); =20 /* Initialize symbol reading routines for this objfile, allow complaints= to appear for this new file, and record how verbose to be, then do the @@ -1033,7 +1033,7 @@ finish_new_objfile (struct objfile *objfile, symfile_= add_flags add_flags) Upon failure, jumps back to command level (never returns). */ =20 static struct objfile * -symbol_file_add_with_addrs (bfd *abfd, const char *name, +symbol_file_add_with_addrs (const gdb_bfd_ref_ptr &abfd, const char *name, symfile_add_flags add_flags, section_addr_info *addrs, objfile_flags flags, struct objfile *parent) @@ -1139,7 +1139,7 @@ symbol_file_add_with_addrs (bfd *abfd, const char *na= me, see the objfile constructor. */ =20 void -symbol_file_add_separate (bfd *bfd, const char *name, +symbol_file_add_separate (const gdb_bfd_ref_ptr &bfd, const char *name, symfile_add_flags symfile_flags, struct objfile *objfile) { @@ -1160,7 +1160,7 @@ symbol_file_add_separate (bfd *bfd, const char *name, See symbol_file_add_with_addrs's comments for details. */ =20 struct objfile * -symbol_file_add_from_bfd (bfd *abfd, const char *name, +symbol_file_add_from_bfd (const gdb_bfd_ref_ptr &abfd, const char *name, symfile_add_flags add_flags, section_addr_info *addrs, objfile_flags flags, struct objfile *parent) @@ -1178,7 +1178,7 @@ symbol_file_add (const char *name, symfile_add_flags = add_flags, { gdb_bfd_ref_ptr bfd (symfile_bfd_open (name)); =20 - return symbol_file_add_from_bfd (bfd.get (), name, add_flags, addrs, + return symbol_file_add_from_bfd (bfd, name, add_flags, addrs, flags, NULL); } =20 @@ -1289,7 +1289,7 @@ separate_debug_file_exists (const std::string &name, = unsigned long crc, =20 if (bfd_stat (abfd.get (), &abfd_stat) =3D=3D 0 && abfd_stat.st_ino !=3D 0 - && bfd_stat (parent_objfile->obfd, &parent_stat) =3D=3D 0) + && bfd_stat (parent_objfile->obfd.get (), &parent_stat) =3D=3D 0) { if (abfd_stat.st_dev =3D=3D parent_stat.st_dev && abfd_stat.st_ino =3D=3D parent_stat.st_ino) @@ -1325,7 +1325,7 @@ separate_debug_file_exists (const std::string &name, = unsigned long crc, =20 if (!verified_as_different) { - if (!gdb_bfd_crc (parent_objfile->obfd, &parent_crc)) + if (!gdb_bfd_crc (parent_objfile->obfd.get (), &parent_crc)) { if (separate_debug_file_debug) gdb_printf (gdb_stdlog, @@ -1516,7 +1516,7 @@ find_separate_debug_file_by_debuglink (struct objfile= *objfile) unsigned long crc32; =20 gdb::unique_xmalloc_ptr debuglink - (bfd_get_debug_link_info (objfile->obfd, &crc32)); + (bfd_get_debug_link_info (objfile->obfd.get (), &crc32)); =20 if (debuglink =3D=3D NULL) { @@ -1747,7 +1747,7 @@ symfile_bfd_open (const char *name) int get_section_index (struct objfile *objfile, const char *section_name) { - asection *sect =3D bfd_get_section_by_name (objfile->obfd, section_name); + asection *sect =3D bfd_get_section_by_name (objfile->obfd.get (), sectio= n_name); =20 if (sect) return sect->index; @@ -2424,7 +2424,7 @@ reread_symbols (int from_tty) =20 for (objfile *objfile : current_program_space->objfiles ()) { - if (objfile->obfd =3D=3D NULL) + if (objfile->obfd.get () =3D=3D NULL) continue; =20 /* Separate debug objfiles are handled in the main objfile. */ @@ -2468,12 +2468,12 @@ reread_symbols (int from_tty) clear_symtab_users_cleanup defer_clear_users (0); =20 if (current_program_space->exec_bfd () !=3D NULL - && filename_cmp (bfd_get_filename (objfile->obfd), + && filename_cmp (bfd_get_filename (objfile->obfd.get ()), bfd_get_filename (current_program_space->exec_bfd ())) =3D=3D 0) { /* Reload EXEC_BFD without asking anything. */ =20 - exec_file_attach (bfd_get_filename (objfile->obfd), 0); + exec_file_attach (bfd_get_filename (objfile->obfd.get ()), 0); } =20 /* Keep the calls order approx. the same as in free_objfile. */ @@ -2504,14 +2504,14 @@ reread_symbols (int from_tty) =20 /* Clean up any state BFD has sitting around. */ { - gdb_bfd_ref_ptr obfd (objfile->obfd); + gdb_bfd_ref_ptr obfd =3D objfile->obfd; const char *obfd_filename; =20 - obfd_filename =3D bfd_get_filename (objfile->obfd); + obfd_filename =3D bfd_get_filename (objfile->obfd.get ()); /* Open the new BFD before freeing the old one, so that the filename remains live. */ gdb_bfd_ref_ptr temp (gdb_bfd_open (obfd_filename, gnutarget)); - objfile->obfd =3D temp.release (); + objfile->obfd =3D std::move (temp); if (objfile->obfd =3D=3D NULL) error (_("Can't open %s to read symbols."), obfd_filename); } @@ -2519,7 +2519,7 @@ reread_symbols (int from_tty) std::string original_name =3D objfile->original_name; =20 /* bfd_openr sets cacheable to true, which is what we want. */ - if (!bfd_check_format (objfile->obfd, bfd_object)) + if (!bfd_check_format (objfile->obfd.get (), bfd_object)) error (_("Can't read symbols from %s: %s."), objfile_name (objfile), bfd_errmsg (bfd_get_error ())); =20 @@ -2553,7 +2553,7 @@ reread_symbols (int from_tty) /* Reset the sym_fns pointer. The ELF reader can change it based on whether .gdb_index is present, and we need it to start over. PR symtab/15885 */ - objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd)); + objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd.get ())); objfile->qf.clear (); =20 build_objfile_section_table (objfile); @@ -3674,12 +3674,11 @@ symfile_map_offsets_to_segments (bfd *abfd, static void symfile_find_segment_sections (struct objfile *objfile) { - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); int i; asection *sect; =20 - symfile_segment_data_up data - =3D get_symfile_segment_data (objfile->obfd); + symfile_segment_data_up data =3D get_symfile_segment_data (abfd); if (data =3D=3D NULL) return; =20 diff --git a/gdb/symfile.h b/gdb/symfile.h index 5216e85c4e3..1d13e82502b 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -233,12 +233,13 @@ extern void add_filename_language (const char *ext, e= num language lang); extern struct objfile *symbol_file_add (const char *, symfile_add_flags, section_addr_info *, objfile_flags); =20 -extern struct objfile *symbol_file_add_from_bfd (bfd *, const char *, symf= ile_add_flags, +extern struct objfile *symbol_file_add_from_bfd (const gdb_bfd_ref_ptr &, + const char *, symfile_add_flags, section_addr_info *, objfile_flags, struct objfile *parent); =20 -extern void symbol_file_add_separate (bfd *, const char *, symfile_add_fla= gs, - struct objfile *); +extern void symbol_file_add_separate (const gdb_bfd_ref_ptr &, const char = *, + symfile_add_flags, struct objfile *); =20 extern std::string find_separate_debug_file_by_debuglink (struct objfile *= ); =20 diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 68b76bf3b8e..8508c06b343 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -116,7 +116,7 @@ dump_objfile (struct objfile *objfile) gdb_printf ("\nObject file %s: ", objfile_name (objfile)); gdb_printf ("Objfile at %s, bfd at %s, %d minsyms\n\n", host_address_to_string (objfile), - host_address_to_string (objfile->obfd), + host_address_to_string (objfile->obfd.get ()), objfile->per_bfd->minimal_symbol_count); =20 objfile->dump (); diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 6be0a7c4464..b7d65771115 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -301,7 +301,7 @@ xcoff_secnum_to_sections (int n_scnum, struct objfile *= objfile, *bfd_sect =3D NULL; *secnum =3D SECT_OFF_TEXT (objfile); =20 - bfd_map_over_sections (objfile->obfd, find_targ_sec, &args); + bfd_map_over_sections (objfile->obfd.get (), find_targ_sec, &args); } =20 /* Return the section number (SECT_OFF_*) that N_SCNUM points to. */ @@ -782,7 +782,7 @@ enter_line_range (struct subfile *subfile, unsigned beg= inoffset, else limit_offset -=3D 1; =20 - abfd =3D objfile->obfd; + abfd =3D objfile->obfd.get (); linesz =3D coff_data (abfd)->local_linesz; ext_lnno =3D alloca (linesz); =20 @@ -892,7 +892,7 @@ xcoff_next_symbol_text (struct objfile *objfile) if (this_symtab_objfile) objfile =3D this_symtab_objfile; =20 - bfd_coff_swap_sym_in (objfile->obfd, raw_symbol, &symbol); + bfd_coff_swap_sym_in (objfile->obfd.get (), raw_symbol, &symbol); if (symbol.n_zeroes) { complaint (_("Unexpected symbol continuation")); @@ -923,7 +923,7 @@ xcoff_next_symbol_text (struct objfile *objfile) static void read_xcoff_symtab (struct objfile *objfile, legacy_psymtab *pst) { - bfd *abfd =3D objfile->obfd; + bfd *abfd =3D objfile->obfd.get (); char *raw_auxptr; /* Pointer to first raw aux entry for sym. */ struct xcoff_symfile_info *xcoff =3D XCOFF_DATA (objfile); char *strtbl =3D xcoff->strtbl; @@ -1628,7 +1628,7 @@ read_symbol (struct internal_syment *symbol, int symn= o) symbol->n_scnum =3D -1; return; } - bfd_coff_swap_sym_in (this_symtab_objfile->obfd, + bfd_coff_swap_sym_in (this_symtab_objfile->obfd.get (), stbl + (symno * local_symesz), symbol); } @@ -1704,7 +1704,7 @@ read_symbol_lineno (int symno) gotit: /* Take aux entry and return its lineno. */ symno++; - bfd_coff_swap_aux_in (objfile->obfd, stbl + symno * local_symesz, + bfd_coff_swap_aux_in (objfile->obfd.get (), stbl + symno * local_symesz, symbol->n_type, symbol->n_sclass, 0, symbol->n_numaux, main_aux); =20 @@ -1989,7 +1989,7 @@ swap_sym (struct internal_syment *symbol, union inter= nal_auxent *aux, const char **name, char **raw, unsigned int *symnump, struct objfile *objfile) { - bfd_coff_swap_sym_in (objfile->obfd, *raw, symbol); + bfd_coff_swap_sym_in (objfile->obfd.get (), *raw, symbol); if (symbol->n_zeroes) { /* If it's exactly E_SYMNMLEN characters long it isn't @@ -2023,7 +2023,7 @@ swap_sym (struct internal_syment *symbol, union inter= nal_auxent *aux, *raw +=3D coff_data (objfile->obfd)->local_symesz; if (symbol->n_numaux > 0) { - bfd_coff_swap_aux_in (objfile->obfd, *raw, symbol->n_type, + bfd_coff_swap_aux_in (objfile->obfd.get (), *raw, symbol->n_type, symbol->n_sclass, 0, symbol->n_numaux, aux); =20 *symnump +=3D symbol->n_numaux; @@ -2090,7 +2090,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, =20 set_last_source_file (NULL); =20 - abfd =3D objfile->obfd; + abfd =3D objfile->obfd.get (); next_symbol_text_func =3D xcoff_next_symbol_text; =20 sraw_symbol =3D XCOFF_DATA (objfile)->symtbl; @@ -2120,7 +2120,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, if (symbol.n_numaux > 1) { bfd_coff_swap_aux_in - (objfile->obfd, + (objfile->obfd.get (), sraw_symbol - coff_data (abfd)->local_symesz, symbol.n_type, symbol.n_sclass, @@ -2795,7 +2795,7 @@ xcoff_initial_scan (struct objfile *objfile, symfile_= add_flags symfile_flags) unsigned int size; =20 info =3D XCOFF_DATA (objfile); - symfile_bfd =3D abfd =3D objfile->obfd; + symfile_bfd =3D abfd =3D objfile->obfd.get (); name =3D objfile_name (objfile); =20 num_symbols =3D bfd_get_symcount (abfd); /* # of symbols */