Use gdb_bfd_ref_ptr in objfile
authorTom Tromey <tom@tromey.com>
Tue, 2 Aug 2022 15:55:32 +0000 (09:55 -0600)
committerTom Tromey <tom@tromey.com>
Wed, 3 Aug 2022 19:26:58 +0000 (13:26 -0600)
commit98badbfdc222d1d7f346046f23a64522b88d22a0
treea57a95b75f64a0e318e0b1bd31dd6b246e4797d8
parent4d44946794e68cf79cfba467fa414a958dba2185
Use gdb_bfd_ref_ptr in objfile

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.
40 files changed:
gdb/arm-tdep.c
gdb/auto-load.c
gdb/build-id.c
gdb/coff-pe-read.c
gdb/coffread.c
gdb/compile/compile-object-load.c
gdb/ctfread.c
gdb/dbxread.c
gdb/dtrace-probe.c
gdb/dwarf2/frame.c
gdb/dwarf2/index-cache.c
gdb/dwarf2/index-write.c
gdb/dwarf2/loc.c
gdb/dwarf2/read.c
gdb/elfread.c
gdb/gcore.c
gdb/hppa-tdep.c
gdb/i386-tdep.c
gdb/jit.c
gdb/machoread.c
gdb/maint.c
gdb/mdebugread.c
gdb/minidebug.c
gdb/minsyms.c
gdb/mipsread.c
gdb/objfiles.c
gdb/objfiles.h
gdb/python/py-objfile.c
gdb/remote.c
gdb/solib-aix.c
gdb/solib-frv.c
gdb/solib-svr4.c
gdb/solib.c
gdb/source.c
gdb/stap-probe.c
gdb/symfile-mem.c
gdb/symfile.c
gdb/symfile.h
gdb/symmisc.c
gdb/xcoffread.c