aboutsummaryrefslogtreecommitdiff
path: root/gdb/solib-svr4.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2022-08-02 09:55:32 -0600
committerTom Tromey <tom@tromey.com>2022-08-03 13:26:58 -0600
commit98badbfdc222d1d7f346046f23a64522b88d22a0 (patch)
treea57a95b75f64a0e318e0b1bd31dd6b246e4797d8 /gdb/solib-svr4.c
parent4d44946794e68cf79cfba467fa414a958dba2185 (diff)
downloadgdb-98badbfdc222d1d7f346046f23a64522b88d22a0.zip
gdb-98badbfdc222d1d7f346046f23a64522b88d22a0.tar.gz
gdb-98badbfdc222d1d7f346046f23a64522b88d22a0.tar.bz2
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.
Diffstat (limited to 'gdb/solib-svr4.c')
-rw-r--r--gdb/solib-svr4.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index f9a43e2..6f8680f 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;
- tmp_bfd = os->objfile->obfd;
+ tmp_bfd = os->objfile->obfd.get ();
load_addr = os->objfile->text_section_offset ();
interp_sect = bfd_get_section_by_name (tmp_bfd, ".text");
@@ -3149,7 +3149,7 @@ svr4_iterate_over_objfiles_in_search_order
if (current_objfile == current_program_space->symfile_object_file)
abfd = current_program_space->exec_bfd ();
else
- abfd = current_objfile->obfd;
+ abfd = current_objfile->obfd.get ();
if (abfd != nullptr
&& gdb_bfd_scan_elf_dyntag (DT_SYMBOLIC, abfd, nullptr, nullptr) == 1)