mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-12-16 14:19:52 +08:00
gdb: fix owner passed to remove_target_sections in clear_solib
Commit 8971d2788e ("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
This commit is contained in:
committed by
Simon Marchi
parent
4a6daabb94
commit
0e17d3fc08
@@ -207,10 +207,11 @@ program_space::exec_close ()
|
||||
{
|
||||
/* Removing target sections may close the exec_ops target.
|
||||
Clear ebfd before doing so to prevent recursion. */
|
||||
bfd *saved_ebfd = ebfd.get ();
|
||||
ebfd.reset (nullptr);
|
||||
ebfd_mtime = 0;
|
||||
|
||||
remove_target_sections (&ebfd);
|
||||
remove_target_sections (saved_ebfd);
|
||||
|
||||
exec_filename.reset (nullptr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user