]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gdb/progspace.c
gdb: fix owner passed to remove_target_sections in clear_solib
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 19 Oct 2023 20:40:52 +0000 (20:40 +0000)
committerSimon Marchi <simon.marchi@polymtl.ca>
Sat, 21 Oct 2023 02:00:23 +0000 (22:00 -0400)
commit0e17d3fc080f543d81e6c2520ba0bd8046ea3a95
tree2f0a495b079cc9edb11114028e480890a1c1f866
parent4a6daabb94982ccc17ea45ebb6f6e8efa8f86399
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
gdb/exec.c
gdb/maint.c
gdb/progspace.c
gdb/progspace.h
gdb/solib.c
gdb/target-section.h