aboutsummaryrefslogtreecommitdiff
path: root/gdb/exec.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2023-10-19 20:40:52 +0000
committerSimon Marchi <simon.marchi@polymtl.ca>2023-10-20 22:00:23 -0400
commit0e17d3fc080f543d81e6c2520ba0bd8046ea3a95 (patch)
tree2f0a495b079cc9edb11114028e480890a1c1f866 /gdb/exec.c
parent4a6daabb94982ccc17ea45ebb6f6e8efa8f86399 (diff)
downloadbinutils-0e17d3fc080f543d81e6c2520ba0bd8046ea3a95.zip
binutils-0e17d3fc080f543d81e6c2520ba0bd8046ea3a95.tar.gz
binutils-0e17d3fc080f543d81e6c2520ba0bd8046ea3a95.tar.bz2
gdb: fix owner passed to remove_target_sections in clear_solib
Commit 8971d2788e7 ("gdb: link so_list using intrusive_list") introduced a bug in clear_solib. Instead of passing an `so_list *` to remove_target_sections, it passed an `so_list **`. This was not caught by the compiler, because remove_target_sections takes a `void *` as the "owner", so you can pass it any pointer and it won't complain. This happened because I previously had a patch to change the type of the disposer parameter to be a reference rather than a pointer, so had to change `so` to `&so`. When dropping that patch, I forgot to revert this bit and / or it got re-introduced when handling subsequent merge conflicts. And I didn't properly retest. Fix that, but try to make things less error prone. Add a union to represent the possible owner kinds for a target_section. Trying to pass a pointer to another type than those will not compile. Change-Id: I600cab5ea0408ccc5638467b760768161ca3036c
Diffstat (limited to 'gdb/exec.c')
-rw-r--r--gdb/exec.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/gdb/exec.c b/gdb/exec.c
index 0f9f9d0..5956012 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -492,8 +492,8 @@ exec_file_attach (const char *filename, int from_tty)
/* Add the executable's sections to the current address spaces'
list of sections. This possibly pushes the exec_ops
target. */
- current_program_space->add_target_sections (&current_program_space->ebfd,
- sections);
+ current_program_space->add_target_sections
+ (current_program_space->ebfd.get (), sections);
/* Tell display code (if any) about the changed file name. */
if (deprecated_exec_file_display_hook)
@@ -599,8 +599,8 @@ build_section_table (struct bfd *some_bfd)
current set of target sections. */
void
-program_space::add_target_sections (const void *owner,
- const std::vector<target_section> &sections)
+program_space::add_target_sections
+ (target_section_owner owner, const std::vector<target_section> &sections)
{
if (!sections.empty ())
{
@@ -643,7 +643,7 @@ program_space::add_target_sections (struct objfile *objfile)
continue;
m_target_sections.emplace_back (osect->addr (), osect->endaddr (),
- osect->the_bfd_section, (void *) objfile);
+ osect->the_bfd_section, objfile);
}
}
@@ -651,15 +651,15 @@ program_space::add_target_sections (struct objfile *objfile)
OWNER must be the same value passed to add_target_sections. */
void
-program_space::remove_target_sections (const void *owner)
+program_space::remove_target_sections (target_section_owner owner)
{
- gdb_assert (owner != NULL);
+ gdb_assert (owner.v () != nullptr);
auto it = std::remove_if (m_target_sections.begin (),
m_target_sections.end (),
[&] (target_section &sect)
{
- return sect.owner == owner;
+ return sect.owner.v () == owner.v ();
});
m_target_sections.erase (it, m_target_sections.end ());