diff options
author | Tom Tromey <tom@tromey.com> | 2022-08-02 09:55:32 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2022-08-03 13:26:58 -0600 |
commit | 98badbfdc222d1d7f346046f23a64522b88d22a0 (patch) | |
tree | a57a95b75f64a0e318e0b1bd31dd6b246e4797d8 /gdb/ctfread.c | |
parent | 4d44946794e68cf79cfba467fa414a958dba2185 (diff) | |
download | gdb-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/ctfread.c')
-rw-r--r-- | gdb/ctfread.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 0da4f0d..9436ce5 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 = of->obfd; + bfd *abfd = of->obfd.get (); const asection *codes; codes = bfd_get_section_by_name (abfd, ".text"); @@ -1543,7 +1543,7 @@ scan_partial_symbols (ctf_dict_t *cfp, psymtab_storage *partial_symtabs, if (strcmp (fname, ".ctf") == 0) { - fname = bfd_get_filename (of->obfd); + fname = bfd_get_filename (of->obfd.get ()); isparent = true; } @@ -1602,7 +1602,7 @@ void elfctf_build_psymtabs (struct objfile *of) { struct ctf_per_tu_data pcu; - bfd *abfd = of->obfd; + bfd *abfd = of->obfd.get (); int err; ctf_archive_t *arc = ctf_bfdopen (abfd, &err); |