aboutsummaryrefslogtreecommitdiff
path: root/gdb/hppa-tdep.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/hppa-tdep.c
parent4d44946794e68cf79cfba467fa414a958dba2185 (diff)
downloadbinutils-98badbfdc222d1d7f346046f23a64522b88d22a0.zip
binutils-98badbfdc222d1d7f346046f23a64522b88d22a0.tar.gz
binutils-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/hppa-tdep.c')
-rw-r--r--gdb/hppa-tdep.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index 54b3d22..91f9cec 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -264,7 +264,7 @@ internalize_unwinds (struct objfile *objfile, struct unwind_table_entry *table,
{
low_text_segment_address = -1;
- bfd_map_over_sections (objfile->obfd,
+ bfd_map_over_sections (objfile->obfd.get (),
record_text_segment_lowaddr,
&low_text_segment_address);
@@ -275,7 +275,7 @@ internalize_unwinds (struct objfile *objfile, struct unwind_table_entry *table,
text_offset = tdep->solib_get_text_base (objfile);
}
- bfd_get_section_contents (objfile->obfd, section, buf, 0, size);
+ bfd_get_section_contents (objfile->obfd.get (), section, buf, 0, size);
/* Now internalize the information being careful to handle host/target
endian issues. */
@@ -379,7 +379,8 @@ read_unwind_info (struct objfile *objfile)
/* Now compute the size of the stub unwinds. Note the ELF tools do not
use stub unwinds at the current time. */
- stub_unwind_sec = bfd_get_section_by_name (objfile->obfd, "$UNWIND_END$");
+ stub_unwind_sec = bfd_get_section_by_name (objfile->obfd.get (),
+ "$UNWIND_END$");
if (stub_unwind_sec)
{
@@ -427,7 +428,7 @@ read_unwind_info (struct objfile *objfile)
char *buf = (char *) alloca (stub_unwind_size);
/* 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);
/* Now convert them into regular unwind entries. */